Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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;
120 andreas 45
class TQBusy;
2 andreas 46
QT_END_NAMESPACE
47
 
14 andreas 48
Q_DECLARE_METATYPE(size_t)
49
 
3 andreas 50
int qtmain(int argc, char **argv, TPageManager *pmanager);
2 andreas 51
 
107 andreas 52
class MainWindow : public QMainWindow, TQManageQueue
2 andreas 53
{
14 andreas 54
    Q_OBJECT
2 andreas 55
 
5 andreas 56
    public:
88 andreas 57
        typedef enum J_ORIENTATION
58
        {
59
            O_UNDEFINED = -1,
60
            O_LANDSCAPE = 0,
61
            O_PORTRAIT = 1
62
        }J_ORIENTATION;
63
 
5 andreas 64
        MainWindow();
34 andreas 65
        ~MainWindow();
22 andreas 66
        void setConfigFile(const std::string& file) { mFileConfig = file; }
23 andreas 67
        void setSetChange(bool state) { settingsChanged = state; }
38 andreas 68
        void setScaleFactor(double scale) { mScaleFactor = scale; }
69
        double getScaleFactor() { return mScaleFactor; }
2 andreas 70
 
14 andreas 71
    signals:
72
        void sigDisplayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
98 andreas 73
        void sigSetVisible(ulong handle, bool state);
14 andreas 74
        void sigSetPage(ulong handle, int width, int height);
41 andreas 75
        void sigSetSubPage(ulong handle, int left, int top, int width, int height, ANIMATION_t animate);
38 andreas 76
        void sigSetBackground(ulong handle, QByteArray image, size_t rowBytes, int width, int height, ulong color);
14 andreas 77
        void sigDropPage(ulong handle);
78
        void sigDropSubPage(ulong handle);
98 andreas 79
        void sigDropButton(ulong handle);
21 andreas 80
        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 81
        void sigInputText(Button::TButton * button, QByteArray buffer, int width, int height, size_t pixline);
63 andreas 82
        void sigKeyboard(const std::string& init, const std::string& prompt, bool priv);
83
        void sigKeypad(const std::string& init, const std::string& prompt, bool priv);
84
        void sigResetKeyboard();
64 andreas 85
        void sigShowSetup();
71 andreas 86
        void sigPlaySound(const std::string& file);
111 andreas 87
        void sigSendVirtualKeys(const std::string& str);
14 andreas 88
 
5 andreas 89
    protected:
57 andreas 90
        bool event(QEvent *event) override;
5 andreas 91
        void closeEvent(QCloseEvent *event) override;
10 andreas 92
        void mousePressEvent(QMouseEvent* event) override;
93
        void mouseReleaseEvent(QMouseEvent* event) override;
15 andreas 94
        bool eventFilter(QObject *obj, QEvent *ev) override;
2 andreas 95
 
5 andreas 96
    private slots:
97
        void settings();
98
        void about();
2 andreas 99
#ifndef QT_NO_SESSIONMANAGER
5 andreas 100
        void commitData(QSessionManager &);
2 andreas 101
#endif
14 andreas 102
        void displayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
98 andreas 103
        void SetVisible(ulong handle, bool state);
5 andreas 104
        void setPage(ulong handle, int width, int height);
41 andreas 105
        void setSubPage(ulong hanlde, int left, int top, int width, int height, ANIMATION_t animate);
38 andreas 106
        void setBackground(ulong handle, QByteArray image, size_t rowBytes, int width, int height, ulong color);
11 andreas 107
        void dropPage(ulong handle);
108
        void dropSubPage(ulong handle);
98 andreas 109
        void dropButton(ulong handle);
21 andreas 110
        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 111
        void inputText(Button::TButton *button, QByteArray buffer, int width, int height, size_t pixline);
63 andreas 112
        void showKeyboard(const std::string& init, const std::string& prompt, bool priv);
113
        void showKeypad(const std::string& init, const std::string& prompt, bool priv);
111 andreas 114
        void sendVirtualKeys(const std::string& str);
63 andreas 115
        void resetKeyboard();
64 andreas 116
        void showSetup();
71 andreas 117
        void playSound(const std::string& file);
31 andreas 118
        void appStateChanged(Qt::ApplicationState state);
32 andreas 119
        void arrowLeft();
120
        void arrowRight();
121
        void arrowUp();
122
        void arrowDown();
123
        void selectOk();
33 andreas 124
        void volumeUpPressed();
125
        void volumeUpReleased();
126
        void volumeDownPressed();
127
        void volumeDownReleased();
38 andreas 128
//        void volumeMute();
42 andreas 129
        void animationFinished();
51 andreas 130
        void textChangedMultiLine();
131
        void textSingleLineReturn();
44 andreas 132
 
14 andreas 133
    private:
57 andreas 134
        bool gestureEvent(QGestureEvent *event);
14 andreas 135
        void createActions();
136
        void writeSettings();
31 andreas 137
        void playShowList();
38 andreas 138
        int scale(int value);
139
        bool isScaled() { return (mScaleFactor != 1.0); }
107 andreas 140
        void startAnimation(TObject::OBJECT_t *obj, ANIMATION_t& ani, bool in = true);
120 andreas 141
        void busyIndicator(const std::string& msg, QWidget *parent);
142
        void runEvents();
14 andreas 143
 
144
        void _displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top);
98 andreas 145
        void _setVisible(ulong handle, bool state);
14 andreas 146
        void _setPage(ulong handle, int width, int height);
41 andreas 147
        void _setSubPage(ulong handle, int left, int top, int width, int height, ANIMATION_t animate);
38 andreas 148
        void _setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, int width, int height, ulong color);
14 andreas 149
        void _dropPage(ulong handle);
150
        void _dropSubPage(ulong handle);
98 andreas 151
        void _dropButton(ulong handle);
21 andreas 152
        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 153
        void _inputText(Button::TButton *button, Button::BITMAP_t& bm);
63 andreas 154
        void _showKeyboard(const std::string& init, const std::string& prompt, bool priv=false);
155
        void _showKeypad(const std::string& init, const std::string& prompt, bool priv=false);
156
        void _resetKeyboard();
64 andreas 157
        void _showSetup();
44 andreas 158
        void _resetSurface();
64 andreas 159
        void _shutdown();
71 andreas 160
        void _playSound(const std::string& file);
88 andreas 161
        void _setOrientation(J_ORIENTATION ori);
111 andreas 162
        void _sendVirtualKeys(const std::string& str);
93 andreas 163
#ifdef __ANDROID__
164
        void _signalState(Qt::ApplicationState state);
165
#endif
70 andreas 166
        void doReleaseButton();
167
 
23 andreas 168
        TQtSettings *mSettings{nullptr};    // The pointer to the settings dialog
22 andreas 169
        bool settingsChanged{false};        // true = settings have changed
13 andreas 170
        QWidget *mBackground{nullptr};      // The background of the visible page
88 andreas 171
        QToolBar *mToolbar{nullptr};        // The toolbar, if there is any
21 andreas 172
        std::string mVideoURL;              // If the button is a video, this is the URL where it plays from.
22 andreas 173
        std::string mFileConfig;            // Path and file name of the config file
31 andreas 174
        bool mHasFocus{true};               // If this is FALSE, no output to sceen is allowed.
38 andreas 175
        std::atomic<double> mScaleFactor{1.0}; // The actual scale factor
107 andreas 176
        std::atomic<TObject::OBJECT_t *> mLastObject{nullptr};     // This is for the hide effect of widgets.
120 andreas 177
        std::atomic<bool> mBusy{false};     // If TRUE the busy indicator is active
178
        TQBusy *mBusyDialog{nullptr};       // Pointer to busy indicator dialog window
63 andreas 179
        TQKeyboard *mQKeyboard{nullptr};    // Pointer to an active virtual keyboard
180
        TQKeypad *mQKeypad{nullptr};        // Pointer to an active virtual keypad
120 andreas 181
//        std::thread mThreadBusy;            // The thread of the busy indicator.
65 andreas 182
        bool mKeyboard{false};              // TRUE = keyboard is visible
183
        bool mKeypad{false};                // TRUE = keypad is visible
70 andreas 184
        // Mouse
185
        int mLastPressX{-1};                // Remember the last mouse press X coordinate
186
        int mLastPressY{-1};                // Remember the last mouse press Y coordinate
2 andreas 187
};
188
 
189
#endif