diff options
author | 2022-09-26 22:14:18 -0400 | |
---|---|---|
committer | 2022-09-26 22:17:44 -0400 | |
commit | 2e7924a07d45c1d1468552f951dcd2f2dcc948fa (patch) | |
tree | 24b6788b505a82f70f7dd82f8d9f1570fc88fef1 /qdeduper/settings.hpp | |
parent | 43a058c0957bec3fc564a7a019bdc03829e32e70 (diff) | |
download | deduper-2e7924a07d45c1d1468552f951dcd2f2dcc948fa.tar.xz |
Add a few basic settings items.
Yes I stole qmp's settings design and silently relicensed the
(largely identical) code. But who in the world cares, plus I'm the
author of qmp anyway.
Diffstat (limited to 'qdeduper/settings.hpp')
-rw-r--r-- | qdeduper/settings.hpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/qdeduper/settings.hpp b/qdeduper/settings.hpp new file mode 100644 index 0000000..fb1daa4 --- /dev/null +++ b/qdeduper/settings.hpp @@ -0,0 +1,58 @@ +#ifndef SETTINGS_HPP +#define SETTINGS_HPP + +#include <map> +#include <string> +#include <utility> +#include <vector> + +#include <QKeySequence> +#include <QSettings> + +struct SettingsItem +{ + enum ParameterType + { + _int, + _bool, + _double, + _keyseq, + _str, + _strlist + }; + ParameterType type; + int tab; + std::string key; + QString desc; + QVariant min, max; + QVariant defaultv; + QWidget *w; +}; + +class SettingsRegistry +{ +public: + SettingsRegistry(QString path); + ~SettingsRegistry(); + int register_tab(QString tab_name); + void register_int_option(int tab, std::string key, QString desc, int min, int max, int defaultval); + int get_option_int(std::string key); + void set_option_int(std::string key, int val); + void register_bool_option(int tab, std::string key, QString desc, bool defaultval); + bool get_option_bool(std::string key); + void set_option_bool(std::string key, bool val); + void register_double_option(int tab, std::string key, QString desc, double min, double max, double defaultval); + double get_option_double(std::string key); + void set_option_double(std::string key, double val); + void register_keyseq_option(int tab, std::string key, QString desc, QKeySequence defaultval); + QKeySequence get_option_keyseq(std::string key); + void set_option_keyseq(std::string key, QKeySequence ks); +private: + QSettings *s; + QStringList tabs; + std::map<std::string, SettingsItem> smap; + std::vector<std::string> klist; + friend class PreferenceDialog; +}; + +#endif |