aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--lib/settings/CMakeLists.txt2
-rw-r--r--lib/settings/settingsdialog.cpp2
-rw-r--r--src/browser.h2
-rw-r--r--src/configuration.cpp (renamed from lib/settings/configuration.cpp)40
-rw-r--r--src/configuration.h (renamed from lib/settings/configuration.h)42
-rw-r--r--src/main.cpp11
-rw-r--r--src/widgets/mainwindowtabbar.cpp5
8 files changed, 52 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc1cc4c..0147a9f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,8 @@ set(SourceCode
"src/singleapplication.h"
"src/browser.cpp"
"src/browser.h"
+ src/configuration.cpp
+ src/configuration.h
"data/resources.qrc"
# main window
diff --git a/lib/settings/CMakeLists.txt b/lib/settings/CMakeLists.txt
index 26d8525..20c78ae 100644
--- a/lib/settings/CMakeLists.txt
+++ b/lib/settings/CMakeLists.txt
@@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.1.0)
add_library(configuration
- configuration.cpp
- configuration.h
settingsdialog.cpp
settingsdialog.h
settingsdialog.ui)
diff --git a/lib/settings/settingsdialog.cpp b/lib/settings/settingsdialog.cpp
index 36b7d2c..bd0aa49 100644
--- a/lib/settings/settingsdialog.cpp
+++ b/lib/settings/settingsdialog.cpp
@@ -7,7 +7,7 @@
*/
#include "settingsdialog.h"
-#include "configuration.h"
+#include "../../src/configuration.h"
#include "ui_settingsdialog.h"
#include <QFormLayout>
#include <QGroupBox>
diff --git a/src/browser.h b/src/browser.h
index 2cb6969..f58dce7 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -9,7 +9,7 @@
#ifndef BROWSER_H
#define BROWSER_H
-#include "settings/configuration.h"
+#include "configuration.h"
#include "singleapplication.h"
#include "webengine/webengineprofile.h"
#include <QVector>
diff --git a/lib/settings/configuration.cpp b/src/configuration.cpp
index 10c284c..b281b70 100644
--- a/lib/settings/configuration.cpp
+++ b/src/configuration.cpp
@@ -97,7 +97,7 @@ std::vector<std::string> Configuration::childrenGroups(const char *name)
return groupNames;
}
-std::string Configuration::castToString(const libconfig::Setting &v) const
+std::string castToString(const libconfig::Setting &v)
{
// cast depending on type
// type checks are done during compile time
@@ -132,12 +132,38 @@ std::string Configuration::castToString(const libconfig::Setting &v) const
}
}
-std::string patchHome(const std::string &path, const std::string &home)
+void setFromString(libconfig::Setting &setting, const std::string &value)
{
- std::string r = path;
- const size_t location = path.find('~');
- if(location != std::string::npos) {
- return r.replace(location, 1, home);
+ switch(setting.getType()) {
+ case libconfig::Setting::TypeNone:
+ break;
+
+ case libconfig::Setting::TypeInt:
+ case libconfig::Setting::TypeInt64:
+ setting = std::stoi(value);
+ break;
+
+ case libconfig::Setting::TypeFloat:
+ setting = std::stod(value);
+ break;
+
+ case libconfig::Setting::TypeString:
+ setting = value.c_str();
+ break;
+
+ case libconfig::Setting::TypeBoolean:
+ if(value == "true") {
+ setting = true;
+ } else if(value == "false") {
+ setting = false;
+ }
+ break;
+
+ case libconfig::Setting::TypeGroup:
+ break;
+ case libconfig::Setting::TypeArray:
+ break;
+ case libconfig::Setting::TypeList:
+ break;
}
- return r;
}
diff --git a/lib/settings/configuration.h b/src/configuration.h
index 82e0c58..8173a86 100644
--- a/lib/settings/configuration.h
+++ b/src/configuration.h
@@ -15,6 +15,9 @@
#include <vector>
#include <QString>
+std::string castToString(const libconfig::Setting &v);
+void setFromString(libconfig::Setting &setting, const std::string &value);
+
class Configuration
{
public:
@@ -61,39 +64,7 @@ public:
if constexpr(std::is_unsigned_v<T> && !std::is_same_v<T, bool>) {
setting = static_cast<typename std::make_signed_t<T>>(val);
} else if constexpr(std::is_same_v<T, std::string>) {
- switch(setting.getType()) {
- case libconfig::Setting::TypeNone:
- break;
-
- case libconfig::Setting::TypeInt:
- case libconfig::Setting::TypeInt64:
- setting = std::stoi(static_cast<std::string>(val));
- break;
-
- case libconfig::Setting::TypeFloat:
- setting = std::stod(static_cast<std::string>(val));
- break;
-
- case libconfig::Setting::TypeString:
- setting = static_cast<std::string>(val).c_str();
- break;
-
- case libconfig::Setting::TypeBoolean:
- if(static_cast<std::string>(val) == "true") {
- setting = true;
- } else if(static_cast<std::string>(val) == "false") {
- setting = false;
- }
- break;
-
- case libconfig::Setting::TypeGroup:
- break;
- case libconfig::Setting::TypeArray:
- break;
- case libconfig::Setting::TypeList:
- break;
- }
-
+ setFromString(setting, val);
} else {
setting = val;
}
@@ -103,15 +74,10 @@ public:
}
private:
- std::string castToString(const libconfig::Setting &v) const;
-
bool changed = false;
std::string m_homePath;
std::string m_userCfgPath;
libconfig::Config *m_userCfg;
};
-// replace ~ with home
-std::string patchHome(const std::string &path, const std::string &home);
-
#endif // CONFIGURATION_H
diff --git a/src/main.cpp b/src/main.cpp
index 66df526..cce2c61 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -99,10 +99,17 @@ int main(int argc, char **argv)
instance.setConfiguration(config);
- instance.createSession(parser.value(profileOption), parser.isSet(newWindowOption), parser.positionalArguments());
+ if(parser.isSet(profileOption))
+ instance.createSession(parser.value(profileOption), parser.isSet(newWindowOption), parser.positionalArguments());
+ else
+ instance.createSession(QString::fromStdString(config->value<std::string>("browser.profile").value()), parser.isSet(newWindowOption), parser.positionalArguments());
#ifdef QT_DEBUG
qDebug("Startup complete in %lldms", timer.elapsed());
#endif
- return instance.exec();
+
+ // Normally we'd use
+ //return instance.exec();
+ // but, Call to "exec" is ambiguous
+ return static_cast<QApplication *>(&instance)->exec();
}
diff --git a/src/widgets/mainwindowtabbar.cpp b/src/widgets/mainwindowtabbar.cpp
index 5b7ce4b..213b2c2 100644
--- a/src/widgets/mainwindowtabbar.cpp
+++ b/src/widgets/mainwindowtabbar.cpp
@@ -7,11 +7,10 @@
*/
#include "mainwindowtabbar.h"
+#include "src/configuration.h"
+#include "src/mainwindow/mainwindow.h"
#include <QContextMenuEvent>
#include <QShortcut>
-#include <settings/configuration.h>
-
-#include "src/mainwindow/mainwindow.h"
MainWindowTabBar::MainWindowTabBar(const std::shared_ptr<Configuration> &config, MainWindow *parent)
: QTabBar(parent)