Browser: Move the "About" action to WindowActions

This commit is contained in:
Andreas Kling 2020-04-24 20:50:06 +02:00
parent 45a932a600
commit 3fcfab4404
4 changed files with 16 additions and 4 deletions

View file

@ -29,7 +29,6 @@
#include "WindowActions.h"
#include "History.h"
#include "InspectorWidget.h"
#include <LibGUI/AboutDialog.h>
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@ -257,9 +256,7 @@ Tab::Tab()
bookmarks_menu.add_action(show_bookmarksbar_action);
auto& help_menu = m_menubar->add_menu("Help");
help_menu.add_action(GUI::Action::create("About", [this](const GUI::Action&) {
GUI::AboutDialog::show("Browser", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window());
}));
help_menu.add_action(WindowActions::the().about_action());
}
Tab::~Tab()

View file

@ -36,6 +36,13 @@ WindowActions::WindowActions(GUI::Window& window)
on_previous_tab();
},
&window);
m_about_action = GUI::Action::create(
"About", [this](const GUI::Action&) {
if (on_about)
on_about();
},
&window);
}
}

View file

@ -13,15 +13,18 @@ public:
Function<void()> on_create_new_tab;
Function<void()> on_next_tab;
Function<void()> on_previous_tab;
Function<void()> on_about;
GUI::Action& create_new_tab_action() { return *m_create_new_tab_action; }
GUI::Action& next_tab_action() { return *m_next_tab_action; }
GUI::Action& previous_tab_action() { return *m_previous_tab_action; }
GUI::Action& about_action() { return *m_about_action; }
private:
RefPtr<GUI::Action> m_create_new_tab_action;
RefPtr<GUI::Action> m_next_tab_action;
RefPtr<GUI::Action> m_previous_tab_action;
RefPtr<GUI::Action> m_about_action;
};
}

View file

@ -28,6 +28,7 @@
#include "Tab.h"
#include "WindowActions.h"
#include <LibCore/File.h>
#include <LibGUI/AboutDialog.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/TabWidget.h>
@ -140,6 +141,10 @@ int main(int argc, char** argv)
tab_widget.activate_previous_tab();
};
window_actions.on_about = [&] {
GUI::AboutDialog::show("Browser", Gfx::Bitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window);
};
create_new_tab(default_url, true);
window->show();