2 |
andreas |
1 |
/*
|
21 |
andreas |
2 |
* Copyright (C) 2020, 2021 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"
|
2 |
andreas |
26 |
#include "terror.h"
|
|
|
27 |
|
21 |
andreas |
28 |
extern bool prg_stopped;
|
|
|
29 |
|
2 |
andreas |
30 |
QT_BEGIN_NAMESPACE
|
|
|
31 |
class QAction;
|
|
|
32 |
class QMenu;
|
|
|
33 |
class QSessionManager;
|
5 |
andreas |
34 |
class QLabel;
|
|
|
35 |
class QWidget;
|
14 |
andreas |
36 |
class QByteArray;
|
10 |
andreas |
37 |
class QMouseEvent;
|
15 |
andreas |
38 |
class QMoveEvent;
|
|
|
39 |
class QEvent;
|
23 |
andreas |
40 |
class TQtSettings;
|
2 |
andreas |
41 |
QT_END_NAMESPACE
|
|
|
42 |
|
14 |
andreas |
43 |
Q_DECLARE_METATYPE(size_t)
|
|
|
44 |
|
3 |
andreas |
45 |
int qtmain(int argc, char **argv, TPageManager *pmanager);
|
2 |
andreas |
46 |
|
5 |
andreas |
47 |
class MainWindow : public QMainWindow, TObject
|
2 |
andreas |
48 |
{
|
14 |
andreas |
49 |
Q_OBJECT
|
2 |
andreas |
50 |
|
5 |
andreas |
51 |
public:
|
|
|
52 |
MainWindow();
|
22 |
andreas |
53 |
void setConfigFile(const std::string& file) { mFileConfig = file; }
|
23 |
andreas |
54 |
void setSetChange(bool state) { settingsChanged = state; }
|
2 |
andreas |
55 |
|
14 |
andreas |
56 |
signals:
|
|
|
57 |
void sigDisplayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
|
|
|
58 |
void sigSetPage(ulong handle, int width, int height);
|
|
|
59 |
void sigSetSubPage(ulong handle, int left, int top, int width, int height);
|
|
|
60 |
void sigSetBackground(ulong handle, QByteArray image, size_t rowBytes, ulong color);
|
|
|
61 |
void sigSetText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww);
|
|
|
62 |
void sigDropPage(ulong handle);
|
|
|
63 |
void sigDropSubPage(ulong handle);
|
21 |
andreas |
64 |
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);
|
14 |
andreas |
65 |
|
5 |
andreas |
66 |
protected:
|
|
|
67 |
void closeEvent(QCloseEvent *event) override;
|
10 |
andreas |
68 |
void mousePressEvent(QMouseEvent* event) override;
|
|
|
69 |
void mouseReleaseEvent(QMouseEvent* event) override;
|
15 |
andreas |
70 |
bool eventFilter(QObject *obj, QEvent *ev) override;
|
2 |
andreas |
71 |
|
5 |
andreas |
72 |
private slots:
|
|
|
73 |
void settings();
|
|
|
74 |
void about();
|
2 |
andreas |
75 |
#ifndef QT_NO_SESSIONMANAGER
|
5 |
andreas |
76 |
void commitData(QSessionManager &);
|
2 |
andreas |
77 |
#endif
|
14 |
andreas |
78 |
void displayButton(ulong handle, ulong parent, QByteArray buffer, int width, int height, int pixline, int left, int top);
|
5 |
andreas |
79 |
void setPage(ulong handle, int width, int height);
|
|
|
80 |
void setSubPage(ulong hanlde, int left, int top, int width, int height);
|
14 |
andreas |
81 |
void setBackground(ulong handle, QByteArray image, size_t rowBytes, ulong color);
|
7 |
andreas |
82 |
void setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww);
|
11 |
andreas |
83 |
void dropPage(ulong handle);
|
|
|
84 |
void dropSubPage(ulong handle);
|
21 |
andreas |
85 |
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);
|
31 |
andreas |
86 |
void appStateChanged(Qt::ApplicationState state);
|
13 |
andreas |
87 |
|
14 |
andreas |
88 |
private:
|
|
|
89 |
void createActions();
|
|
|
90 |
void writeSettings();
|
31 |
andreas |
91 |
void removeFromShowList(ulong handle);
|
|
|
92 |
void playShowList();
|
14 |
andreas |
93 |
|
|
|
94 |
void _displayButton(ulong handle, ulong parent, unsigned char* buffer, int width, int height, int pixline, int left, int top);
|
|
|
95 |
void _setPage(ulong handle, int width, int height);
|
|
|
96 |
void _setSubPage(ulong handle, int left, int top, int width, int height);
|
|
|
97 |
void _setBackground(ulong handle, unsigned char *image, size_t size, size_t rowBytes, ulong color);
|
|
|
98 |
void _setText(ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, Button::TEXT_ORIENTATION ori, Button::TEXT_EFFECT effect, bool ww);
|
|
|
99 |
void _dropPage(ulong handle);
|
|
|
100 |
void _dropSubPage(ulong handle);
|
21 |
andreas |
101 |
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);
|
14 |
andreas |
102 |
|
23 |
andreas |
103 |
TQtSettings *mSettings{nullptr}; // The pointer to the settings dialog
|
22 |
andreas |
104 |
bool settingsChanged{false}; // true = settings have changed
|
13 |
andreas |
105 |
QWidget *mBackground{nullptr}; // The background of the visible page
|
21 |
andreas |
106 |
std::string mVideoURL; // If the button is a video, this is the URL where it plays from.
|
22 |
andreas |
107 |
std::string mFileConfig; // Path and file name of the config file
|
31 |
andreas |
108 |
bool mHasFocus{true}; // If this is FALSE, no output to sceen is allowed.
|
|
|
109 |
std::map<ulong, QWidget *> mToShow; // List of widgets to show after focus is restored
|
2 |
andreas |
110 |
};
|
|
|
111 |
|
|
|
112 |
#endif
|