blob: c5e2289eef822104858e24bbb846c4df422b6e84 (
plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#include "colorhighlighting.h"
#include <QApplication>
#include <QDebug>
#include "SettingsGroup.hpp"
#include "models/DecodeHighlightingModel.hpp"
#include "ui_colorhighlighting.h"
#include "moc_colorhighlighting.cpp"
ColorHighlighting::ColorHighlighting (QSettings * settings, DecodeHighlightingModel const& highlight_model, QWidget * parent)
: QDialog {parent}
, ui {new Ui::ColorHighlighting}
, settings_ {settings}
{
ui->setupUi(this);
setWindowTitle (QApplication::applicationName () + " - Colors");
read_settings ();
set_items (highlight_model);
}
ColorHighlighting::~ColorHighlighting()
{
if (isVisible ()) write_settings ();
}
void ColorHighlighting::read_settings ()
{
SettingsGroup group {settings_, "ColorScheme"};
restoreGeometry (settings_->value ("window/geometry").toByteArray ());
}
void ColorHighlighting::write_settings ()
{
SettingsGroup group {settings_, "ColorScheme"};
settings_->setValue ("window/geometry", saveGeometry ());
}
void ColorHighlighting::set_items (DecodeHighlightingModel const& highlighting_model)
{
int index {0};
for (auto const& item : highlighting_model.items ())
{
QLabel * example;
QLabel * label;
switch (index++)
{
case 0:
example = ui->example1_label;
label = ui->p1_label;
break;
case 1:
example = ui->example2_label;
label = ui->p2_label;
break;
case 2:
example = ui->example3_label;
label = ui->p3_label;
break;
case 3:
example = ui->example4_label;
label = ui->p4_label;
break;
case 4:
example = ui->example5_label;
label = ui->p5_label;
break;
case 5:
example = ui->example6_label;
label = ui->p6_label;
break;
case 6:
example = ui->example7_label;
label = ui->p7_label;
break;
case 7:
example = ui->example8_label;
label = ui->p8_label;
break;
case 8:
example = ui->example9_label;
label = ui->p9_label;
break;
case 9:
example = ui->example10_label;
label = ui->p10_label;
break;
case 10:
example = ui->example11_label;
label = ui->p11_label;
break;
case 11:
example = ui->example12_label;
label = ui->p12_label;
break;
case 12:
example = ui->example13_label;
label = ui->p13_label;
break;
case 13:
example = ui->example14_label;
label = ui->p14_label;
break;
case 14:
example = ui->example15_label;
label = ui->p15_label;
break;
case 15:
example = ui->example16_label;
label = ui->p16_label;
break;
}
auto palette = example->parentWidget ()->palette ();
if (Qt::NoBrush != item.background_.style ())
{
palette.setColor (QPalette::Window, item.background_.color ());
}
if (Qt::NoBrush != item.foreground_.style ())
{
palette.setColor (QPalette::WindowText, item.foreground_.color ());
}
example->setPalette (palette);
example->setEnabled (item.enabled_);
label->setText (DecodeHighlightingModel::highlight_name (item.type_));
label->setEnabled (item.enabled_);
}
}
|