mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-08 12:56:23 +03:00
NotificationServer: Convert the notification window contents to GML
This commit is contained in:
parent
e4c7b9817b
commit
84e8bf3421
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/84e8bf3421 Pull-request: https://github.com/SerenityOS/serenity/pull/22809 Reviewed-by: https://github.com/trflynn89 ✅
@ -4,12 +4,14 @@ serenity_component(
|
||||
TARGETS NotificationServer
|
||||
)
|
||||
|
||||
compile_gml(NotificationWidget.gml NotificationWidgetGML.cpp)
|
||||
compile_ipc(NotificationServer.ipc NotificationServerEndpoint.h)
|
||||
compile_ipc(NotificationClient.ipc NotificationClientEndpoint.h)
|
||||
|
||||
set(SOURCES
|
||||
ConnectionFromClient.cpp
|
||||
main.cpp
|
||||
NotificationWidgetGML.cpp
|
||||
NotificationWindow.cpp
|
||||
)
|
||||
|
||||
|
27
Userland/Services/NotificationServer/NotificationWidget.gml
Normal file
27
Userland/Services/NotificationServer/NotificationWidget.gml
Normal file
@ -0,0 +1,27 @@
|
||||
@NotificationServer::NotificationWidget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
margins: [8]
|
||||
spacing: 6
|
||||
}
|
||||
fill_with_background_color: true
|
||||
|
||||
@GUI::ImageWidget {
|
||||
name: "icon"
|
||||
visible: false
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::VerticalBoxLayout {}
|
||||
|
||||
@GUI::Label {
|
||||
name: "title"
|
||||
font_weight: "Bold"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
name: "text"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
}
|
||||
}
|
23
Userland/Services/NotificationServer/NotificationWidget.h
Normal file
23
Userland/Services/NotificationServer/NotificationWidget.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace NotificationServer {
|
||||
|
||||
class NotificationWidget : public GUI::Widget {
|
||||
C_OBJECT_ABSTRACT(NotificationWidget)
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<NotificationWidget>> try_create();
|
||||
virtual ~NotificationWidget() override = default;
|
||||
|
||||
private:
|
||||
NotificationWidget() = default;
|
||||
};
|
||||
|
||||
}
|
@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "NotificationWindow.h"
|
||||
#include "NotificationWidget.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Vector.h>
|
||||
@ -65,25 +67,19 @@ NotificationWindow::NotificationWindow(i32 client_id, String const& text, String
|
||||
|
||||
set_rect(rect);
|
||||
|
||||
auto widget = set_main_widget<GUI::Widget>();
|
||||
auto widget = NotificationServer::NotificationWidget::try_create().release_value_but_fixme_should_propagate_errors();
|
||||
set_main_widget(widget);
|
||||
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout<GUI::HorizontalBoxLayout>(8, 6);
|
||||
|
||||
m_image = &widget->add<GUI::ImageWidget>();
|
||||
m_image = widget->find_descendant_of_type_named<GUI::ImageWidget>("icon"sv);
|
||||
m_image->set_visible(icon.is_valid());
|
||||
if (icon.is_valid()) {
|
||||
m_image->set_bitmap(icon.bitmap());
|
||||
}
|
||||
|
||||
auto& left_container = widget->add<GUI::Widget>();
|
||||
left_container.set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
m_title_label = &left_container.add<GUI::Label>(title);
|
||||
m_title_label->set_font(Gfx::FontDatabase::default_font().bold_variant());
|
||||
m_title_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
m_text_label = &left_container.add<GUI::Label>(text);
|
||||
m_text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
m_title_label = widget->find_descendant_of_type_named<GUI::Label>("title");
|
||||
m_title_label->set_text(title);
|
||||
m_text_label = widget->find_descendant_of_type_named<GUI::Label>("text");
|
||||
m_text_label->set_text(text);
|
||||
|
||||
// FIXME: There used to be code for setting the tooltip here, but since we
|
||||
// expand the notification now we no longer set the tooltip. Should there be
|
||||
|
Loading…
Reference in New Issue
Block a user