DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
dbe
apps
SchemaEditor
SchemaSettings.cpp
Go to the documentation of this file.
1
#include <QSettings>
2
#include <QStringList>
3
4
#include "
dbe/SchemaSettings.hpp
"
5
#include "
dbe/SchemaStyle.hpp
"
6
7
#include "ui_SchemaSettings.h"
8
9
using namespace
dbse
;
10
11
SchemaSettings::SchemaSettings
(QWidget* parent)
12
: QDialog(parent)
13
,
m_ui
(new
Ui
::
SchemaSettings
)
14
{
15
m_ui
->setupUi(
this
);
16
setObjectName(
"Settings"
);
17
18
SchemaStyle::load
();
19
20
for
(
auto
entry : QStringList{
"default/normal unhighlighted text"
,
21
"active_file/items associated with the active file"
,
22
"inherited/properties inherited from a parent class"
,
23
"highlight/highlighted class"
,
24
"readonly/items from a readonly file"
,
25
"error/error messages"
,
26
"note/notes on class diagrams"
,
27
"line/lines showing inheritance or relationships between classes"
}) {
28
auto
list = entry.split(
"/"
);
29
auto
group = list.at(0);
30
auto
fg_colour =
SchemaStyle::get_color
(
"foreground"
, group);
31
auto
bg_colour =
SchemaStyle::get_color
(
"background"
, group);
32
for
(
auto
fb : QStringList{
"Foreground"
,
"Background"
}) {
33
auto
item =
new
QListWidgetItem(group +
" "
+ fb);
34
item->setForeground(fg_colour);
35
item->setBackground(bg_colour);
36
if
(list.size() > 1) {
37
item->setToolTip(fb +
" color for "
+ list.at(1));
38
}
39
m_ui
->color_list->addItem(item);
40
}
41
}
42
43
for
(
auto
entry : QStringList{
"default/normal unhighlighted text"
,
44
"highlight/highlighted class"
,
45
"abstract/abstract base class"
,
46
"note/notes on class diagrams"
,
47
"line/lines showing inheritance or relationships between classes"
}) {
48
auto
list = entry.split(
"/"
);
49
auto
group = list.at(0);
50
auto
item =
new
QListWidgetItem(group +
" font"
);
51
item->setFont(
SchemaStyle::get_font
(group));
52
if
(list.size() > 1) {
53
item->setToolTip(
"Font for "
+ list.at(1));
54
}
55
m_ui
->font_list->addItem(item);
56
}
57
58
connect(
m_ui
->color_list, SIGNAL(itemActivated(QListWidgetItem*)),
this
, SLOT(
set_color
(QListWidgetItem*)));
59
connect(
m_ui
->font_list, SIGNAL(itemActivated(QListWidgetItem*)),
this
, SLOT(
set_font
(QListWidgetItem*)));
60
61
QSettings settings;
62
settings.beginGroup(
"view defaults"
);
63
m_ui
->abstract_button->setChecked(settings.value(
"highlight_abstract"
,
false
).toBool());
64
connect(
m_ui
->abstract_button, SIGNAL(stateChanged(
int
)),
this
, SLOT(
toggle_abstract
(
int
)));
65
m_ui
->active_button->setChecked(settings.value(
"highlight_active"
,
false
).toBool());
66
connect(
m_ui
->active_button, SIGNAL(stateChanged(
int
)),
this
, SLOT(
toggle_active
(
int
)));
67
m_ui
->inherited_button->setChecked(settings.value(
"show_inherited"
,
false
).toBool());
68
connect(
m_ui
->inherited_button, SIGNAL(stateChanged(
int
)),
this
, SLOT(
toggle_inherited
(
int
)));
69
m_ui
->default_value_button->setChecked(settings.value(
"show_default"
,
false
).toBool());
70
connect(
m_ui
->default_value_button, SIGNAL(stateChanged(
int
)),
this
, SLOT(
toggle_default
(
int
)));
71
settings.endGroup();
72
73
settings.beginGroup(
"MainWindow"
);
74
m_ui
->save_settings->setChecked(settings.value(
"saveLayout"
,
false
).toBool());
75
connect(
m_ui
->save_settings, SIGNAL(stateChanged(
int
)),
this
, SLOT(
toggle_save
(
int
)));
76
settings.endGroup();
77
}
78
79
void
80
SchemaSettings::toggle_abstract
(
int
state)
81
{
82
QSettings settings;
83
settings.beginGroup(
"view defaults"
);
84
settings.setValue(
"highlight_abstract"
, (state > 0));
85
}
86
void
87
SchemaSettings::toggle_active
(
int
state)
88
{
89
QSettings settings;
90
settings.beginGroup(
"view defaults"
);
91
settings.setValue(
"highlight_active"
, (state > 0));
92
}
93
void
94
SchemaSettings::toggle_inherited
(
int
state)
95
{
96
QSettings settings;
97
settings.beginGroup(
"view defaults"
);
98
settings.setValue(
"show_inherited"
, (state > 0));
99
}
100
void
101
SchemaSettings::toggle_default
(
int
state)
102
{
103
QSettings settings;
104
settings.beginGroup(
"view defaults"
);
105
settings.setValue(
"show_default"
, (state > 0));
106
}
107
void
108
SchemaSettings::toggle_save
(
int
state)
109
{
110
QSettings settings;
111
settings.beginGroup(
"MainWindow"
);
112
settings.setValue(
"saveLayout"
, (state > 0));
113
}
114
115
void
116
SchemaSettings::set_color
(QListWidgetItem* item)
117
{
118
QStringList text = item->text().toLower().split(
" "
);
119
SchemaStyle::set_color
(text.at(1), text.at(0));
120
item->setForeground(
SchemaStyle::get_color
(
"foreground"
, text.at(0)));
121
item->setBackground(
SchemaStyle::get_color
(
"background"
, text.at(0)));
122
m_ui
->color_list->update();
123
emit
settings_updated
();
124
}
125
void
126
SchemaSettings::set_font
(QListWidgetItem* item)
127
{
128
QStringList text = item->text().toLower().split(
" "
);
129
SchemaStyle::set_font
(text.at(0));
130
emit
settings_updated
();
131
}
SchemaSettings.hpp
SchemaStyle.hpp
dbse::SchemaSettings::toggle_save
void toggle_save(int)
Definition
SchemaSettings.cpp:108
dbse::SchemaSettings::toggle_abstract
void toggle_abstract(int)
Definition
SchemaSettings.cpp:80
dbse::SchemaSettings::settings_updated
void settings_updated()
dbse::SchemaSettings::toggle_default
void toggle_default(int)
Definition
SchemaSettings.cpp:101
dbse::SchemaSettings::toggle_inherited
void toggle_inherited(int)
Definition
SchemaSettings.cpp:94
dbse::SchemaSettings::set_color
void set_color(QListWidgetItem *)
Definition
SchemaSettings.cpp:116
dbse::SchemaSettings::set_font
void set_font(QListWidgetItem *)
Definition
SchemaSettings.cpp:126
dbse::SchemaSettings::SchemaSettings
SchemaSettings(QWidget *parent=0)
Definition
SchemaSettings.cpp:11
dbse::SchemaSettings::toggle_active
void toggle_active(int)
Definition
SchemaSettings.cpp:87
dbse::SchemaSettings::m_ui
Ui::SchemaSettings * m_ui
Definition
SchemaSettings.hpp:32
Ui
Definition
SchemaSettings.hpp:9
dbse
Including QT Headers.
Definition
SchemaAttributeEditor.hpp:13
dbse::SchemaStyle::set_color
static QColor set_color(const QString &item, const QString &group)
Definition
SchemaStyle.cpp:112
dbse::SchemaStyle::get_color
static QColor get_color(const QString &item, const QString &group)
Definition
SchemaStyle.cpp:105
dbse::SchemaStyle::get_font
static QFont get_font(const QString &group)
Definition
SchemaStyle.cpp:127
dbse::SchemaStyle::set_font
static QFont set_font(const QString &group)
Definition
SchemaStyle.cpp:138
dbse::SchemaStyle::load
static void load()
Definition
SchemaStyle.cpp:11
Generated on
for DUNE-DAQ by
1.18.0