Restore on system tray icon double click
This commit is contained in:
parent
30d2c0f6c6
commit
ed4a70c19e
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "systray.h"
|
#include "systray.h"
|
||||||
#include "rclmain_w.h"
|
#include "rclmain_w.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
void RclTrayIcon::init()
|
void RclTrayIcon::init()
|
||||||
{
|
{
|
||||||
@ -27,16 +28,32 @@ void RclTrayIcon::init()
|
|||||||
|
|
||||||
connect(restoreAction, SIGNAL(triggered()), this, SLOT(onRestore()));
|
connect(restoreAction, SIGNAL(triggered()), this, SLOT(onRestore()));
|
||||||
connect(quitAction, SIGNAL(triggered()), m_mainw, SLOT(fileExit()));
|
connect(quitAction, SIGNAL(triggered()), m_mainw, SLOT(fileExit()));
|
||||||
|
|
||||||
QMenu *trayIconMenu = new QMenu(0);
|
QMenu *trayIconMenu = new QMenu(0);
|
||||||
trayIconMenu->addAction(restoreAction);
|
trayIconMenu->addAction(restoreAction);
|
||||||
trayIconMenu->addAction(quitAction);
|
trayIconMenu->addAction(quitAction);
|
||||||
setContextMenu(trayIconMenu);
|
setContextMenu(trayIconMenu);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
|
this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RclTrayIcon::onRestore()
|
void RclTrayIcon::onRestore()
|
||||||
{
|
{
|
||||||
// Hide and show to restore on current desktop
|
// Hide and show to restore on current desktop
|
||||||
m_mainw->hide();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class RclTrayIcon : public QSystemTrayIcon {
|
|||||||
}
|
}
|
||||||
public slots:
|
public slots:
|
||||||
void onRestore();
|
void onRestore();
|
||||||
|
void onActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
RclMain *m_mainw;
|
RclMain *m_mainw;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user