mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:07:36 +00:00
LoginServer: Layout a basic login window
This commit is contained in:
parent
f8fb0359ae
commit
9e3d6d161b
6 changed files with 143 additions and 0 deletions
|
@ -11,6 +11,7 @@ add_subdirectory(ImageDecoder)
|
||||||
add_subdirectory(InspectorServer)
|
add_subdirectory(InspectorServer)
|
||||||
add_subdirectory(KeyboardPreferenceLoader)
|
add_subdirectory(KeyboardPreferenceLoader)
|
||||||
add_subdirectory(LaunchServer)
|
add_subdirectory(LaunchServer)
|
||||||
|
add_subdirectory(LoginServer)
|
||||||
add_subdirectory(LookupServer)
|
add_subdirectory(LookupServer)
|
||||||
add_subdirectory(NotificationServer)
|
add_subdirectory(NotificationServer)
|
||||||
add_subdirectory(RequestServer)
|
add_subdirectory(RequestServer)
|
||||||
|
|
15
Userland/Services/LoginServer/CMakeLists.txt
Normal file
15
Userland/Services/LoginServer/CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
serenity_component(
|
||||||
|
LoginServer
|
||||||
|
TARGETS LoginServer
|
||||||
|
)
|
||||||
|
|
||||||
|
compile_gml(LoginWindow.gml LoginWindowGML.h login_window_gml)
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
LoginWindowGML.h
|
||||||
|
LoginWindow.cpp
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
serenity_bin(LoginServer)
|
||||||
|
target_link_libraries(LoginServer LibGUI)
|
36
Userland/Services/LoginServer/LoginWindow.cpp
Normal file
36
Userland/Services/LoginServer/LoginWindow.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibGUI/Icon.h>
|
||||||
|
#include <LibGUI/Widget.h>
|
||||||
|
#include <Services/LoginServer/LoginWindow.h>
|
||||||
|
#include <Services/LoginServer/LoginWindowGML.h>
|
||||||
|
|
||||||
|
LoginWindow::LoginWindow(GUI::Window* parent)
|
||||||
|
: GUI::Window(parent)
|
||||||
|
{
|
||||||
|
set_title("Login to SerenityOS");
|
||||||
|
resize(413, 170);
|
||||||
|
center_on_screen();
|
||||||
|
set_resizable(false);
|
||||||
|
set_icon(GUI::Icon::default_icon("ladyball").bitmap_for_size(16));
|
||||||
|
|
||||||
|
auto& widget = set_main_widget<GUI::Widget>();
|
||||||
|
widget.load_from_gml(login_window_gml);
|
||||||
|
m_banner = *widget.find_descendant_of_type_named<GUI::ImageWidget>("banner");
|
||||||
|
m_banner->load_from_file("/res/graphics/brand-banner.png");
|
||||||
|
m_banner->set_auto_resize(true);
|
||||||
|
|
||||||
|
m_username = *widget.find_descendant_of_type_named<GUI::TextBox>("username");
|
||||||
|
m_username->set_focus(true);
|
||||||
|
m_password = *widget.find_descendant_of_type_named<GUI::PasswordBox>("password");
|
||||||
|
|
||||||
|
m_ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok");
|
||||||
|
m_ok_button->on_click = [&](auto) {
|
||||||
|
if (on_submit)
|
||||||
|
on_submit();
|
||||||
|
};
|
||||||
|
}
|
38
Userland/Services/LoginServer/LoginWindow.gml
Normal file
38
Userland/Services/LoginServer/LoginWindow.gml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
@GUI::Widget {
|
||||||
|
fill_with_background_color: true
|
||||||
|
|
||||||
|
layout: @GUI::VerticalBoxLayout
|
||||||
|
|
||||||
|
@GUI::ImageWidget {
|
||||||
|
name: "banner"
|
||||||
|
auto_resie: true
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::VerticalBoxLayout {
|
||||||
|
margins: [8, 8, 8, 8]
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::TextBox {
|
||||||
|
name: "username"
|
||||||
|
placeholder: "username"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::PasswordBox {
|
||||||
|
name: "password"
|
||||||
|
placeholder: "password"
|
||||||
|
}
|
||||||
|
|
||||||
|
@GUI::Widget {
|
||||||
|
layout: @GUI::HorizontalBoxLayout
|
||||||
|
|
||||||
|
@GUI::Widget
|
||||||
|
|
||||||
|
@GUI::Button {
|
||||||
|
name: "ok"
|
||||||
|
text: "Ok"
|
||||||
|
fixed_width: 60
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
Userland/Services/LoginServer/LoginWindow.h
Normal file
35
Userland/Services/LoginServer/LoginWindow.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibGUI/Button.h>
|
||||||
|
#include <LibGUI/ImageWidget.h>
|
||||||
|
#include <LibGUI/TextBox.h>
|
||||||
|
#include <LibGUI/Window.h>
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
class LoginWindow final : public GUI::Window {
|
||||||
|
C_OBJECT(LoginWindow);
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~LoginWindow() override { }
|
||||||
|
|
||||||
|
Function<void()> on_submit;
|
||||||
|
|
||||||
|
String username() const { return m_username->text(); }
|
||||||
|
void set_username(StringView const& username) { m_username->set_text(username); }
|
||||||
|
|
||||||
|
String password() const { return m_password->text(); }
|
||||||
|
void set_password(StringView const& password) { m_password->set_text(password); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
LoginWindow(GUI::Window* parent = nullptr);
|
||||||
|
|
||||||
|
RefPtr<GUI::ImageWidget> m_banner;
|
||||||
|
RefPtr<GUI::TextBox> m_username;
|
||||||
|
RefPtr<GUI::PasswordBox> m_password;
|
||||||
|
RefPtr<GUI::Button> m_ok_button;
|
||||||
|
};
|
18
Userland/Services/LoginServer/main.cpp
Normal file
18
Userland/Services/LoginServer/main.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibGUI/Application.h>
|
||||||
|
#include <Services/LoginServer/LoginWindow.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
|
||||||
|
auto window = LoginWindow::construct();
|
||||||
|
window->show();
|
||||||
|
|
||||||
|
return app->exec();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue