Systray: add Take Screenshot menu item

This commit is contained in:
lupoDharkael
2018-04-11 19:27:33 +02:00
parent 91bf065e82
commit 009b6fb71a
3 changed files with 26 additions and 17 deletions

View File

@@ -105,6 +105,11 @@ void Controller::enableTrayIcon() {
return;
}
ConfigHandler().setDisabledTrayIcon(false);
QAction *captureAction = new QAction(tr("&Take Screenshot"), this);
connect(captureAction, &QAction::triggered, this, [this](){
// Wait 400 ms to hide the QMenu
doLater(400, this, [this](){ this->createVisualCapture(); });
});
QAction *configAction = new QAction(tr("&Configuration"), this);
connect(configAction, &QAction::triggered, this,
&Controller::openConfigWindow);
@@ -116,6 +121,7 @@ void Controller::enableTrayIcon() {
&QCoreApplication::quit);
QMenu *trayIconMenu = new QMenu();
trayIconMenu->addAction(captureAction);
trayIconMenu->addAction(configAction);
trayIconMenu->addAction(infoAction);
trayIconMenu->addSeparator();
@@ -160,3 +166,11 @@ void Controller::updateConfigComponents() {
m_configWindow->updateChildren();
}
}
void doLater(int msec, QObject *receiver, lambda func) {
QTimer *timer = new QTimer(receiver);
QObject::connect(timer, &QTimer::timeout, receiver,
[timer, func](){ func(); timer->deleteLater(); });
timer->setInterval(msec);
timer->start();
}