diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-12 19:05:24 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-04-12 19:05:24 +0530 |
| commit | c8352009ceb6b9240ef7c1ad5be93f42312b59a2 (patch) | |
| tree | 9f71d00d2a8c5200dde4dd6a3f44354168d9017f /src/Configuration.hpp | |
| parent | 39b3e8d1e2581a47dff1f09450383df0466dac94 (diff) | |
| download | null-browser-c8352009ceb6b9240ef7c1ad5be93f42312b59a2.tar.gz null-browser-c8352009ceb6b9240ef7c1ad5be93f42312b59a2.zip | |
Switch to using map for configuration
Diffstat (limited to 'src/Configuration.hpp')
| -rw-r--r-- | src/Configuration.hpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Configuration.hpp b/src/Configuration.hpp index 06335dc..a1eca51 100644 --- a/src/Configuration.hpp +++ b/src/Configuration.hpp @@ -1,14 +1,33 @@ #pragma once #include <QtCore> +#include <unordered_map> class Configuration : public QObject { Q_OBJECT +private: + std::unordered_map<QString, QVariant> config_map{ + {"new_view_url", "https://duckduckgo.com"}, + {"close_window_when_no_views", true}, + }; + public: using QObject::QObject; - QString new_view_url = "https://duckduckgo.com"; + void set_config(const QString &name, const QVariant &value) { + qDebug() << "config update" << name << value; + config_map[name] = value; + emit config_updated(name, value); + } + + QVariant get_config(const QString &name) const { return config_map.at(name); } + + QString new_view_url() const { return get_config("new_view_url").toString(); } + bool close_window_when_no_views() const { + return get_config("close_window_when_no_views").toBool(); + } - bool close_window_when_no_views = true; +signals: + void config_updated(const QString &name, const QVariant &value); }; |
