2 |
andreas |
1 |
/*
|
101 |
andreas |
2 |
* Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
|
2 |
andreas |
3 |
*
|
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
#ifndef __TQTMAIN_H__
|
|
|
19 |
#define __TQTMAIN_H__
|
|
|
20 |
|
|
|
21 |
#include <QMainWindow>
|
14 |
andreas |
22 |
#include <QMetaType>
|
2 |
andreas |
23 |
|
3 |
andreas |
24 |
#include "tpagemanager.h"
|
5 |
andreas |
25 |
#include "tobject.h"
|
61 |
andreas |
26 |
#include "tqemitqueue.h"
|
2 |
andreas |
27 |
#include "terror.h"
|
|
|
28 |
|
21 |
andreas |
29 |
extern bool prg_stopped;
|
34 |
andreas |
30 |
extern std::atomic<bool> killed;
|
21 |
andreas |
31 |
|
2 |
andreas |
32 |
QT_BEGIN_NAMESPACE
|
|
|
33 |
class QAction;
|
|
|
34 |
class QMenu;
|
|
|
35 |
class QSessionManager;
|
5 |
andreas |
36 |
class QLabel;
|
|
|
37 |
class QWidget;
|
14 |
andreas |
38 |
class QByteArray;
|
10 |
andreas |
39 |
class QMouseEvent;
|
15 |
andreas |
40 |
class QMoveEvent;
|
|
|
41 |
class QEvent;
|
23 |
andreas |
42 |
class TQtSettings;
|
63 |
andreas |
43 |
class TQKeyboard;
|
|
|
44 |
class TQKeypad;
|
2 |
andreas |
45 |
QT_END_NAMESPACE
|
|
|
46 |
|
14 |
andreas |
47 |
Q_DECLARE_METATYPE(size_t)
|
|
|
48 |
|
3 |
andreas |
49 |
int qtmain(int argc, char **argv, TPageManager *pmanager);
|
2 |
andreas |
50 |
|
107 |
andreas |
51 |
class MainWindow : public QMainWindow, TQManageQueue
|
2 |
andreas |
52 |
{
|
14 |
andreas |
53 |
Q_OBJECT
|
2 |
andreas |
54 |
|
5 |
andreas |
55 |
public:
|
88 |
andreas |
56 |
typedef enum J_ORIENTATION
|
|
|
57 |
{
|
|
|
58 |
O_UNDEFINED = -1,
|
|
|
59 |
O_LANDSCAPE = 0,
|
|
|
60 |
O_PORTRAIT = 1
|
|
|
61 |
}J_ORIENTATION;
|
|
|
62 |
|
5 |
andreas |
63 |
MainWindow();
|
34 |
andreas |
64 |
~MainWindow();
|
22 |
andreas |
65 |
void setConfigFile(const std::string& file) { mFileConfig = file; }
|
23 |
andreas |
66 |
void setSetChange(bool state) { settingsChanged = state; }
|
38 |
andreas |
67 |
void setScaleFactor(double scale) { mScaleFactor = scale; }
|
|
|
68 |
double getScaleFactor() { return mScaleFactor; }
|
2 |
andreas |
69 |
|
14 |
andreas |
70 |
signals:
|
|
|
71 |
void sigDisplayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
|
98 |
andreas |
72 |
void sigSetVisible(ulong handle, bool state);
|
14 |
andreas |
73 |
void sigSetPage(ulong handle, int width, int height);
|
41 |
andreas |
74 |
void sigSetSubPage(ulong handle, int left, int top, int width, int height, ANIMATION_t animate);
|
38 |
andreas |
75 |
void sigSetBackground(ulong handle, QByteArray image, size_t rowBytes, int width, int height, ulong color);
|
14 |
andreas |
76 |
void sigDropPage(ulong handle);
|
|
|
77 |
void sigDropSubPage(ulong handle);
|
98 |
andreas |
78 |
void sigDropButton(ulong handle);
|
21 |
andreas |
79 |
void sigPlayVideo(ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw);
|
52 |
andreas |
80 |
void sigInputText(Button::TButton * button, QByteArray buffer, int width, int height, size_t pixline);
|
63 |
andreas |
81 |
void sigKeyboard(const std::string& init, const std::string& prompt, bool priv);
|
|
|
82 |
void sigKeypad(const std::string& init, const std::string& prompt, bool priv);
|
|
|
83 |
void sigResetKeyboard();
|
64 |
andreas |
84 |
void sigShowSetup();
|
71 |
andreas |
85 |
void sigPlaySound(const std::string& file);
|
111 |
andreas |
86 |
void sigSendVirtualKeys(const std::string& str);
|
14 |
andreas |
87 |
|
5 |
andreas |
88 |
protected:
|
57 |
andreas |
89 |
bool event(QEvent *event) override;
|
5 |
andreas |
90 |
void closeEvent(QCloseEvent *event) override;
|
10 |
andreas |
91 |
void mousePressEvent(QMouseEvent* event) override;
|
|
|
92 |
void mouseReleaseEvent(QMouseEvent* event) override;
|
15 |
andreas |
93 |
bool eventFilter(QObject *obj, QEvent *ev) override;
|
2 |
andreas |
94 |
|
5 |
andreas |
95 |
private slots:
|
|
|
96 |
void settings();
|
|
|
97 |
void about();
|
2 |
andreas |
98 |
#ifndef QT_NO_SESSIONMANAGER
|
5 |
andreas |
99 |
void commitData(QSessionManager &);
|
2 |
andreas |
100 |
#endif
|
14 |
andreas |
101 |
void displayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
|
98 |
andreas |
102 |
void SetVisible(ulong handle, bool state);
|
5 |
andreas |
103 |
void setPage(ulong handle, int width, int height);
|
41 |
andreas |
104 |
void setSubPage(ulong hanlde, int left, int top, int width, int height, ANIMATION_t animate);
|
38 |
andreas |
105 |
void setBackground(ulong handle, QByteArray image, size_t rowBytes, int width, int height, ulong color);
|
11 |
andreas |
106 |
void dropPage(ulong handle);
|
|
|
107 |
void dropSubPage(ulong handle);
|
98 |
andreas |
108 |
void dropButton(ulong handle);
|
21 |
andreas |
109 |
void playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw);
|
52 |
andreas |
110 |
void inputText(Button::TButton *button, QByteArray buffer, int width, int height, size_t pixline);
|
63 |
andreas |
111 |
void showKeyboard(const std::string& init, const std::string& prompt, bool priv);
|
|
|
112 |
void showKeypad(const std::string& init, const std::string& prompt, bool priv);
|
111 |
andreas |
113 |
void sendVirtualKeys(const std::string& str);
|
63 |
andreas |
114 |
void resetKeyboard();
|
64 |
andreas |
115 |
void showSetup();
|
71 |
andreas |
116 |
void playSound(const std::string& file);
|
31 |
andreas |
117 |
void appStateChanged(Qt::ApplicationState state);
|
32 |
andreas |
118 |
void arrowLeft();
|
|
|
119 |
void arrowRight();
|
|
|
120 |
void arrowUp();
|
|
|
121 |
void arrowDown();
|
|
|
122 |
void selectOk();
|
33 |
andreas |
123 |
void volumeUpPressed();
|
|
|
124 |
void volumeUpReleased();
|
|
|
125 |
void volumeDownPressed();
|
|
|
126 |
void volumeDownReleased();
|
38 |
andreas |
127 |
// void volumeMute();
|
42 |
andreas |
128 |
void animationFinished();
|
51 |
andreas |
129 |
void textChangedMultiLine();
|
|
|
130 |
void textSingleLineReturn();
|
44 |
andreas |
131 |
|
14 |
andreas |
132 |
private:
|
57 |
andreas |
133 |
bool gestureEvent(QGestureEvent *event);
|
14 |
andreas |
134 |
void createActions();
|
|
|
135 |
void writeSettings();
|
31 |
andreas |
136 |
void playShowList();
|
38 |
andreas |
137 |
int scale(int value);
|
|
|
138 |
bool isScaled() { return (mScaleFactor != 1.0); }
|
107 |
andreas |
139 |
void startAnimation(TObject::OBJECT_t *obj, ANIMATION_t& ani, bool in = true);
|
14 |
andreas |
140 |
|
|
|
141 |
void _displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top);
|
98 |
andreas |
142 |
void _setVisible(ulong handle, bool state);
|
14 |
andreas |
143 |
void _setPage(ulong handle, int width, int height);
|
41 |
andreas |
144 |
void _setSubPage(ulong handle, int left, int top, int width, int height, ANIMATION_t animate);
|
38 |
andreas |
145 |
void _setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color);
|
14 |
andreas |
146 |
void _dropPage(ulong handle);
|
|
|
147 |
void _dropSubPage(ulong handle);
|
98 |
andreas |
148 |
void _dropButton(ulong handle);
|
21 |
andreas |
149 |
void _playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw);
|
52 |
andreas |
150 |
void _inputText(Button::TButton *button, Button::BITMAP_t& bm);
|
63 |
andreas |
151 |
void _showKeyboard(const std::string& init, const std::string& prompt, bool priv=false);
|
|
|
152 |
void _showKeypad(const std::string& init, const std::string& prompt, bool priv=false);
|
|
|
153 |
void _resetKeyboard();
|
64 |
andreas |
154 |
void _showSetup();
|
44 |
andreas |
155 |
void _resetSurface();
|
64 |
andreas |
156 |
void _shutdown();
|
71 |
andreas |
157 |
void _playSound(const std::string& file);
|
88 |
andreas |
158 |
void _setOrientation(J_ORIENTATION ori);
|
111 |
andreas |
159 |
void _sendVirtualKeys(const std::string& str);
|
93 |
andreas |
160 |
#ifdef __ANDROID__
|
|
|
161 |
void _signalState(Qt::ApplicationState state);
|
|
|
162 |
#endif
|
70 |
andreas |
163 |
void doReleaseButton();
|
|
|
164 |
|
23 |
andreas |
165 |
TQtSettings *mSettings{nullptr}; // The pointer to the settings dialog
|
22 |
andreas |
166 |
bool settingsChanged{false}; // true = settings have changed
|
13 |
andreas |
167 |
QWidget *mBackground{nullptr}; // The background of the visible page
|
88 |
andreas |
168 |
QToolBar *mToolbar{nullptr}; // The toolbar, if there is any
|
21 |
andreas |
169 |
std::string mVideoURL; // If the button is a video, this is the URL where it plays from.
|
22 |
andreas |
170 |
std::string mFileConfig; // Path and file name of the config file
|
31 |
andreas |
171 |
bool mHasFocus{true}; // If this is FALSE, no output to sceen is allowed.
|
38 |
andreas |
172 |
std::atomic<double> mScaleFactor{1.0}; // The actual scale factor
|
107 |
andreas |
173 |
std::atomic<TObject::OBJECT_t *> mLastObject{nullptr}; // This is for the hide effect of widgets.
|
63 |
andreas |
174 |
TQKeyboard *mQKeyboard{nullptr}; // Pointer to an active virtual keyboard
|
|
|
175 |
TQKeypad *mQKeypad{nullptr}; // Pointer to an active virtual keypad
|
65 |
andreas |
176 |
bool mKeyboard{false}; // TRUE = keyboard is visible
|
|
|
177 |
bool mKeypad{false}; // TRUE = keypad is visible
|
70 |
andreas |
178 |
// Mouse
|
|
|
179 |
int mLastPressX{-1}; // Remember the last mouse press X coordinate
|
|
|
180 |
int mLastPressY{-1}; // Remember the last mouse press Y coordinate
|
2 |
andreas |
181 |
};
|
|
|
182 |
|
|
|
183 |
#endif
|