Dashie der otter 1 year ago
parent
commit
b2b60d32e8
Signed by: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
1 1
 build-*/
2
+GNS1000_ui/GNS1000_ui.pro.user

+ 40
- 0
GNS1000_ui/GNS1000_ui.pro View File

@@ -0,0 +1,40 @@
1
+#-------------------------------------------------
2
+#
3
+# Project created by QtCreator 2017-02-10T08:37:08
4
+#
5
+#-------------------------------------------------
6
+
7
+QT       += core gui
8
+
9
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10
+
11
+
12
+
13
+target.files = GNS1000_ui
14
+target.path = /home/pi/GNS1000_ui
15
+INSTALLS = target
16
+
17
+
18
+TARGET = GNS1000_ui
19
+TEMPLATE = app
20
+
21
+# The following define makes your compiler emit warnings if you use
22
+# any feature of Qt which as been marked as deprecated (the exact warnings
23
+# depend on your compiler). Please consult the documentation of the
24
+# deprecated API in order to know how to port your code away from it.
25
+DEFINES += QT_DEPRECATED_WARNINGS
26
+
27
+# You can also make your code fail to compile if you use deprecated APIs.
28
+# In order to do so, uncomment the following line.
29
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
30
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
31
+
32
+
33
+SOURCES += main.cpp\
34
+        mainwindow.cpp \
35
+    workerkeyboard.cpp
36
+
37
+HEADERS  += mainwindow.h \
38
+    workerkeyboard.h
39
+
40
+FORMS    += mainwindow.ui

+ 26
- 0
GNS1000_ui/main.cpp View File

@@ -0,0 +1,26 @@
1
+#include "mainwindow.h"
2
+#include <QApplication>
3
+#include <csignal>
4
+#include <QDebug>
5
+
6
+static void onExit(int sig) {
7
+    qDebug() << "Exiting application, signal:" << sig;
8
+    QCoreApplication::exit(0);
9
+}
10
+
11
+int main(int argc, char *argv[])
12
+{
13
+    QApplication a(argc, argv);
14
+    MainWindow w;
15
+
16
+    signal(SIGINT, &onExit);
17
+    signal(SIGTERM, &onExit);
18
+    signal(SIGQUIT, &onExit);
19
+
20
+    w.show();
21
+
22
+    return a.exec();
23
+}
24
+
25
+
26
+

+ 47
- 0
GNS1000_ui/mainwindow.cpp View File

@@ -0,0 +1,47 @@
1
+#include "mainwindow.h"
2
+#include "ui_mainwindow.h"
3
+
4
+MainWindow::MainWindow(QWidget *parent) :
5
+    QMainWindow(parent),
6
+    ui(new Ui::MainWindow)
7
+{
8
+    ui->setupUi(this);
9
+
10
+    qDebug() << "Starting GNS1000_ui";
11
+
12
+    // Add time statusbar widget
13
+    sbClockLabel = new QLabel(this);
14
+    sbClockLabel->setText("...");
15
+    ui->statusBar->addPermanentWidget(sbClockLabel);
16
+
17
+    // timer for it
18
+    QTimer *timerDate = new QTimer(this);
19
+    connect(timerDate, SIGNAL(timeout()), this, SLOT(onUpdateTime()));
20
+    timerDate->start(1000);
21
+
22
+    // WorkerKeyboard
23
+    qDebug() << "Creating WorkerKeyboard";
24
+    WorkerKeyboard *wk = new WorkerKeyboard;
25
+    wk->moveToThread(&wkThread);
26
+    connect(&wkThread, &QThread::finished, wk, &QObject::deleteLater);
27
+    connect(this, &MainWindow::operate, wk, &WorkerKeyboard::doWorkerKeyboard);
28
+    connect(wk, &WorkerKeyboard::keyPressed, this, &MainWindow::handleKeyPress);
29
+    wkThread.start();
30
+}
31
+
32
+void MainWindow::onUpdateTime() {
33
+    QDateTime time = QDateTime::currentDateTime();
34
+    sbClockLabel->setText(time.time().toString());
35
+}
36
+
37
+void MainWindow::handleKeyPress(const QString &key) {
38
+    qDebug() << "key pressed" << key;
39
+    (void)key;
40
+}
41
+
42
+MainWindow::~MainWindow()
43
+{
44
+    delete ui;
45
+    wkThread.quit();
46
+    wkThread.wait();
47
+}

+ 38
- 0
GNS1000_ui/mainwindow.h View File

@@ -0,0 +1,38 @@
1
+#ifndef MAINWINDOW_H
2
+#define MAINWINDOW_H
3
+
4
+#include <QMainWindow>
5
+#include <QLabel>
6
+#include <QTimer>
7
+#include <QDateTime>
8
+#include <QThread>
9
+#include "workerkeyboard.h"
10
+
11
+namespace Ui {
12
+class MainWindow;
13
+}
14
+
15
+class MainWindow : public QMainWindow
16
+{
17
+    Q_OBJECT
18
+    QThread wkThread;
19
+
20
+public:
21
+    explicit MainWindow(QWidget *parent = 0);
22
+    ~MainWindow();
23
+
24
+private:
25
+    Ui::MainWindow *ui;
26
+    QLabel         *sbClockLabel;
27
+
28
+private slots:
29
+    void onUpdateTime();
30
+
31
+public slots:
32
+    void handleKeyPress(const QString &);
33
+
34
+signals:
35
+    void operate(const QString &);
36
+};
37
+
38
+#endif // MAINWINDOW_H

