blob: 54fa8a6b5b8890dfcc4909cf06b111c404e6f037 (
plain)
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
|
// QT Includes
#include <QApplication>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QTimer>
#include <LuminaXDG.h>
class TrayApp : public QSystemTrayIcon {
Q_OBJECT
private:
QTimer *timer;
int iconnum;
private slots:
void ChangeIcon(){
this->setToolTip("Icon Number:"+QString::number(iconnum));
QString ico;
//Rotate the icon every time
if(iconnum <=0){ ico = "arrow-left"; iconnum=1; }
else if(iconnum==1){ ico = "arrow-up"; iconnum=2; }
else if(iconnum==2){ ico = "arrow-right"; iconnum=3; }
else{ico = "arrow-down"; iconnum=0; }
this->setIcon( LXDG::findIcon(ico,"") );
}
void StopTest(){
QApplication::exit(0);
}
public:
TrayApp() : QSystemTrayIcon(){
iconnum = 0;
this->setContextMenu(new QMenu());
this->contextMenu()->addAction("Stop Test", this, SLOT(StopTest()) );
timer = new QTimer(this);
timer->setInterval(3000); //change every 3 seconds
connect(timer, SIGNAL(timeout()), this, SLOT(ChangeIcon()) );
ChangeIcon(); //get it updated now
timer->start();
}
virtual ~TrayApp(){}
};
|