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)
14 , m_ui(new Ui::Preferences)
15{
16 m_ui->setupUi(this);
17 setObjectName("Preferences");
18
19 QSettings settings;
20 auto item = new QListWidgetItem("Attribute Foreground");
21 item->setToolTip("Foreground colour for attributes");
22 item->setForeground(settings.value("attribute/foreground").value<QColor>());
23 m_ui->attribute_list->addItem(item);
24
25 item = new QListWidgetItem("Attribute Background");
26 item->setToolTip("Normal background colour for attributes");
27 item->setBackground(settings.value("attribute/background").value<QColor>());
28 m_ui->attribute_list->addItem(item);
29
30 item = new QListWidgetItem("Attribute Default-Background");
31 item->setToolTip("Background colour for attributes set to their default value");
32 item->setBackground(settings.value("attribute/default-background").value<QColor>());
33 m_ui->attribute_list->addItem(item);
34
35 item = new QListWidgetItem("Relationship Foreground");
36 item->setToolTip("Foreground colour for relationships");
37 item->setForeground(settings.value("relationship/foreground").value<QColor>());
38 m_ui->relationship_list->addItem(item);
39
40 item = new QListWidgetItem("Relationship Background");
41 item->setToolTip("background colour for relationships");
42 item->setBackground(settings.value("relationship/background").value<QColor>());
43 m_ui->relationship_list->addItem(item);
44
45 item = new QListWidgetItem("Readonly Foreground");
46 item->setToolTip("Foreground text colour for readonly items");
47 item->setForeground(settings.value("readonly/foreground").value<QColor>());
48 m_ui->read_only_list->addItem(item);
49
50 item = new QListWidgetItem("Readonly Background");
51 item->setToolTip("Background text colour for readonly items");
52 item->setBackground(settings.value("readonly/background").value<QColor>());
53 m_ui->read_only_list->addItem(item);
54
55 connect(m_ui->attribute_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(set_color(QListWidgetItem*)));
56 connect(m_ui->relationship_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(set_color(QListWidgetItem*)));
57 connect(m_ui->read_only_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(set_color(QListWidgetItem*)));
58}
59
60void
61Preferences::set_color(QListWidgetItem* item)
62{
63 QSettings settings;
64 QStringList text = item->text().toLower().split(" ");
65 settings.beginGroup(text.at(0));
66
67 auto color = settings.value(text.at(1)).value<QColor>();
68 auto title = QString("Select color for ") + item->text();
69 color = QColorDialog::getColor(color, nullptr, title);
70
71 if (color.isValid()) {
72 settings.setValue(text.at(1), color);
74 }
75}
76} // namespace dbe
Ui::Preferences * m_ui
Preferences(QWidget *parent=0)
void set_color(QListWidgetItem *)
static void InitColorManagement()
Include QT Headers.