mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibGUI: Put all classes in the GUI namespace and remove the leading G
This took me a moment. Welcome to the new world of GUI::Widget! :^)
This commit is contained in:
parent
2d39da5405
commit
c5bd9d4ed1
337 changed files with 5400 additions and 4816 deletions
|
@ -94,9 +94,9 @@ void IRCAppWindow::setup_client()
|
|||
};
|
||||
|
||||
if (m_client.hostname().is_empty()) {
|
||||
auto input_box = GInputBox::construct("Enter server:", "Connect to server", this);
|
||||
auto input_box = GUI::InputBox::construct("Enter server:", "Connect to server", this);
|
||||
auto result = input_box->exec();
|
||||
if (result == GInputBox::ExecCancel)
|
||||
if (result == GUI::InputBox::ExecCancel)
|
||||
::exit(0);
|
||||
|
||||
m_client.set_server(input_box->text_value(), 6667);
|
||||
|
@ -108,13 +108,13 @@ void IRCAppWindow::setup_client()
|
|||
|
||||
void IRCAppWindow::setup_actions()
|
||||
{
|
||||
m_join_action = GAction::create("Join channel", { Mod_Ctrl, Key_J }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
||||
auto input_box = GInputBox::construct("Enter channel name:", "Join channel", this);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter channel name:", "Join channel", this);
|
||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_client.handle_join_action(input_box->text_value());
|
||||
});
|
||||
|
||||
m_part_action = GAction::create("Part from channel", { Mod_Ctrl, Key_P }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
||||
m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) {
|
||||
auto* window = m_client.current_window();
|
||||
if (!window || window->type() != IRCWindow::Type::Channel) {
|
||||
// FIXME: Perhaps this action should have been disabled instead of allowing us to activate it.
|
||||
|
@ -123,41 +123,41 @@ void IRCAppWindow::setup_actions()
|
|||
m_client.handle_part_action(window->channel().name());
|
||||
});
|
||||
|
||||
m_whois_action = GAction::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
|
||||
auto input_box = GInputBox::construct("Enter nickname:", "IRC WHOIS lookup", this);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_whois_action = GUI::Action::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "IRC WHOIS lookup", this);
|
||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_client.handle_whois_action(input_box->text_value());
|
||||
});
|
||||
|
||||
m_open_query_action = GAction::create("Open query", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
|
||||
auto input_box = GInputBox::construct("Enter nickname:", "Open IRC query with...", this);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_open_query_action = GUI::Action::create("Open query", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "Open IRC query with...", this);
|
||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_client.handle_open_query_action(input_box->text_value());
|
||||
});
|
||||
|
||||
m_close_query_action = GAction::create("Close query", { Mod_Ctrl, Key_D }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) {
|
||||
m_close_query_action = GUI::Action::create("Close query", { Mod_Ctrl, Key_D }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) {
|
||||
printf("FIXME: Implement close-query action\n");
|
||||
});
|
||||
|
||||
m_change_nick_action = GAction::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
|
||||
auto input_box = GInputBox::construct("Enter nickname:", "Change nickname", this);
|
||||
if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_change_nick_action = GUI::Action::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) {
|
||||
auto input_box = GUI::InputBox::construct("Enter nickname:", "Change nickname", this);
|
||||
if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty())
|
||||
m_client.handle_change_nick_action(input_box->text_value());
|
||||
});
|
||||
}
|
||||
|
||||
void IRCAppWindow::setup_menus()
|
||||
{
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = GMenu::construct("IRC Client");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
auto app_menu = GUI::Menu::construct("IRC Client");
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GApplication::the().quit(0);
|
||||
GUI::Application::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto server_menu = GMenu::construct("Server");
|
||||
auto server_menu = GUI::Menu::construct("Server");
|
||||
server_menu->add_action(*m_change_nick_action);
|
||||
server_menu->add_separator();
|
||||
server_menu->add_action(*m_join_action);
|
||||
|
@ -168,24 +168,24 @@ void IRCAppWindow::setup_menus()
|
|||
server_menu->add_action(*m_close_query_action);
|
||||
menubar->add_menu(move(server_menu));
|
||||
|
||||
auto help_menu = GMenu::construct("Help");
|
||||
help_menu->add_action(GAction::create("About", [this](const GAction&) {
|
||||
GAboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this);
|
||||
auto help_menu = GUI::Menu::construct("Help");
|
||||
help_menu->add_action(GUI::Action::create("About", [this](const GUI::Action&) {
|
||||
GUI::AboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
GApplication::the().set_menubar(move(menubar));
|
||||
GUI::Application::the().set_menubar(move(menubar));
|
||||
}
|
||||
|
||||
void IRCAppWindow::setup_widgets()
|
||||
{
|
||||
auto widget = GWidget::construct();
|
||||
auto widget = GUI::Widget::construct();
|
||||
set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GVBoxLayout>());
|
||||
widget->set_layout(make<GUI::VBoxLayout>());
|
||||
widget->layout()->set_spacing(0);
|
||||
|
||||
auto toolbar = GToolBar::construct(widget);
|
||||
auto toolbar = GUI::ToolBar::construct(widget);
|
||||
toolbar->set_has_frame(false);
|
||||
toolbar->add_action(*m_change_nick_action);
|
||||
toolbar->add_separator();
|
||||
|
@ -196,25 +196,25 @@ void IRCAppWindow::setup_widgets()
|
|||
toolbar->add_action(*m_open_query_action);
|
||||
toolbar->add_action(*m_close_query_action);
|
||||
|
||||
auto outer_container = GWidget::construct(widget.ptr());
|
||||
outer_container->set_layout(make<GVBoxLayout>());
|
||||
auto outer_container = GUI::Widget::construct(widget.ptr());
|
||||
outer_container->set_layout(make<GUI::VBoxLayout>());
|
||||
outer_container->layout()->set_margins({ 2, 0, 2, 2 });
|
||||
|
||||
auto horizontal_container = GSplitter::construct(Orientation::Horizontal, outer_container);
|
||||
auto horizontal_container = GUI::Splitter::construct(Orientation::Horizontal, outer_container);
|
||||
|
||||
m_window_list = GTableView::construct(horizontal_container);
|
||||
m_window_list = GUI::TableView::construct(horizontal_container);
|
||||
m_window_list->set_headers_visible(false);
|
||||
m_window_list->set_alternating_row_colors(false);
|
||||
m_window_list->set_size_columns_to_fit_content(true);
|
||||
m_window_list->set_model(m_client.client_window_list_model());
|
||||
m_window_list->set_activates_on_selection(true);
|
||||
m_window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
m_window_list->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
m_window_list->set_preferred_size(100, 0);
|
||||
m_window_list->on_activation = [this](auto& index) {
|
||||
set_active_window(m_client.window_at(index.row()));
|
||||
};
|
||||
|
||||
m_container = GStackWidget::construct(horizontal_container);
|
||||
m_container = GUI::StackWidget::construct(horizontal_container);
|
||||
m_container->on_active_widget_change = [this](auto*) {
|
||||
update_part_action();
|
||||
};
|
||||
|
|
|
@ -31,11 +31,12 @@
|
|||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
|
||||
class GAction;
|
||||
class GStackWidget;
|
||||
class GTableView;
|
||||
namespace GUI {
|
||||
class StackWidget;
|
||||
class TableView;
|
||||
}
|
||||
|
||||
class IRCAppWindow : public GWindow {
|
||||
class IRCAppWindow : public GUI::Window {
|
||||
public:
|
||||
IRCAppWindow();
|
||||
virtual ~IRCAppWindow() override;
|
||||
|
@ -54,12 +55,12 @@ private:
|
|||
|
||||
IRCWindow& create_window(void* owner, IRCWindow::Type, const String& name);
|
||||
IRCClient m_client;
|
||||
RefPtr<GStackWidget> m_container;
|
||||
RefPtr<GTableView> m_window_list;
|
||||
RefPtr<GAction> m_join_action;
|
||||
RefPtr<GAction> m_part_action;
|
||||
RefPtr<GAction> m_whois_action;
|
||||
RefPtr<GAction> m_open_query_action;
|
||||
RefPtr<GAction> m_close_query_action;
|
||||
RefPtr<GAction> m_change_nick_action;
|
||||
RefPtr<GUI::StackWidget> m_container;
|
||||
RefPtr<GUI::TableView> m_window_list;
|
||||
RefPtr<GUI::Action> m_join_action;
|
||||
RefPtr<GUI::Action> m_part_action;
|
||||
RefPtr<GUI::Action> m_whois_action;
|
||||
RefPtr<GUI::Action> m_open_query_action;
|
||||
RefPtr<GUI::Action> m_close_query_action;
|
||||
RefPtr<GUI::Action> m_change_nick_action;
|
||||
};
|
||||
|
|
|
@ -38,12 +38,12 @@ IRCChannelMemberListModel::~IRCChannelMemberListModel()
|
|||
{
|
||||
}
|
||||
|
||||
int IRCChannelMemberListModel::row_count(const GModelIndex&) const
|
||||
int IRCChannelMemberListModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return m_channel.member_count();
|
||||
}
|
||||
|
||||
int IRCChannelMemberListModel::column_count(const GModelIndex&) const
|
||||
int IRCChannelMemberListModel::column_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ String IRCChannelMemberListModel::column_name(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const
|
||||
GUI::Model::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name:
|
||||
|
@ -66,7 +66,7 @@ GModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) co
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GVariant IRCChannelMemberListModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant IRCChannelMemberListModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
class IRCChannel;
|
||||
|
||||
class IRCChannelMemberListModel final : public GModel {
|
||||
class IRCChannelMemberListModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
Name
|
||||
|
@ -39,11 +39,11 @@ public:
|
|||
static NonnullRefPtr<IRCChannelMemberListModel> create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); }
|
||||
virtual ~IRCChannelMemberListModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex&) const override;
|
||||
virtual int column_count(const GModelIndex&) const override;
|
||||
virtual int row_count(const GUI::ModelIndex&) const override;
|
||||
virtual int column_count(const GUI::ModelIndex&) const override;
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -35,32 +35,32 @@
|
|||
#include <LibGUI/GTextEditor.h>
|
||||
#include <LibHTML/HtmlView.h>
|
||||
|
||||
IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GWidget* parent)
|
||||
: GWidget(parent)
|
||||
IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
, m_client(client)
|
||||
, m_owner(owner)
|
||||
, m_type(type)
|
||||
, m_name(name)
|
||||
{
|
||||
set_layout(make<GVBoxLayout>());
|
||||
set_layout(make<GUI::VBoxLayout>());
|
||||
|
||||
// Make a container for the log buffer view + (optional) member list.
|
||||
auto container = GSplitter::construct(Orientation::Horizontal, this);
|
||||
auto container = GUI::Splitter::construct(Orientation::Horizontal, this);
|
||||
|
||||
m_html_view = HtmlView::construct(container);
|
||||
|
||||
if (m_type == Channel) {
|
||||
auto member_view = GTableView::construct(container);
|
||||
auto member_view = GUI::TableView::construct(container);
|
||||
member_view->set_headers_visible(false);
|
||||
member_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
member_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
member_view->set_preferred_size(100, 0);
|
||||
member_view->set_alternating_row_colors(false);
|
||||
member_view->set_model(channel().member_model());
|
||||
member_view->set_activates_on_selection(true);
|
||||
}
|
||||
|
||||
m_text_editor = GTextEditor::construct(GTextEditor::SingleLine, this);
|
||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_text_editor = GUI::TextEditor::construct(GUI::TextEditor::SingleLine, this);
|
||||
m_text_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_text_editor->set_preferred_size(0, 19);
|
||||
m_text_editor->on_return_pressed = [this] {
|
||||
if (m_type == Channel)
|
||||
|
|
|
@ -28,14 +28,17 @@
|
|||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
namespace GUI {
|
||||
class TextEditor;
|
||||
}
|
||||
|
||||
class IRCChannel;
|
||||
class IRCClient;
|
||||
class IRCQuery;
|
||||
class IRCLogBuffer;
|
||||
class GTextEditor;
|
||||
class HtmlView;
|
||||
|
||||
class IRCWindow : public GWidget {
|
||||
class IRCWindow : public GUI::Widget {
|
||||
C_OBJECT(IRCWindow)
|
||||
public:
|
||||
enum Type {
|
||||
|
@ -44,7 +47,7 @@ public:
|
|||
Query,
|
||||
};
|
||||
|
||||
IRCWindow(IRCClient&, void* owner, Type, const String& name, GWidget* parent);
|
||||
IRCWindow(IRCClient&, void* owner, Type, const String& name, GUI::Widget* parent);
|
||||
virtual ~IRCWindow() override;
|
||||
|
||||
String name() const { return m_name; }
|
||||
|
@ -73,7 +76,7 @@ private:
|
|||
Type m_type;
|
||||
String m_name;
|
||||
RefPtr<HtmlView> m_html_view;
|
||||
RefPtr<GTextEditor> m_text_editor;
|
||||
RefPtr<GUI::TextEditor> m_text_editor;
|
||||
RefPtr<IRCLogBuffer> m_log_buffer;
|
||||
int m_unread_count { 0 };
|
||||
};
|
||||
|
|
|
@ -40,12 +40,12 @@ IRCWindowListModel::~IRCWindowListModel()
|
|||
{
|
||||
}
|
||||
|
||||
int IRCWindowListModel::row_count(const GModelIndex&) const
|
||||
int IRCWindowListModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return m_client.window_count();
|
||||
}
|
||||
|
||||
int IRCWindowListModel::column_count(const GModelIndex&) const
|
||||
int IRCWindowListModel::column_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ String IRCWindowListModel::column_name(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
||||
GUI::Model::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Name:
|
||||
|
@ -68,7 +68,7 @@ GModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const
|
|||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
GVariant IRCWindowListModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant IRCWindowListModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class IRCClient;
|
||||
class IRCWindow;
|
||||
|
||||
class IRCWindowListModel final : public GModel {
|
||||
class IRCWindowListModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
Name,
|
||||
|
@ -41,11 +41,11 @@ public:
|
|||
static NonnullRefPtr<IRCWindowListModel> create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); }
|
||||
virtual ~IRCWindowListModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex&) const override;
|
||||
virtual int column_count(const GModelIndex&) const override;
|
||||
virtual int row_count(const GUI::ModelIndex&) const override;
|
||||
virtual int column_count(const GUI::ModelIndex&) const override;
|
||||
virtual String column_name(int column) const override;
|
||||
virtual ColumnMetadata column_metadata(int column) const override;
|
||||
virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
|
||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||
virtual void update() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
GApplication app(argc, argv);
|
||||
GUI::Application app(argc, argv);
|
||||
|
||||
if (pledge("stdio inet dns unix shared_buffer rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue