From a2a93daaab253b4d4b2e489610621b086793d658 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 24 May 2021 22:59:01 -0500 Subject: [PATCH] Add numerical_labels setting to UserInterface settings --- qt/DeviceView.cpp | 8 +++++++- qt/DeviceView.h | 3 +++ qt/OpenRGBDevicePage.cpp | 19 ++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/qt/DeviceView.cpp b/qt/DeviceView.cpp index 767d7b3e..7303e1d7 100644 --- a/qt/DeviceView.cpp +++ b/qt/DeviceView.cpp @@ -21,6 +21,7 @@ DeviceView::DeviceView(QWidget *parent) : mouseDown(false) { controller = NULL; + numerical_labels = false; setMouseTracking(1); size = width(); @@ -317,7 +318,7 @@ void DeviceView::setController(RGBController * controller_ptr) { led_labels[led_idx] = it->second.label_utf8; } - else + else if(numerical_labels) { led_labels[led_idx] = QString::number(led_idx); } @@ -336,6 +337,11 @@ void DeviceView::setController(RGBController * controller_ptr) } } +void DeviceView::setNumericalLabels(bool enable) +{ + numerical_labels = enable; +} + QSize DeviceView::sizeHint () const { return QSize(height() - 1, height() - 1); diff --git a/qt/DeviceView.h b/qt/DeviceView.h index 9243828c..bddf27bf 100644 --- a/qt/DeviceView.h +++ b/qt/DeviceView.h @@ -22,6 +22,7 @@ public: virtual QSize minimumSizeHint () const; void setController(RGBController * controller_ptr); + void setNumericalLabels(bool enable); protected: void mousePressEvent(QMouseEvent *event); @@ -50,6 +51,8 @@ private: float matrix_h; + bool numerical_labels; + RGBController* controller; QColor posColor(const QPoint &point); diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index dd4bf918..a0e4b2d7 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -66,9 +66,26 @@ OpenRGBDevicePage::OpenRGBDevicePage(RGBController *dev, QWidget *parent) : \*-----------------------------------------------------*/ connect(ui->DeviceViewBox, &DeviceView::selectionChanged, this, &OpenRGBDevicePage::on_DeviceViewBox_selectionChanged); + /*-----------------------------------------------------*\ + | Get the UserInterface settings and check the | + | numerical labels setting | + \*-----------------------------------------------------*/ + SettingsManager* settings_manager = ResourceManager::get()->GetSettingsManager(); + std::string ui_string = "UserInterface"; + json ui_settings; + + ui_settings = settings_manager->GetSettings(ui_string); + + if(ui_settings.contains("numerical_labels")) + { + bool numerical_labels = ui_settings["numerical_labels"]; + + ui->DeviceViewBox->setNumericalLabels(numerical_labels); + } + ui->DeviceViewBox->setController(device); ui->DeviceViewBox->hide(); - + /*-----------------------------------------------------*\ | Set up the color palette buttons | \*-----------------------------------------------------*/