DockManager.h
Go to the documentation of this file.
1 #ifndef DockManagerH
2 #define DockManagerH
3 /*******************************************************************************
4 ** Qt Advanced Docking System
5 ** Copyright (C) 2017 Uwe Kindler
6 **
7 ** This library is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU Lesser General Public
9 ** License as published by the Free Software Foundation; either
10 ** version 2.1 of the License, or (at your option) any later version.
11 **
12 ** This library is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ** Lesser General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with this library; If not, see <http://www.gnu.org/licenses/>.
19 ******************************************************************************/
20 
21 
22 //============================================================================
27 //============================================================================
28 
29 
30 //============================================================================
31 // INCLUDES
32 //============================================================================
33 #include "ads_globals.h"
34 #include "DockContainerWidget.h"
35 #include "DockWidget.h"
36 #include "FloatingDockContainer.h"
37 
38 
39 QT_FORWARD_DECLARE_CLASS(QSettings)
40 QT_FORWARD_DECLARE_CLASS(QMenu)
41 
42 namespace ads
43 {
44 struct DockManagerPrivate;
45 class CFloatingDockContainer;
46 struct FloatingDockContainerPrivate;
47 class CDockContainerWidget;
48 class DockContainerWidgetPrivate;
49 class CDockOverlay;
50 class CDockAreaTabBar;
51 class CDockWidgetTab;
52 struct DockWidgetTabPrivate;
53 struct DockAreaWidgetPrivate;
54 class CIconProvider;
55 class CDockComponentsFactory;
56 
70 {
71  Q_OBJECT
72 private:
74  friend struct DockManagerPrivate;
75  friend class CFloatingDockContainer;
77  friend class CDockContainerWidget;
79  friend class CDockAreaTabBar;
80  friend class CDockWidgetTab;
81  friend struct DockAreaWidgetPrivate;
82  friend struct DockWidgetTabPrivate;
83  friend class CFloatingDragPreview;
85  friend class CDockAreaTitleBar;
86 
87 
88 protected:
93  void registerFloatingWidget(CFloatingDockContainer* FloatingWidget);
94 
99  void removeFloatingWidget(CFloatingDockContainer* FloatingWidget);
100 
104  void registerDockContainer(CDockContainerWidget* DockContainer);
105 
110  void removeDockContainer(CDockContainerWidget* DockContainer);
111 
115  CDockOverlay* containerOverlay() const;
116 
120  CDockOverlay* dockAreaOverlay() const;
121 
122 
127  void notifyWidgetOrAreaRelocation(QWidget* RelocatedWidget);
128 
135  void notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);
136 
137 
141  virtual void showEvent(QShowEvent *event) override;
142 
143 public:
145 
147  {
149  MenuAlphabeticallySorted
150  };
151 
158  {
159  ActiveTabHasCloseButton = 0x0001,
160  DockAreaHasCloseButton = 0x0002,
161  DockAreaCloseButtonClosesTab = 0x0004,
162  OpaqueSplitterResize = 0x0008,
163  XmlAutoFormattingEnabled = 0x0010,
164  XmlCompressionEnabled = 0x0020,
165  TabCloseButtonIsToolButton = 0x0040,
166  AllTabsHaveCloseButton = 0x0080,
167  RetainTabSizeWhenCloseButtonHidden = 0x0100,
168  OpaqueUndocking = 0x0200,
169  DragPreviewIsDynamic = 0x0400,
170  DragPreviewShowsContentPixmap = 0x0800,
171  DragPreviewHasWindowFrame = 0x1000,
172  AlwaysShowTabs = 0x2000,
173  DockAreaHasUndockButton = 0x4000,
174  DockAreaHasTabsMenuButton = 0x8000,
175  DockAreaHideDisabledButtons = 0x10000,
176  DockAreaDynamicTabsMenuButtonVisibility = 0x20000,
177  FloatingContainerHasWidgetTitle = 0x40000,
178  FloatingContainerHasWidgetIcon = 0x80000,
179  HideSingleCentralWidgetTitleBar = 0x100000,
180 
182  FocusHighlighting = 0x200000,
183  EqualSplitOnInsertion = 0x400000,
184 
185  FloatingContainerForceNativeTitleBar = 0x800000,
186  FloatingContainerForceQWidgetTitleBar = 0x1000000,
189 
192  DefaultDockAreaButtons = DockAreaHasCloseButton
193  | DockAreaHasUndockButton
194  | DockAreaHasTabsMenuButton,
195 
196  DefaultBaseConfig = DefaultDockAreaButtons
197  | ActiveTabHasCloseButton
198  | XmlCompressionEnabled
199  | FloatingContainerHasWidgetTitle,
200 
201  DefaultOpaqueConfig = DefaultBaseConfig
202  | OpaqueSplitterResize
203  | OpaqueUndocking,
204 
205  DefaultNonOpaqueConfig = DefaultBaseConfig
206  | DragPreviewShowsContentPixmap,
207 
208  NonOpaqueWithWindowFrame = DefaultNonOpaqueConfig
209  | DragPreviewHasWindowFrame
210  };
211  Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag)
212 
213 
220  CDockManager(QWidget* parent = nullptr);
221 
225  virtual ~CDockManager() override;
226 
230  static ConfigFlags configFlags();
231 
237  static void setConfigFlags(const ConfigFlags Flags);
238 
243  static void setConfigFlag(eConfigFlag Flag, bool On = true);
244 
248  static bool testConfigFlag(eConfigFlag Flag);
249 
255  static CIconProvider& iconProvider();
256 
270  CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
271  CDockAreaWidget* DockAreaWidget = nullptr);
272 
279  CDockAreaWidget* addDockWidgetTab(DockWidgetArea area,
280  CDockWidget* Dockwidget);
281 
286  CDockAreaWidget* addDockWidgetTabToArea(CDockWidget* Dockwidget,
287  CDockAreaWidget* DockAreaWidget);
288 
293  CFloatingDockContainer* addDockWidgetFloating(CDockWidget* Dockwidget);
294 
300  CDockWidget* findDockWidget(const QString& ObjectName) const;
301 
305  void removeDockWidget(CDockWidget* Dockwidget);
306 
311  QMap<QString, CDockWidget*> dockWidgetsMap() const;
312 
317  const QList<CDockContainerWidget*> dockContainers() const;
318 
322  const QList<CFloatingDockContainer*> floatingWidgets() const;
323 
328  unsigned int zOrderIndex() const override;
329 
342  QByteArray saveState(int version = 0) const;
343 
352  bool restoreState(const QByteArray &state, int version = 0);
353 
362  void addPerspective(const QString& UniquePrespectiveName);
363 
367  void removePerspective(const QString& Name);
368 
372  void removePerspectives(const QStringList& Names);
373 
377  QStringList perspectiveNames() const;
378 
382  void savePerspectives(QSettings& Settings) const;
383 
387  void loadPerspectives(QSettings& Settings);
388 
392  CDockWidget* centralWidget() const;
393 
411  CDockAreaWidget* setCentralWidget(CDockWidget* widget);
412 
431  QAction* addToggleViewActionToMenu(QAction* ToggleViewAction,
432  const QString& Group = QString(), const QIcon& GroupIcon = QIcon());
433 
439  QMenu* viewMenu() const;
440 
449  void setViewMenuInsertionOrder(eViewMenuInsertionOrder Order);
450 
455  bool isRestoringState() const;
456 
461  static int startDragDistance();
462 
467  template <class QWidgetPtr>
468  static void setWidgetFocus(QWidgetPtr widget)
469  {
471  {
472  return;
473  }
474 
475  widget->setFocus(Qt::OtherFocusReason);
476  }
477 
478 #ifdef Q_OS_LINUX
479  bool eventFilter(QObject *obj, QEvent *e) override;
480 #endif
481 
488  CDockWidget* focusedDockWidget() const;
489 
496  QList<int> splitterSizes(CDockAreaWidget *ContainedArea) const;
497 
507  void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<int>& sizes);
508 
509 public slots:
513  void openPerspective(const QString& PerspectiveName);
514 
520  void setDockWidgetFocused(CDockWidget* DockWidget);
521 
522 signals:
526  void perspectiveListChanged();
527 
531  void perspectivesRemoved();
532 
538  void restoringState();
539 
545  void stateRestored();
546 
555  void openingPerspective(const QString& PerspectiveName);
556 
561  void perspectiveOpened(const QString& PerspectiveName);
562 
568  void floatingWidgetCreated(ads::CFloatingDockContainer* FloatingWidget);
569 
575  void dockAreaCreated(ads::CDockAreaWidget* DockArea);
576 
581  void dockWidgetAdded(ads::CDockWidget* DockWidget);
582 
587  void dockWidgetAboutToBeRemoved(ads::CDockWidget* DockWidget);
588 
595  void dockWidgetRemoved(ads::CDockWidget* DockWidget);
596 
602  void focusedDockWidgetChanged(ads::CDockWidget* old, ads::CDockWidget* now);
603 }; // class DockManager
604 } // namespace ads
605 //-----------------------------------------------------------------------------
606 #endif // DockManagerH
ads_globals.h
Declaration of.
detail::state
state
Definition: core.h:2305
ads::DockAreaWidgetPrivate
Definition: DockAreaWidget.cpp:245
DockContainerWidget.h
Declaration of CDockContainerWidget class.
FloatingDockContainer.h
Declaration of CFloatingDockContainer class.
ads::DockWidgetArea
DockWidgetArea
Definition: ads_globals.h:73
ads::CDockAreaTitleBar
Definition: DockAreaTitleBar.h:50
ads::CDockManager::d
DockManagerPrivate * d
private data (pimpl)
Definition: DockManager.h:73
DockWidget.h
Declaration of CDockWidget class.
QList
Definition: qwt_abstract_legend.h:17
ads::CDockAreaWidget
Definition: DockAreaWidget.h:55
ads::CFloatingDragPreview
Definition: FloatingDragPreview.h:28
ads::CDockManager::setWidgetFocus
static void setWidgetFocus(QWidgetPtr widget)
Definition: DockManager.h:468
QMap
Definition: qwt_compass.h:19
ads::DockContainerWidgetPrivate
Definition: DockContainerWidget.cpp:127
ads::CDockManager
Definition: DockManager.h:69
ads
Definition: ads_globals.h:69
zmq::version
void version(int *major_, int *minor_, int *patch_)
Definition: zmq.hpp:360
DockWidget
Definition: plot_docker.h:16
ads::DockManagerPrivate
Definition: DockManager.cpp:97
ads::CDockAreaTabBar
Definition: DockAreaTabBar.h:53
ads::CDockWidget
Definition: DockWidget.h:54
Name
@ Name
Definition: curvelist_view.h:46
ads::FloatingDockContainerPrivate
Definition: FloatingDockContainer.cpp:364
ads::CFloatingDockContainer
Definition: FloatingDockContainer.h:104
ads::CIconProvider
Definition: IconProvider.h:28
ads::CDockContainerWidget
Definition: DockContainerWidget.h:61
ads::CDockManager::MenuSortedByInsertion
@ MenuSortedByInsertion
Definition: DockManager.h:148
ads::CDockManager::FocusHighlighting
@ FocusHighlighting
enables styling of focused dock widget tabs or floating widget titlebar
Definition: DockManager.h:182
ads::DockWidgetTabPrivate
Definition: DockWidgetTab.cpp:63
ads::FloatingDragPreviewPrivate
Definition: FloatingDragPreview.cpp:31
ads::CDockWidgetTab
Definition: DockWidgetTab.h:50
ADS_EXPORT
#define ADS_EXPORT
Definition: ads_globals.h:50
ads::CDockManager::testConfigFlag
static bool testConfigFlag(eConfigFlag Flag)
Definition: DockManager.cpp:1041
ads::CDockManager::eViewMenuInsertionOrder
eViewMenuInsertionOrder
Definition: DockManager.h:146
ads::CDockManager::eConfigFlag
eConfigFlag
Definition: DockManager.h:157


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44