From 2e7924a07d45c1d1468552f951dcd2f2dcc948fa Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 26 Sep 2022 22:14:18 -0400 Subject: 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. --- qdeduper/settings.hpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 qdeduper/settings.hpp (limited to 'qdeduper/settings.hpp') 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 +#include +#include +#include + +#include +#include + +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 smap; + std::vector klist; + friend class PreferenceDialog; +}; + +#endif -- cgit v1.2.3