aboutsummaryrefslogtreecommitdiff
path: root/src/browser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/browser.cpp')
-rw-r--r--src/browser.cpp67
1 files changed, 47 insertions, 20 deletions
diff --git a/src/browser.cpp b/src/browser.cpp
index 0135a4c..4df7eb9 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -30,6 +30,13 @@ Browser::Browser(int &argc, char *argv[]) :
// This lets the web view automatically scale on high-dpi displays.
setAttribute(Qt::AA_EnableHighDpiScaling);
+
+ m_settings = nullptr;
+ m_localServer = nullptr;
+
+ m_networkAccessManager = nullptr;
+ m_bookmarksManager = nullptr;
+ m_downloadManager = nullptr;
}
Browser::~Browser()
@@ -37,9 +44,17 @@ Browser::~Browser()
qDeleteAll(m_windows);
m_windows.clear();
- delete m_networkAccessManager;
- delete m_bookmarksManager;
- delete m_downloadManager;
+ if(m_networkAccessManager) {
+ delete m_networkAccessManager;
+ }
+
+ if(m_bookmarksManager) {
+ delete m_bookmarksManager;
+ }
+
+ if(m_downloadManager) {
+ delete m_downloadManager;
+ }
}
QString Browser::applicationLongVersion() const
@@ -51,23 +66,7 @@ QString Browser::applicationLongVersion() const
#endif
}
-/*!
- * Check if the settings are empty
- */
-void Browser::firstRun()
-{
- if(m_settings->isEmpty()) {
- // There are no keys in the settings
- QMessageBox::information(0,
- tr("Configuration is empty"),
- tr("The configuration file <i>%1</i> is empty. Using default values").arg(m_settings->filePath()));
- }
-}
-
-/*!
- * Anything that needs to run after the QCommandLineParser but before showing a main window
- */
-bool Browser::preLaunch(QStringList urls)
+bool Browser::prepare(QStringList urls)
{
if(m_settings->value("browser.singleInstance", true).toBool()) {
QString serverName = m_settings->value("browser.localSocket", "smolbote-singlelock").toString();
@@ -98,6 +97,13 @@ bool Browser::preLaunch(QStringList urls)
}
}
+ if(m_settings->isEmpty()) {
+ // There are no keys in the settings
+ QMessageBox::information(0,
+ tr("Configuration is empty"),
+ tr("The configuration file <i>%1</i> is empty. Using default values").arg(m_settings->filePath()));
+ }
+
m_networkAccessManager = new QNetworkAccessManager();
m_bookmarksManager = new BookmarksWidget;
m_downloadManager = new DownloadsWidget;
@@ -187,6 +193,27 @@ void Browser::removeWindow(MainWindow *window)
m_windows.removeOne(window);
}
+WebEngineProfile* Browser::profile(const QString name)
+{
+ if(!m_profiles.contains(name)) {
+ // name can be empty --> off-the-record profile
+ if(name.isEmpty()) {
+ m_profiles.insert(name, new WebEngineProfile(this));
+ } else {
+ m_profiles.insert(name, new WebEngineProfile(name, this));
+ }
+
+ // TODO: UrlRequestInterceptor
+ // UrlRequestInterceptor *interceptor = new UrlRequestInterceptor(this);
+ // interceptor->setSubscription(blocklistManager);
+ // m_profile->setRequestInterceptor(interceptor);
+
+ connect(m_profiles[name], SIGNAL(downloadRequested(QWebEngineDownloadItem*)), downloads(), SLOT(addDownload(QWebEngineDownloadItem*)));
+ }
+
+ return m_profiles[name];
+}
+
void Browser::handleNewConnection()
{
QLocalSocket *socket = m_localServer->nextPendingConnection();