mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +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
|
@ -72,7 +72,7 @@ void BoardListModel::update()
|
|||
};
|
||||
}
|
||||
|
||||
int BoardListModel::row_count(const GModelIndex&) const
|
||||
int BoardListModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return m_boards.size();
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ String BoardListModel::column_name(int column) const
|
|||
}
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata BoardListModel::column_metadata([[maybe_unused]] int column) const
|
||||
GUI::Model::ColumnMetadata BoardListModel::column_metadata([[maybe_unused]] int column) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
GVariant BoardListModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant BoardListModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
auto& board = m_boards.at(index.row()).as_object();
|
||||
if (role == Role::Display) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <LibCore/CHttpJob.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
|
||||
class BoardListModel final : public GModel {
|
||||
class BoardListModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
Board,
|
||||
|
@ -40,11 +40,11 @@ public:
|
|||
static NonnullRefPtr<BoardListModel> create() { return adopt(*new BoardListModel); }
|
||||
virtual ~BoardListModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; }
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
virtual String column_name(int) const override;
|
||||
virtual ColumnMetadata column_metadata(int) 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:
|
||||
|
|
|
@ -100,7 +100,7 @@ void ThreadCatalogModel::update()
|
|||
};
|
||||
}
|
||||
|
||||
int ThreadCatalogModel::row_count(const GModelIndex&) const
|
||||
int ThreadCatalogModel::row_count(const GUI::ModelIndex&) const
|
||||
{
|
||||
return m_catalog.size();
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ String ThreadCatalogModel::column_name(int column) const
|
|||
}
|
||||
}
|
||||
|
||||
GModel::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const
|
||||
GUI::Model::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::ThreadNumber:
|
||||
|
@ -145,7 +145,7 @@ GModel::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const
|
|||
}
|
||||
}
|
||||
|
||||
GVariant ThreadCatalogModel::data(const GModelIndex& index, Role role) const
|
||||
GUI::Variant ThreadCatalogModel::data(const GUI::ModelIndex& index, Role role) const
|
||||
{
|
||||
auto& thread = m_catalog.at(index.row()).as_object();
|
||||
if (role == Role::Display) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <LibCore/CHttpJob.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
|
||||
class ThreadCatalogModel final : public GModel {
|
||||
class ThreadCatalogModel final : public GUI::Model {
|
||||
public:
|
||||
enum Column {
|
||||
ThreadNumber,
|
||||
|
@ -45,11 +45,11 @@ public:
|
|||
static NonnullRefPtr<ThreadCatalogModel> create() { return adopt(*new ThreadCatalogModel); }
|
||||
virtual ~ThreadCatalogModel() override;
|
||||
|
||||
virtual int row_count(const GModelIndex& = GModelIndex()) const override;
|
||||
virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; }
|
||||
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
|
||||
virtual String column_name(int) const override;
|
||||
virtual ColumnMetadata column_metadata(int) 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;
|
||||
|
||||
const String& board() const { return m_board; }
|
||||
|
|
|
@ -45,37 +45,37 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
GApplication app(argc, argv);
|
||||
GUI::Application app(argc, argv);
|
||||
|
||||
if (pledge("stdio dns inet shared_buffer rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto window = GWindow::construct();
|
||||
auto window = GUI::Window::construct();
|
||||
window->set_title("ChanViewer");
|
||||
window->set_rect(100, 100, 800, 500);
|
||||
window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png"));
|
||||
|
||||
auto widget = GWidget::construct();
|
||||
auto widget = GUI::Widget::construct();
|
||||
window->set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout(make<GVBoxLayout>());
|
||||
widget->set_layout(make<GUI::VBoxLayout>());
|
||||
|
||||
auto board_combo = GComboBox::construct(widget);
|
||||
auto board_combo = GUI::ComboBox::construct(widget);
|
||||
board_combo->set_only_allow_values_from_model(true);
|
||||
board_combo->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
board_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
board_combo->set_preferred_size(0, 20);
|
||||
board_combo->set_model(BoardListModel::create());
|
||||
|
||||
auto catalog_view = GTableView::construct(widget);
|
||||
auto catalog_view = GUI::TableView::construct(widget);
|
||||
catalog_view->set_model(ThreadCatalogModel::create());
|
||||
auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model());
|
||||
|
||||
auto statusbar = GStatusBar::construct(widget);
|
||||
auto statusbar = GUI::StatusBar::construct(widget);
|
||||
|
||||
board_combo->on_change = [&] (auto&, const GModelIndex& index) {
|
||||
auto selected_board = board_combo->model()->data(index, GModel::Role::Custom);
|
||||
board_combo->on_change = [&] (auto&, const GUI::ModelIndex& index) {
|
||||
auto selected_board = board_combo->model()->data(index, GUI::Model::Role::Custom);
|
||||
ASSERT(selected_board.is_string());
|
||||
catalog_model.set_board(selected_board.to_string());
|
||||
};
|
||||
|
@ -93,18 +93,18 @@ int main(int argc, char** argv)
|
|||
|
||||
window->show();
|
||||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
||||
auto app_menu = GMenu::construct("ChanViewer");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
auto app_menu = GUI::Menu::construct("ChanViewer");
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto help_menu = GMenu::construct("Help");
|
||||
help_menu->add_action(GAction::create("About", [&](const GAction&) {
|
||||
GAboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window);
|
||||
auto help_menu = GUI::Menu::construct("Help");
|
||||
help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) {
|
||||
GUI::AboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window);
|
||||
}));
|
||||
menubar->add_menu(move(help_menu));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue