aboutsummaryrefslogtreecommitdiff
path: root/dev-tools/systray-tester
diff options
context:
space:
mode:
Diffstat (limited to 'dev-tools/systray-tester')
-rw-r--r--dev-tools/systray-tester/Trayapp.h49
-rw-r--r--dev-tools/systray-tester/main.cpp26
-rw-r--r--dev-tools/systray-tester/systray-tester.pro18
3 files changed, 93 insertions, 0 deletions
diff --git a/dev-tools/systray-tester/Trayapp.h b/dev-tools/systray-tester/Trayapp.h
new file mode 100644
index 00000000..54fa8a6b
--- /dev/null
+++ b/dev-tools/systray-tester/Trayapp.h
@@ -0,0 +1,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(){}
+
+
+
+
+
+};
diff --git a/dev-tools/systray-tester/main.cpp b/dev-tools/systray-tester/main.cpp
new file mode 100644
index 00000000..309ab4cb
--- /dev/null
+++ b/dev-tools/systray-tester/main.cpp
@@ -0,0 +1,26 @@
+#include <QApplication>
+#include <QSystemTrayIcon>
+#include "Trayapp.h"
+
+int main(int argc, char *argv[]) {
+
+ QApplication a(argc, argv);
+
+ bool ready = false;
+ for(int i=0; i<60 && !ready; i++){
+ ready = QSystemTrayIcon::isSystemTrayAvailable();
+ if(!ready){
+ //Pause for 5 seconds
+ sleep(5); //don't worry about stopping event handling - nothing running yet
+ }
+ }
+ if(!ready){
+ qDebug() << "Could not find any available system tray after 5 minutes: exiting....";
+ return 1;
+ }
+
+ TrayApp tray;
+ tray.show();
+ QApplication::setQuitOnLastWindowClosed(false);
+ return a.exec();
+}
diff --git a/dev-tools/systray-tester/systray-tester.pro b/dev-tools/systray-tester/systray-tester.pro
new file mode 100644
index 00000000..b1169ae1
--- /dev/null
+++ b/dev-tools/systray-tester/systray-tester.pro
@@ -0,0 +1,18 @@
+TEMPLATE = app
+LANGUAGE = C++
+QT += core gui widgets
+CONFIG += qt warn_on release
+
+LIBS += -L../../libLumina -L/usr/local/lib -lLuminaUtils
+
+HEADERS += Trayapp.h
+
+SOURCES += main.cpp
+
+INSTALLS =
+
+QMAKE_LIBDIR = /usr/local/lib/qt5
+
+TARGET = test-tray
+
+INCLUDEPATH+= ../../libLumina /usr/local/include
bgstack15