aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-12-13 12:49:28 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-12-13 13:41:50 +0100
commit4eedf60d76a047f63b0991eee0b623e9be854c76 (patch)
treec8b335c8909a309c2bc2765e823bec5da74aa5aa /src/mainwindow
parentFix crash creating ConfigurationEditorPlugin widget (diff)
downloadsmolbote-4eedf60d76a047f63b0991eee0b623e9be854c76.tar.xz
MainWindow: rework menu bar
Split off menu bar into its own class out of MainWindow Menu bar now has a 'Find in menus' function
Diffstat (limited to 'src/mainwindow')
-rw-r--r--src/mainwindow/mainwindow.cpp130
-rw-r--r--src/mainwindow/mainwindow.h17
-rw-r--r--src/mainwindow/mainwindow.ui202
-rw-r--r--src/mainwindow/menubar.cpp239
-rw-r--r--src/mainwindow/menubar.h28
-rw-r--r--src/mainwindow/widgets/menusearch.cpp17
-rw-r--r--src/mainwindow/widgets/menusearch.h20
-rw-r--r--src/mainwindow/widgets/navigationbar.cpp4
8 files changed, 322 insertions, 335 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 1544e79..ea024c5 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -11,11 +11,11 @@
#include "browser.h"
#include "config.h"
#include "configuration.h"
+#include "menubar.h"
#include "profilemanager.h"
#include "session/session.h"
#include "session/sessiondialog.h"
#include "subwindow/subwindow.h"
-#include "ui_mainwindow.h"
#include "webengine/webview.h"
#include "webprofile.h"
#include "widgets/dockwidget.h"
@@ -31,9 +31,6 @@
#include <QMdiSubWindow>
#include <QMenuBar>
#include <QMessageBox>
-#include <QPrintDialog>
-#include <QPrinter>
-#include <QPrinterInfo>
#include <QShortcut>
#include <QStatusBar>
#include <QToolBar>
@@ -71,12 +68,13 @@ inline QDialog *createDevToolsDialog(QWebEnginePage *page)
MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *parent)
: QMainWindow(parent)
- , ui(new Ui::MainWindow)
+ , configuration(config.get())
, mdiArea(new QMdiArea(this))
{
Q_ASSERT(config);
- ui->setupUi(this);
+ m_menuBar = new MenuBar(config.get(), this);
+ this->setMenuBar(m_menuBar);
#ifdef CONFIG_PLASMA_BLUR
setAttribute(Qt::WA_TranslucentBackground, true);
@@ -91,98 +89,6 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
}
show();
- // connect smolbote menu
- {
- connect(ui->actionNewSubwindow, &QAction::triggered, this, [this, &config]() {
- auto *profile = WebProfile::defaultProfile();
- auto *window = createSubWindow(config.get(), profile);
- window->addTab(profile->newtab(), profile);
- });
- config->setShortcut(ui->actionNewSubwindow, "mainwindow.shortcuts.newGroup");
-
- connect(ui->actionNewWindow, &QAction::triggered, this, []() {
- auto *browser = qobject_cast<Browser *>(qApp);
- if(browser)
- browser->createWindow();
- });
- config->setShortcut(ui->actionNewWindow, "mainwindow.shortcuts.newWindow");
-
- connect(ui->actionAbout, &QAction::triggered, qobject_cast<Browser *>(qApp), &Browser::about);
- config->setShortcut(ui->actionAbout, "mainwindow.shortcuts.about");
-
- connect(ui->actionAboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
-
- connect(ui->actionQuit, &QAction::triggered, qApp, &QApplication::quit);
- config->setShortcut(ui->actionQuit, "mainwindow.shortcuts.quit");
- }
-
- // connect session menu
- {
- const QString sessionPath = config->value<QString>("browser.session.path").value();
- connect(ui->actionSaveSession, &QAction::triggered, this, [this, sessionPath]() {
- const QString filename = QFileDialog::getSaveFileName(this, tr("Save Session"), sessionPath, tr("JSON (*.json)"));
- QFile output(filename);
- if(output.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
- auto *browser = qobject_cast<Browser *>(qApp);
- auto data = Session::_session(browser->windows());
- output.write(QJsonDocument(data).toJson());
- output.close();
- }
- });
-
- connect(ui->actionLoadSession, &QAction::triggered, this, [this]() {
- auto *sessionDialog = new SessionDialog(this);
- sessionDialog->exec();
- });
- }
-
- // connect window menu
- {
- connect(ui->actionTileSubwindows, &QAction::triggered, mdiArea, &QMdiArea::tileSubWindows);
- config->setShortcut(ui->actionTileSubwindows, "mainwindow.shortcuts.tileWindows");
-
- connect(ui->actionCascadeSubwindows, &QAction::triggered, mdiArea, &QMdiArea::cascadeSubWindows);
- config->setShortcut(ui->actionCascadeSubwindows, "mainwindow.shortcuts.cascadeWindows");
- }
-
- // connect page menu
- {
- connect(ui->actionBookmarkPage, &QAction::triggered, this, [this]() {
- if(currentView != nullptr)
- emit createBookmark(currentView->title(), currentView->url().toString());
- });
- connect(ui->actionSavePage, &QAction::triggered, this, [this]() {
- if(currentView != nullptr)
- currentView->triggerPageAction(QWebEnginePage::SavePage);
- });
- connect(ui->actionPrintPage, &QAction::triggered, this, [this]() {
- if(currentView != nullptr) {
- auto *printer = new QPrinter(QPrinterInfo::defaultPrinter());
- QPrintDialog dlg(printer, this);
- if(dlg.exec() == QDialog::Accepted) {
- currentView->page()->print(printer, [printer](bool success) {
- Q_UNUSED(success);
- delete printer;
- });
- }
- }
- });
- connect(ui->actionPrintPageToPdf, &QAction::triggered, this, [this]() {
- if(currentView != nullptr) {
- const QString path = QFileDialog::getSaveFileName(this, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)"));
- currentView->page()->printToPdf(path);
- }
- });
-
- connect(ui->actionDeveloperTools, &QAction::triggered, this, [this]() {
- if(currentView != nullptr)
- createDevToolsDialog(currentView->page())->show();
- });
-
- pageLoadProfileMenu = ui->menuPage->addMenu(tr("Load Profile"));
- connect(pageLoadProfileMenu, &QMenu::aboutToShow, this, &MainWindow::updatePageLoadProfileMenu);
- }
-
// current subwindow shortcut
{
QAction *subwindowMenuAction = new QAction(this);
@@ -221,16 +127,13 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
disconnect(viewChangedConnection);
disconnect(searchBoxConnection);
disconnect(statusBarConnection);
- ui->actionCurrentSubwindow->setMenu(nullptr);
auto *w = qobject_cast<SubWindow *>(window);
if(w == nullptr) {
// no current subwindow, clear everything
setView(nullptr);
- ui->actionCurrentSubwindow->setMenu(nullptr);
} else {
setView(w->currentView());
- ui->actionCurrentSubwindow->setMenu(w->systemMenu());
viewChangedConnection = connect(w, &SubWindow::currentViewChanged, this, &MainWindow::setView);
statusBarConnection = connect(w, &SubWindow::showStatusMessage, statusBar(), &QStatusBar::showMessage);
}
@@ -340,7 +243,7 @@ SubWindow *MainWindow::currentSubWindow() const
return qobject_cast<SubWindow *>(mdiArea->currentSubWindow());
}
-SubWindow *MainWindow::createSubWindow(const Configuration *config, WebProfile *profile)
+SubWindow *MainWindow::createSubWindow(WebProfile *profile, bool openProfileNewtab)
{
bool shouldMaximize = true;
// if there is a current window, use its maximize state
@@ -348,7 +251,8 @@ SubWindow *MainWindow::createSubWindow(const Configuration *config, WebProfile *
shouldMaximize = currentWindow->isMaximized();
}
- auto *w = new SubWindow(config, this);
+ auto *w = new SubWindow(configuration, this);
+
w->setProfile(profile);
mdiArea->addSubWindow(w);
if(shouldMaximize)
@@ -357,6 +261,10 @@ SubWindow *MainWindow::createSubWindow(const Configuration *config, WebProfile *
w->show();
w->setFocus();
+
+ if(openProfileNewtab)
+ w->addTab(w->profile()->newtab());
+
return w;
}
@@ -384,22 +292,6 @@ void MainWindow::setView(WebView *view)
searchBox->setView(view);
}
-void MainWindow::updatePageLoadProfileMenu()
-{
- Q_CHECK_PTR(pageLoadProfileMenu);
- pageLoadProfileMenu->clear();
-
- if(currentView == nullptr)
- return;
-
- auto *profileManager = dynamic_cast<Browser *>(qApp)->getProfileManager();
- pageLoadProfileMenu->addActions(profileManager->createProfileMenu([this](WebProfile *profile) {
- this->currentView->setProfile(profile);
- },
- this)
- ->actions());
-}
-
void MainWindow::closeEvent(QCloseEvent *event)
{
if(mdiArea->subWindowList().count() > 1) {
diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h
index de77540..44ee633 100644
--- a/src/mainwindow/mainwindow.h
+++ b/src/mainwindow/mainwindow.h
@@ -22,15 +22,11 @@ class SearchForm;
class WebView;
class NavigationBar;
class WebProfile;
-
-namespace Ui
-{
-class MainWindow;
-}
-
+class MenuBar;
class MainWindow : public QMainWindow
{
friend class Browser;
+ friend class MenuBar;
Q_OBJECT
@@ -49,22 +45,19 @@ public:
const QVector<SubWindow *> subWindows() const;
SubWindow *currentSubWindow() const;
-signals:
- void createBookmark(const QString &title, const QString &url);
-
public slots:
void createTab(const QUrl &url);
- SubWindow *createSubWindow(const Configuration *config, WebProfile *profile);
+ SubWindow *createSubWindow(WebProfile *profile = nullptr, bool openProfileNewtab = false);
private slots:
void setView(WebView *view);
- void updatePageLoadProfileMenu();
protected:
void closeEvent(QCloseEvent *event) override;
private:
- Ui::MainWindow *ui;
+ const Configuration *configuration = nullptr;
+ MenuBar *m_menuBar = nullptr;
QMenu *toolsMenu = nullptr;
QMenu *pageLoadProfileMenu = nullptr;
diff --git a/src/mainwindow/mainwindow.ui b/src/mainwindow/mainwindow.ui
deleted file mode 100644
index 19cecbb..0000000
--- a/src/mainwindow/mainwindow.ui
+++ /dev/null
@@ -1,202 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>600</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>MainWindow</string>
- </property>
- <widget class="QWidget" name="centralwidget"/>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>30</height>
- </rect>
- </property>
- <widget class="QMenu" name="menusmolbote">
- <property name="title">
- <string>s&amp;molbote</string>
- </property>
- <addaction name="actionNewSubwindow"/>
- <addaction name="actionNewWindow"/>
- <addaction name="separator"/>
- <addaction name="actionAbout"/>
- <addaction name="actionAboutQt"/>
- <addaction name="separator"/>
- <addaction name="actionQuit"/>
- </widget>
- <widget class="QMenu" name="menuSession">
- <property name="title">
- <string>Sessio&amp;n</string>
- </property>
- <addaction name="actionSaveSession"/>
- <addaction name="actionLoadSession"/>
- </widget>
- <widget class="QMenu" name="menuSubWindow">
- <property name="title">
- <string>S&amp;ubwindow</string>
- </property>
- <addaction name="actionTileSubwindows"/>
- <addaction name="actionCascadeSubwindows"/>
- <addaction name="separator"/>
- <addaction name="actionCurrentSubwindow"/>
- </widget>
- <widget class="QMenu" name="menuTools">
- <property name="title">
- <string>Too&amp;ls</string>
- </property>
- <addaction name="actionBookmarks"/>
- <addaction name="actionDownloads"/>
- <addaction name="separator"/>
- <addaction name="actionAddPlugin"/>
- <addaction name="separator"/>
- </widget>
- <widget class="QMenu" name="menuPage">
- <property name="title">
- <string>Pa&amp;ge</string>
- </property>
- <addaction name="actionBookmarkPage"/>
- <addaction name="actionSavePage"/>
- <addaction name="actionPrintPage"/>
- <addaction name="actionPrintPageToPdf"/>
- <addaction name="separator"/>
- <addaction name="actionDeveloperTools"/>
- </widget>
- <addaction name="menusmolbote"/>
- <addaction name="menuSession"/>
- <addaction name="menuSubWindow"/>
- <addaction name="menuPage"/>
- <addaction name="menuTools"/>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
- <action name="actionNewSubwindow">
- <property name="text">
- <string>&amp;New Subwindow</string>
- </property>
- </action>
- <action name="actionNewWindow">
- <property name="icon">
- <iconset theme="window-new"/>
- </property>
- <property name="text">
- <string>New &amp;Window</string>
- </property>
- </action>
- <action name="actionAbout">
- <property name="icon">
- <iconset theme="help-about"/>
- </property>
- <property name="text">
- <string>&amp;About</string>
- </property>
- </action>
- <action name="actionAboutQt">
- <property name="text">
- <string>A&amp;bout Qt</string>
- </property>
- </action>
- <action name="actionQuit">
- <property name="icon">
- <iconset theme="application-exit"/>
- </property>
- <property name="text">
- <string>&amp;Quit</string>
- </property>
- </action>
- <action name="actionSaveSession">
- <property name="text">
- <string>&amp;Save Session</string>
- </property>
- </action>
- <action name="actionLoadSession">
- <property name="text">
- <string>&amp;Load Session</string>
- </property>
- </action>
- <action name="actionTileSubwindows">
- <property name="text">
- <string>&amp;Tile Subwindows</string>
- </property>
- </action>
- <action name="actionCascadeSubwindows">
- <property name="text">
- <string>&amp;Cascade Subwindows</string>
- </property>
- </action>
- <action name="actionCurrentSubwindow">
- <property name="text">
- <string>Current &amp;Subwindow</string>
- </property>
- </action>
- <action name="actionBookmarkPage">
- <property name="text">
- <string>&amp;Create Bookmark</string>
- </property>
- </action>
- <action name="actionSavePage">
- <property name="icon">
- <iconset theme="document-save"/>
- </property>
- <property name="text">
- <string>&amp;Save Page</string>
- </property>
- </action>
- <action name="actionPrintPage">
- <property name="icon">
- <iconset theme="document-print"/>
- </property>
- <property name="text">
- <string>&amp;Print Page</string>
- </property>
- </action>
- <action name="actionPrintPageToPdf">
- <property name="icon">
- <iconset theme="document-print"/>
- </property>
- <property name="text">
- <string>P&amp;rint to PDF</string>
- </property>
- </action>
- <action name="actionDeveloperTools">
- <property name="text">
- <string>&amp;Developer Tools</string>
- </property>
- </action>
- <action name="actionBookmarks">
- <property name="icon">
- <iconset theme="bookmarks"/>
- </property>
- <property name="text">
- <string>&amp;Bookmarks</string>
- </property>
- </action>
- <action name="actionDownloads">
- <property name="icon">
- <iconset theme="download"/>
- </property>
- <property name="text">
- <string>&amp;Downloads</string>
- </property>
- </action>
- <action name="actionAddPlugin">
- <property name="icon">
- <iconset theme="plugins"/>
- </property>
- <property name="text">
- <string>&amp;Add Plugin</string>
- </property>
- </action>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
new file mode 100644
index 0000000..0429ffd
--- /dev/null
+++ b/src/mainwindow/menubar.cpp
@@ -0,0 +1,239 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "menubar.h"
+#include "bookmarkswidget.h"
+#include "browser.h"
+#include "configuration.h"
+#include "downloadswidget.h"
+#include "mainwindow.h"
+#include "profilemanager.h"
+#include "session/sessiondialog.h"
+#include "subwindow/subwindow.h"
+#include "webengine/webview.h"
+#include "widgets/menusearch.h"
+#include <QApplication>
+#include <QDir>
+#include <QFileDialog>
+#include <QLineEdit>
+#include <QMdiArea>
+#include <QPrintDialog>
+#include <QPrinter>
+#include <QPrinterInfo>
+#include <QWidgetAction>
+
+MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
+ : QMenuBar(parent)
+{
+ auto *browser = qobject_cast<Browser *>(qApp);
+ Q_CHECK_PTR(browser);
+
+ smolbote = this->addMenu(qApp->applicationName());
+ {
+ auto *findMenu = smolbote->addMenu(tr("Find in menus"));
+
+ auto *findWidget = new QWidgetAction(this);
+ auto *find_lineEdit = new MenuSearch(this);
+ findWidget->setDefaultWidget(find_lineEdit);
+ findMenu->addAction(findWidget);
+
+ connect(findMenu, &QMenu::aboutToShow, [findMenu, find_lineEdit]() {
+ find_lineEdit->clear();
+ const auto actions = findMenu->actions();
+ for(int i = 1; i < actions.length(); i++)
+ findMenu->removeAction(actions.at(i));
+ find_lineEdit->setFocus();
+ });
+
+ connect(find_lineEdit, &QLineEdit::textEdited, [this, findMenu](const QString &text) {
+ // clear menu
+ const auto actions = findMenu->actions();
+ for(int i = 1; i < actions.length(); i++)
+ findMenu->removeAction(actions.at(i));
+
+ if(text.isEmpty())
+ return;
+
+ // findChildren
+ for(QAction *a : this->findChildren<QAction *>()) {
+ if(a->text().contains(text))
+ findMenu->addAction(a);
+ }
+ });
+
+ smolbote->addSeparator();
+
+ const QString sessionPath = config->value<QString>("browser.session.path").value();
+ smolbote->addAction(tr("Save Session"), parent, [parent, sessionPath]() {
+ const QString filename = QFileDialog::getSaveFileName(parent, tr("Save Session"), sessionPath, tr("JSON (*.json)"));
+ QFile output(filename);
+ if(output.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
+ auto *browser = qobject_cast<Browser *>(qApp);
+ auto data = Session::_session(browser->windows());
+ output.write(QJsonDocument(data).toJson());
+ output.close();
+ }
+ });
+
+ smolbote->addAction(tr("Open Session"), parent, [parent]() {
+ auto *sessionDialog = new SessionDialog(parent);
+ sessionDialog->exec();
+ });
+
+ smolbote->addSeparator();
+ auto *actionBookmarks = smolbote->addAction(tr("Bookmarks"), browser, [browser, parent]() {
+ browser->showWidget(browser->bookmarks(), parent);
+ });
+ config->setShortcut(actionBookmarks, "bookmarks.shortcut");
+
+ auto *actionDownloads = smolbote->addAction(tr("Downloads"), browser, [browser, parent]() {
+ browser->showWidget(browser->downloads(), parent);
+ });
+ config->setShortcut(actionDownloads, "downloads.shortcut");
+
+ smolbote->addSeparator();
+ smolbote->addAction(tr("Load Plugin"), browser, [browser]() {
+ const QString path = QFileDialog::getOpenFileName(nullptr, tr("Select Plugin"), QDir::homePath(), tr("Plugins (*.so)"));
+ browser->addPlugin(path);
+ });
+
+ pluginInsertLocation = smolbote->addSeparator();
+
+ auto *actionAbout = smolbote->addAction(tr("About"), browser, &Browser::about);
+ config->setShortcut(actionAbout, "mainwindow.shortcuts.about");
+
+ smolbote->addAction(tr("Help"));
+
+ //smolbote->addAction(tr("Check for updates"));
+
+ smolbote->addSeparator();
+
+ auto *actionQuit = smolbote->addAction(tr("Quit"), qApp, &QApplication::quit);
+ config->setShortcut(actionQuit, "mainwindow.shortcuts.quit");
+ }
+
+ auto *window = this->addMenu(tr("Window"));
+ {
+ auto *actionNewWindow = window->addAction(tr("New Window"), browser, &Browser::createWindow);
+ config->setShortcut(actionNewWindow, "mainwindow.shortcuts.newWindow");
+
+ auto *actionNewSubwindow = window->addAction(tr("New Subwindow"), parent, [parent]() {
+ parent->createSubWindow(nullptr, true);
+ });
+ config->setShortcut(actionNewSubwindow, "mainwindow.shortcuts.newGroup");
+
+ window->addSeparator();
+
+ auto *actionTileSubwindows = window->addAction(tr("Tile Subwindows"), parent->mdiArea, &QMdiArea::tileSubWindows);
+ config->setShortcut(actionTileSubwindows, "mainwindow.shortcuts.tileWindows");
+
+ auto *actionCascadeSubwindows = window->addAction(tr("Cascade Subwindows"), parent->mdiArea, &QMdiArea::cascadeSubWindows);
+ config->setShortcut(actionCascadeSubwindows, "mainwindow.shortcuts.cascadeWindows");
+ }
+
+ auto *subwindow = this->addMenu(tr("Subwindow"));
+ {
+ auto *actionNewTab = subwindow->addAction(tr("New Tab"), parent, [parent]() {
+ auto *_subwindow = parent->currentSubWindow();
+ if(_subwindow != nullptr) {
+ const int index = _subwindow->addTab();
+ _subwindow->setCurrentTab(index);
+ }
+ });
+ config->setShortcut(actionNewTab, "subwindow.shortcuts.new");
+
+ subwindow->addSeparator();
+
+ subwindow->addAction(tr("Restore last tab"), parent, [parent]() {
+ auto *_subwindow = parent->currentSubWindow();
+ if(_subwindow != nullptr) {
+ const int index = _subwindow->restoreLastTab();
+ _subwindow->setCurrentTab(index);
+ }
+ });
+
+ auto *restoreTabsMenu = subwindow->addMenu(tr("Restore previous tab"));
+ connect(restoreTabsMenu, &QMenu::aboutToShow, parent, [parent, restoreTabsMenu]() {
+ restoreTabsMenu->clear();
+ auto *_subwindow = parent->currentSubWindow();
+ if(_subwindow != nullptr) {
+ _subwindow->restoreTabMenu(restoreTabsMenu);
+ }
+ });
+
+ subwindow->addSeparator();
+
+ auto *subwindowProfile = subwindow->addMenu(tr("Subwindow Profile"));
+ connect(subwindowProfile, &QMenu::aboutToShow, subwindowProfile, [=]() {
+ subwindowProfile->clear();
+
+ auto *_subwindow = parent->currentSubWindow();
+ if(_subwindow != nullptr) {
+ browser->getProfileManager()->profilePickerMenu(subwindowProfile, _subwindow->profile(), [_subwindow](WebProfile *profile) {
+ _subwindow->setProfile(profile);
+ });
+ }
+ });
+ }
+
+ auto *page = this->addMenu(tr("Page"));
+ {
+ page->addAction(tr("Create Bookmark"), parent, [browser, parent]() {
+ if(parent->currentView != nullptr)
+ browser->bookmarks()->addBookmark(parent->currentView->title(), parent->currentView->url().toString());
+ });
+
+ page->addSeparator();
+
+ page->addAction(tr("Save"), parent, [parent]() {
+ if(parent->currentView != nullptr)
+ parent->currentView->triggerPageAction(QWebEnginePage::SavePage);
+ });
+ page->addAction(tr("Print"), parent, [parent]() {
+ if(parent->currentView != nullptr) {
+ auto *printer = new QPrinter(QPrinterInfo::defaultPrinter());
+ QPrintDialog dlg(printer, parent);
+ if(dlg.exec() == QDialog::Accepted) {
+ parent->currentView->page()->print(printer, [printer](bool success) {
+ Q_UNUSED(success);
+ delete printer;
+ });
+ }
+ }
+ });
+
+ page->addAction(tr("Print to PDF"), parent, [parent]() {
+ if(parent->currentView != nullptr) {
+ const QString path = QFileDialog::getSaveFileName(parent, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)"));
+ parent->currentView->page()->printToPdf(path);
+ }
+ });
+
+ page->addSeparator();
+
+ auto pageProfile = page->addMenu(tr("Page Profile"));
+ connect(pageProfile, &QMenu::aboutToShow, pageProfile, [=]() {
+ pageProfile->clear();
+
+ if(parent->currentView != nullptr) {
+ browser->getProfileManager()->profilePickerMenu(pageProfile, parent->currentView->profile(), [parent](WebProfile *profile) {
+ parent->currentView->setProfile(profile);
+ });
+ }
+ });
+
+ page->addSeparator();
+ page->addAction(tr("Developer Tools"));
+ page->addAction(tr("View Source"));
+ }
+}
+
+QAction *MenuBar::insertPlugin(QMenu *menu)
+{
+ return smolbote->insertMenu(pluginInsertLocation, menu);
+}
diff --git a/src/mainwindow/menubar.h b/src/mainwindow/menubar.h
new file mode 100644
index 0000000..38b1286
--- /dev/null
+++ b/src/mainwindow/menubar.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef SMOLBOTE_MENUBAR_H
+#define SMOLBOTE_MENUBAR_H
+
+#include <QMenuBar>
+
+class Configuration;
+class MainWindow;
+class MenuBar : public QMenuBar
+{
+public:
+ MenuBar(const Configuration *config, MainWindow *parent = nullptr);
+
+ QAction *insertPlugin(QMenu *menu);
+
+private:
+ QMenu *smolbote = nullptr;
+ QAction *pluginInsertLocation = nullptr;
+};
+
+#endif // SMOLBOTE_MENUBAR_H
diff --git a/src/mainwindow/widgets/menusearch.cpp b/src/mainwindow/widgets/menusearch.cpp
new file mode 100644
index 0000000..2905d6d
--- /dev/null
+++ b/src/mainwindow/widgets/menusearch.cpp
@@ -0,0 +1,17 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "menusearch.h"
+
+MenuSearch::MenuSearch(QWidget *parent)
+ : QLineEdit(parent)
+{
+ setMinimumWidth(300);
+ setPlaceholderText(tr("Find..."));
+ setClearButtonEnabled(true);
+}
diff --git a/src/mainwindow/widgets/menusearch.h b/src/mainwindow/widgets/menusearch.h
new file mode 100644
index 0000000..e20604c
--- /dev/null
+++ b/src/mainwindow/widgets/menusearch.h
@@ -0,0 +1,20 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef SMOLBOTE_MENUSEARCH_H
+#define SMOLBOTE_MENUSEARCH_H
+
+#include <QLineEdit>
+
+class MenuSearch : public QLineEdit
+{
+public:
+ MenuSearch(QWidget *parent = nullptr);
+};
+
+#endif // SMOLBOTE_MENUSEARCH_H
diff --git a/src/mainwindow/widgets/navigationbar.cpp b/src/mainwindow/widgets/navigationbar.cpp
index 61d17fa..c56d342 100644
--- a/src/mainwindow/widgets/navigationbar.cpp
+++ b/src/mainwindow/widgets/navigationbar.cpp
@@ -7,8 +7,9 @@
*/
#include "navigationbar.h"
-#include "urllineedit.h"
#include "configuration.h"
+#include "urllineedit.h"
+#include "util.h"
#include "webengine/webview.h"
#include <QHBoxLayout>
#include <QMenu>
@@ -17,7 +18,6 @@
#include <QToolBar>
#include <QToolButton>
#include <QWebEngineHistory>
-#include "util.h"
NavigationBar::NavigationBar(const Configuration *config, QWidget *parent)
: QToolBar(parent)