Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
5 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
 
19
#ifndef __TOBJECT_H__
20
#define __TOBJECT_H__
21
 
22
#include <string>
23
#include <QtGlobal>
51 andreas 24
#include <QtWidgets>
42 andreas 25
#include "tsubpage.h"
26
 
5 andreas 27
QT_BEGIN_NAMESPACE
28
class QLabel;
29
class QWidget;
51 andreas 30
class QTextEdit;
31
class QLineEdit;
21 andreas 32
class QMediaPlayer;
33
class QVideoWidget;
41 andreas 34
class QPropertyAnimation;
5 andreas 35
QT_END_NAMESPACE
36
 
37
class TObject
38
{
39
    public:
40
        typedef enum OBJECT_TYPE
41
        {
42
            OBJ_NONE,
43
            OBJ_PAGE,
44
            OBJ_SUBPAGE,
45
            OBJ_BUTTON,
46
            OBJ_TEXT,
21 andreas 47
            OBJ_INPUT,
48
            OBJ_VIDEO
5 andreas 49
        }OBJECT_TYPE;
50
 
51
        typedef union _OBJ
52
        {
21 andreas 53
            QVideoWidget *vwidget{nullptr}; // A video window
54
            QLabel *label;                  // For buttons
55
            QWidget *widget;                // For subpage
51 andreas 56
            QTextEdit *multitext;           // For multiple text lines with input
57
            QLineEdit *linetext;            // For single input lines
5 andreas 58
        }_OBJ;
59
 
60
        typedef struct OBJECT_t
61
        {
62
            OBJECT_TYPE type{OBJ_NONE};
63
            ulong handle{0};
64
            _OBJ object;
21 andreas 65
            QMediaPlayer *player{nullptr};  // Pointer to video player if this is a video button
5 andreas 66
            int left{0};
67
            int top{0};
68
            int width{0};
69
            int height{0};
41 andreas 70
            QPropertyAnimation *animation{nullptr};
42 andreas 71
            ANIMATION_t animate;
107 andreas 72
            bool aniDirection{false};
51 andreas 73
            WId wid{0};                     // Used to identify a QTextEdit or QLineEdit
107 andreas 74
            std::atomic<bool> remove{false};// Object is marked for remove. Used with animation.
5 andreas 75
            OBJECT_t *next{nullptr};
76
        }OBJECT_t;
77
 
78
        TObject();
79
        ~TObject();
80
 
89 andreas 81
        void clear(bool force=false);
5 andreas 82
        OBJECT_t *addObject();
83
        OBJECT_t *findObject(ulong handle);
51 andreas 84
        OBJECT_t *findObject(WId id);
11 andreas 85
        OBJECT_t *findFirstChild(ulong handle);
86
        OBJECT_t *findNextChild(ulong handle);
42 andreas 87
        OBJECT_t *getMarkedRemove();
88
        OBJECT_t *getNextMarkedRemove(OBJECT_t *obj);
107 andreas 89
        void cleanMarked();
11 andreas 90
        void removeAllChilds(ulong handle);
5 andreas 91
        void removeObject(ulong handle);
92
 
93
        static std::string handleToString(ulong handle)
94
        {
95
            ulong part1 = (handle >> 16) & 0x0000ffff;
96
            ulong part2 = handle & 0x0000ffff;
97
            return std::to_string(part1)+":"+std::to_string(part2);
98
        }
99
 
14 andreas 100
        static std::string objectToString(OBJECT_TYPE o);
101
        void dropContent(OBJECT_t *obj);
102
 
5 andreas 103
    private:
104
        OBJECT_t *mObject{nullptr};
105
};
106
 
107
#endif