mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-26 03:06:36 -05:00
Display device name on 2 lines if needed. Fix #1480
This commit is contained in:
@@ -154,6 +154,7 @@ HEADERS +=
|
||||
DeviceDetector.h \
|
||||
filesystem.h \
|
||||
qt/DetectorTableModel.h \
|
||||
qt/DeviceTabHeader.h \
|
||||
qt/OpenRGBClientInfoPage.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
@@ -462,6 +463,7 @@ SOURCES +=
|
||||
ResourceManager.cpp \
|
||||
SettingsManager.cpp \
|
||||
qt/DetectorTableModel.cpp \
|
||||
qt/DeviceTabHeader.cpp \
|
||||
qt/OpenRGBClientInfoPage.cpp \
|
||||
qt/OpenRGBDeviceInfoPage.cpp \
|
||||
qt/OpenRGBDevicePage.cpp \
|
||||
@@ -795,6 +797,7 @@ RESOURCES +=
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
qt/DeviceTabHeader.ui \
|
||||
qt/OpenRGBClientInfoPage.ui \
|
||||
qt/OpenRGBDeviceInfoPage.ui \
|
||||
qt/OpenRGBDevicePage.ui \
|
||||
|
||||
15
qt/DeviceTabHeader.cpp
Normal file
15
qt/DeviceTabHeader.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "DeviceTabHeader.h"
|
||||
|
||||
Ui::DeviceTabHeader::DeviceTabHeader(QString icon, QString device_name) :
|
||||
QWidget(nullptr),
|
||||
ui(new Ui::DeviceTabHeaderUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->device_icon->setText("<img src=':/" + icon + "' height='16' width='16' />");
|
||||
ui->device_name->setText(device_name);
|
||||
}
|
||||
|
||||
Ui::DeviceTabHeader::~DeviceTabHeader()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
23
qt/DeviceTabHeader.h
Normal file
23
qt/DeviceTabHeader.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef DEVICETABHEADER_H
|
||||
#define DEVICETABHEADER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_DeviceTabHeader.h"
|
||||
|
||||
namespace Ui {
|
||||
class DeviceTabHeader;
|
||||
}
|
||||
|
||||
class Ui::DeviceTabHeader : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeviceTabHeader(QString, QString);
|
||||
~DeviceTabHeader();
|
||||
|
||||
private:
|
||||
Ui::DeviceTabHeaderUi *ui;
|
||||
};
|
||||
|
||||
#endif // DEVICETABHEADER_H
|
||||
50
qt/DeviceTabHeader.ui
Normal file
50
qt/DeviceTabHeader.ui
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DeviceTabHeaderUi</class>
|
||||
<widget class="QWidget" name="DeviceTabHeaderUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>224</width>
|
||||
<height>43</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="device_icon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="device_name">
|
||||
<property name="text">
|
||||
<string>device name</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "OpenRGBServerInfoPage.h"
|
||||
#include "OpenRGBPluginContainer.h"
|
||||
#include "OpenRGBProfileSaveDialog.h"
|
||||
#include "DeviceTabHeader.h"
|
||||
#include "ResourceManager.h"
|
||||
#include <QLabel>
|
||||
#include <QTabBar>
|
||||
@@ -883,23 +884,12 @@ void OpenRGBDialog2::UpdateDevicesList()
|
||||
| text in the tab label. Choose icon based on device |
|
||||
| type and append device name string. |
|
||||
\*-----------------------------------------------------*/
|
||||
QString NewLabelString = "<html><table><tr><td width='30'><img src=':/";
|
||||
NewLabelString += GetIconString(controllers[controller_idx]->type, IsDarkTheme());
|
||||
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(controllers[controller_idx]->name) + "</td></tr></table></html>";
|
||||
DeviceTabHeader* device_tab_header = new DeviceTabHeader(
|
||||
GetIconString(controllers[controller_idx]->type, IsDarkTheme()),
|
||||
QString::fromStdString(controllers[controller_idx]->name)
|
||||
);
|
||||
|
||||
QLabel *NewTabLabel = new QLabel();
|
||||
NewTabLabel->setText(NewLabelString);
|
||||
NewTabLabel->setIndent(20);
|
||||
if(IsDarkTheme())
|
||||
{
|
||||
NewTabLabel->setGeometry(0, 25, 200, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTabLabel->setGeometry(0, 0, 200, 25);
|
||||
}
|
||||
|
||||
ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, NewTabLabel);
|
||||
ui->DevicesTabBar->tabBar()->setTabButton(ui->DevicesTabBar->count() - 1, QTabBar::LeftSide, device_tab_header);
|
||||
ui->DevicesTabBar->tabBar()->setTabToolTip(ui->DevicesTabBar->count() - 1, QString::fromStdString(controllers[controller_idx]->name));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
|
||||
Reference in New Issue
Block a user