Clean up zone initialization dialog

This commit is contained in:
Adam Honse
2026-04-12 16:37:44 -05:00
parent 336be5bb44
commit 6851a508e7
30 changed files with 90 additions and 83 deletions

View File

@@ -1485,7 +1485,7 @@ void NetworkClient::ProcessRequest_RGBController_SignalUpdate(unsigned int data_
\*-------------------------------------------------*/
case RGBCONTROLLER_UPDATE_REASON_UPDATEMODE:
case RGBCONTROLLER_UPDATE_REASON_SAVEMODE:
case RGBCONTROLLER_UPDATE_REASON_RESIZEZONE:
case RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE:
case RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS:
case RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT:
case RGBCONTROLLER_UPDATE_REASON_HIDDEN:

View File

@@ -2979,7 +2979,7 @@ void NetworkServer::SendRequest_RGBController_SignalUpdate(RGBController * contr
\*-------------------------------------*/
case RGBCONTROLLER_UPDATE_REASON_UPDATEMODE:
case RGBCONTROLLER_UPDATE_REASON_SAVEMODE:
case RGBCONTROLLER_UPDATE_REASON_RESIZEZONE:
case RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE:
case RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS:
case RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT:
case RGBCONTROLLER_UPDATE_REASON_HIDDEN:
@@ -3025,7 +3025,7 @@ void NetworkServer::SendRequest_RGBController_SignalUpdate(RGBController * contr
\*-------------------------------------*/
case RGBCONTROLLER_UPDATE_REASON_UPDATEMODE:
case RGBCONTROLLER_UPDATE_REASON_SAVEMODE:
case RGBCONTROLLER_UPDATE_REASON_RESIZEZONE:
case RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE:
case RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS:
case RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT:
case RGBCONTROLLER_UPDATE_REASON_HIDDEN:

View File

@@ -1849,24 +1849,30 @@ void RGBController::DeviceCallThreadFunction()
void RGBController::ClearSegments(int zone)
{
AccessMutex.lock();
zones[zone].segments.clear();
AccessMutex.unlock();
if((std::size_t)zone < zones.size())
{
AccessMutex.lock();
zones[zone].segments.clear();
AccessMutex.unlock();
zones[zone].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS;
zones[zone].flags &= ~ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS;
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS);
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS);
}
}
void RGBController::AddSegment(int zone, segment new_segment)
{
AccessMutex.lock();
zones[zone].segments.push_back(new_segment);
AccessMutex.unlock();
if((std::size_t)zone < zones.size())
{
AccessMutex.lock();
zones[zone].segments.push_back(new_segment);
AccessMutex.unlock();
zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS;
zones[zone].flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SEGMENTS;
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT);
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT);
}
}
void RGBController::ConfigureZone(int zone_idx, zone new_zone)
@@ -1939,21 +1945,23 @@ void RGBController::ConfigureZone(int zone_idx, zone new_zone)
AccessMutex.unlock();
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_RESIZEZONE);
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE);
}
void RGBController::ResizeZone(int zone_idx, int new_size)
{
zone new_zone = zones[zone_idx];
if((std::size_t)zone_idx < zones.size())
{
if(zones[zone_idx].flags & (ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE | ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY))
{
zone new_zone = zones[zone_idx];
new_zone.leds_count = new_size;
new_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE;
new_zone.leds_count = new_size;
new_zone.flags |= ZONE_FLAG_MANUALLY_CONFIGURED_SIZE;
AccessMutex.lock();
ConfigureZone(zone_idx, new_zone);
AccessMutex.unlock();
SignalUpdate(RGBCONTROLLER_UPDATE_REASON_RESIZEZONE);
ConfigureZone(zone_idx, new_zone);
}
}
}
/*---------------------------------------------------------*\

View File

@@ -339,7 +339,7 @@ enum
RGBCONTROLLER_UPDATE_REASON_UPDATELEDS, /* UpdateLEDs() called */
RGBCONTROLLER_UPDATE_REASON_UPDATEMODE, /* UpdateMode() called */
RGBCONTROLLER_UPDATE_REASON_SAVEMODE, /* SaveMode() called */
RGBCONTROLLER_UPDATE_REASON_RESIZEZONE, /* ResizeZone() called */
RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE, /* ConfigureZone() called */
RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS, /* ClearSegments() called */
RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT, /* AddSegment() called */
RGBCONTROLLER_UPDATE_REASON_HIDDEN, /* Hidden flag set */

