aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-06-04 16:59:06 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-06-04 16:59:06 +0200
commitf5c858d477db5fc9d725b502e7f59d622fab380d (patch)
tree18f09b3931c9c2abc14c5fd00ac9d2c58e72bfb7
parentBrowser class refactoring (diff)
downloadsmolbote-f5c858d477db5fc9d725b502e7f59d622fab380d.tar.xz
Proper Profile loading
-rw-r--r--data/poi.toml8
-rw-r--r--src/browser.cpp16
-rw-r--r--src/webengine/webengineprofile.cpp12
-rw-r--r--src/webengine/webengineprofile.h2
4 files changed, 24 insertions, 14 deletions
diff --git a/data/poi.toml b/data/poi.toml
index 34fb697..904ad7a 100644
--- a/data/poi.toml
+++ b/data/poi.toml
@@ -1,8 +1,9 @@
#
# poi.conf
#
-# See https://gitlab.com/xiannox/smolbote/wikis/settings for options
-#
+# §home is ???
+# $cache is ???
+# $settings is ???
# General
[general]
@@ -15,8 +16,9 @@ search="https://duckduckgo.com/?q=$term&kp=-1"
#sessionPath="$cache/session.json"
# Profile
+# A nameless ("") profile is off-the-record
[browser.profile]
-default="" # "" is off-the-record
+default=""
path="$cache/Profiles/"
# Main window settings
diff --git a/src/browser.cpp b/src/browser.cpp
index ce36123..9ee7315 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -106,9 +106,16 @@ void Browser::loadPlugins()
void Browser::loadProfiles()
{
- // TODO properly
+ qDebug(">> Looking for profiles...");
profile("");
- profile("Default");
+ QDir dir(settings()->value("browser.profile.path").toString());
+ for(const QString name : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
+ qDebug("- Adding profile %s", qUtf8Printable(name));
+ profile(name);
+ }
+ qDebug("<< Profiles end...");
+
+ connect(this, SIGNAL(messageAvailable(QStringList)), this, SLOT(addWindow(QStringList)));
}
Browser *Browser::instance()
@@ -219,7 +226,8 @@ void Browser::addWindow(const QStringList params)
if(params.at(i) == "-p" || params.at(i) == "--profile") {
i++;
p = params.at(i);
- } else if(!params.at(i).startsWith('-')) {
+ } else if(!params.at(i).startsWith('-') && i > 0) {
+ qDebug("Appending url: %s", qUtf8Printable(params.at(i)));
urls.append(params.at(i));
}
}
@@ -242,7 +250,7 @@ WebEngineProfile* Browser::profile(const QString name)
if(name.isEmpty()) {
m_profiles.insert(name, new WebEngineProfile(this));
} else {
- m_profiles.insert(name, new WebEngineProfile(name, this));
+ m_profiles.insert(name, new WebEngineProfile(name, settings()->value("browser.profile.path").toString(), this));
}
if(!m_urlRequestInterceptor) {
diff --git a/src/webengine/webengineprofile.cpp b/src/webengine/webengineprofile.cpp
index 2fed937..ddf62a8 100644
--- a/src/webengine/webengineprofile.cpp
+++ b/src/webengine/webengineprofile.cpp
@@ -30,14 +30,14 @@ WebEngineProfile::WebEngineProfile(QObject *parent) :
m_name = tr("Off-the-record");
}
-WebEngineProfile::WebEngineProfile(const QString &storageName, QObject *parent) :
- QWebEngineProfile(storageName, parent)
+WebEngineProfile::WebEngineProfile(const QString &name, const QString &path, QObject *parent) :
+ QWebEngineProfile(name, parent)
{
- m_name = storageName;
- setPersistentStoragePath(sSettings->value("browser.profile.path").toString() + storageName);
- setCachePath(sSettings->value("browser.profile.path").toString() + storageName);
+ m_name = name;
+ setPersistentStoragePath(path + name);
+ setCachePath(path + name);
- QString profilePath = persistentStoragePath() + "/profile.ini";
+ QString profilePath = path + "/profile.ini";
qDebug("Reading profile from [%s]", qUtf8Printable(profilePath));
QSettings config(profilePath, QSettings::IniFormat);
diff --git a/src/webengine/webengineprofile.h b/src/webengine/webengineprofile.h
index 9a7be22..f13b266 100644
--- a/src/webengine/webengineprofile.h
+++ b/src/webengine/webengineprofile.h
@@ -29,7 +29,7 @@ class WebEngineProfile : public QWebEngineProfile
Q_OBJECT
public:
explicit WebEngineProfile(QObject *parent = Q_NULLPTR);
- WebEngineProfile(const QString &storageName, QObject *parent = Q_NULLPTR);
+ explicit WebEngineProfile(const QString &name, const QString &path, QObject *parent = Q_NULLPTR);
~WebEngineProfile();