-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwindow.cpp
More file actions
92 lines (78 loc) · 2.35 KB
/
Copy pathwindow.cpp
File metadata and controls
92 lines (78 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <QtWidgets>
#include "window.h"
// http://qt-project.org/doc/qt-4.8/desktop-systray.html
Window::Window():
settings("Pixelpulse2-Trayer","Pixelpulse2-Trayer")
{
createActions();
createTrayIcon();
auto icon = QIcon(":/icons/professor.png");
trayIcon->setToolTip("Pixelpulse2 - Trayer");
trayIcon->setIcon(icon);
trayIcon->show();
settings.setDefaultFormat(QSettings::defaultFormat());
// use OS-specific window icon set by pp2trayer.pro
//setWindowIcon(icon);
}
void Window::setDisabled(PP2Wrapper &pp2wrapper){
bool deactiv = settings.value("deactivate").toBool();
deactivateAction->setChecked(deactiv);
pp2wrapper.setDisabled(deactiv);
}
void Window::closeEvent(QCloseEvent *event)
{
if(trayIcon->isVisible()) {
QMessageBox::information(this, tr("SysTray"),
tr("The program will keep running in the "
"system tray. To terminate the program, "
"choose <b>Quit</b> in the context menu "
"of the system tray entry."));
hide();
event->ignore();
}
}
void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
switch(reason)
{
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::DoubleClick:
break;
case QSystemTrayIcon::MiddleClick:
showMessage();
break;
default:
;
}
}
void Window::showMessage()
{
}
void Window::messageClicked()
{
QMessageBox::information(this, tr("SysTray"),
tr("Sorry, I alreaady gave what help I could."));
}
void Window::deactivate(bool status)
{
emit deactivateChanged(status);
settings.setValue("deactivate", status);
settings.sync();
}
void Window::createActions()
{
quitAction = new QAction(tr("&Quit"), this);
deactivateAction = new QAction(tr("&Deactivate"), this);
deactivateAction->setCheckable(true);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(deactivateAction, SIGNAL(triggered(bool)),
this, SLOT(deactivate(bool)));
}
void Window::createTrayIcon()
{
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(quitAction);
trayIconMenu->addAction(deactivateAction);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(trayIconMenu);
}