swift
Loading...
Searching...
No Matches
infoarea.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_INFOAREA_H
7#define SWIFT_GUI_INFOAREA_H
8
9#include <QDockWidget>
10#include <QList>
11#include <QMainWindow>
12#include <QObject>
13#include <QSize>
14#include <QString>
15#include <QTabWidget>
16#include <Qt>
17
19#include "gui/swiftguiexport.h"
20#include "misc/statusmessage.h"
22
23class QAction;
24class QCloseEvent;
25class QKeyEvent;
26class QMenu;
27class QPaintEvent;
28class QPixmap;
29class QPoint;
30class QTabBar;
31class QWidget;
32
33namespace swift::gui
34{
35 class CDockWidget;
37
41 {
43
44 public:
46 ~CInfoArea() override = default;
47
49 void addToContextMenu(QMenu *menu) const;
50
52 bool isFloating() const { return m_infoAreaFloating; }
53
55 bool isSelectedDockWidgetInfoArea(const CDockWidgetInfoArea *infoArea) const;
56
58 const CDockWidgetInfoArea *getSelectedDockInfoArea() const;
59
61 int getSelectedDockInfoAreaIndex() const;
62
64 QList<const CDockWidgetInfoArea *> getDockWidgetInfoAreas() const;
65
70 QList<QAction *> getInfoAreaSelectActions(bool withShortcut, QWidget *parent) const;
71
75 QList<QAction *> getInfoAreaToggleFloatingActions(QWidget *parent) const;
76
80 QList<QAction *> getInfoAreaRestoreActions(QWidget *parent) const;
81
85 QList<QAction *> getInfoAreaResetPositionActions(QWidget *parent) const;
86
88 QList<int> getAreaIndexesDockedOrFloating(bool floating) const;
89
91 void dockAllWidgets();
92
94 void adjustSizeForAllDockWidgets();
95
97 void floatAllWidgets();
98
100 void allFloatingOnTop();
101
103 void resetAllFloatingWidgetSettings();
104
106 void resetAllWidgetSettings();
107
109 virtual void toggleFloatingWholeInfoArea();
110
112 void toggleFloatingByIndex(int areaIndex);
113
115 void toggleVisibility(int areaIndex);
116
118 void selectArea(int areaIndex);
119
121 void resetPosition(int areaIndex);
122
124 void selectArea(const CDockWidgetInfoArea *dockWidgetInfoArea);
125
127 void selectAreaByAction();
128
130 void resetPositionByAction();
131
133 void toggleAreaFloatingByAction();
134
136 void restoreDockWidgetInfoArea();
137
139 void restoreDockWidgetInfoAreaByIndex(int areaIndex);
140
142 void selectLeftTab();
143
145 void selectRightTab();
146
148 void displayStatusMessage(const swift::misc::CStatusMessage &statusMessage);
149
151 void displayStatusMessages(const swift::misc::CStatusMessageList &statusMessages);
152
153 signals:
156
158 void changedInfoAreaStatus(int currentTabIndex, QList<int> dockedAreas, QList<int> floatingAreas);
159
161 void changedWholeInfoAreaFloating(bool floating);
162
163 protected:
165 explicit CInfoArea(QWidget *parent = nullptr);
166
168 void closeEvent(QCloseEvent *event) override;
169
171 void paintEvent(QPaintEvent *event) override;
172
175 void keyPressEvent(QKeyEvent *event) override;
176
178 virtual QSize getPreferredSizeWhenFloating(int areaIndex) const = 0;
179
181 virtual const QPixmap &indexToPixmap(int areaIndex) const = 0;
182
184 void initInfoArea();
185
189
191 void toggleTabBarLocked(bool locked);
192
193 private:
194 QList<CDockWidgetInfoArea *> m_dockWidgetInfoAreas;
195 QList<CInfoArea *> m_childInfoAreas;
196 QTabBar *m_tabBar = nullptr;
197 bool m_showTabTexts = true;
198 bool m_infoAreaFloating = false;
199 bool m_showTabBar = true;
200 bool m_lockTabBar = false;
201
203 void toggleTabBarPosition();
204
206 void tabifyAllWidgets();
207
209 void unTabifyAllWidgets();
210
212 bool isValidAreaIndex(int areaIndex) const;
213
215 int getAreaIndexByWindowTitle(const QString &title) const;
216
218 int getTabBarIndexByTitle(const QString &title) const;
219
221 CDockWidgetInfoArea *getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) const;
222
224 CDockWidgetInfoArea *getDockWidgetInfoAreaByWindowTitle(const QString &title) const;
225
227 int dockWidgetInfoAreaToTabBarIndex(const CDockWidgetInfoArea *dockWidgetInfoArea) const;
228
230 void setFeaturesForDockableWidgets(QDockWidget::DockWidgetFeatures features);
231
233 int countDockedWidgetInfoAreas() const;
234
236 void setTabPixmaps();
237
239 void connectTopLevelChanged();
240
242 void onTabBarDoubleClicked(int tabBarIndex);
243
245 void onWidgetTopLevelChanged(CDockWidget *dockWidget, bool topLevel);
246
248 void onStyleSheetChanged();
249
251 void showContextMenu(const QPoint &pos);
252
254 void showTabTexts(bool show);
255
257 void showTabBar(bool show);
258
260 void setDockArea(Qt::DockWidgetArea area);
261
263 void setWholeInfoAreaFloating(bool floating);
264
266 void emitInfoAreaStatus();
267
269 void onTabBarIndexChanged(int tabBarIndex);
270
274 QList<CInfoArea *> findOwnChildInfoAreas() const;
275
278 QList<CDockWidgetInfoArea *> findOwnDockWidgetInfoAreas() const;
279 };
280} // namespace swift::gui
281
282#endif // SWIFT_GUI_INFOAREA_H
Our base class for dockable widgets containing some specialized functionality on top of QDockWidget.
Definition dockwidget.h:52
Specialized class for dock widgets serving as info area.
CEnableForFramelessWindow(WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyname, QWidget *correspondingWidget)
Constructor.
~CInfoArea()=default
Destructor.
CInfoArea(QWidget *parent=nullptr)
Constructor.
Definition infoarea.cpp:38
void changedInfoAreaStatus(int currentTabIndex, QList< int > dockedAreas, QList< int > floatingAreas)
Status of info area changed.
void addToContextMenu(QMenu *menu) const
Add items to context menu.
Definition infoarea.cpp:87
void closeEvent(QCloseEvent *event)
void setTabBarPosition(QTabWidget::TabPosition position)
Tab position for docked widgets tab.
void paintEvent(QPaintEvent *event)
Definition infoarea.cpp:345
void initInfoArea()
Init area after(!) GUI is initialized.
Definition infoarea.cpp:45
void toggleTabBarLocked(bool locked)
Toogle lock tabbar.
void changedInfoAreaTabBarIndex(int index)
Tab bar changed.
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const =0
Preferred size when floating (size hint).
void changedWholeInfoAreaFloating(bool floating)
Whole info area floating.
bool isFloating() const
Is the area floating?
Definition infoarea.h:52
virtual const QPixmap & indexToPixmap(int areaIndex) const =0
Info area (index) to icon.
void keyPressEvent(QKeyEvent *event)
Definition infoarea.cpp:351
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
GUI related classes.
typedef DockWidgetFeatures
QMainWindow(QWidget *parent, Qt::WindowFlags flags)
virtual bool event(QEvent *event) override
Q_OBJECTQ_OBJECT
QObject * parent() const const
DockWidgetArea
QWidget(QWidget *parent, Qt::WindowFlags f)
void show()
#define SWIFT_GUI_EXPORT
Export a class or function from the library.