From df1d9784e31c7570699af9bd9e0d9d68ce9029f2 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 29 Mar 2026 00:45:45 -0500 Subject: [PATCH] Don't emit selection update on mouse click event to avoid sending unnecessary events, also only send one type of event per mouse release event. Fix LED box not being updated --- qt/DeviceView.cpp | 23 +++++++++++++++++----- qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/qt/DeviceView.cpp b/qt/DeviceView.cpp index 14ee5f35e..86cc666b3 100644 --- a/qt/DeviceView.cpp +++ b/qt/DeviceView.cpp @@ -640,6 +640,11 @@ void DeviceView::mouseMoveEvent(QMouseEvent *event) | Update selection | \*---------------------------------------------*/ UpdateSelection(); + + /*---------------------------------------------*\ + | Send selection changed signal | + \*---------------------------------------------*/ + emit selectionChanged(-1, -1, selected_leds); } /*-------------------------------------------------*\ @@ -661,6 +666,7 @@ void DeviceView::mouseReleaseEvent(QMouseEvent* event) | selection rect | \*-------------------------------------------------*/ mouse_down = false; + bool signal_sent = false; selection_rect = selection_rect.normalized(); /*-------------------------------------------------*\ @@ -703,6 +709,8 @@ void DeviceView::mouseReleaseEvent(QMouseEvent* event) if(rect.contains(event->pos())) { SelectZone(zone_idx, ctrl_down); + signal_sent = true; + break; } /*-----------------------------------------*\ @@ -724,11 +732,21 @@ void DeviceView::mouseReleaseEvent(QMouseEvent* event) if(rect.contains(event->pos())) { SelectSegment(zone_idx, segment_idx, ctrl_down); + signal_sent = true; + break; } } } } + /*-------------------------------------------------*\ + | Send selection changed signal | + \*-------------------------------------------------*/ + if(!signal_sent) + { + emit selectionChanged(-1, -1, selected_leds); + } + /*-------------------------------------------------*\ | Update UI | \*-------------------------------------------------*/ @@ -1404,9 +1422,4 @@ void DeviceView::UpdateSelection() | Update UI | \*-----------------------------------------------------*/ update(); - - /*-----------------------------------------------------*\ - | Send selection changed signal | - \*-----------------------------------------------------*/ - emit selectionChanged(-1, -1, selected_leds); } diff --git a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp index d7ca76a4c..9c3e6fe55 100644 --- a/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage/OpenRGBDevicePage.cpp @@ -2138,6 +2138,7 @@ void OpenRGBDevicePage::on_DeviceViewBox_selectionChanged(int selected_zone, int MultipleSelected = false; SetSelectedZone(true, -1, -1); + ui->LEDBox->setCurrentIndex(0); } /*-------------------------------------------------*\ | Handle case where a zone or segment is selected | @@ -2151,6 +2152,7 @@ void OpenRGBDevicePage::on_DeviceViewBox_selectionChanged(int selected_zone, int MultipleSelected = false; SetSelectedZone(false, selected_zone, selected_segment); + ui->LEDBox->setCurrentIndex(0); } /*-------------------------------------------------*\ | Handle case where a single LED is selected |