Restore on system tray icon double click

This commit is contained in:
Jean-Francois Dockes 2019-02-14 16:05:54 +01:00
parent 30d2c0f6c6
commit ed4a70c19e
2 changed files with 20 additions and 3 deletions

View File

@ -19,6 +19,7 @@
#include "systray.h"
#include "rclmain_w.h"
#include "log.h"
void RclTrayIcon::init()
{
@ -27,16 +28,32 @@ void RclTrayIcon::init()
connect(restoreAction, SIGNAL(triggered()), this, SLOT(onRestore()));
connect(quitAction, SIGNAL(triggered()), m_mainw, SLOT(fileExit()));
QMenu *trayIconMenu = new QMenu(0);
trayIconMenu->addAction(restoreAction);
trayIconMenu->addAction(quitAction);
setContextMenu(trayIconMenu);
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
}
void RclTrayIcon::onRestore()
{
// Hide and show to restore on current desktop
m_mainw->hide();
m_mainw->show();
m_mainw->showNormal();
}
void RclTrayIcon::onActivated(QSystemTrayIcon::ActivationReason reason)
{
LOGDEB("RclTrayIcon::onActivated: reason " << reason << std::endl);
switch (reason) {
case QSystemTrayIcon::DoubleClick:
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::MiddleClick:
onRestore();
break;
default:
return;
}
}

View File

@ -33,7 +33,7 @@ class RclTrayIcon : public QSystemTrayIcon {
}
public slots:
void onRestore();
void onActivated(QSystemTrayIcon::ActivationReason reason);
private:
void init();
RclMain *m_mainw;