-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.h
More file actions
82 lines (63 loc) · 1.88 KB
/
settings.h
File metadata and controls
82 lines (63 loc) · 1.88 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QDialog>
#include <QKeySequenceEdit>
#include <QKeyEvent>
#include <QDataStream>
namespace Ui {
class Settings;
}
/**
* @brief Structure SettingsConfig represents the configuration of the program.
* Provide basic functionatility to store/read the configuraiton from file
*/
typedef struct SettingsConfig
{
QKeyEvent mute;
QKeyEvent volDown;
QKeyEvent volUp;
bool showPopup;
bool isCorrect();
bool saveToFile(const QString& filename);
bool loadFromFile(const QString& filename);
} SettingsConfig_t;
QDataStream &operator<<(QDataStream &out, const SettingsConfig_t &settingsConfig);
QDataStream &operator>>(QDataStream &in, SettingsConfig_t &settingsConfig);
/**
* @brief The class that represents Settings dialog.
* All possbible configuration changes should be performed vie this dilog
*/
class Settings : public QDialog
{
Q_OBJECT
public:
explicit Settings(QWidget *parent = 0, SettingsConfig_t& config = Settings::DEFAULT_CFG );
~Settings();
const SettingsConfig_t& getConfig(){return _config;}
static SettingsConfig_t DEFAULT_CFG;
static void setAutoRun(bool autorun);
static bool isAutoRun();
private:
Ui::Settings *ui;
SettingsConfig_t _config = DEFAULT_CFG; //Thanks C++11!
signals:
void volumeChanged(double value);
void configChanged(SettingsConfig_t value);
private slots:
void slt_sliderValueChanged(int value);
void slt_muteChanged(QKeyEvent event);
void slt_volDownChanged(QKeyEvent event);
void slt_volUpChanged(QKeyEvent event);
void accept();
};
class SettingsKeySequence : public QKeySequenceEdit
{
Q_OBJECT
public:
explicit SettingsKeySequence(QWidget *parent = 0):QKeySequenceEdit(parent){}
signals:
void hotKeysReady(QKeyEvent event);
protected:
void keyPressEvent(QKeyEvent * event);
};
#endif // SETTINGS_H