Add settings page to enable and disable devices
Commits squashed and amended to read information only from settings manager by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
a90edce03b
commit
8a88573443
9 changed files with 375 additions and 10 deletions
|
|
@ -117,6 +117,7 @@ HEADERS +=
|
||||||
SettingsManager.h \
|
SettingsManager.h \
|
||||||
Detector.h \
|
Detector.h \
|
||||||
DeviceDetector.h \
|
DeviceDetector.h \
|
||||||
|
qt/DetectorTableModel.h \
|
||||||
qt/OpenRGBClientInfoPage.h \
|
qt/OpenRGBClientInfoPage.h \
|
||||||
qt/OpenRGBDeviceInfoPage.h \
|
qt/OpenRGBDeviceInfoPage.h \
|
||||||
qt/OpenRGBDevicePage.h \
|
qt/OpenRGBDevicePage.h \
|
||||||
|
|
@ -130,6 +131,7 @@ HEADERS +=
|
||||||
qt/OpenRGBProfileSaveDialog.h \
|
qt/OpenRGBProfileSaveDialog.h \
|
||||||
qt/OpenRGBServerInfoPage.h \
|
qt/OpenRGBServerInfoPage.h \
|
||||||
qt/OpenRGBSoftwareInfoPage.h \
|
qt/OpenRGBSoftwareInfoPage.h \
|
||||||
|
qt/OpenRGBSupportedDevicesPage.h \
|
||||||
qt/OpenRGBSystemInfoPage.h \
|
qt/OpenRGBSystemInfoPage.h \
|
||||||
qt/OpenRGBZoneResizeDialog.h \
|
qt/OpenRGBZoneResizeDialog.h \
|
||||||
serial_port/find_usb_serial_port.h \
|
serial_port/find_usb_serial_port.h \
|
||||||
|
|
@ -290,6 +292,7 @@ SOURCES +=
|
||||||
ProfileManager.cpp \
|
ProfileManager.cpp \
|
||||||
ResourceManager.cpp \
|
ResourceManager.cpp \
|
||||||
SettingsManager.cpp \
|
SettingsManager.cpp \
|
||||||
|
qt/DetectorTableModel.cpp \
|
||||||
qt/OpenRGBClientInfoPage.cpp \
|
qt/OpenRGBClientInfoPage.cpp \
|
||||||
qt/OpenRGBDeviceInfoPage.cpp \
|
qt/OpenRGBDeviceInfoPage.cpp \
|
||||||
qt/OpenRGBDevicePage.cpp \
|
qt/OpenRGBDevicePage.cpp \
|
||||||
|
|
@ -302,6 +305,7 @@ SOURCES +=
|
||||||
qt/OpenRGBProfileSaveDialog.cpp \
|
qt/OpenRGBProfileSaveDialog.cpp \
|
||||||
qt/OpenRGBServerInfoPage.cpp \
|
qt/OpenRGBServerInfoPage.cpp \
|
||||||
qt/OpenRGBSoftwareInfoPage.cpp \
|
qt/OpenRGBSoftwareInfoPage.cpp \
|
||||||
|
qt/OpenRGBSupportedDevicesPage.cpp \
|
||||||
qt/OpenRGBSystemInfoPage.cpp \
|
qt/OpenRGBSystemInfoPage.cpp \
|
||||||
qt/OpenRGBZoneResizeDialog.cpp \
|
qt/OpenRGBZoneResizeDialog.cpp \
|
||||||
qt/hsv.cpp \
|
qt/hsv.cpp \
|
||||||
|
|
@ -510,6 +514,7 @@ FORMS +=
|
||||||
qt/OpenRGBProfileSaveDialog.ui \
|
qt/OpenRGBProfileSaveDialog.ui \
|
||||||
qt/OpenRGBServerInfoPage.ui \
|
qt/OpenRGBServerInfoPage.ui \
|
||||||
qt/OpenRGBSoftwareInfoPage.ui \
|
qt/OpenRGBSoftwareInfoPage.ui \
|
||||||
|
qt/OpenRGBSupportedDevicesPage.ui \
|
||||||
qt/OpenRGBSystemInfoPage.ui \
|
qt/OpenRGBSystemInfoPage.ui \
|
||||||
qt/OpenRGBZoneResizeDialog.ui \
|
qt/OpenRGBZoneResizeDialog.ui \
|
||||||
|
|
||||||
|
|
|
||||||
147
qt/DetectorTableModel.cpp
Normal file
147
qt/DetectorTableModel.cpp
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
#include "DetectorTableModel.h"
|
||||||
|
|
||||||
|
DetectorTableModel::DetectorTableModel(QObject* parent) : QAbstractTableModel(parent)
|
||||||
|
{
|
||||||
|
detectors.clear();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Read the detector list from the settings manager |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
json settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
|
||||||
|
|
||||||
|
if(settings.contains("detectors"))
|
||||||
|
{
|
||||||
|
for(json::const_iterator it = settings["detectors"].begin(); it != settings["detectors"].end(); it++)
|
||||||
|
{
|
||||||
|
DetectorTableValue new_entry;
|
||||||
|
|
||||||
|
new_entry.key = it.key();
|
||||||
|
new_entry.value = it.value();
|
||||||
|
|
||||||
|
detectors.push_back(new_entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| If settings contains the detectors list, fill in rows |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
beginInsertRows(QModelIndex(), 0, detectors.size());
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DetectorTableModel::columnCount(const QModelIndex&) const
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| The table has two columns - detector name and enable |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DetectorTableModel::rowCount(const QModelIndex&) const
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| The number of rows is equal to the number of detectors|
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
return detectors.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DetectorTableModel::data(const QModelIndex& index, int role) const
|
||||||
|
{
|
||||||
|
switch(role)
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Column 0 is the detector name, 1 is the enable flag |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
switch(index.column())
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return detectors[index.row()].key.c_str();
|
||||||
|
case 1:
|
||||||
|
return detectors[index.row()].value;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
case Qt::CheckStateRole:
|
||||||
|
switch(index.column())
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
return 2 * detectors[index.row()].value;
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DetectorTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Update detector value for column 1 |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
if(index.column() == 1 && role == Qt::CheckStateRole)
|
||||||
|
{
|
||||||
|
detectors[index.row()].value = value.toBool();
|
||||||
|
emit dataChanged(index, index);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant DetectorTableModel::headerData(int index, Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if(role == Qt::DisplayRole)
|
||||||
|
{
|
||||||
|
switch(orientation)
|
||||||
|
{
|
||||||
|
case Qt::Vertical:
|
||||||
|
return index + 1;
|
||||||
|
|
||||||
|
case Qt::Horizontal:
|
||||||
|
switch(index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return "Name";
|
||||||
|
case 1:
|
||||||
|
return "Enabled";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags DetectorTableModel::flags(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
Qt::ItemFlags fl = Qt::ItemIsEnabled;
|
||||||
|
|
||||||
|
if(index.column() == 1)
|
||||||
|
{
|
||||||
|
fl |= Qt::ItemIsUserCheckable;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DetectorTableModel::applySettings()
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Read the detector list from the settings manager |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
json settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Loop through all detectors in the list and update the |
|
||||||
|
| value in the settings |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
if(settings.contains("detectors"))
|
||||||
|
{
|
||||||
|
for(unsigned int detector_idx = 0; detector_idx < detectors.size(); detector_idx++)
|
||||||
|
{
|
||||||
|
settings["detectors"][detectors[detector_idx].key] = detectors[detector_idx].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Set and save the settings |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
ResourceManager::get()->GetSettingsManager()->SetSettings("Detectors", settings);
|
||||||
|
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||||
|
}
|
||||||
33
qt/DetectorTableModel.h
Normal file
33
qt/DetectorTableModel.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef DETECTORTABLEMODEL_H
|
||||||
|
#define DETECTORTABLEMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
#include "ResourceManager.h"
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
std::string key;
|
||||||
|
bool value;
|
||||||
|
} DetectorTableValue;
|
||||||
|
|
||||||
|
class DetectorTableModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<DetectorTableValue> detectors;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DetectorTableModel(QObject *parent = nullptr);
|
||||||
|
int columnCount(const QModelIndex&) const override;
|
||||||
|
int rowCount(const QModelIndex&) const override;
|
||||||
|
QVariant data(const QModelIndex& index, int role) const override;
|
||||||
|
bool setData(const QModelIndex& index, const QVariant&, int role) override;
|
||||||
|
QVariant headerData(int index, Qt::Orientation orientation, int role) const override;
|
||||||
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void applySettings();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DETECTORTABLEMODEL_H
|
||||||
|
|
@ -260,21 +260,26 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
UpdateDevicesList();
|
UpdateDevicesList();
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
|
||||||
| Add Server Tab |
|
|
||||||
\*-----------------------------------------------------*/
|
|
||||||
AddServerTab();
|
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Add Client Tab |
|
| Add Client Tab |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
AddClientTab();
|
AddClientTab();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Add Server Tab |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
AddServerTab();
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Add the Software Info page |
|
| Add the Software Info page |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
AddSoftwareInfoPage();
|
AddSoftwareInfoPage();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Add the upported Devices page |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
AddSupportedDevicesPage();
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Add the SMBus Tools page if enabled |
|
| Add the SMBus Tools page if enabled |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
|
|
@ -324,6 +329,35 @@ void OpenRGBDialog2::AddSoftwareInfoPage()
|
||||||
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel);
|
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenRGBDialog2::AddSupportedDevicesPage()
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Create the Supported Devices page |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
SupportedPage = new OpenRGBSupportedDevicesPage();
|
||||||
|
|
||||||
|
ui->SettingsTabBar->addTab(SupportedPage, "");
|
||||||
|
|
||||||
|
QString SupportedLabelString = "<html><table><tr><td width='30'><img src='";
|
||||||
|
SupportedLabelString += ":/software";
|
||||||
|
if(IsDarkTheme()) SupportedLabelString += "_dark";
|
||||||
|
SupportedLabelString += ".png' height='16' width='16'></td><td>Supported Devices</td></tr></table></html>";
|
||||||
|
|
||||||
|
QLabel *SupportedTabLabel = new QLabel();
|
||||||
|
SupportedTabLabel->setText(SupportedLabelString);
|
||||||
|
SupportedTabLabel->setIndent(20);
|
||||||
|
if(IsDarkTheme())
|
||||||
|
{
|
||||||
|
SupportedTabLabel->setGeometry(0, 25, 200, 50);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SupportedTabLabel->setGeometry(0, 0, 200, 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SupportedTabLabel);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenRGBDialog2::AddI2CToolsPage()
|
void OpenRGBDialog2::AddI2CToolsPage()
|
||||||
{
|
{
|
||||||
ShowI2CTools = true;
|
ShowI2CTools = true;
|
||||||
|
|
@ -365,7 +399,7 @@ void OpenRGBDialog2::AddClientTab()
|
||||||
if(ClientInfoPage == NULL)
|
if(ClientInfoPage == NULL)
|
||||||
{
|
{
|
||||||
ClientInfoPage = new OpenRGBClientInfoPage();
|
ClientInfoPage = new OpenRGBClientInfoPage();
|
||||||
ui->MainTabBar->addTab(ClientInfoPage, "SDK Client");
|
ui->MainTabBar->insertTab(2, ClientInfoPage, "SDK Client");
|
||||||
|
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| Connect the page's Set All button to the Set All slot |
|
| Connect the page's Set All button to the Set All slot |
|
||||||
|
|
@ -394,7 +428,7 @@ void OpenRGBDialog2::AddServerTab()
|
||||||
| Add server information tab if there is a server |
|
| Add server information tab if there is a server |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(ResourceManager::get()->GetServer());
|
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(ResourceManager::get()->GetServer());
|
||||||
ui->MainTabBar->addTab(ServerInfoPage, "SDK Server");
|
ui->MainTabBar->insertTab(2, ServerInfoPage, "SDK Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenRGBDialog2::ClearDevicesList()
|
void OpenRGBDialog2::ClearDevicesList()
|
||||||
|
|
@ -426,7 +460,7 @@ void OpenRGBDialog2::UpdateDevicesList()
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for(unsigned int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++)
|
for(int tab_idx = 0; tab_idx < ui->DevicesTabBar->count(); tab_idx++)
|
||||||
{
|
{
|
||||||
OpenRGBDevicePage* page = (OpenRGBDevicePage*) ui->DevicesTabBar->widget(tab_idx);
|
OpenRGBDevicePage* page = (OpenRGBDevicePage*) ui->DevicesTabBar->widget(tab_idx);
|
||||||
|
|
||||||
|
|
@ -501,7 +535,7 @@ void OpenRGBDialog2::UpdateDevicesList()
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
for(unsigned int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||||
{
|
{
|
||||||
/*-----------------------------------------------------*\
|
/*-----------------------------------------------------*\
|
||||||
| If type is a device info page, check it |
|
| If type is a device info page, check it |
|
||||||
|
|
@ -581,7 +615,7 @@ void OpenRGBDialog2::UpdateDevicesList()
|
||||||
| Remove all remaining device information tabs, leaving |
|
| Remove all remaining device information tabs, leaving |
|
||||||
| other information tabs alone |
|
| other information tabs alone |
|
||||||
\*-----------------------------------------------------*/
|
\*-----------------------------------------------------*/
|
||||||
for(unsigned int tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
for(int tab_idx = controllers.size(); tab_idx < ui->InformationTabBar->count(); tab_idx++)
|
||||||
{
|
{
|
||||||
std::string type_str = ui->InformationTabBar->widget(tab_idx)->metaObject()->className();
|
std::string type_str = ui->InformationTabBar->widget(tab_idx)->metaObject()->className();
|
||||||
if(type_str == "Ui::OpenRGBDeviceInfoPage")
|
if(type_str == "Ui::OpenRGBDeviceInfoPage")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "OpenRGBClientInfoPage.h"
|
#include "OpenRGBClientInfoPage.h"
|
||||||
#include "OpenRGBSoftwareInfoPage.h"
|
#include "OpenRGBSoftwareInfoPage.h"
|
||||||
#include "OpenRGBSystemInfoPage.h"
|
#include "OpenRGBSystemInfoPage.h"
|
||||||
|
#include "OpenRGBSupportedDevicesPage.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "i2c_smbus.h"
|
#include "i2c_smbus.h"
|
||||||
|
|
@ -48,6 +49,7 @@ private:
|
||||||
OpenRGBClientInfoPage *ClientInfoPage;
|
OpenRGBClientInfoPage *ClientInfoPage;
|
||||||
OpenRGBSystemInfoPage *SMBusToolsPage;
|
OpenRGBSystemInfoPage *SMBusToolsPage;
|
||||||
OpenRGBSoftwareInfoPage *SoftInfoPage;
|
OpenRGBSoftwareInfoPage *SoftInfoPage;
|
||||||
|
OpenRGBSupportedDevicesPage *SupportedPage;
|
||||||
|
|
||||||
bool ShowI2CTools = false;
|
bool ShowI2CTools = false;
|
||||||
|
|
||||||
|
|
@ -63,6 +65,7 @@ private:
|
||||||
Ui::OpenRGBDialog2Ui *ui;
|
Ui::OpenRGBDialog2Ui *ui;
|
||||||
|
|
||||||
void AddSoftwareInfoPage();
|
void AddSoftwareInfoPage();
|
||||||
|
void AddSupportedDevicesPage();
|
||||||
|
|
||||||
void ClearDevicesList();
|
void ClearDevicesList();
|
||||||
void UpdateDevicesList();
|
void UpdateDevicesList();
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,23 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="TabSettings">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Settings</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTabWidget" name="SettingsTabBar">
|
||||||
|
<property name="tabPosition">
|
||||||
|
<enum>QTabWidget::West</enum>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0" colspan="5">
|
<item row="6" column="0" colspan="5">
|
||||||
|
|
|
||||||
49
qt/OpenRGBSupportedDevicesPage.cpp
Normal file
49
qt/OpenRGBSupportedDevicesPage.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include "OpenRGBSupportedDevicesPage.h"
|
||||||
|
#include "ui_OpenRGBSupportedDevicesPage.h"
|
||||||
|
|
||||||
|
using namespace Ui;
|
||||||
|
|
||||||
|
OpenRGBSupportedDevicesPage::OpenRGBSupportedDevicesPage(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::OpenRGBSupportedDevicesPageUi)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Create a detector table model and a sort model and |
|
||||||
|
| set them |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
detectorTableModel = new DetectorTableModel;
|
||||||
|
detectorSortModel = new QSortFilterProxyModel;
|
||||||
|
|
||||||
|
detectorSortModel->setSourceModel(detectorTableModel);
|
||||||
|
ui->SupportedDevicesTable->setModel(detectorSortModel);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Disable header, enable sorting, and sort in ascending |
|
||||||
|
| order |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
ui->SupportedDevicesTable->verticalHeader()->setVisible(0);
|
||||||
|
ui->SupportedDevicesTable->setSortingEnabled(true);
|
||||||
|
ui->SupportedDevicesTable->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Resize columns to fit the contents |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
ui->SupportedDevicesTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenRGBSupportedDevicesPage::~OpenRGBSupportedDevicesPage()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenRGBSupportedDevicesPage::on_SaveButton_clicked()
|
||||||
|
{
|
||||||
|
detectorTableModel->applySettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenRGBSupportedDevicesPage::on_Filter_textChanged(const QString &arg1)
|
||||||
|
{
|
||||||
|
detectorSortModel->setFilterRegExp(QRegExp(arg1, Qt::CaseInsensitive));
|
||||||
|
}
|
||||||
32
qt/OpenRGBSupportedDevicesPage.h
Normal file
32
qt/OpenRGBSupportedDevicesPage.h
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef SUPPORTEDDEVICESPAGE_H
|
||||||
|
#define SUPPORTEDDEVICESPAGE_H
|
||||||
|
|
||||||
|
#include "DetectorTableModel.h"
|
||||||
|
#include "ui_OpenRGBSupportedDevicesPage.h"
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class OpenRGBSupportedDevicesPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Ui::OpenRGBSupportedDevicesPage : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit OpenRGBSupportedDevicesPage(QWidget *parent = nullptr);
|
||||||
|
~OpenRGBSupportedDevicesPage();
|
||||||
|
DetectorTableModel* detectorTableModel;
|
||||||
|
QSortFilterProxyModel* detectorSortModel;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_SaveButton_clicked();
|
||||||
|
|
||||||
|
void on_Filter_textChanged(const QString &arg1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::OpenRGBSupportedDevicesPageUi *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SUPPORTEDDEVICESPAGE_H
|
||||||
45
qt/OpenRGBSupportedDevicesPage.ui
Normal file
45
qt/OpenRGBSupportedDevicesPage.ui
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>OpenRGBSupportedDevicesPageUi</class>
|
||||||
|
<widget class="QWidget" name="OpenRGBSupportedDevicesPageUi">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Supported devices</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Filter:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="Filter"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTableView" name="SupportedDevicesTable"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="SaveButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply changes</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue