Add settings page under settings tab
This commit is contained in:
parent
4764198df7
commit
c1b9f79052
9 changed files with 197 additions and 10 deletions
|
|
@ -157,6 +157,7 @@ HEADERS +=
|
|||
qt/OpenRGBPluginContainer.h \
|
||||
qt/OpenRGBProfileSaveDialog.h \
|
||||
qt/OpenRGBServerInfoPage.h \
|
||||
qt/OpenRGBSettingsPage.h \
|
||||
qt/OpenRGBSoftwareInfoPage.h \
|
||||
qt/OpenRGBSupportedDevicesPage.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
|
|
@ -392,6 +393,7 @@ SOURCES +=
|
|||
qt/OpenRGBPluginContainer.cpp \
|
||||
qt/OpenRGBProfileSaveDialog.cpp \
|
||||
qt/OpenRGBServerInfoPage.cpp \
|
||||
qt/OpenRGBSettingsPage.cpp \
|
||||
qt/OpenRGBSoftwareInfoPage.cpp \
|
||||
qt/OpenRGBSupportedDevicesPage.cpp \
|
||||
qt/OpenRGBSystemInfoPage.cpp \
|
||||
|
|
@ -668,9 +670,10 @@ FORMS +=
|
|||
qt/OpenRGBDevicePage.ui \
|
||||
qt/OpenRGBDialog.ui \
|
||||
qt/OpenRGBDialog2.ui \
|
||||
qt/OpenRGBPluginContainer.ui \
|
||||
qt/OpenRGBPluginContainer.ui \
|
||||
qt/OpenRGBProfileSaveDialog.ui \
|
||||
qt/OpenRGBServerInfoPage.ui \
|
||||
qt/OpenRGBSettingsPage.ui \
|
||||
qt/OpenRGBSoftwareInfoPage.ui \
|
||||
qt/OpenRGBSupportedDevicesPage.ui \
|
||||
qt/OpenRGBSystemInfoPage.ui \
|
||||
|
|
|
|||
|
|
@ -150,6 +150,18 @@ bool OpenRGBDialog2::IsDarkTheme()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool OpenRGBDialog2::IsMinimizeOnClose()
|
||||
{
|
||||
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
|
||||
|
||||
if(ui_settings.contains("minimize_on_close"))
|
||||
{
|
||||
return ui_settings["minimize_on_close"];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new OpenRGBDialog2Ui)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
|
@ -321,12 +333,6 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
|
||||
settings_manager->SetSettings(ui_string, ui_settings);
|
||||
settings_manager->SaveSettings();
|
||||
|
||||
MinimizeToTray = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MinimizeToTray = ui_settings["minimize_on_close"].get<bool>();
|
||||
}
|
||||
|
||||
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_ReShow(QSystemTrayIcon::ActivationReason)));
|
||||
|
|
@ -386,10 +392,15 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
AddSoftwareInfoPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the upported Devices page |
|
||||
| Add the supported Devices page |
|
||||
\*-----------------------------------------------------*/
|
||||
AddSupportedDevicesPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
AddSettingsPage();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the SMBus Tools page if enabled |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
@ -454,7 +465,7 @@ void OpenRGBDialog2::closeEvent(QCloseEvent *event)
|
|||
{
|
||||
ResourceManager::get()->WaitForDeviceDetection();
|
||||
|
||||
if (MinimizeToTray && !this->isHidden())
|
||||
if (IsMinimizeOnClose() && !this->isHidden())
|
||||
{
|
||||
hide();
|
||||
event->ignore();
|
||||
|
|
@ -523,6 +534,36 @@ void OpenRGBDialog2::AddSupportedDevicesPage()
|
|||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SupportedTabLabel);
|
||||
}
|
||||
|
||||
|
||||
void OpenRGBDialog2::AddSettingsPage()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the Settings page |
|
||||
\*-----------------------------------------------------*/
|
||||
SettingsPage = new OpenRGBSettingsPage();
|
||||
|
||||
ui->SettingsTabBar->addTab(SettingsPage, "");
|
||||
|
||||
QString SettingsLabelString = "<html><table><tr><td width='30'><img src='";
|
||||
SettingsLabelString += ":/settings";
|
||||
if(IsDarkTheme()) SettingsLabelString += "_dark";
|
||||
SettingsLabelString += ".png' height='16' width='16'></td><td>Settings</td></tr></table></html>";
|
||||
|
||||
QLabel *SettingsTabLabel = new QLabel();
|
||||
SettingsTabLabel->setText(SettingsLabelString);
|
||||
SettingsTabLabel->setIndent(20);
|
||||
if(IsDarkTheme())
|
||||
{
|
||||
SettingsTabLabel->setGeometry(0, 25, 200, 50);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsTabLabel->setGeometry(0, 0, 200, 25);
|
||||
}
|
||||
|
||||
ui->SettingsTabBar->tabBar()->setTabButton(ui->SettingsTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SettingsTabLabel);
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddPluginTab(PluginManager* plugin_manager, int plugin_index)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "OpenRGBSoftwareInfoPage.h"
|
||||
#include "OpenRGBSystemInfoPage.h"
|
||||
#include "OpenRGBSupportedDevicesPage.h"
|
||||
#include "OpenRGBSettingsPage.h"
|
||||
#include "PluginManager.h"
|
||||
|
||||
#include <vector>
|
||||
|
|
@ -42,6 +43,7 @@ public:
|
|||
void setMode(unsigned char mode_val);
|
||||
|
||||
static bool IsDarkTheme();
|
||||
static bool IsMinimizeOnClose();
|
||||
|
||||
private:
|
||||
/*-------------------------------------*\
|
||||
|
|
@ -51,13 +53,13 @@ private:
|
|||
OpenRGBSystemInfoPage *SMBusToolsPage;
|
||||
OpenRGBSoftwareInfoPage *SoftInfoPage;
|
||||
OpenRGBSupportedDevicesPage *SupportedPage;
|
||||
OpenRGBSettingsPage *SettingsPage;
|
||||
|
||||
bool ShowI2CTools = false;
|
||||
|
||||
/*-------------------------------------*\
|
||||
| System tray icon and menu |
|
||||
\*-------------------------------------*/
|
||||
bool MinimizeToTray;
|
||||
QSystemTrayIcon* trayIcon;
|
||||
QMenu* profileMenu;
|
||||
|
||||
|
|
@ -68,6 +70,7 @@ private:
|
|||
|
||||
void AddSoftwareInfoPage();
|
||||
void AddSupportedDevicesPage();
|
||||
void AddSettingsPage();
|
||||
void AddPluginTab(PluginManager* plugin_manager,int plugin_index);
|
||||
|
||||
void ClearDevicesList();
|
||||
|
|
|
|||
59
qt/OpenRGBSettingsPage.cpp
Normal file
59
qt/OpenRGBSettingsPage.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#include "OpenRGBSettingsPage.h"
|
||||
#include "ui_OpenRGBSettingsPage.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenRGBSettingsPage::OpenRGBSettingsPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OpenRGBSettingsPageUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
ui->ComboBoxTheme->addItems({"auto", "light", "dark"});
|
||||
|
||||
json theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Theme");
|
||||
|
||||
if(theme_settings.contains("theme"))
|
||||
{
|
||||
std::string theme = theme_settings["theme"];
|
||||
ui->ComboBoxTheme->setCurrentText(QString::fromStdString(theme));
|
||||
}
|
||||
#else
|
||||
ui->ComboBoxTheme->hide();
|
||||
ui->ThemeLabel->hide();
|
||||
#endif
|
||||
|
||||
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
|
||||
ui->CheckboxMinimizeOnClose->setChecked(ui_settings["minimize_on_close"]);
|
||||
}
|
||||
|
||||
OpenRGBSettingsPage::~OpenRGBSettingsPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenRGBSettingsPage::on_ComboBoxTheme_currentTextChanged(const QString theme)
|
||||
{
|
||||
json theme_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Theme");
|
||||
theme_settings["theme"] = theme.toStdString();
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("Theme", theme_settings);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void OpenRGBSettingsPage::on_CheckboxMinimizeOnClose_clicked()
|
||||
{
|
||||
json ui_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("UserInterface");
|
||||
ui_settings["minimize_on_close"] = ui->CheckboxMinimizeOnClose->isChecked();
|
||||
ResourceManager::get()->GetSettingsManager()->SetSettings("UserInterface", ui_settings);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
void OpenRGBSettingsPage::SaveSettings()
|
||||
{
|
||||
ResourceManager::get()->GetSettingsManager()->SaveSettings();
|
||||
}
|
||||
|
||||
|
||||
28
qt/OpenRGBSettingsPage.h
Normal file
28
qt/OpenRGBSettingsPage.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef SETTINGSPAGE_H
|
||||
#define SETTINGSPAGE_H
|
||||
|
||||
#include "ui_OpenRGBSettingsPage.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class OpenRGBSettingsPage;
|
||||
}
|
||||
|
||||
class Ui::OpenRGBSettingsPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenRGBSettingsPage(QWidget *parent = nullptr);
|
||||
~OpenRGBSettingsPage();
|
||||
|
||||
private:
|
||||
Ui::OpenRGBSettingsPageUi *ui;
|
||||
void SaveSettings();
|
||||
|
||||
private slots:
|
||||
void on_ComboBoxTheme_currentTextChanged(const QString);
|
||||
void on_CheckboxMinimizeOnClose_clicked();
|
||||
};
|
||||
|
||||
#endif // OPENRGBSETTINGSPAGE_H
|
||||
51
qt/OpenRGBSettingsPage.ui
Normal file
51
qt/OpenRGBSettingsPage.ui
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenRGBSettingsPageUi</class>
|
||||
<widget class="QWidget" name="OpenRGBSettingsPageUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>144</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="ComboBoxTheme"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="CheckboxMinimizeOnClose">
|
||||
<property name="text">
|
||||
<string>Minimize on close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="ThemeLabel">
|
||||
<property name="text">
|
||||
<string>Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -38,5 +38,7 @@
|
|||
<file>speaker_dark.png</file>
|
||||
<file>virtual.png</file>
|
||||
<file>virtual_dark.png</file>
|
||||
<file>settings.png</file>
|
||||
<file>settings_dark.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
BIN
qt/settings.png
Normal file
BIN
qt/settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
BIN
qt/settings_dark.png
Normal file
BIN
qt/settings_dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
Loading…
Add table
Add a link
Reference in a new issue