aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp6
-rw-r--r--src/browser.h1
-rw-r--r--src/main.cpp1
-rw-r--r--src/mainwindow/mainwindow.cpp17
-rw-r--r--src/subwindow/subwindow.cpp15
-rw-r--r--src/webengine/webview.cpp16
6 files changed, 15 insertions, 41 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 1e2ad25..493493f 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -139,12 +139,6 @@ void Browser::setup(const QString &defaultProfile)
});
}
-const QVector<WebProfile *> Browser::profiles() const
-{
- const QMap<QString, WebProfile *> profileList = profileManager->profileList();
- return QVector<WebProfile *>::fromList(profileList.values());
-}
-
void Browser::createSession(const QJsonObject &object)
{
MainWindow *mainwindow = nullptr;
diff --git a/src/browser.h b/src/browser.h
index 6969087..c82afa0 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -40,7 +40,6 @@ public:
Configuration *getConfiguration() const override;
const ProfileManager *getProfileManager() const override;
- const QVector<WebProfile *> profiles() const override;
QPair<QString, WebProfile *> loadProfile(const QString &id) override;
void setConfiguration(std::unique_ptr<Configuration> &config);
diff --git a/src/main.cpp b/src/main.cpp
index 405210f..12961ff 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -141,6 +141,7 @@ int main(int argc, char **argv)
// if app is primary, create new sessions from received messages
if(app.isPrimary() && !isStandalone) {
QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) {
+ Q_UNUSED(instanceId);
auto doc = QJsonDocument::fromJson(message);
app.createSession(doc.object());
});
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index 91e820a..eb4d34f 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -161,6 +161,7 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa
QPrintDialog dlg(printer, this);
if(dlg.exec() == QDialog::Accepted) {
currentView->page()->print(printer, [printer](bool success) {
+ Q_UNUSED(success);
delete printer;
});
}
@@ -379,19 +380,9 @@ void MainWindow::updatePageLoadProfileMenu()
if(currentView == nullptr)
return;
- auto *browser = qobject_cast<Browser *>(qApp);
- Q_CHECK_PTR(browser);
-
- ProfileIterator it(profileManager->profileList());
- while(it.hasNext()) {
- it.next();
- auto *profile = it.value();
- auto *loadAction = pageLoadProfileMenu->addAction(profile->name());
-
- connect(loadAction, &QAction::triggered, this, [=]() {
- currentView->setProfile(profile);
- });
- }
+ pageLoadProfileMenu->addActions(profileManager->createProfileMenu([this](WebProfile *profile) {
+ this->currentView->setProfile(profile);
+ }, this)->actions());
}
void MainWindow::closeEvent(QCloseEvent *event)
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp
index 4e79a03..0873010 100644
--- a/src/subwindow/subwindow.cpp
+++ b/src/subwindow/subwindow.cpp
@@ -50,17 +50,10 @@ SubWindow::SubWindow(const std::unique_ptr<Configuration> &config, QWidget *pare
Browser *browser = qobject_cast<Browser *>(qApp);
Q_CHECK_PTR(browser);
- ProfileIterator it(profileManager->profileList());
- while(it.hasNext()) {
- it.next();
- auto *profile = it.value();
- auto *loadAction = loadProfile_menu->addAction(profile->name());
-
- connect(loadAction, &QAction::triggered, this, [=]() {
- this->setProfile(profile);
- profileName_action->setText(tr("Profile: %1").arg(profile->name()));
- });
- }
+ loadProfile_menu->addActions(profileManager->createProfileMenu([this, profileName_action](WebProfile *profile) {
+ this->setProfile(profile);
+ profileName_action->setText(tr("Profile: %1").arg(profile->name()));
+ }, this)->actions());
menu->insertSeparator(firstAction);
}
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 94f73bc..963a894 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -243,16 +243,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
createWindow(QWebEnginePage::WebBrowserTab)->load(ctxdata.linkUrl());
});
- auto *newTabMenu = new QMenu(tr("Open link in new tab with profile"), this);
- ProfileIterator it(profileManager->profileList());
- while(it.hasNext()) {
- it.next();
- connect(newTabMenu->addAction(it.key()), &QAction::triggered, this, [this, ctxdata, it]() {
- auto *view = createWindow(QWebEnginePage::WebBrowserTab);
- view->setProfile(it.value());
- view->load(ctxdata.linkUrl());
- });
- }
+ QMenu *newTabMenu = profileManager->createProfileMenu([this, ctxdata](WebProfile *profile) {
+ auto *view = this->createWindow(QWebEnginePage::WebBrowserTab);
+ view->setProfile(profile);
+ view->load(ctxdata.linkUrl());
+ }, this);
+ newTabMenu->setTitle(tr("Open link in new tab with profile"));
menu->addMenu(newTabMenu);
connect(menu->addAction(tr("Open link in new window")), &QAction::triggered, this, [this, ctxdata]() {