aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser.cpp39
-rw-r--r--src/browser.h6
-rw-r--r--src/mainwindow/mainwindow.cpp2
-rw-r--r--src/mainwindow/menubar.cpp10
-rw-r--r--src/meson.build2
-rw-r--r--src/session/savesessiondialog.cpp2
-rw-r--r--src/session/session.cpp2
-rw-r--r--src/subwindow/subwindow.cpp27
-rw-r--r--src/webengine/webview.cpp11
9 files changed, 37 insertions, 64 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 3a23eeb..6e1e2ba 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -15,7 +15,7 @@
#include "configuration.h"
#include "downloadswidget.h"
#include "mainwindow/mainwindow.h"
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "subwindow/subwindow.h"
#include "util.h"
#include "webengine/urlinterceptor.h"
@@ -94,13 +94,18 @@ const QList<QPair<QString, Profile *>> Browser::profileList() const
QPair<QString, Profile *> Browser::loadProfile(const QString &id, bool isOffTheRecord)
{
- WebProfile *profile = nullptr;
- if(QFile::exists(id)) {
- profile = m_profileManager->loadProfile(id);
- } else {
- profile = m_profileManager->createProfile(id, isOffTheRecord);
- }
+ const QString _id = [id](){
+ // if id contains a separator, it should be a path
+ if(id.contains(QDir::separator())) {
+ return QFileInfo(id).baseName();
+ } else {
+ return id;
+ }
+ }();
+
+ auto *profile = m_profileManager->profile(/* id */ _id, /* path */ (_id == id) ? QString() : id, isOffTheRecord);
connect(profile, &WebProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload);
+
auto *interceptor = new UrlRequestInterceptor(profile, profile);
for(UrlFilter *filter : m_filters) {
interceptor->addFilter(filter);
@@ -113,7 +118,7 @@ QPair<QString, Profile *> Browser::loadProfile(const QString &id, bool isOffTheR
}
profile->setRequestInterceptor(interceptor);
- return QPair<QString, WebProfile *>(m_profileManager->id(profile), profile);
+ return QPair<QString, WebProfile *>(_id, profile);
}
void Browser::removeProfile(const QString &id)
@@ -133,7 +138,7 @@ Configuration *Browser::getConfiguration() const
return m_config.get();
}
-ProfileManager *Browser::getProfileManager()
+WebProfileManager *Browser::getProfileManager()
{
return m_profileManager;
}
@@ -192,7 +197,7 @@ void Browser::setup(QVector<QPluginLoader *> plugins)
// cookie request filter
// load profiles
- m_profileManager = new ProfileManager(m_config->section("profile"), this);
+ m_profileManager = new WebProfileManager(m_config->section("profile"), this);
for(const QString &profilePath : Util::files(m_config->value<QString>("profile.path").value(), { "*.profile" })) {
this->loadProfile(profilePath);
}
@@ -220,22 +225,20 @@ void Browser::setup(QVector<QPluginLoader *> plugins)
subwindow->currentView()->load(url);
});
- auto *openInCurrentTabWithProfile = m_profileManager->createProfileMenu([url, subwindow](WebProfile *profile) {
+ auto *openInCurrentTabWithProfile = menu->addMenu(tr("Open link in current tab with profile"));
+ m_profileManager->profileMenu(openInCurrentTabWithProfile, [url, subwindow](WebProfile *profile) {
subwindow->currentView()->setProfile(profile);
subwindow->currentView()->load(url);
- }, nullptr);
- openInCurrentTabWithProfile->setTitle(tr("Open link in current tab with profile"));
- menu->addMenu(openInCurrentTabWithProfile);
+ });
menu->addAction(tr("Open link in new tab"), subwindow, [url, subwindow]() {
subwindow->addTab(url);
});
- auto *openInNewTabWithProfile = m_profileManager->createProfileMenu([url, subwindow](WebProfile *profile) {
+ auto *openInNewTabWithProfile = menu->addMenu(tr("Open link in new tab with profile"));
+ m_profileManager->profileMenu(openInNewTabWithProfile, [url, subwindow](WebProfile *profile) {
subwindow->addTab(url, profile);
- }, nullptr);
- openInNewTabWithProfile->setTitle(tr("Open link in new tab with profile"));
- menu->addMenu(openInNewTabWithProfile);
+ });
menu->exec(pos);
});
diff --git a/src/browser.h b/src/browser.h
index 8a40152..32011e0 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -24,7 +24,7 @@ class Configuration;
class BookmarksWidget;
class DownloadsWidget;
class MainWindow;
-class ProfileManager;
+class WebProfileManager;
class Browser : public SingleApplication, public BrowserInterface
{
Q_OBJECT
@@ -43,7 +43,7 @@ public:
const QString configuration(const QString &key) const override;
void setConfiguration(const QString &key, const QString &value) override;
- ProfileManager *getProfileManager();
+ WebProfileManager *getProfileManager();
const QList<QPair<QString, Profile *>> profileList() const override;
QPair<QString, Profile *> loadProfile(const QString &id, bool isOffTheRecord = true) override;
void removeProfile(const QString &id) override;
@@ -90,7 +90,7 @@ private:
std::unique_ptr<Configuration> m_config;
std::shared_ptr<BookmarksWidget> m_bookmarks;
std::unique_ptr<DownloadsWidget> m_downloads;
- ProfileManager *m_profileManager;
+ WebProfileManager *m_profileManager;
QVector<UrlFilter *> m_filters;
QVector<MainWindow *> m_windows;
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp
index a5f1c90..71b594a 100644
--- a/src/mainwindow/mainwindow.cpp
+++ b/src/mainwindow/mainwindow.cpp
@@ -12,7 +12,7 @@
#include "config.h"
#include "configuration.h"
#include "menubar.h"
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "session/session.h"
#include "session/sessiondialog.h"
#include "subwindow/subwindow.h"
diff --git a/src/mainwindow/menubar.cpp b/src/mainwindow/menubar.cpp
index 8e2180d..117641f 100644
--- a/src/mainwindow/menubar.cpp
+++ b/src/mainwindow/menubar.cpp
@@ -12,7 +12,7 @@
#include "configuration.h"
#include "downloadswidget.h"
#include "mainwindow.h"
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "session/savesessiondialog.h"
#include "session/sessiondialog.h"
#include "subwindow/subwindow.h"
@@ -344,9 +344,9 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
auto *_subwindow = parent->currentSubWindow();
if(_subwindow != nullptr) {
- browser->getProfileManager()->profilePickerMenu(subwindowProfile, _subwindow->profile(), [_subwindow](WebProfile *profile) {
+ browser->getProfileManager()->profileMenu(subwindowProfile, [_subwindow](WebProfile *profile) {
_subwindow->setProfile(profile);
- });
+ }, _subwindow->profile(), true);
}
});
}
@@ -391,9 +391,9 @@ MenuBar::MenuBar(const Configuration *config, MainWindow *parent)
pageProfile->clear();
if(parent->currentView != nullptr) {
- browser->getProfileManager()->profilePickerMenu(pageProfile, parent->currentView->profile(), [parent](WebProfile *profile) {
+ browser->getProfileManager()->profileMenu(pageProfile, [parent](WebProfile *profile) {
parent->currentView->setProfile(profile);
- });
+ }, parent->currentView->profile(), true);
}
});
diff --git a/src/meson.build b/src/meson.build
index fb338d8..ce4e216 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -14,7 +14,7 @@ poi_moc = qt5.preprocess(
poi = executable(get_option('poiName'), install: true,
cpp_args: ['-DQAPPLICATION_CLASS=QApplication'],
dependencies: [dep_qt5, dep_boost, dep_SingleApplication, dep_genheaders, dep_breakpad, dep_plasma,
- dep_about, dep_addressbar, dep_bookmarks, dep_configuration, dep_downloads, dep_urlfilter, dep_web],
+ dep_about, dep_addressbar, dep_bookmarks, dep_configuration, dep_downloads, dep_urlfilter, dep_webprofile],
include_directories: [include],
sources: ['main.cpp', 'builtins.cpp', 'crashhandler.cpp', poi_moc,
'browser.cpp',
diff --git a/src/session/savesessiondialog.cpp b/src/session/savesessiondialog.cpp
index 808ba45..9291215 100644
--- a/src/session/savesessiondialog.cpp
+++ b/src/session/savesessiondialog.cpp
@@ -9,7 +9,7 @@
#include "savesessiondialog.h"
#include "browser.h"
#include "mainwindow/mainwindow.h"
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "subwindow/subwindow.h"
#include "ui_savesessiondialog.h"
#include "webengine/webview.h"
diff --git a/src/session/session.cpp b/src/session/session.cpp
index f7d372b..51575bf 100644
--- a/src/session/session.cpp
+++ b/src/session/session.cpp
@@ -10,7 +10,7 @@
#include "../webengine/webview.h"
#include "browser.h"
#include "mainwindow/mainwindow.h"
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "subwindow/subwindow.h"
#include "webengine/webview.h"
#include <QJsonArray>
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp
index 76eddb3..31b49b9 100644
--- a/src/subwindow/subwindow.cpp
+++ b/src/subwindow/subwindow.cpp
@@ -20,7 +20,6 @@
#include <QTabBar>
#include <QToolButton>
#include "configuration.h"
-#include "profilemanager.h"
#include "webprofile.h"
SubWindow::SubWindow(const Configuration *config, QWidget *parent, Qt::WindowFlags flags)
@@ -35,32 +34,6 @@ SubWindow::SubWindow(const Configuration *config, QWidget *parent, Qt::WindowFla
m_profile = WebProfile::defaultProfile();
- // system menu
- {
- QMenu *menu = systemMenu();
- auto *firstAction = menu->actions().at(0);
-
- auto *profileName_action = new QAction(tr("Profile: %1").arg(m_profile->name()), menu);
- profileName_action->setEnabled(false);
- menu->insertAction(firstAction, profileName_action);
-
- auto *loadProfile_menu = new QMenu(tr("Load profile"), menu);
- menu->insertMenu(firstAction, loadProfile_menu);
-
- Browser *browser = qobject_cast<Browser *>(qApp);
- Q_CHECK_PTR(browser);
-
- auto *profileManager = dynamic_cast<Browser *>(qApp)->getProfileManager();
- 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);
- }
-
auto *fullScreen_shortcut = new QShortcut(QKeySequence(config->value<QString>("subwindow.shortcuts.fullscreen").value()), this);
connect(fullScreen_shortcut, &QShortcut::activated, this, [=]() {
auto *w = this->window();
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 3861306..5e350eb 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -20,7 +20,7 @@
#include <QWebEngineContextMenuData>
#include <QWebEngineHistoryItem>
#include <QWidgetAction>
-#include "profilemanager.h"
+#include "webprofilemanager.h"
#include "webprofile.h"
#include "browser.h"
#include "wallet/wallet.h"
@@ -247,15 +247,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
createWindow(QWebEnginePage::WebBrowserTab)->load(ctxdata.linkUrl());
});
- auto *profileManager = dynamic_cast<Browser *>(qApp)->getProfileManager();
- QMenu *newTabMenu = profileManager->createProfileMenu([this, ctxdata](WebProfile *profile) {
+ auto *newTabMenu = menu->addMenu(tr("Open link in new tab with profile"));
+ dynamic_cast<Browser*>(qApp)->getProfileManager()->profileMenu(newTabMenu, [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]() {
createWindow(QWebEnginePage::WebBrowserWindow)->load(ctxdata.linkUrl());