+ 104
- 0
GNS1000_ui/mainwindow.ui View File

@@ -0,0 +1,104 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<ui version="4.0">
3
+ <class>MainWindow</class>
4
+ <widget class="QMainWindow" name="MainWindow">
5
+  <property name="geometry">
6
+   <rect>
7
+    <x>0</x>
8
+    <y>0</y>
9
+    <width>385</width>
10
+    <height>305</height>
11
+   </rect>
12
+  </property>
13
+  <property name="sizePolicy">
14
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
15
+    <horstretch>0</horstretch>
16
+    <verstretch>0</verstretch>
17
+   </sizepolicy>
18
+  </property>
19
+  <property name="cursor">
20
+   <cursorShape>BlankCursor</cursorShape>
21
+  </property>
22
+  <property name="windowTitle">
23
+   <string>MainWindow</string>
24
+  </property>
25
+  <property name="autoFillBackground">
26
+   <bool>false</bool>
27
+  </property>
28
+  <widget class="QWidget" name="centralWidget"/>
29
+  <widget class="QMenuBar" name="menuBar">
30
+   <property name="geometry">
31
+    <rect>
32
+     <x>0</x>
33
+     <y>0</y>
34
+     <width>385</width>
35
+     <height>23</height>
36
+    </rect>
37
+   </property>
38
+   <property name="font">
39
+    <font>
40
+     <pointsize>11</pointsize>
41
+    </font>
42
+   </property>
43
+   <property name="defaultUp">
44
+    <bool>false</bool>
45
+   </property>
46
+   <widget class="QMenu" name="menuAbout">
47
+    <property name="title">
48
+     <string>About</string>
49
+    </property>
50
+    <addaction name="actionGNS_1000"/>
51
+   </widget>
52
+   <widget class="QMenu" name="menuNAV">
53
+    <property name="title">
54
+     <string>NAV</string>
55
+    </property>
56
+   </widget>
57
+   <widget class="QMenu" name="menuPLAN">
58
+    <property name="title">
59
+     <string>PLAN</string>
60
+    </property>
61
+   </widget>
62
+   <widget class="QMenu" name="menuFPL">
63
+    <property name="title">
64
+     <string>FPL</string>
65
+    </property>
66
+   </widget>
67
+   <widget class="QMenu" name="menuAPCH">
68
+    <property name="title">
69
+     <string>APCH</string>
70
+    </property>
71
+   </widget>
72
+   <widget class="QMenu" name="menuTUNE">
73
+    <property name="title">
74
+     <string>TUNE</string>
75
+    </property>
76
+   </widget>
77
+   <widget class="QMenu" name="menuMSG">
78
+    <property name="title">
79
+     <string>MSG</string>
80
+    </property>
81
+   </widget>
82
+   <addaction name="menuAbout"/>
83
+   <addaction name="menuNAV"/>
84
+   <addaction name="menuPLAN"/>
85
+   <addaction name="menuFPL"/>
86
+   <addaction name="menuAPCH"/>
87
+   <addaction name="menuTUNE"/>
88
+   <addaction name="menuMSG"/>
89
+  </widget>
90
+  <widget class="QStatusBar" name="statusBar">
91
+   <property name="sizeGripEnabled">
92
+    <bool>false</bool>
93
+   </property>
94
+  </widget>
95
+  <action name="actionGNS_1000">
96
+   <property name="text">
97
+    <string>GNS-1000</string>
98
+   </property>
99
+  </action>
100
+ </widget>
101
+ <layoutdefault spacing="6" margin="11"/>
102
+ <resources/>
103
+ <connections/>
104
+</ui>

+ 6
- 0
GNS1000_ui/workerkeyboard.cpp View File

@@ -0,0 +1,6 @@
1
+#include "workerkeyboard.h"
2
+
3
+void WorkerKeyboard::doWorkerKeyboard() {
4
+    qDebug() << "Started WorkerKeyboard";
5
+    emit keyPressed("test");
6
+}

+ 18
- 0
GNS1000_ui/workerkeyboard.h View File

@@ -0,0 +1,18 @@
1
+#ifndef WORKERKEYBOARD_H
2
+#define WORKERKEYBOARD_H
3
+
4
+#include <QObject>
5
+#include <QDebug>
6
+
7
+class WorkerKeyboard : public QObject
8
+{
9
+    Q_OBJECT
10
+public slots:
11
+    void doWorkerKeyboard();
12
+
13
+signals:
14
+    void keyPressed(const QString &result);
15
+
16
+};
17
+
18
+#endif // WORKERKEYBOARD_H