diff --git a/qt/OpenRGBDialog2.cpp b/qt/OpenRGBDialog2.cpp index d75df291..5be520ca 100644 --- a/qt/OpenRGBDialog2.cpp +++ b/qt/OpenRGBDialog2.cpp @@ -14,6 +14,24 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector& bus, std::vec QIcon logo(":OpenRGB.png"); setWindowIcon(logo); + + QMenu* trayIconMenu = new QMenu( this ); + + trayIcon = new QSystemTrayIcon(this); + + QAction* actionShowHide = new QAction("Show/Hide", this); + connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide())); + trayIconMenu->addAction(actionShowHide); + + QAction* actionExit = new QAction( "Exit", this ); + connect( actionExit, SIGNAL( triggered() ), this, SLOT( on_Exit() )); + trayIconMenu->addAction(actionExit); + + trayIcon->setIcon(logo); + trayIcon->setToolTip("OpenRGB"); + trayIcon->setContextMenu(trayIconMenu); + trayIcon->show(); + /*-----------------------------------------------------*\ | Set up list of devices | \*-----------------------------------------------------*/ @@ -156,6 +174,11 @@ void OpenRGBDialog2::show() QMainWindow::show(); } +void OpenRGBDialog2::on_Exit() +{ + close(); +} + void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue) { for(int device = 0; device < ui->DevicesTabBar->count(); device++) @@ -163,3 +186,15 @@ void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, un qobject_cast(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue); } } + +void OpenRGBDialog2::on_ShowHide() +{ + if(isHidden()) + { + show(); + } + else + { + hide(); + } +} \ No newline at end of file diff --git a/qt/OpenRGBDialog2.h b/qt/OpenRGBDialog2.h index a6ff8cad..4c2a981e 100644 --- a/qt/OpenRGBDialog2.h +++ b/qt/OpenRGBDialog2.h @@ -34,9 +34,12 @@ protected: private: Ui::OpenRGBDialog2Ui *ui; + QSystemTrayIcon* trayIcon; private slots: + void on_Exit(); void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue); + void on_ShowHide(); }; #endif // OPENRGBDIALOG2_H