View File

@@ -2054,7 +2054,7 @@ void OpenRGBDevicePage::UpdateInterface(unsigned int update_reason)
case RGBCONTROLLER_UPDATE_REASON_ADDSEGMENT:
case RGBCONTROLLER_UPDATE_REASON_CLEARSEGMENTS:
case RGBCONTROLLER_UPDATE_REASON_RESIZEZONE:
case RGBCONTROLLER_UPDATE_REASON_CONFIGUREZONE:
UpdateModeUi();
ui->DeviceViewBox->SetChanged();
ui->DeviceViewBox->repaint();

View File

@@ -20,7 +20,7 @@
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "TabLabel.h"
#include "OpenRGBZonesBulkResizer.h"
#include "OpenRGBZoneInitializationDialog.h"
#include "OpenRGBThemeManager.h"
#include "OpenRGBFont.h"
@@ -1382,7 +1382,7 @@ void OpenRGBDialog::onDetectionEnded()
/*-----------------------------------------------------*\
| Detect unconfigured zones and prompt for resizing |
\*-----------------------------------------------------*/
OpenRGBZonesBulkResizer::RunChecks(this);
OpenRGBZoneInitializationDialog::RunChecks(this);
/*-----------------------------------------------------*\
| Load plugins after the first detection (ONLY the |

View File

@@ -1,25 +1,25 @@
/*---------------------------------------------------------*\
| OpenRGBZonesBulkResizer.cpp |
| OpenRGBZoneInitializationDialog.cpp |
| |
| User interface for bulk resizing zones |
| User interface for initializing zones |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "OpenRGBZonesBulkResizer.h"
#include "OpenRGBZoneInitializationDialog.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "LogManager.h"
#include "OpenRGBDialog.h"
#include "ui_OpenRGBZonesBulkResizer.h"
#include "ui_OpenRGBZoneInitializationDialog.h"
#include <QDialog>
#include <QFile>
#include <QSpinBox>
void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
void OpenRGBZoneInitializationDialog::RunChecks(QWidget *parent)
{
/*---------------------------------------------------------*\
| Determine if we should run (user setting) |
@@ -37,13 +37,13 @@ void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
if(!should_run)
{
LOG_DEBUG("[ZonesBulkResizer] Skipping zones sizes checks.");
LOG_DEBUG("[OpenRGBZoneInitializationDialog] Skipping zones sizes checks.");
return;
}
}
}
LOG_DEBUG("[ZonesBulkResizer] Running zones sizes checks...");
LOG_DEBUG("[OpenRGBZoneInitializationDialog] Running zones sizes checks...");
/*-----------------------------------------------------*\
| Collect the unconfigured zones |
@@ -57,20 +57,19 @@ void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
for(unsigned int zone_index = 0; zone_index < controller->GetZoneCount(); zone_index++)
{
/*---------------------------------------------*\
| Consider unconfigured if zone is size 0, zone |
| size is less than max size, and not manually |
| Consider unconfigured if zone has manually |
| configurable size but has not been manually |
| configured |
\*---------------------------------------------*/
if((controller->GetZoneLEDsCount(zone_index) == 0) &&
(controller->GetZoneLEDsCount(zone_index) < controller->GetZoneLEDsMax(zone_index)) &&
(controller->GetZoneFlags(zone_index) & ZONE_FLAGS_MANUALLY_CONFIGURED) == 0)
if((controller->GetZoneFlags(zone_index) & (ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE | ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE_EFFECTS_ONLY))
&& !(controller->GetZoneFlags(zone_index) & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
unconfigured_zones.push_back({controller, zone_index});
}
}
}
LOG_DEBUG("[ZonesBulkResizer] Zones checks finished: %d unconfigured zone(s).", unconfigured_zones.size());
LOG_DEBUG("[OpenRGBZoneInitializationDialog] Zones checks finished: %d unconfigured zone(s).", unconfigured_zones.size());
/*-----------------------------------------------------*\
| Show the configuration tool GUI if we have some |
@@ -79,18 +78,18 @@ void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
if(!unconfigured_zones.empty())
{
QDialog* dialog = new QDialog(parent);
dialog->setWindowTitle(tr("Resize the zones"));
dialog->setWindowTitle(tr("Zone Initialization"));
dialog->setMinimumSize(600,480);
dialog->setModal(true);
QVBoxLayout* dialog_layout = new QVBoxLayout(dialog);
OpenRGBZonesBulkResizer* widget = new OpenRGBZonesBulkResizer(dialog, unconfigured_zones);
OpenRGBZoneInitializationDialog* widget = new OpenRGBZoneInitializationDialog(dialog, unconfigured_zones);
dialog_layout->addWidget(widget);
connect(widget, &OpenRGBZonesBulkResizer::CloseRequest, [=](){
connect(widget, &OpenRGBZoneInitializationDialog::CloseRequest, [=](){
dialog->reject();
});
@@ -98,9 +97,9 @@ void OpenRGBZonesBulkResizer::RunChecks(QWidget *parent)
}
}
OpenRGBZonesBulkResizer::OpenRGBZonesBulkResizer(QWidget *parent, const std::vector<std::tuple<RGBController*, unsigned int>>& unconfigured_zones) :
OpenRGBZoneInitializationDialog::OpenRGBZoneInitializationDialog(QWidget *parent, const std::vector<std::tuple<RGBController*, unsigned int>>& unconfigured_zones) :
QWidget(parent),
ui(new Ui::OpenRGBZonesBulkResizer),
ui(new Ui::OpenRGBZoneInitializationDialog),
unconfigured_zones(unconfigured_zones)
{
ui->setupUi(this);
@@ -128,12 +127,12 @@ OpenRGBZonesBulkResizer::OpenRGBZonesBulkResizer(QWidget *parent, const std::ve
}
}
OpenRGBZonesBulkResizer::~OpenRGBZonesBulkResizer()
OpenRGBZoneInitializationDialog::~OpenRGBZoneInitializationDialog()
{
delete ui;
}
void OpenRGBZonesBulkResizer::changeEvent(QEvent *event)
void OpenRGBZoneInitializationDialog::changeEvent(QEvent *event)
{
if(event->type() == QEvent::LanguageChange)
{
@@ -141,7 +140,7 @@ void OpenRGBZonesBulkResizer::changeEvent(QEvent *event)
}
}
void OpenRGBZonesBulkResizer::CreateZoneWidget(RGBController* controller, unsigned int zone_index)
void OpenRGBZoneInitializationDialog::CreateZoneWidget(RGBController* controller, unsigned int zone_index)
{
/*---------------------------------------------------------*\
| Labels: controller name + zone name |
@@ -171,7 +170,7 @@ void OpenRGBZonesBulkResizer::CreateZoneWidget(RGBController* controller, unsign
ui->zones_table->setCellWidget(row, 2, spin_box);
}
void OpenRGBZonesBulkResizer::on_save_button_clicked()
void OpenRGBZoneInitializationDialog::on_save_button_clicked()
{
/*---------------------------------------------------------*\
| Resize what needs to be resized |
@@ -207,7 +206,7 @@ void OpenRGBZonesBulkResizer::on_save_button_clicked()
emit CloseRequest();
}
void OpenRGBZonesBulkResizer::on_ignore_button_clicked()
void OpenRGBZoneInitializationDialog::on_ignore_button_clicked()
{
/*---------------------------------------------------------*\
| Save the "Do not show again" checkbox state, then close |
@@ -217,7 +216,7 @@ void OpenRGBZonesBulkResizer::on_ignore_button_clicked()
emit CloseRequest();
}
void OpenRGBZonesBulkResizer::SaveDoNotRunState()
void OpenRGBZoneInitializationDialog::SaveDoNotRunState()
{
/*---------------------------------------------------------*\
| Save the "Do not show again" checkbox state in |

View File

@@ -1,7 +1,7 @@
/*---------------------------------------------------------*\
| OpenRGBZonesBulkResizer.h |
| OpenRGBZoneInitializationDialog.h |
| |
| User interface for bulk resizing zones |
| User interface for initializing zones |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
@@ -14,21 +14,21 @@
namespace Ui
{
class OpenRGBZonesBulkResizer;
class OpenRGBZoneInitializationDialog;
}
class OpenRGBZonesBulkResizer : public QWidget
class OpenRGBZoneInitializationDialog : public QWidget
{
Q_OBJECT
public:
static void RunChecks(QWidget *parent);
explicit OpenRGBZonesBulkResizer(QWidget*, const std::vector<std::tuple<RGBController*, unsigned int>>&);
~OpenRGBZonesBulkResizer();
explicit OpenRGBZoneInitializationDialog(QWidget*, const std::vector<std::tuple<RGBController*, unsigned int>>&);
~OpenRGBZoneInitializationDialog();
private:
Ui::OpenRGBZonesBulkResizer *ui;
Ui::OpenRGBZoneInitializationDialog *ui;
const std::vector<std::tuple<RGBController*, unsigned int>>& unconfigured_zones;

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBZonesBulkResizer</class>
<widget class="QWidget" name="OpenRGBZonesBulkResizer">
<class>OpenRGBZoneInitializationDialog</class>
<widget class="QWidget" name="OpenRGBZoneInitializationDialog">
<property name="geometry">
<rect>
<x>0</x>
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Zones Resizer</string>
<string>Zone Initialization</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0" colspan="2">
@@ -36,7 +36,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;One or more resizable zones have not been configured. Resizable zones are most commonly used for addressable RGB headers where the size of the connected device cannot be detected automatically.&lt;/p&gt;&lt;p&gt;Please enter the number of LEDs in each zone below.&lt;/p&gt;&lt;p&gt;For more information about calcuating the correct size, please check &lt;a href=&quot;https://openrgb.org/resize.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;this link.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;One or more manually configurable zones have not been configured. Manually configurable zones are most commonly used for addressable RGB headers where the number of LEDs in the connected device(s) cannot be detected automatically.&lt;/p&gt;&lt;p&gt;Please enter the number of LEDs in each zone below.&lt;/p&gt;&lt;p&gt;For more information about calcuating the correct size, please check &lt;a href=&quot;https://openrgb.org/resize.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;this link.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Больш не паказваць</translation>

View File

@@ -1496,7 +1496,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Nicht wieder anzeigen</translation>

View File

@@ -1496,7 +1496,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Να μην εμφανιστεί ξανά</translation>

View File

@@ -1194,7 +1194,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation></translation>

View File

@@ -1194,7 +1194,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation></translation>

View File

@@ -1194,7 +1194,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation type="unfinished"></translation>

View File

@@ -1497,7 +1497,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>No mostrar de nuevo</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Ne plus afficher</translation>
@@ -1931,7 +1931,7 @@
</message>
</context>
<context>
<name>Ui::OpenRGBZonesBulkResizer</name>
<name>Ui::OpenRGBZoneInitializationDialog</name>
<message>
<source>Resize the zones</source>
<translation type="vanished">Redimensionner les zones</translation>

View File

@@ -1497,7 +1497,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Ne pokušavaj ponovno</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Non mostrare di nuovo</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation></translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation> </translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Jangan tunjukkan lagi</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Ikke vis igjen</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Nie pokazuj więcej</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Não mostrar novamente</translation>

View File

@@ -1196,7 +1196,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Zones Resizer</source>
<translation>Изменение размера зон</translation>

View File

@@ -1194,7 +1194,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation>Tekrar gösterme</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Zones Resizer</source>
<translation>Зміна розміру зон</translation>

View File

@@ -1495,7 +1495,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation></translation>

View File

@@ -1499,7 +1499,7 @@
</message>
</context>
<context>
<name>OpenRGBZonesBulkResizer</name>
<name>OpenRGBZoneInitializationDialog</name>
<message>
<source>Do not show again</source>
<translation></translation>