swift
Loading...
Searching...
No Matches
dockwidget.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_GUI_DOCKWIDGET_H
7#define SWIFT_GUI_DOCKWIDGET_H
8
9#include <QDockWidget>
10#include <QMargins>
11#include <QObject>
12#include <QPoint>
13#include <QSize>
14#include <QString>
15
20#include "gui/swiftguiexport.h"
21#include "misc/statusmessage.h"
23
24class QCloseEvent;
25class QMenu;
26class QMouseEvent;
27class QPaintEvent;
28class QWidget;
29class QWidgetAction;
30
31namespace swift::gui
32{
33 namespace components
34 {
35 class CMarginsInput;
36 }
37 namespace menus
38 {
39 class CFontMenu;
40 }
41
52 {
54
55 public:
58
60 void setEmptyTitleBar();
61
64
66 const QString &windowTitleBackup() const { return m_windowTitleBackup; }
67
69 QString windowTitleOrBackup() const;
70
72 bool showTitleWhenDocked() const { return m_windowTitleWhenDocked; }
73
75 bool isSelected() const { return m_selected; }
76
79 bool isWidgetVisible() const;
80
82 void allowStatusBar(bool allow) { m_allowStatusBar = allow; }
83
85 void showTitleWhenDocked(bool show);
86
88 void resetWasAlreadyFloating();
89
91 bool wasAlreadyFloating() const { return m_wasAlreadyFloating; }
92
94 void setPreferredSizeWhenFloating(const QSize &size);
95
97 void setOffsetWhenFloating(const QPoint &point, bool frameless);
98
100 void setFrameless(bool frameless) override;
101
103 void toggleFloating();
104
106 void toggleVisibility();
107
109 void toggleFrameless();
110
112 // void toggleFramelessDeferred(int delayMs = 1000);
113
115 void windowAlwaysOnTop();
116
118 void windowNotAlwaysOnTop();
119
121 void setAlwaysOnTop(bool onTop) { m_alwaysOnTop = onTop; }
122
124 bool restoreFromSettings();
125
127 void saveCurrentStateToSettings();
128
130 void resetSettings();
131
133 void resetPosition();
134
136 void setWindowTitle(const QString &title);
137
139 void displayStatusMessage(const swift::misc::CStatusMessage &statusMessage);
140
142 void displayStatusMessages(const swift::misc::CStatusMessageList &statusMessages);
143
145 static const QString &propertyOuterWidget();
146
148 static const QString &propertyInnerWidget();
149
150 signals:
152 void widgetTopLevelChanged(CDockWidget *, bool topLevel);
153
159
160 protected:
162 explicit CDockWidget(QWidget *parent = nullptr);
163
165 CDockWidget(bool allowStatusBar, QWidget *parent = nullptr);
166
168 void setMargins();
169
171 void setMarginsWhenFloating(const QMargins &margins);
172
174 void setMarginsWhenFloating(int left, int top, int right, int bottom);
175
178
180 void setMarginsWhenFramelessFloating(const QMargins &margins);
181
183 void setMarginsWhenFramelessFloating(int left, int top, int right, int bottom);
184
187
189 void setMarginsWhenDocked(const QMargins &margins);
190
192 void setMarginsWhenDocked(int left, int top, int right, int bottom);
193
196
198 void setAlwaysOnTopFlag(bool onTop);
199
201 void closeEvent(QCloseEvent *event) override;
202
204 void paintEvent(QPaintEvent *event) override;
205
207 void mouseMoveEvent(QMouseEvent *event) override;
208
210 void keyPressEvent(QKeyEvent *event) override;
211
213 void mousePressEvent(QMouseEvent *event) override;
214
216 virtual void addToContextMenu(QMenu *contextMenu) const;
217
221 virtual void initialFloating();
222
224 virtual void onStyleSheetsChanged();
225
226 private:
227 QWidget *m_titleBarWidgetEmpty = nullptr;
228 QWidget *m_titleBarWidgetOriginal = nullptr;
229 QWidgetAction *m_marginMenuAction = nullptr;
230 components::CMarginsInput *m_input = nullptr;
231 menus::CFontMenu *m_fontMenu = nullptr;
232 bool m_allowStatusBar = true;
233 bool m_windowTitleWhenDocked = true;
234 bool m_wasAlreadyFloating = false;
235 bool m_selected = false;
236 bool m_dockWidgetVisible = false;
237 bool m_wasFrameless = false;
238 bool m_alwaysOnTop = false;
239 CManagedStatusBar m_statusBar;
240 QString m_windowTitleBackup;
241 QSize m_preferredSizeWhenFloating;
242 QSize m_initialDockedMinimumSize;
243 QSize m_lastFloatingSize;
244 QPoint m_offsetWhenFloating;
245 QPoint m_lastFloatingPosition;
246 Qt::DockWidgetAreas m_originalAreas;
247
248 swift::misc::CSetting<swift::gui::settings::TDockWidget> m_settings { this, &CDockWidget::settingsChanged };
249
251 void onTopLevelChanged(bool topLevel);
252
254 void showContextMenu(const QPoint &pos);
255
257 void onVisibilityChanged(bool visible);
258
260 void menuChangeMargins(const QMargins &margins);
261
263 void settingsChanged();
264
266 void dummy();
267
269 void initTitleBarWidgets();
270
272 void initStatusBarAndProperties();
273
275 void forceStyleSheetUpdate();
276
278 void rememberFloatingSizeAndPosition();
279
281 void restoreFloatingSizeAndPosition();
282
284 void restoreFloatingSizeAndPositionDeferred();
285
287 settings::CDockWidgetSettings getSettings() const;
288
290 void saveSettings(const swift::gui::settings::CDockWidgetSettings &settings);
291 };
292} // namespace swift::gui
293
294#endif // SWIFT_GUI_DOCKWIDGET_H
void closeEvent(QCloseEvent *event)
CDockWidget(QWidget *parent=nullptr)
Constructor.
void setAlwaysOnTop(bool onTop)
Set always on top.
Definition dockwidget.h:121
virtual void addToContextMenu(QMenu *contextMenu) const
Contribute to menu.
void widgetTopLevelChanged(CDockWidget *, bool topLevel)
Top level has changed for given widget.
void mousePressEvent(QMouseEvent *event)
void allowStatusBar(bool allow)
Allow a status bar to be displayed.
Definition dockwidget.h:82
void setMarginsWhenFramelessFloating(const QMargins &margins)
Margins when window is floating (frameless).
void setAlwaysOnTopFlag(bool onTop)
Set the on top flag.
bool wasAlreadyFloating() const
Was widget already floating?
Definition dockwidget.h:91
virtual void onStyleSheetsChanged()
Style sheet has changed.
void paintEvent(QPaintEvent *event)
void setNullTitleBarWidget()
Set null (nullptr) title bar.
QMargins getMarginsWhenDocked() const
Margins when docked.
void setOriginalTitleBar()
Set original title bar.
QMargins getMarginsWhenFramelessFloating() const
Margins when floating and frameless.
void fontSizeMinus()
Font size signals.
void setMargins()
Set margins from settings.
void mouseMoveEvent(QMouseEvent *event)
void setEmptyTitleBar()
Set empty title bar (empty widget as title bar).
bool isSelected() const
Selected when tabbed.
Definition dockwidget.h:75
void fontSizePlus()
Font size signals.
void setMarginsWhenDocked(const QMargins &margins)
Margins when widget is floating.
const QString & windowTitleBackup() const
Window title backup.
Definition dockwidget.h:66
QMargins getMarginsWhenFloating() const
Margins when floating.
void keyPressEvent(QKeyEvent *event)
void setMarginsWhenFloating(const QMargins &margins)
Margins when window is floating.
bool showTitleWhenDocked() const
Window title when window is docked.
Definition dockwidget.h:72
virtual void initialFloating()
Widget is initialized by being a floating window for a shot period.
CEnableForFramelessWindow(WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyname, QWidget *correspondingWidget)
Constructor.
COverlayMessagesDockWidget(QWidget *parent=nullptr)
Constructor.
Widget alows to enter margins.
Standard font (size, style) menus. Can be used as nested menu or via getActions added manually.
Definition fontmenus.h:21
Class template for accessing a specific value in the CSettingsCache.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
High level reusable GUI components.
GUI related classes.
virtual bool event(QEvent *event) override
Q_OBJECTQ_OBJECT
QObject * parent() const const
typedef DockWidgetAreas
QWidget(QWidget *parent, Qt::WindowFlags f)
#define SWIFT_GUI_EXPORT
Export a class or function from the library.