From 7eb573a67ea883228ff7905190ff46c0f29593b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 17 Dec 2017 13:25:38 +0100 Subject: ProfileView dialog --- src/widgets/mainwindowmenubar.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/widgets/mainwindowmenubar.cpp') diff --git a/src/widgets/mainwindowmenubar.cpp b/src/widgets/mainwindowmenubar.cpp index 5ef0618..dfd8b5b 100644 --- a/src/widgets/mainwindowmenubar.cpp +++ b/src/widgets/mainwindowmenubar.cpp @@ -22,10 +22,12 @@ #include #include #include -#include "forms/profilesdialog.h" +#include "forms/profileview.h" #include "mainwindow.h" #include +#include "browser.h" + MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr config, MainWindow *parent) : QMenuBar(parent) { @@ -74,9 +76,16 @@ MainWindowMenuBar::MainWindowMenuBar(std::shared_ptr config, Main //toolsMenu->addAction(tr("Filter"), browser->blocklists(), SLOT(show()), QKeySequence::fromString(browser->settings()->value("blocker.shortcut").toString())); // Profile menu - QMenu *profileMenu = new QMenu(tr("Profile"), this); - addMenu(profileMenu); - //profileMenu->addAction(tr("Profiles"), this, SLOT(handleLoadProfile())); + QMenu *profileMenu = addMenu(tr("Profile")); + m_profileAction = profileMenu->addAction(tr("Current profile")); + connect(m_profileAction, &QAction::triggered, this, [parent]() { + ProfileView *dlg = new ProfileView(parent->profile(), parent); + dlg->exec(); + delete dlg; + }); + + QMenu *loadMenu = profileMenu->addMenu(tr("Load")); + loadMenu->setEnabled(false); } QAction *MainWindowMenuBar::bookmarksAction() @@ -91,14 +100,13 @@ QAction *MainWindowMenuBar::downloadsAction() return m_downloadsAction; } -void MainWindowMenuBar::handleLoadProfile(MainWindow *window) +void MainWindowMenuBar::setProfileName(const QString &name) +{ + Q_CHECK_PTR(m_profileAction); + m_profileAction->setText(tr("Current: %1").arg(name)); +} + +void MainWindowMenuBar::handleLoadProfile(const QString &name, MainWindow *window) { - ProfilesDialog *dlg = new ProfilesDialog(window, this); - dlg->exec(); - -// bool ok; -// QString _name = QInputDialog::getText(this, tr("Load Profile"), tr("Enter Profile name"), QLineEdit::Normal, QString(""), &ok); -// if(ok) { -// m_parentWindow->setProfile(qApp->profile(_name)); -// } + window->setProfile(static_cast(qApp->instance())->profile(name)); } -- cgit v1.2.1