diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/mainwindowmenubar.cpp | 58 | ||||
-rw-r--r-- | src/widgets/mainwindowmenubar.h | 8 | ||||
-rw-r--r-- | src/widgets/webviewtabbar.cpp | 7 |
3 files changed, 42 insertions, 31 deletions
diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp index 964d9fd..c233d29 100644 --- a/src/widgets/mainwindowmenubar.cpp +++ b/src/widgets/mainwindowmenubar.cpp @@ -19,49 +19,61 @@ ******************************************************************************/ #include "mainwindowmenubar.h" +#include <QApplication> #include <QMenu> -#include "browser.h" #include <QInputDialog> #include "forms/profilesdialog.h" - -#include "interfaces.h" - #include "mainwindow.h" +#include <settings/configuration.h> -MainWindowMenuBar::MainWindowMenuBar(MainWindow *parent) : +MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, MainWindow *parent) : QMenuBar(parent) { - m_parentWindow = parent; + Q_ASSERT(config); + Q_ASSERT(parent); // Browser menu QMenu *browserMenu = new QMenu(qApp->applicationName(), this); addMenu(browserMenu); - browserMenu->addAction(tr("New Window"), parent, SLOT(newWindow()), QKeySequence::fromString(browser->settings()->value("window.shortcuts.windowNew").toString())); - browserMenu->addAction(tr("New Tab"), parent, SLOT(newTab()), QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabNew").toString())); + + QAction *newWindowAction = browserMenu->addAction(tr("New Window")); + connect(newWindowAction, &QAction::triggered, parent, [parent]() { + parent->newWindow(); + }); + newWindowAction->setShortcut(QKeySequence(config->value<std::string>("browser.shortcuts.newWindow").value().c_str())); + + QAction *newTabAction = browserMenu->addAction(tr("New Tab")); + connect(newTabAction, &QAction::triggered, parent, [parent]() { + parent->newTab(); + }); + newTabAction->setShortcut(QKeySequence(config->value<std::string>("browser.shortcuts.newTab").value().c_str())); + browserMenu->addSeparator(); - browserMenu->addAction(tr("About"), parent, SLOT(about()), QKeySequence(tr("F1"))); - browserMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt())); + browserMenu->addAction(tr("About"), parent, &MainWindow::about, QKeySequence(config->value<std::string>("browser.shortcuts.about").value().c_str())); + browserMenu->addAction(tr("About Qt"), qApp, &QApplication::aboutQt); browserMenu->addSeparator(); - browserMenu->addAction(tr("Quit"), qApp, SLOT(quit()), QKeySequence::fromString(browser->settings()->value("window.shortcuts.windowClose").toString())); + + QAction *quitAction = browserMenu->addAction(tr("Quit"), qApp, &QApplication::quit); + quitAction->setShortcut(QKeySequence(config->value<std::string>("browser.shortcuts.quit").value().c_str())); // Tools menu QMenu *toolsMenu = new QMenu(tr("Tools"), this); addMenu(toolsMenu); QAction *downloadsAction = toolsMenu->addAction(tr("Downloads")); downloadsAction->setParent(parent); - downloadsAction->setShortcut(QKeySequence::fromString(browser->settings()->value("downloads.dialogShortcut").toString())); - connect(downloadsAction, &QAction::triggered, this, [&]() { - m_parentWindow->addTabbedDock(Qt::RightDockWidgetArea, browser->downloads()); - }); + //downloadsAction->setShortcut(QKeySequence::fromString(browser->settings()->value("downloads.dialogShortcut").toString())); + //connect(downloadsAction, &QAction::triggered, this, [&]() { + // m_parentWindow->addTabbedDock(Qt::RightDockWidgetArea, browser->downloads()); + //}); QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks")); bookmarksAction->setParent(parent); - bookmarksAction->setShortcut(QKeySequence(browser->settings()->value("bookmarks.dialogShortcut").toString())); - connect(bookmarksAction, &QAction::triggered, this, [&]() { - m_parentWindow->addTabbedDock(Qt::RightDockWidgetArea, browser->bookmarks()); - }); + //bookmarksAction->setShortcut(QKeySequence(browser->settings()->value("bookmarks.dialogShortcut").toString())); + //connect(bookmarksAction, &QAction::triggered, this, [&]() { + // m_parentWindow->addTabbedDock(Qt::RightDockWidgetArea, browser->bookmarks()); + //}); toolsMenu->addSeparator(); - toolsMenu->addAction(tr("Filter"), browser->blocklists(), SLOT(show()), QKeySequence::fromString(browser->settings()->value("blocker.shortcut").toString())); + //toolsMenu->addAction(tr("Filter"), browser->blocklists(), SLOT(show()), QKeySequence::fromString(browser->settings()->value("blocker.shortcut").toString())); // Plugins // if(qApp->plugin("")) { @@ -78,7 +90,7 @@ MainWindowMenuBar::MainWindowMenuBar(MainWindow *parent) : // Profile menu QMenu *profileMenu = new QMenu(tr("Profile"), this); addMenu(profileMenu); - profileMenu->addAction(tr("Profiles"), this, SLOT(handleLoadProfile())); + //profileMenu->addAction(tr("Profiles"), this, SLOT(handleLoadProfile())); // Page menu QMenu *pageMenu = new QMenu(tr("Page"), this); @@ -93,9 +105,9 @@ QAction *MainWindowMenuBar::printAction() return m_printAction; } -void MainWindowMenuBar::handleLoadProfile() +void MainWindowMenuBar::handleLoadProfile(MainWindow *window) { - ProfilesDialog *dlg = new ProfilesDialog(m_parentWindow, this); + ProfilesDialog *dlg = new ProfilesDialog(window, this); dlg->exec(); // bool ok; diff --git a/src/widgets/mainwindowmenubar.h b/src/widgets/mainwindowmenubar.h index 43c786b..e5e5f38 100644 --- a/src/widgets/mainwindowmenubar.h +++ b/src/widgets/mainwindowmenubar.h @@ -22,22 +22,22 @@ #define MAINWINDOWMENUBAR_H #include <QMenuBar> +#include <memory> class MainWindow; +class Configuration; class MainWindowMenuBar : public QMenuBar { Q_OBJECT public: - explicit MainWindowMenuBar(MainWindow *parent = nullptr); + explicit MainWindowMenuBar(std::shared_ptr<Configuration> config, MainWindow *parent = nullptr); QAction *printAction(); private slots: - void handleLoadProfile(); + void handleLoadProfile(MainWindow *window); private: - MainWindow *m_parentWindow; - QAction *m_printAction; }; diff --git a/src/widgets/webviewtabbar.cpp b/src/widgets/webviewtabbar.cpp index 1367e40..f8d3dc1 100644 --- a/src/widgets/webviewtabbar.cpp +++ b/src/widgets/webviewtabbar.cpp @@ -19,7 +19,6 @@ ******************************************************************************/ #include "webviewtabbar.h" -#include "browser.h" #include <QAction> #include <QContextMenuEvent> #include <QMenu> @@ -40,19 +39,19 @@ WebViewTabBar::WebViewTabBar(WebEngineProfile *profile, QWidget *parent) : connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(updateVectorArrangement(int,int))); QShortcut *tabCloseShortcut = new QShortcut(this); - tabCloseShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabClose").toString())); + //tabCloseShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabClose").toString())); connect(tabCloseShortcut, &QShortcut::activated, [this]() { this->removeTab(currentIndex()); }); QShortcut *tabLeftShortcut = new QShortcut(this); - tabLeftShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabLeft").toString())); + //tabLeftShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabLeft").toString())); connect(tabLeftShortcut, &QShortcut::activated, [this]() { this->setCurrentIndex(currentIndex()-1); }); QShortcut *tabRightShortcut = new QShortcut(this); - tabRightShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabRight").toString())); + //tabRightShortcut->setKey(QKeySequence::fromString(browser->settings()->value("window.shortcuts.tabRight").toString())); connect(tabRightShortcut, &QShortcut::activated, [this]() { this->setCurrentIndex(currentIndex()+1); }); |