aboutsummaryrefslogtreecommitdiff
path: root/qdeduper/settings.hpp
blob: fb1daa46616a012fa269858d5f8f4f08e0213c5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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