diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/configuration/configuration.cpp | 23 | ||||
-rw-r--r-- | lib/configuration/configuration.h | 3 |
2 files changed, 24 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; +} diff --git a/lib/configuration/configuration.h b/lib/configuration/configuration.h index c8fcdff..1c919b0 100644 --- a/lib/configuration/configuration.h +++ b/lib/configuration/configuration.h @@ -15,6 +15,7 @@ #include <QString> #include <boost/program_options.hpp> #include <QStringList> +#include <QVariant> class Configuration { @@ -68,6 +69,8 @@ public: return desc.options(); } + QHash<QString, QString> section(const std::string &prefix) const; + private: boost::program_options::options_description desc; boost::program_options::variables_map vm; |