From 6709cfb7357f7c51f93ed3bc25e7539e8a3856a9 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 21 Jan 2022 13:00:40 +1100 Subject: [PATCH] Aligning `Direction` updates for consistency and readability + Adding check to see if the UI DirectionBox is enabled before executing changes to the box. --- qt/OpenRGBDevicePage.cpp | 63 +++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/qt/OpenRGBDevicePage.cpp b/qt/OpenRGBDevicePage.cpp index cf5b1a62..63ebb682 100644 --- a/qt/OpenRGBDevicePage.cpp +++ b/qt/OpenRGBDevicePage.cpp @@ -779,44 +779,47 @@ void Ui::OpenRGBDevicePage::UpdateMode() bool supports_dir_hv = ( device->modes[(unsigned int)current_mode].flags & MODE_FLAG_HAS_DIRECTION_HV ); /*-----------------------------------------------------*\ - | Set the direction value | + | If DirectionBox is enabled, set the direction values | \*-----------------------------------------------------*/ - if(supports_dir_hv) + if(ui->DirectionBox->isEnabled()) { - if(supports_dir_lr && supports_dir_ud) + if(supports_dir_hv) + { + if(supports_dir_lr && supports_dir_ud) + { + current_direction = current_dir_idx; + } + else if(supports_dir_lr || supports_dir_ud) + { + current_direction = current_dir_idx + 2; + } + else + { + current_direction = current_dir_idx + 4; + } + } + + if(supports_dir_ud) + { + if(supports_dir_lr) + { + current_direction = current_dir_idx; + } + else + { + current_direction = current_dir_idx + 2; + } + } + + if((supports_dir_lr) + &&(current_dir_idx < 2)) { current_direction = current_dir_idx; } - else if(supports_dir_lr || supports_dir_ud) - { - current_direction = current_dir_idx + 2; - } - else - { - current_direction = current_dir_idx + 4; - } - } - if(supports_dir_ud) - { - if(supports_dir_lr) - { - current_direction = current_dir_idx; - } - else - { - current_direction = current_dir_idx + 2; - } + device->modes[(unsigned int)current_mode].direction = current_direction; } - if((supports_dir_lr) - &&(current_dir_idx < 2)) - { - current_direction = current_dir_idx; - } - - device->modes[(unsigned int)current_mode].direction = current_direction; - /*-----------------------------------------------------*\ | If Speed Slider is enabled, read the speed value | \*-----------------------------------------------------*/