Skip to content

Commit 2ffef5f

Browse files
committed
Updated the Device IDs dialog to use a tree
1 parent 50629dc commit 2ffef5f

File tree

3 files changed

+63
-21
lines changed

3 files changed

+63
-21
lines changed

qt/OpenRGBHardwareIDsDialog.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ int Ui::OpenRGBHardwareIDsDialog::show()
3131
\*---------------------------------------------------------*/
3232
std::vector<i2c_smbus_interface*> i2CBusses = ResourceManager::get()->GetI2CBusses();
3333

34-
strings.push_back("i2c busses");
34+
// The widget takes control over items after creation
35+
QTreeWidgetItem* i2c_top = new QTreeWidgetItem(ui->HardwareIdsList, {"i2c busses"});
36+
strings.push_back("[ i2c busses ]");
3537

3638
for(i2c_smbus_interface* bus : i2CBusses)
3739
{
3840
char line[550];
39-
snprintf(line, 550, "%04X:%04X %04X:%04X - %s", bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device, bus->device_name);
41+
snprintf(line, 550, "%04X:%04X %04X:%04X", bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device);
42+
new QTreeWidgetItem(i2c_top, {line, bus->device_name});
43+
// We keep the strings for the clipboard feature
44+
strncat(line, " - ", 550);
45+
strncat(line, bus->device_name, 550);
4046
strings.push_back(line);
4147
}
4248

@@ -49,7 +55,8 @@ int Ui::OpenRGBHardwareIDsDialog::show()
4955
hid_device_info* current_hid_device;
5056
current_hid_device = hid_devices;
5157

52-
strings.push_back("HID devices");
58+
QTreeWidgetItem* hid_top = new QTreeWidgetItem(ui->HardwareIdsList, {"HID devices"});
59+
strings.push_back("\n[ i2c devices ]");
5360

5461
while(current_hid_device)
5562
{
@@ -58,8 +65,12 @@ int Ui::OpenRGBHardwareIDsDialog::show()
5865

5966
char line[550];
6067

61-
snprintf(line, 550, "[%04X:%04X U=%04X P=0x%04X I=%d] %s - %s", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name);
68+
snprintf(line, 550, "[%04X:%04X U=%04X P=0x%04X I=%d]", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number);
69+
new QTreeWidgetItem(hid_top, {line, prod_name, manu_name});
6270

71+
strncat(line, manu_name, 550);
72+
strncat(line, " - ", 550);
73+
strncat(line, prod_name, 550);
6374
strings.push_back(line);
6475
current_hid_device = current_hid_device->next;
6576
}
@@ -69,7 +80,8 @@ int Ui::OpenRGBHardwareIDsDialog::show()
6980
\*---------------------------------------------------------*/
7081
libusb_device** devices = nullptr;
7182

72-
strings.push_back("LibUSB devices");
83+
QTreeWidgetItem* libusb_top = new QTreeWidgetItem(ui->HardwareIdsList, {"LibUSB devices"});
84+
strings.push_back("\n[ LibUSB devices ]");
7385

7486
int ret;
7587

@@ -103,6 +115,7 @@ int Ui::OpenRGBHardwareIDsDialog::show()
103115

104116
char line[512];
105117
sprintf(line, "%04X:%04X", descriptor.idVendor, descriptor.idProduct);
118+
new QTreeWidgetItem(libusb_top, {line});
106119
strings.push_back(line);
107120
}
108121

@@ -111,8 +124,6 @@ int Ui::OpenRGBHardwareIDsDialog::show()
111124
libusb_free_device_list(devices, 1);
112125
}
113126

114-
ui->HardwareIdsList->addItems(strings);
115-
116127
return this->exec();
117128
}
118129

