DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Preferences.cpp
Go to the documentation of this file.
1#include <QColorDialog>
2#include <QSettings>
3#include <QStringList>
4
5#include "dbe/Preferences.hpp"
7
8#include "ui_Preferences.h"
9
10namespace dbe {
11
13 : QDialog(parent), m_ui(new Ui::Preferences)
14{
15 m_ui->setupUi(this);
16 setObjectName("Preferences");
17
18 QSettings settings;
19 auto item = new QListWidgetItem("Attribute Foreground");
20 item->setToolTip("Foreground colour for attributes");
21 item->setForeground(settings.value("attribute/foreground").value<QColor>());
22 m_ui->attribute_list->addItem(item);
23
24 item = new QListWidgetItem("Attribute Background");
25 item->setToolTip("Normal background colour for attributes");
26 item->setBackground(settings.value("attribute/background").value<QColor>());
27 m_ui->attribute_list->addItem(item);
28
29 item = new QListWidgetItem("Attribute Default-Background");
30 item->setToolTip("Background colour for attributes set to their default value");
31 item->setBackground(settings.value("attribute/default-background").value<QColor>());
32 m_ui->attribute_list->addItem(item);
33
34 item = new QListWidgetItem("Relationship Foreground");
35 item->setToolTip("Foreground colour for relationships");
36 item->setForeground(settings.value("relationship/foreground").value<QColor>());
37 m_ui->relationship_list->addItem(item);
38
39 item = new QListWidgetItem("Relationship Background");
40 item->setToolTip("background colour for relationships");
41 item->setBackground(settings.value("relationship/background").value<QColor>());
42 m_ui->relationship_list->addItem(item);
43
44 item = new QListWidgetItem("Readonly Foreground");
45 item->setToolTip("Foreground text colour for readonly items");
46 item->setForeground(settings.value("readonly/foreground").value<QColor>());
47 m_ui->read_only_list->addItem(item);
48
49 item = new QListWidgetItem("Readonly Background");
50 item->setToolTip("Background text colour for readonly items");
51 item->setBackground(settings.value("readonly/background").value<QColor>());
52 m_ui->read_only_list->addItem(item);
53
54 connect (m_ui->attribute_list, SIGNAL(itemActivated(QListWidgetItem*)),
55 this, SLOT(set_color(QListWidgetItem*)));
56 connect (m_ui->relationship_list, SIGNAL(itemActivated(QListWidgetItem*)),
57 this, SLOT(set_color(QListWidgetItem*)));
58 connect (m_ui->read_only_list, SIGNAL(itemActivated(QListWidgetItem*)),
59 this, SLOT(set_color(QListWidgetItem*)));
60
61}
62
63void Preferences::set_color(QListWidgetItem* item) {
64 QSettings settings;
65 QStringList text = item->text().toLower().split(" ");
66 settings.beginGroup(text.at(0));
67
68 auto color = settings.value(text.at(1)).value<QColor>();
69 auto title = QString("Select color for ") + item->text();
70 color = QColorDialog::getColor(color, nullptr, title);
71
72 if (color.isValid()) {
73 settings.setValue(text.at(1), color);
75 }
76}
77} // namespace dbe
Ui::Preferences * m_ui
Preferences(QWidget *parent=0)
void set_color(QListWidgetItem *)
static void InitColorManagement()
Include QT Headers.