mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:57:34 +00:00
LoginServer: Use new GML compiler
This commit is contained in:
parent
8ee014a437
commit
3afbf66295
6 changed files with 40 additions and 13 deletions
|
@ -4,16 +4,13 @@ serenity_component(
|
||||||
TARGETS LoginServer
|
TARGETS LoginServer
|
||||||
)
|
)
|
||||||
|
|
||||||
stringify_gml(LoginWindow.gml LoginWindowGML.h login_window_gml)
|
compile_gml(LoginWindow.gml LoginWindowGML.cpp)
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
LoginWindow.cpp
|
LoginWindow.cpp
|
||||||
|
LoginWindowGML.cpp
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(GENERATED_SOURCES
|
|
||||||
LoginWindowGML.h
|
|
||||||
)
|
|
||||||
|
|
||||||
serenity_bin(LoginServer)
|
serenity_bin(LoginServer)
|
||||||
target_link_libraries(LoginServer PRIVATE LibCore LibGfx LibGUI LibMain)
|
target_link_libraries(LoginServer PRIVATE LibCore LibGfx LibGUI LibMain)
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include <LibGUI/Icon.h>
|
#include <LibGUI/Icon.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <Services/LoginServer/LoginWindow.h>
|
#include <Services/LoginServer/LoginWindow.h>
|
||||||
#include <Services/LoginServer/LoginWindowGML.h>
|
#include <Services/LoginServer/Widget.h>
|
||||||
|
|
||||||
|
namespace LoginServer {
|
||||||
|
|
||||||
LoginWindow::LoginWindow(GUI::Window* parent)
|
LoginWindow::LoginWindow(GUI::Window* parent)
|
||||||
: GUI::Window(parent)
|
: GUI::Window(parent)
|
||||||
|
@ -20,11 +22,9 @@ LoginWindow::LoginWindow(GUI::Window* parent)
|
||||||
set_closeable(false);
|
set_closeable(false);
|
||||||
set_icon(GUI::Icon::default_icon("ladyball"sv).bitmap_for_size(16));
|
set_icon(GUI::Icon::default_icon("ladyball"sv).bitmap_for_size(16));
|
||||||
|
|
||||||
auto widget = set_main_widget<GUI::Widget>();
|
auto widget = MUST(LoginServer::Widget::try_create());
|
||||||
widget->load_from_gml(login_window_gml).release_value_but_fixme_should_propagate_errors();
|
set_main_widget(widget);
|
||||||
m_banner = *widget->find_descendant_of_type_named<GUI::ImageWidget>("banner");
|
m_banner = *widget->find_descendant_of_type_named<GUI::ImageWidget>("banner");
|
||||||
m_banner->load_from_file("/res/graphics/brand-banner.png"sv);
|
|
||||||
m_banner->set_auto_resize(true);
|
|
||||||
|
|
||||||
m_username = *widget->find_descendant_of_type_named<GUI::TextBox>("username");
|
m_username = *widget->find_descendant_of_type_named<GUI::TextBox>("username");
|
||||||
m_username->set_focus(true);
|
m_username->set_focus(true);
|
||||||
|
@ -46,3 +46,5 @@ LoginWindow::LoginWindow(GUI::Window* parent)
|
||||||
m_fail_message->set_text({});
|
m_fail_message->set_text({});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
@GUI::Widget {
|
@LoginServer::Widget {
|
||||||
fill_with_background_color: true
|
fill_with_background_color: true
|
||||||
layout: @GUI::VerticalBoxLayout {}
|
layout: @GUI::VerticalBoxLayout {}
|
||||||
|
|
||||||
@GUI::ImageWidget {
|
@GUI::ImageWidget {
|
||||||
name: "banner"
|
name: "banner"
|
||||||
|
bitmap: "/res/graphics/brand-banner.png"
|
||||||
auto_resize: true
|
auto_resize: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include <LibGUI/TextBox.h>
|
#include <LibGUI/TextBox.h>
|
||||||
#include <LibGUI/Window.h>
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
|
namespace LoginServer {
|
||||||
|
|
||||||
class LoginWindow final : public GUI::Window {
|
class LoginWindow final : public GUI::Window {
|
||||||
C_OBJECT(LoginWindow);
|
C_OBJECT(LoginWindow);
|
||||||
|
|
||||||
|
@ -37,3 +39,5 @@ private:
|
||||||
RefPtr<GUI::Label> m_fail_message;
|
RefPtr<GUI::Label> m_fail_message;
|
||||||
RefPtr<GUI::Button> m_log_in_button;
|
RefPtr<GUI::Button> m_log_in_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
23
Userland/Services/LoginServer/Widget.h
Normal file
23
Userland/Services/LoginServer/Widget.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibGUI/Widget.h>
|
||||||
|
|
||||||
|
namespace LoginServer {
|
||||||
|
|
||||||
|
class Widget : public GUI::Widget {
|
||||||
|
C_OBJECT_ABSTRACT(Widget)
|
||||||
|
|
||||||
|
public:
|
||||||
|
static ErrorOr<NonnullRefPtr<Widget>> try_create();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Widget() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -43,7 +43,7 @@ static void child_process(Core::Account const& account)
|
||||||
exit(127);
|
exit(127);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void login(Core::Account const& account, LoginWindow& window)
|
static void login(Core::Account const& account, LoginServer::LoginWindow& window)
|
||||||
{
|
{
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
|
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Core::System::unveil("/res", "r"));
|
TRY(Core::System::unveil("/res", "r"));
|
||||||
TRY(Core::System::unveil(nullptr, nullptr));
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
auto window = LoginWindow::construct();
|
auto window = LoginServer::LoginWindow::construct();
|
||||||
window->on_submit = [&]() {
|
window->on_submit = [&]() {
|
||||||
auto username = window->username();
|
auto username = window->username();
|
||||||
auto password = Core::SecretString::take_ownership(window->password().to_byte_buffer());
|
auto password = Core::SecretString::take_ownership(window->password().to_byte_buffer());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue