-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolorpickeroptionspage.cpp
More file actions
108 lines (80 loc) · 2.56 KB
/
colorpickeroptionspage.cpp
File metadata and controls
108 lines (80 loc) · 2.56 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "colorpickeroptionspage.h"
// Qt includes
#include <QCoreApplication>
#include <QDebug>
// QtCreator includes
#include <coreplugin/icore.h>
// Plugin includes
#include "colorpickerconstants.h"
#include "generalsettings.h"
#include "widgets/colorpickersettingswidget.h"
namespace ColorPicker {
namespace Internal {
////////////////////////// ColorPickerOptionsPageImpl //////////////////////////
class ColorPickerOptionsPageImpl
{
public:
ColorPickerOptionsPageImpl();
~ColorPickerOptionsPageImpl();
/* functions */
void init();
/* variables */
QString settingsPrefix;
GeneralSettings generalSettings;
QPointer<ColorPickerSettingsWidget> widget;
};
ColorPickerOptionsPageImpl::ColorPickerOptionsPageImpl() :
settingsPrefix(QLatin1String(Constants::COLORPICKER_SETTINGS_PREFIX)),
generalSettings()
{}
ColorPickerOptionsPageImpl::~ColorPickerOptionsPageImpl()
{}
void ColorPickerOptionsPageImpl::init()
{
const QSettings *s = Core::ICore::settings();
generalSettings.fromSettings(settingsPrefix, s);
}
////////////////////////// ColorPickerOptionsPage //////////////////////////
ColorPickerOptionsPage::ColorPickerOptionsPage(QObject *parent) :
Core::IOptionsPage(parent),
d(new ColorPickerOptionsPageImpl)
{
setId(Constants::COLORPICKER_SETTINGS_ID);
setDisplayName(tr(Constants::COLORPICKER_SETTINGS_DISPLAY_NAME));
setCategory(Constants::COLORPICKER_SETTINGS_CATEGORY);
setDisplayCategory(QCoreApplication::translate("ColorPicker",
Constants::COLORPICKER_SETTINGS_TR_CATEGORY));
setCategoryIcon(QLatin1String(Constants::COLORPICKER_SETTINGS_CATEGORY_ICON));
d->init();
}
ColorPickerOptionsPage::~ColorPickerOptionsPage()
{}
const GeneralSettings &ColorPickerOptionsPage::generalSettings() const
{
return d->generalSettings;
}
QWidget *ColorPickerOptionsPage::widget()
{
if (!d->widget)
d->widget = new ColorPickerSettingsWidget;
d->widget->settingsToUI(d->generalSettings);
return d->widget;
}
void ColorPickerOptionsPage::apply()
{
GeneralSettings newGeneralSettings;
d->widget->settingsFromUI(&newGeneralSettings);
QSettings *s = Core::ICore::settings();
if (d->generalSettings != newGeneralSettings) {
d->generalSettings = newGeneralSettings;
if (s)
d->generalSettings.toSettings(d->settingsPrefix, s);
emit generalSettingsChanged(newGeneralSettings);
}
}
void ColorPickerOptionsPage::finish()
{
delete d->widget;
}
} // namespace Internal
} // namespace ColorPicker