1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4//
5// W A R N I N G
6// -------------
7//
8// This file is not part of the Qt API. It exists for the convenience
9// of Qt Designer. This header file may change from version to version
10// without notice, or even be removed.
11//
12// We mean it.
13//
14
15#ifndef SKIN_H
16#define SKIN_H
17
18#include <QtWidgets/QWidget>
19
20#include <QtGui/QPixmap>
21#include <QtGui/QPolygon>
22#include <QtGui/QRegion>
23
24#include <QtCore/QList>
25
26QT_BEGIN_NAMESPACE
27
28namespace qvfb_internal {
29 class CursorWindow;
30}
31
32class QTextStream;
33
34// ------- Button Area
35struct DeviceSkinButtonArea {
36 QString name;
37 int keyCode{0};
38 QPolygon area;
39 QString text;
40 bool activeWhenClosed{false};
41 bool toggleArea{false};
42 bool toggleActiveArea{false};
43};
44
45// -------- Parameters
46struct DeviceSkinParameters {
47 enum ReadMode { ReadAll, ReadSizeOnly };
48 bool read(const QString &skinDirectory, ReadMode rm, QString *errorMessage);
49 bool read(QTextStream &ts, ReadMode rm, QString *errorMessage);
50
51 QSize screenSize() const { return screenRect.size(); }
52 QSize secondaryScreenSize() const;
53 bool hasSecondaryScreen() const;
54
55 QString skinImageUpFileName;
56 QString skinImageDownFileName;
57 QString skinImageClosedFileName;
58 QString skinCursorFileName;
59
60 QImage skinImageUp;
61 QImage skinImageDown;
62 QImage skinImageClosed;
63 QImage skinCursor;
64
65 QRect screenRect;
66 QRect backScreenRect;
67 QRect closedScreenRect;
68 int screenDepth;
69 QPoint cursorHot;
70 QList<DeviceSkinButtonArea> buttonAreas;
71 QList<int> toggleAreaList;
72
73 int joystick;
74 QString prefix;
75 bool hasMouseHover;
76};
77
78// --------- Skin Widget
79class DeviceSkin : public QWidget
80{
81 Q_OBJECT
82public:
83 explicit DeviceSkin(const DeviceSkinParameters &parameters, QWidget *p );
84 ~DeviceSkin( );
85
86 QWidget *view() const { return m_view; }
87 void setView( QWidget *v );
88
89 QWidget *secondaryView() const { return m_secondaryView; }
90 void setSecondaryView( QWidget *v );
91
92 void setZoom( double );
93 void setTransform(const QTransform &);
94
95 bool hasCursor() const;
96
97 QString prefix() const {return m_parameters.prefix;}
98
99signals:
100 void popupMenu();
101 void skinKeyPressEvent(int code, const QString& text, bool autorep);
102 void skinKeyReleaseEvent(int code, const QString& text, bool autorep);
103
104protected slots:
105 void skinKeyRepeat();
106 void moveParent();
107
108protected:
109 void paintEvent(QPaintEvent *) override;
110 void mousePressEvent(QMouseEvent *e) override;
111 void mouseMoveEvent(QMouseEvent *e) override;
112 void mouseReleaseEvent(QMouseEvent *) override;
113
114private:
115 void calcRegions();
116 void flip(bool open);
117 void updateSecondaryScreen();
118 void loadImages();
119 void startPress(int);
120 void endPress();
121
122 const DeviceSkinParameters m_parameters;
123 QList<QRegion> buttonRegions;
124 QPixmap skinImageUp;
125 QPixmap skinImageDown;
126 QPixmap skinImageClosed;
127 QPixmap skinCursor;
128 QWidget *parent;
129 QWidget *m_view = nullptr;
130 QWidget *m_secondaryView = nullptr;
131 QPoint parentpos;
132 QPoint clickPos;
133 bool buttonPressed = false;
134 int buttonIndex = 0;
135 QTransform transform;
136 qvfb_internal::CursorWindow *cursorw = nullptr;
137
138 bool joydown = false;
139 QTimer *t_skinkey;
140 QTimer *t_parentmove;
141 int onjoyrelease = 0;
142
143 bool flipped_open = true;
144};
145
146QT_END_NAMESPACE
147
148#endif
149

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qttools/src/shared/deviceskin/deviceskin_p.h