blob: 0d2841a08c6c7841d9f9a2b1ffc8a0d8d38f05d3 (
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
|
// QT Includes
#include <QApplication>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QTimer>
#include <QDebug>
#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
qDebug() << "Changing Icon:" << iconnum;
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,"") );
this->showMessage("Title","Some random message", QSystemTrayIcon::Information, 1500); //1.5 second popup
}
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(){}
};
|