qt/OpenRGBHardwareIDsDialog.ui

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,35 @@
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
14-
<string>Form</string>
14+
<string>Hardware IDs</string>
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
17-
<item row="0" column="0">
18-
<widget class="QListWidget" name="HardwareIdsList"/>
19-
</item>
2017
<item row="1" column="0">
2118
<widget class="QPushButton" name="CopyToClipboardButton">
2219
<property name="text">
2320
<string>Copy to clipboard</string>
2421
</property>
2522
</widget>
2623
</item>
24+
<item row="0" column="0">
25+
<widget class="QTreeWidget" name="HardwareIdsList">
26+
<column>
27+
<property name="text">
28+
<string>Location</string>
29+
</property>
30+
</column>
31+
<column>
32+
<property name="text">
33+
<string>Device</string>
34+
</property>
35+
</column>
36+
<column>
37+
<property name="text">
38+
<string>Vendor</string>
39+
</property>
40+
</column>
41+
</widget>
42+
</item>
2743
</layout>
2844
</widget>
2945
<resources/>

qt/i18n/OpenRGB_ru.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -574,15 +574,34 @@
574574
<context>
575575
<name>OpenRGBHardwareIDsDialogUi</name>
576576
<message>
577-
<location filename="../OpenRGBHardwareIDsDialog.ui" line="14"/>
578577
<source>Form</source>
579-
<translation type="unfinished">Идентификаторы устройств</translation>
578+
<translation type="obsolete">Идентификаторы устройств</translation>
580579
</message>
581580
<message>
582-
<location filename="../OpenRGBHardwareIDsDialog.ui" line="23"/>
581+
<location filename="../OpenRGBHardwareIDsDialog.ui" line="20"/>
583582
<source>Copy to clipboard</source>
584583
<translation>Скопировать в буфер обмена</translation>
585584
</message>
585+
<message>
586+
<location filename="../OpenRGBHardwareIDsDialog.ui" line="14"/>
587+
<source>Hardware IDs</source>
588+
<translation>Идентификаторы устройств</translation>
589+
</message>
590+
<message>
591+
<location filename="../OpenRGBHardwareIDsDialog.ui" line="28"/>
592+
<source>Location</source>
593+
<translation>Расположение</translation>
594+
</message>
595+
<message>
596+
<location filename="../OpenRGBHardwareIDsDialog.ui" line="33"/>
597+
<source>Device</source>
598+
<translation>Устройство</translation>
599+
</message>
600+
<message>
601+
<location filename="../OpenRGBHardwareIDsDialog.ui" line="38"/>
602+
<source>Vendor</source>
603+
<translation>Изготовитель</translation>
604+
</message>
586605
</context>
587606
<context>
588607
<name>OpenRGBKasaSmartSettingsEntryUi</name>
@@ -732,7 +751,7 @@
732751
<message>
733752
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="81"/>
734753
<source>Username:</source>
735-
<translation>Имя пользоватля:</translation>
754+
<translation>Имя пользователя:</translation>
736755
</message>
737756
<message>
738757
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="74"/>
@@ -761,7 +780,7 @@
761780
<message>
762781
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="46"/>
763782
<source>Auto Connect Group:</source>
764-
<translation>Группа автоматического подключения:</translation>
783+
<translation>Автоматически подключаться к этой группе:</translation>
765784
</message>
766785
</context>
767786
<context>
@@ -1480,10 +1499,6 @@
14801499
</context>
14811500
<context>
14821501
<name>OpenRGBZonesBulkResizerUi</name>
1483-
<message>
1484-
<source>&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&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;</source>
1485-
<translation type="vanished">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Не настроены параметры одной или нескольких настраиваемых областей. Обычно такие области используются для адресуемых RGB разъёмов, не позволяющих определить размер подключённого устройства автоматически.&lt;/p&gt;&lt;p&gt;Укажите количество светодиодов в каждой из областей, представленных ниже.&lt;/p&gt;&lt;p&gt;Подробная информация по правильному рассчёту размера доступна &lt;a href=&quot;https://openrgb.org/resize&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;здесь.&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</translation>
1486-
</message>
14871502
<message>
14881503
<location filename="../OpenRGBZonesBulkResizer.ui" line="39"/>
14891504
<source>&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;</source>
@@ -1772,7 +1787,7 @@
17721787
<message>
17731788
<location filename="../OpenRGBDialog2.cpp" line="984"/>
17741789
<source>Serial Devices</source>
1775-
<translation type="unfinished">Устройства последовательного порта</translation>
1790+
<translation>Устройства последовательного порта</translation>
17761791
</message>
17771792
<message>
17781793
<location filename="../OpenRGBDialog2.cpp" line="1012"/>

0 commit comments

Comments
 (0)