Allow closing to tray by setting "minimize_on_close" to true in settings key "Minimize"
Code changes and setting key name change by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
be7ca2a16c
commit
75df81f972
2 changed files with 45 additions and 1 deletions
|
|
@ -229,6 +229,24 @@ OpenRGBDialog2::OpenRGBDialog2(QWidget *parent) : QMainWindow(parent), ui(new Op
|
|||
connect( actionExit, SIGNAL( triggered() ), this, SLOT( on_Exit() ));
|
||||
trayIconMenu->addAction(actionExit);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Tray minimization |
|
||||
| Defaults to false |
|
||||
\*-------------------------------------------------*/
|
||||
json MinimizeSettings;
|
||||
MinimizeSettings = ResourceManager::get()->GetSettingsManager()->GetSettings("Minimize");
|
||||
|
||||
if (MinimizeSettings.contains("minimize_on_close"))
|
||||
{
|
||||
OpenRGBDialog2::MinimizeToTray = MinimizeSettings["minimize_on_close"];
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenRGBDialog2::MinimizeToTray = false;
|
||||
}
|
||||
|
||||
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_ReShow(QSystemTrayIcon::ActivationReason)));
|
||||
|
||||
trayIcon->setIcon(logo);
|
||||
trayIcon->setToolTip("OpenRGB");
|
||||
trayIcon->setContextMenu(trayIconMenu);
|
||||
|
|
@ -316,7 +334,16 @@ OpenRGBDialog2::~OpenRGBDialog2()
|
|||
void OpenRGBDialog2::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
ResourceManager::get()->WaitForDeviceDetection();
|
||||
event->accept();
|
||||
|
||||
if (OpenRGBDialog2::MinimizeToTray)
|
||||
{
|
||||
hide();
|
||||
event->ignore();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::AddSoftwareInfoPage()
|
||||
|
|
@ -771,6 +798,10 @@ void OpenRGBDialog2::UpdateProfileList()
|
|||
|
||||
void OpenRGBDialog2::on_Exit()
|
||||
{
|
||||
/*-----------------------------------------------*\
|
||||
| This is the exit from the tray icon |
|
||||
| NOT the main exit button (top right on Windows) |
|
||||
\*-----------------------------------------------*/
|
||||
trayIcon->hide();
|
||||
close();
|
||||
}
|
||||
|
|
@ -873,6 +904,17 @@ void OpenRGBDialog2::on_ShowHide()
|
|||
}
|
||||
}
|
||||
|
||||
void OpenRGBDialog2::on_ReShow(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (reason == QSystemTrayIcon::DoubleClick)
|
||||
{
|
||||
if (isHidden())
|
||||
{
|
||||
show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenRGBDialog2::on_ProfileSelected()
|
||||
{
|
||||
ProfileManager* profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ private:
|
|||
/*-------------------------------------*\
|
||||
| System tray icon and menu |
|
||||
\*-------------------------------------*/
|
||||
bool MinimizeToTray;
|
||||
QSystemTrayIcon* trayIcon;
|
||||
QMenu* profileMenu;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ private slots:
|
|||
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void on_SaveSizeProfile();
|
||||
void on_ShowHide();
|
||||
void on_ReShow(QSystemTrayIcon::ActivationReason reason);
|
||||
void on_ProfileSelected();
|
||||
void on_ButtonSaveProfile_clicked();
|
||||
void on_ButtonLoadProfile_clicked();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue