Updated the Device IDs dialog to use a tree

This commit is contained in:
k1-801 2023-07-04 17:29:05 +04:00
parent 50629dc4f9
commit 2ffef5facf
3 changed files with 63 additions and 21 deletions

View file

@ -31,12 +31,18 @@ int Ui::OpenRGBHardwareIDsDialog::show()
\*---------------------------------------------------------*/
std::vector<i2c_smbus_interface*> i2CBusses = ResourceManager::get()->GetI2CBusses();
strings.push_back("i2c busses");
// The widget takes control over items after creation
QTreeWidgetItem* i2c_top = new QTreeWidgetItem(ui->HardwareIdsList, {"i2c busses"});
strings.push_back("[ i2c busses ]");
for(i2c_smbus_interface* bus : i2CBusses)
{
char line[550];
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);
snprintf(line, 550, "%04X:%04X %04X:%04X", bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device);
new QTreeWidgetItem(i2c_top, {line, bus->device_name});
// We keep the strings for the clipboard feature
strncat(line, " - ", 550);
strncat(line, bus->device_name, 550);
strings.push_back(line);
}
@ -49,7 +55,8 @@ int Ui::OpenRGBHardwareIDsDialog::show()
hid_device_info* current_hid_device;
current_hid_device = hid_devices;
strings.push_back("HID devices");
QTreeWidgetItem* hid_top = new QTreeWidgetItem(ui->HardwareIdsList, {"HID devices"});
strings.push_back("\n[ i2c devices ]");
while(current_hid_device)
{
@ -58,8 +65,12 @@ int Ui::OpenRGBHardwareIDsDialog::show()
char line[550];
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);
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);
new QTreeWidgetItem(hid_top, {line, prod_name, manu_name});
strncat(line, manu_name, 550);
strncat(line, " - ", 550);
strncat(line, prod_name, 550);
strings.push_back(line);
current_hid_device = current_hid_device->next;
}
@ -69,7 +80,8 @@ int Ui::OpenRGBHardwareIDsDialog::show()
\*---------------------------------------------------------*/
libusb_device** devices = nullptr;
strings.push_back("LibUSB devices");
QTreeWidgetItem* libusb_top = new QTreeWidgetItem(ui->HardwareIdsList, {"LibUSB devices"});
strings.push_back("\n[ LibUSB devices ]");
int ret;
@ -103,6 +115,7 @@ int Ui::OpenRGBHardwareIDsDialog::show()
char line[512];
sprintf(line, "%04X:%04X", descriptor.idVendor, descriptor.idProduct);
new QTreeWidgetItem(libusb_top, {line});
strings.push_back(line);
}
@ -111,8 +124,6 @@ int Ui::OpenRGBHardwareIDsDialog::show()
libusb_free_device_list(devices, 1);
}
ui->HardwareIdsList->addItems(strings);
return this->exec();
}

View file

@ -11,12 +11,9 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Hardware IDs</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="HardwareIdsList"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="CopyToClipboardButton">
<property name="text">
@ -24,6 +21,25 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTreeWidget" name="HardwareIdsList">
<column>
<property name="text">
<string>Location</string>
</property>
</column>
<column>
<property name="text">
<string>Device</string>
</property>
</column>
<column>
<property name="text">
<string>Vendor</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>

View file

@ -574,15 +574,34 @@
<context>
<name>OpenRGBHardwareIDsDialogUi</name>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="14"/>
<source>Form</source>
<translation type="unfinished">Идентификаторы устройств</translation>
<translation type="obsolete">Идентификаторы устройств</translation>
</message>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="23"/>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="20"/>
<source>Copy to clipboard</source>
<translation>Скопировать в буфер обмена</translation>
</message>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="14"/>
<source>Hardware IDs</source>
<translation>Идентификаторы устройств</translation>
</message>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="28"/>
<source>Location</source>
<translation>Расположение</translation>
</message>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="33"/>
<source>Device</source>
<translation>Устройство</translation>
</message>
<message>
<location filename="../OpenRGBHardwareIDsDialog.ui" line="38"/>
<source>Vendor</source>
<translation>Изготовитель</translation>
</message>
</context>
<context>
<name>OpenRGBKasaSmartSettingsEntryUi</name>
@ -732,7 +751,7 @@
<message>
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="81"/>
<source>Username:</source>
<translation>Имя пользоватля:</translation>
<translation>Имя пользователя:</translation>
</message>
<message>
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="74"/>
@ -761,7 +780,7 @@
<message>
<location filename="../OpenRGBPhilipsHueSettingsPage/OpenRGBPhilipsHueSettingsEntry.ui" line="46"/>
<source>Auto Connect Group:</source>
<translation>Группа автоматического подключения:</translation>
<translation>Автоматически подключаться к этой группе:</translation>
</message>
</context>
<context>
@ -1480,10 +1499,6 @@
</context>
<context>
<name>OpenRGBZonesBulkResizerUi</name>
<message>
<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>
<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>
</message>
<message>
<location filename="../OpenRGBZonesBulkResizer.ui" line="39"/>
<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 @@
<message>
<location filename="../OpenRGBDialog2.cpp" line="984"/>
<source>Serial Devices</source>
<translation type="unfinished">Устройства последовательного порта</translation>
<translation>Устройства последовательного порта</translation>
</message>
<message>
<location filename="../OpenRGBDialog2.cpp" line="1012"/>