From 2ec4183789589acd57a7ada04788f255c9d6d2b5 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 23 Jul 2024 22:47:03 -0500 Subject: [PATCH] Ensure Device View updates when segments are configured --- qt/DeviceView.cpp | 18 ++++++++++++++++++ qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/qt/DeviceView.cpp b/qt/DeviceView.cpp index ee052a0f..371ffc4f 100644 --- a/qt/DeviceView.cpp +++ b/qt/DeviceView.cpp @@ -724,6 +724,24 @@ void DeviceView::paintEvent(QPaintEvent* /* event */) InitDeviceView(); } + /*-----------------------------------------------------*\ + | If segments have resized, reinitialize local data | + \*-----------------------------------------------------*/ + unsigned int segments = 0; + + for(std::size_t zone_idx = 0; zone_idx < controller->zones.size(); zone_idx++) + { + for(std::size_t segment_idx = 0; segment_idx < controller->zones[zone_idx].segments.size(); segment_idx++) + { + segments++; + } + } + + if(segments != segment_pos.size()) + { + InitDeviceView(); + } + /*-----------------------------------------------------*\ | LED rectangles | \*-----------------------------------------------------*/ diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index 7f93fcf8..d8376239 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -1615,6 +1615,11 @@ void Ui::OpenRGBDevicePage::on_EditZoneButton_clicked() \*-----------------------------------------------------*/ UpdateModeUi(); + /*-----------------------------------------------------*\ + | Update interface to update Device View | + \*-----------------------------------------------------*/ + UpdateInterface(); + /*-----------------------------------------------------*\ | Update LED box | \*-----------------------------------------------------*/