aboutsummaryrefslogtreecommitdiff
path: root/lib/configuration/configuration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/configuration/configuration.cpp')
-rw-r--r--lib/configuration/configuration.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/configuration/configuration.cpp b/lib/configuration/configuration.cpp
index 75d0a5b..fa01951 100644
--- a/lib/configuration/configuration.cpp
+++ b/lib/configuration/configuration.cpp
@@ -9,6 +9,7 @@
#include "configuration.h"
#include <QStandardPaths>
#include <fstream>
+#include <boost/algorithm/string/predicate.hpp>
namespace po = boost::program_options;
@@ -48,6 +49,11 @@ Configuration::Configuration()
("browser.shortcuts.reload", po::value<std::string>()->default_value("Ctrl+F5"))
("browser.shortcuts.home", po::value<std::string>()->default_value("Ctrl+Home"))
+ // address bar
+ ("addressbar.shortcuts.focus", po::value<std::string>()->default_value("F4"))
+ ("addressbar.shortcuts.pageMenu", po::value<std::string>()->default_value("F2"))
+ ("addressbar.shortcuts.toolsMenu", po::value<std::string>()->default_value("F10"))
+
// tabs
("browser.shortcuts.tabClose", po::value<std::string>()->default_value("Ctrl+X"))
("browser.shortcuts.tabLeft", po::value<std::string>()->default_value("Ctrl+O"))
@@ -55,7 +61,6 @@ Configuration::Configuration()
// page
("browser.shortcuts.toggleSearchBox", po::value<std::string>()->default_value("F3"))
- ("browser.shortcuts.focusAddress", po::value<std::string>()->default_value("F4"))
("browser.shortcuts.fullscreen", po::value<std::string>()->default_value("F11"))
// Filter settings
@@ -106,7 +111,9 @@ QString Configuration::defaultUserConfigLocation()
bool Configuration::read(const QString &path)
{
std::ifstream f(path.toStdString(), std::ifstream::in);
- po::store(po::parse_config_file(f, desc, false), vm);
+
+ // parse_config_file(file, options_description, allow_unregistered)
+ po::store(po::parse_config_file(f, desc, true), vm);
return true;
}
@@ -120,3 +127,15 @@ bool Configuration::parse(int argc, const char **argv)
return true;
}
+
+QHash<QString, QString> Configuration::section(const std::string &prefix) const
+{
+ QHash<QString, QString> v;
+ for(auto s : desc.options()) {
+ if(boost::starts_with(s->long_name(), prefix)) {
+ v[s->long_name().c_str()] = QString::fromStdString(value<std::string>(s->long_name().c_str()).value());
+ }
+ }
+
+ return v;
+}