add timer to run the xlib loop
authorGuillaume Castagnino <guillaume.castagnino@rohde-schwarz.com>
Wed, 11 Mar 2020 16:35:47 +0000 (17:35 +0100)
committerGuillaume Castagnino <guillaume.castagnino@rohde-schwarz.com>
Wed, 11 Mar 2020 16:35:47 +0000 (17:35 +0100)
fookb.cpp
fookb.pro
fookb.qml
fookb.qrc [new file with mode: 0644]
xlib_wrapper.cpp [new file with mode: 0644]
xlib_wrapper.h [new file with mode: 0644]
xlib_wrapper.o [new file with mode: 0644]

index 75e0ade49dc45ebb70f83b9ca5913c681cc9e9cc..982d9d29fd72f6e9a39869ffd558755a1e70af6a 100644 (file)
--- a/fookb.cpp
+++ b/fookb.cpp
@@ -1,5 +1,8 @@
 #include <QApplication>
 #include <QQmlApplicationEngine>
+#include <QDebug>
+
+#include "xlib_wrapper.h"
 
 int main(int argc, char *argv[])
 {
@@ -7,5 +10,8 @@ int main(int argc, char *argv[])
     QApplication app(argc, argv);
     QQmlApplicationEngine engine;
     engine.load(QUrl(QStringLiteral("qrc:/fookb.qml")));
+
+    XlibWrapper xlib;
+
     return app.exec();
 }
index ef96108470640fde63c7fe7166e3003b75ed58ae..e3554f06fa9a93b861e3378a8a29324442915dd7 100644 (file)
--- a/fookb.pro
+++ b/fookb.pro
@@ -1,3 +1,7 @@
-QT += widgets
-SOURCES = fookb.cpp
+SOURCES = fookb.cpp \
+    xlib_wrapper.cpp
+HEADERS = xlib_wrapper.h
 TARGET = fookb
+
+RESOURCES = fookb.qrc
+QT += widgets qml
index 56585bb235443c73a884cc11119633163f352851..f6d7cb49022d9c8cf2d2bc00b3c910b4f0d689b2 100644 (file)
--- a/fookb.qml
+++ b/fookb.qml
@@ -1,3 +1,5 @@
+import Qt.labs.platform 1.1
+
 SystemTrayIcon {
     visible: true
     icon.source: "qrc:/images/fr.png"
diff --git a/fookb.qrc b/fookb.qrc
new file mode 100644 (file)
index 0000000..4ac0952
--- /dev/null
+++ b/fookb.qrc
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+    <file>fookb.qml</file>
+    <file>images/fr.png</file>
+    <file>images/ru.png</file>
+</qresource>
+</RCC>
diff --git a/xlib_wrapper.cpp b/xlib_wrapper.cpp
new file mode 100644 (file)
index 0000000..d940a15
--- /dev/null
@@ -0,0 +1,16 @@
+#include "xlib_wrapper.h"
+#include <QDebug>
+
+XlibWrapper::XlibWrapper()
+{
+    timer = new QTimer(this);
+    timer->setSingleShot(true);
+    connect(timer, SIGNAL(timeout()),
+          this, SLOT(XlibWrapperSlot()));
+    timer->start(1000);
+}
+
+void XlibWrapper::XlibWrapperSlot()
+{
+    qDebug() << "Timer...";
+}
diff --git a/xlib_wrapper.h b/xlib_wrapper.h
new file mode 100644 (file)
index 0000000..8362133
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef XLIB_WRAPPER_H
+#define XLIB_WRAPPER_H
+
+#include <QTimer>
+
+class XlibWrapper : public QObject
+{
+       Q_OBJECT
+public:
+       XlibWrapper();
+       QTimer *timer;
+
+public slots:
+       void XlibWrapperSlot();
+};
+
+#endif // XLIB_WRAPPER_H
diff --git a/xlib_wrapper.o b/xlib_wrapper.o
new file mode 100644 (file)
index 0000000..7bceb50
Binary files /dev/null and b/xlib_wrapper.o differ