1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDQTSHELLCHROME_H
5#define QWAYLANDQTSHELLCHROME_H
6
7#include <QtQuick/qquickitem.h>
8#include <QtWaylandCompositor/qwaylandquickshellsurfaceitem.h>
9
10QT_BEGIN_NAMESPACE
11
12class QWaylandQtShellChromePrivate;
13class Q_WAYLANDCOMPOSITOR_EXPORT QWaylandQtShellChrome : public QQuickItem
14{
15 Q_OBJECT
16 QML_NAMED_ELEMENT(QtShellChrome)
17 QML_ADDED_IN_VERSION(1, 0)
18 Q_DECLARE_PRIVATE(QWaylandQtShellChrome)
19 Q_PROPERTY(bool hasDecorations READ hasDecorations NOTIFY windowMetaInfoChanged)
20 Q_PROPERTY(uint windowState READ currentWindowState NOTIFY currentWindowStateChanged)
21 Q_PROPERTY(uint windowFlags READ currentWindowFlags NOTIFY currentWindowFlagsChanged)
22 Q_PROPERTY(QWaylandQuickShellSurfaceItem *shellSurfaceItem READ shellSurfaceItem WRITE setShellSurfaceItem NOTIFY shellSurfaceItemChanged)
23 Q_PROPERTY(QRect maximizedRect READ maximizedRect WRITE setMaximizedRect NOTIFY maximizedRectChanged)
24
25 Q_PROPERTY(int frameMarginLeft READ frameMarginLeft WRITE setFrameMarginLeft NOTIFY frameMarginChanged)
26 Q_PROPERTY(int frameMarginRight READ frameMarginRight WRITE setFrameMarginRight NOTIFY frameMarginChanged)
27 Q_PROPERTY(int frameMarginTop READ frameMarginTop WRITE setFrameMarginTop NOTIFY frameMarginChanged)
28 Q_PROPERTY(int frameMarginBottom READ frameMarginBottom WRITE setFrameMarginBottom NOTIFY frameMarginChanged)
29
30 Q_PROPERTY(QQuickItem *titleBar READ titleBar WRITE setTitleBar NOTIFY titleBarChanged);
31 Q_PROPERTY(QQuickItem *leftResizeHandle READ leftResizeHandle WRITE setLeftResizeHandle NOTIFY leftResizeHandleChanged);
32 Q_PROPERTY(QQuickItem *rightResizeHandle READ rightResizeHandle WRITE setRightResizeHandle NOTIFY rightResizeHandleChanged);
33 Q_PROPERTY(QQuickItem *topResizeHandle READ topResizeHandle WRITE setTopResizeHandle NOTIFY topResizeHandleChanged);
34 Q_PROPERTY(QQuickItem *bottomResizeHandle READ bottomResizeHandle WRITE setBottomResizeHandle NOTIFY bottomResizeHandleChanged);
35 Q_PROPERTY(QQuickItem *topLeftResizeHandle READ topLeftResizeHandle WRITE setTopLeftResizeHandle NOTIFY topLeftResizeHandleChanged);
36 Q_PROPERTY(QQuickItem *topRightResizeHandle READ topRightResizeHandle WRITE setTopRightResizeHandle NOTIFY topRightResizeHandleChanged);
37 Q_PROPERTY(QQuickItem *bottomLeftResizeHandle READ bottomLeftResizeHandle WRITE setBottomLeftResizeHandle NOTIFY bottomLeftResizeHandleChanged);
38 Q_PROPERTY(QQuickItem *bottomRightResizeHandle READ bottomRightResizeHandle WRITE setBottomRightResizeHandle NOTIFY bottomRightResizeHandleChanged);
39public:
40 QWaylandQtShellChrome(QQuickItem *parent = nullptr);
41 ~QWaylandQtShellChrome() override;
42
43 bool hasTitleBar() const;
44 bool hasDecorations() const;
45 uint currentWindowState() const;
46 uint currentWindowFlags() const;
47
48 void setMaximizedRect(const QRect &rect);
49 QRect maximizedRect() const;
50
51 void setShellSurfaceItem(QWaylandQuickShellSurfaceItem *shellSurfaceItem);
52 QWaylandQuickShellSurfaceItem *shellSurfaceItem() const;
53
54 void setTitleBar(QQuickItem *item);
55 QQuickItem *titleBar() const;
56
57 void setLeftResizeHandle(QQuickItem *item);
58 QQuickItem *leftResizeHandle() const;
59
60 void setRightResizeHandle(QQuickItem *item);
61 QQuickItem *rightResizeHandle() const;
62
63 void setTopResizeHandle(QQuickItem *item);
64 QQuickItem *topResizeHandle() const;
65
66 void setBottomResizeHandle(QQuickItem *item);
67 QQuickItem *bottomResizeHandle() const;
68
69 void setTopLeftResizeHandle(QQuickItem *item);
70 QQuickItem *topLeftResizeHandle() const;
71
72 void setBottomLeftResizeHandle(QQuickItem *item);
73 QQuickItem *bottomLeftResizeHandle() const;
74
75 void setTopRightResizeHandle(QQuickItem *item);
76 QQuickItem *topRightResizeHandle() const;
77
78 void setBottomRightResizeHandle(QQuickItem *item);
79 QQuickItem *bottomRightResizeHandle() const;
80
81 int frameMarginLeft() const;
82 void setFrameMarginLeft(int left);
83
84 int frameMarginRight() const;
85 void setFrameMarginRight(int right);
86
87 int frameMarginTop() const;
88 void setFrameMarginTop(int top);
89
90 int frameMarginBottom() const;
91 void setFrameMarginBottom(int bottom);
92
93Q_SIGNALS:
94 void currentWindowStateChanged();
95 void currentWindowFlagsChanged();
96 void windowMetaInfoChanged();
97 void shellSurfaceItemChanged();
98 void maximizedRectChanged();
99
100 void titleBarChanged();
101 void leftResizeHandleChanged();
102 void rightResizeHandleChanged();
103 void topResizeHandleChanged();
104 void bottomResizeHandleChanged();
105 void topLeftResizeHandleChanged();
106 void bottomLeftResizeHandleChanged();
107 void topRightResizeHandleChanged();
108 void bottomRightResizeHandleChanged();
109
110 void activated();
111 void deactivated();
112
113 void clientDestroyed();
114 void frameMarginChanged();
115
116public Q_SLOTS:
117 void raise();
118 void lower();
119 void toggleMaximized();
120 void toggleMinimized();
121 void toggleFullScreen();
122 void activate();
123 void deactivate();
124
125private Q_SLOTS:
126 void activateOnGrab(QPointingDevice::GrabTransition transition);
127 void updateSurface();
128 void updateShellSurface();
129 void updateWindowFlags();
130 void updateWindowState();
131 void updateGeometry();
132 void updateDecorations();
133 void updateActiveState();
134 void updateAutomaticPosition();
135 void stopGrab();
136 void leftResize();
137 void rightResize();
138 void topResize();
139 void bottomResize();
140 void topLeftResize();
141 void topRightResize();
142 void bottomLeftResize();
143 void bottomRightResize();
144 void titleBarMove();
145
146protected:
147 QWaylandQtShellChrome(QWaylandQtShellChromePrivate &dd, QQuickItem *parent);
148
149private:
150 void setWindowState(uint nextState);
151 void init();
152 QRect maxContentRect() const;
153};
154
155QT_END_NAMESPACE
156
157#endif // QWAYLANDQTSHELLSURFACEITEM_H
158

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtwayland/src/imports/compositor-extensions/qtshell/qwaylandqtshellchrome.h