2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2020-02-26 22:02:25 +11:00
|
|
|
* Copyright (c) 2019-2020, Jesse Buhagiar <jooster669@gmail.com>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2020-04-29 15:53:51 +02:00
|
|
|
#include "DisplaySettings.h"
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Action.h>
|
|
|
|
|
#include <LibGUI/Application.h>
|
|
|
|
|
#include <LibGUI/BoxLayout.h>
|
2020-11-02 19:30:17 +00:00
|
|
|
#include <LibGUI/Icon.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Menu.h>
|
2021-04-13 16:18:20 +02:00
|
|
|
#include <LibGUI/Menubar.h>
|
2021-01-02 00:58:05 +11:00
|
|
|
#include <LibGUI/TabWidget.h>
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Window.h>
|
2020-02-14 23:02:47 +01:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2020-01-13 12:22:49 +01:00
|
|
|
#include <stdio.h>
|
2021-03-12 17:29:37 +01:00
|
|
|
#include <unistd.h>
|
2019-09-03 21:45:02 +10:00
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
2021-01-16 17:42:31 +01:00
|
|
|
if (pledge("stdio thread recvfd sendfd rpath accept cpath wpath unix fattr", nullptr) < 0) {
|
2020-01-13 12:22:49 +01:00
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-04 14:05:19 +02:00
|
|
|
auto app = GUI::Application::construct(argc, argv);
|
2020-01-13 12:22:49 +01:00
|
|
|
|
2021-01-16 17:42:31 +01:00
|
|
|
if (pledge("stdio thread recvfd sendfd rpath accept cpath wpath", nullptr) < 0) {
|
2020-01-13 12:22:49 +01:00
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 19:30:17 +00:00
|
|
|
auto app_icon = GUI::Icon::default_icon("app-display-settings");
|
|
|
|
|
|
2021-01-02 00:58:05 +11:00
|
|
|
// Let's create the tab pane that we'll hook our widgets up to :^)
|
|
|
|
|
auto tab_widget = GUI::TabWidget::construct();
|
|
|
|
|
tab_widget->add_tab<DisplaySettingsWidget>("Display Settings");
|
|
|
|
|
tab_widget->set_fill_with_background_color(true); // No black backgrounds!
|
2019-09-03 21:45:02 +10:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
auto window = GUI::Window::construct();
|
2020-10-04 21:14:40 +02:00
|
|
|
dbgln("main window: {}", window);
|
2021-01-04 23:22:38 +01:00
|
|
|
window->set_title("Display Settings");
|
2021-01-02 00:58:05 +11:00
|
|
|
window->resize(360, 410);
|
2019-09-03 21:45:02 +10:00
|
|
|
window->set_resizable(false);
|
2021-01-02 00:58:05 +11:00
|
|
|
window->set_main_widget(tab_widget.ptr());
|
2020-11-02 19:30:17 +00:00
|
|
|
window->set_icon(app_icon.bitmap_for_size(16));
|
2019-09-03 21:45:02 +10:00
|
|
|
|
2021-04-13 16:18:20 +02:00
|
|
|
auto menubar = GUI::Menubar::construct();
|
2019-12-29 00:59:56 +11:00
|
|
|
|
2021-03-25 21:41:39 +01:00
|
|
|
auto& app_menu = menubar->add_menu("File");
|
2020-04-04 12:18:40 +02:00
|
|
|
app_menu.add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) {
|
2020-07-04 14:05:19 +02:00
|
|
|
app->quit();
|
2019-12-29 00:59:56 +11:00
|
|
|
}));
|
|
|
|
|
|
2020-04-04 12:18:40 +02:00
|
|
|
auto& help_menu = menubar->add_menu("Help");
|
2021-01-30 13:38:19 +01:00
|
|
|
help_menu.add_action(GUI::CommonActions::make_about_action("Display Settings", app_icon, window));
|
2019-12-29 00:59:56 +11:00
|
|
|
|
2021-03-25 21:41:39 +01:00
|
|
|
window->set_menubar(move(menubar));
|
2019-09-03 21:45:02 +10:00
|
|
|
window->show();
|
2020-07-04 14:05:19 +02:00
|
|
|
return app->exec();
|
2019-09-03 21:45:02 +10:00
|
|
|
}
|