aboutsummaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-01-30 13:34:44 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-01-30 13:34:44 +0100
commitaffad4abfdd065a3c329ef40c1a46042c0562f2f (patch)
tree49368a9f941ef4192c3a5e10bd7007ce84867100 /src/widgets
parentAdded profile and plugin list to About dialog (diff)
downloadsmolbote-affad4abfdd065a3c329ef40c1a46042c0562f2f.tar.xz
Profile menu lists loadable profiles
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/mainwindowmenubar.cpp21
-rw-r--r--src/widgets/mainwindowmenubar.h5
2 files changed, 14 insertions, 12 deletions
diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp
index d24f273..3c5b042 100644
--- a/src/widgets/mainwindowmenubar.cpp
+++ b/src/widgets/mainwindowmenubar.cpp
@@ -7,6 +7,7 @@
*/
#include "mainwindowmenubar.h"
+#include "browser.h"
#include "downloads/downloadswidget.h"
#include "src/mainwindow/mainwindow.h"
#include <QInputDialog>
@@ -19,6 +20,8 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, Main
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+ auto *browser = dynamic_cast<Browser *>(QApplication::instance());
+
// Browser menu
QMenu *browserMenu = new QMenu(qApp->applicationName(), this);
addMenu(browserMenu);
@@ -36,7 +39,7 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, Main
newTabAction->setShortcut(QKeySequence(config->value<std::string>("browser.shortcuts.newTab").value().c_str()));
browserMenu->addSeparator();
- browserMenu->addAction(tr("Settings"), parent, &MainWindow::showSettingsDialog);
+ //browserMenu->addAction(tr("Settings"), parent, &MainWindow::showSettingsDialog);
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();
@@ -67,7 +70,13 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr<Configuration> config, Main
m_profileAction->setEnabled(false);
QMenu *loadMenu = profileMenu->addMenu(tr("Load"));
- loadMenu->setEnabled(false);
+
+ for(const QString &name : browser->profiles()) {
+ QAction *profileAction = loadMenu->addAction(browser->profile(name)->name());
+ connect(profileAction, &QAction::triggered, this, [browser, parent, name] {
+ parent->setProfile(browser->profile(name));
+ });
+ }
}
QAction *MainWindowMenuBar::bookmarksAction()
@@ -76,13 +85,9 @@ QAction *MainWindowMenuBar::bookmarksAction()
return m_bookmarksAction;
}
-void MainWindowMenuBar::setProfileName(const QString &name)
+QAction *MainWindowMenuBar::profileAction() const
{
Q_CHECK_PTR(m_profileAction);
- m_profileAction->setText(tr("Current: %1").arg(name));
+ return m_profileAction;
}
-void MainWindowMenuBar::handleLoadProfile(const QString &name, MainWindow *window)
-{
- window->setProfile(static_cast<Browser *>(qApp->instance())->profile(name));
-}
diff --git a/src/widgets/mainwindowmenubar.h b/src/widgets/mainwindowmenubar.h
index 334829f..11c8beb 100644
--- a/src/widgets/mainwindowmenubar.h
+++ b/src/widgets/mainwindowmenubar.h
@@ -21,10 +21,7 @@ public:
explicit MainWindowMenuBar(std::shared_ptr<Configuration> config, MainWindow *parent = nullptr);
QAction *bookmarksAction();
- void setProfileName(const QString &name);
-
-private slots:
- void handleLoadProfile(const QString &name, MainWindow *window);
+ QAction *profileAction() const;
private:
QAction *m_bookmarksAction;