LCOV - code coverage report
Current view: top level - dbe/src/internal - Preferences.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 48 0
Test Date: 2026-08-30 15:04:40 Functions: 0.0 % 2 0

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

Generated by: LCOV version 2.0-1