Go to the documentation of this file.
37 #include <QMainWindow>
44 #include <QXmlStreamWriter>
47 #include <QApplication>
144 FloatingWidget->hide();
186 QString FileName =
":ads/stylesheets/";
188 ?
"focus_highlighting" :
"default";
190 FileName +=
"_linux";
193 QFile StyleSheetFile(FileName);
194 StyleSheetFile.open(QIODevice::ReadOnly);
195 QTextStream StyleSheetStream(&StyleSheetFile);
196 Result = StyleSheetStream.readAll();
197 StyleSheetFile.close();
218 ADS_PRINT(
"d->Containers[i]->restoreState ");
220 if (Container->isFloating())
222 Result = Container->floatingWidget()->restoreState(stream, Testing);
226 Result = Container->restoreState(stream, Testing);
252 s.readNextStartElement();
253 if (
s.name() !=
"QtAdvancedDockingSystem")
259 int v =
s.attributes().value(
"Version").toInt(&
ok);
266 ADS_PRINT(
s.attributes().value(
"UserVersion"));
269 if (!
s.attributes().value(
"UserVersion").isEmpty())
271 v =
s.attributes().value(
"UserVersion").toInt(&
ok);
279 #ifdef ADS_DEBUG_PRINT
280 int DockContainers =
s.attributes().value(
"Containers").toInt();
286 const auto CentralWidgetAttribute =
s.attributes().value(
"CentralWidget");
289 if (CentralWidgetAttribute.isEmpty())
291 qWarning() <<
"Dock manager has central widget but saved state does not have central widget.";
297 if (
CentralWidget->objectName() != CentralWidgetAttribute.toString())
299 qWarning() <<
"Object name of central widget does not match name of central widget in saved state.";
304 int DockContainerCount = 0;
305 while (
s.readNextStartElement())
307 if (
s.name() ==
"Container")
314 DockContainerCount++;
321 int FloatingWidgetIndex = DockContainerCount - 1;
326 floatingWidget->deleteLater();
366 for (
int i = 0; i < DockContainer->dockAreaCount(); ++i)
369 QString DockWidgetName = DockArea->property(
"currentDockWidget").toString();
371 if (!DockWidgetName.isEmpty())
400 CDockWidget* TopLevelDockWidget = DockContainer->topLevelDockWidget();
401 if (TopLevelDockWidget)
407 for (
int i = 0; i < DockContainer->dockAreaCount(); ++i)
409 auto DockArea = DockContainer->dockArea(i);
410 for (
auto DockWidget : DockArea->dockWidgets())
423 QByteArray
state = State.startsWith(
"<?xml") ? State : qUncompress(State);
426 ADS_PRINT(
"checkFormat: Error checking format!!!!!!!");
436 ADS_PRINT(
"restoreState: Error restoring state!!!!!!!");
454 auto Actions = Menu->actions();
455 auto it = std::find_if(Actions.begin(), Actions.end(),
456 [&Action](
const QAction* a)
458 return a->text().compare(Action->text(), Qt::CaseInsensitive) > 0;
461 if (it == Actions.end())
463 Menu->addAction(Action);
467 Menu->insertAction(*it, Action);
472 Menu->addAction(Action);
483 QMainWindow*
MainWindow = qobject_cast<QMainWindow*>(parent);
489 d->
ViewMenu =
new QMenu(tr(
"Show View"),
this);
490 d->
DockAreaOverlay =
new CDockOverlay(
this, CDockOverlay::ModeDockAreaOverlay);
491 d->
ContainerOverlay =
new CDockOverlay(
this, CDockOverlay::ModeContainerOverlay);
501 window()->installEventFilter(
this);
509 for (
auto FloatingWidget : FloatingWidgets)
511 delete FloatingWidget;
518 bool CDockManager::eventFilter(QObject *obj, QEvent *e)
524 if (e->type() == QEvent::WindowActivate)
528 if (!_window->isVisible() || window()->isMinimized())
535 internal::xcb_update_prop(
true, _window->window()->winId(),
536 "_NET_WM_STATE",
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_STAYS_ON_TOP");
539 else if (e->type() == QEvent::WindowDeactivate)
543 if (!_window->isVisible() || window()->isMinimized())
547 internal::xcb_update_prop(
false, _window->window()->winId(),
548 "_NET_WM_STATE",
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_STAYS_ON_TOP");
554 if (e->type() == QEvent::WindowStateChange)
558 if (! _window->isVisible())
563 if (window()->isMinimized())
565 _window->showMinimized();
569 _window->setWindowState(_window->windowState() & (~Qt::WindowMinimized));
572 if (!window()->isMinimized())
574 QApplication::setActiveWindow(window());
577 return Super::eventFilter(obj, e);
607 if (
this != DockContainer)
653 QXmlStreamWriter
s(&xmldata);
656 s.writeStartDocument();
657 s.writeStartElement(
"QtAdvancedDockingSystem");
659 s.writeAttribute(
"UserVersion", QString::number(
version));
660 s.writeAttribute(
"Containers", QString::number(
d->
Containers.count()));
667 Container->saveState(
s);
671 s.writeEndDocument();
674 ? qCompress(xmldata, 9) : xmldata;
696 bool IsHidden = this->isHidden();
726 FloatingWidget->resize(Dockwidget->size());
729 FloatingWidget->show();
736 return FloatingWidget;
743 Super::showEvent(
event);
751 FloatingWidget->show();
762 auto Container = DockAreaWidget ? DockAreaWidget->
dockContainer():
this;
763 auto AreaOfAddedDockWidget = Container->
addDockWidget(area, Dockwidget, DockAreaWidget);
765 return AreaOfAddedDockWidget;
839 for (
auto Name : Names)
877 Settings.beginWriteArray(
"Perspectives",
d->
Perspectives.size());
881 Settings.setArrayIndex(i);
882 Settings.setValue(
"Name", it.key());
883 Settings.setValue(
"State", it.value());
894 int Size = Settings.beginReadArray(
"Perspectives");
901 for (
int i = 0; i < Size; ++i)
903 Settings.setArrayIndex(i);
904 QString
Name = Settings.value(
"Name").toString();
905 QByteArray Data = Settings.value(
"State").toByteArray();
906 if (
Name.isEmpty() || Data.isEmpty())
938 qWarning(
"Setting a central widget not possible because there is already a central widget.");
946 qWarning(
"Setting a central widget not possible - the central widget need to be the first "
947 "dock widget that is added to the dock manager.");
957 CentralArea->
setDockAreaFlag(CDockAreaWidget::eDockAreaFlag::HideSingleWidgetTitleBar,
true);
963 const QString& Group,
const QIcon& GroupIcon)
966 if (!Group.isEmpty())
971 GroupMenu =
new QMenu(Group,
this);
972 GroupMenu->setIcon(GroupIcon);
976 else if (GroupMenu->icon().isNull() && !GroupIcon.isNull())
978 GroupMenu->setIcon(GroupIcon);
982 return GroupMenu->menuAction();
987 return ToggleViewAction;
1016 return QApplication::startDragDistance() * 1.5;
1103 auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
1106 return Splitter->sizes();
1120 auto Splitter = internal::findParent<CDockSplitter*>(ContainedArea);
1121 if (Splitter && Splitter->count() == sizes.count())
1123 Splitter->setSizes(sizes);
Declaration of CDockSplitter.
void removeDockContainer(CDockContainerWidget *DockContainer)
@ InitialVersion
InitialVersion.
void notifyFloatingWidgetDrop(CFloatingDockContainer *FloatingWidget)
void dockWidgetRemoved(ads::CDockWidget *DockWidget)
CDockWidget * centralWidget() const
@ CurrentVersion
CurrentVersion.
DockManagerPrivate(CDockManager *_public)
static void setConfigFlag(eConfigFlag Flag, bool On=true)
bool restoreState(const QByteArray &state, int version)
QByteArray saveState(int version=0) const
void openPerspective(const QString &PerspectiveName)
@ MenuAlphabeticallySorted
void registerFloatingWidget(CFloatingDockContainer *FloatingWidget)
QVector< CFloatingDockContainer * > UninitializedFloatingWidgets
static void initResource()
void setDockWidgetFocused(CDockWidget *focusedNow)
Declaration of CFloatingDockContainer class.
static CDockManager::ConfigFlags StaticConfigFlags
void notifyFloatingWidgetDrop(CFloatingDockContainer *FloatingWidget)
CDockOverlay * dockAreaOverlay() const
static const char *const DirtyProperty
void hideFloatingWidgets()
void openingPerspective(const QString &PerspectiveName)
CDockAreaWidget * addDockWidgetTabToArea(CDockWidget *Dockwidget, CDockAreaWidget *DockAreaWidget)
DockManagerPrivate * d
private data (pimpl)
void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList< int > &sizes)
QMap< QString, CDockWidget * > DockWidgetsMap
bool restoreStateFromXml(const QByteArray &state, int version, bool Testing=internal::Restore)
CDockOverlay * containerOverlay() const
void restoreDockWidgetsOpenState()
QList< CFloatingDockContainer * > FloatingWidgets
QList< int > splitterSizes(CDockAreaWidget *ContainedArea) const
void perspectiveOpened(const QString &PerspectiveName)
void savePerspectives(QSettings &Settings) const
bool restoreContainer(int Index, CDockingStateReader &stream, bool Testing)
@ XmlCompressionEnabled
If enabled, the XML output will be compressed and is not human readable anymore.
void removePerspectives(const QStringList &Names)
static const char *const ClosedProperty
void dockWidgetAdded(ads::CDockWidget *DockWidget)
void loadPerspectives(QSettings &Settings)
unsigned int zOrderIndex() const override
static int startDragDistance()
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder
bool restoreState(const QByteArray &state, int version=0)
void version(int *major_, int *minor_, int *patch_)
CDockAreaWidget * addDockWidgetTab(DockWidgetArea area, CDockWidget *Dockwidget)
void perspectivesRemoved()
Declaration of CDockFocusController class.
Declaration of CDockAreaTitleBar class.
void addPerspective(const QString &UniquePrespectiveName)
@ DefaultNonOpaqueConfig
the default configuration for non opaque operations
QMap< QString, CDockWidget * > dockWidgetsMap() const
void floatingWidgetCreated(ads::CFloatingDockContainer *FloatingWidget)
virtual ~CDockManager() override
void setViewMenuInsertionOrder(eViewMenuInsertionOrder Order)
bool restoreState(CDockingStateReader &Stream, bool Testing)
void setDockWidgetFocused(CDockWidget *DockWidget)
QMap< QString, QByteArray > Perspectives
virtual void showEvent(QShowEvent *event) override
const QList< CFloatingDockContainer * > floatingWidgets() const
void addActionToMenu(QAction *Action, QMenu *Menu, bool InsertSorted)
QMap< QString, QMenu * > ViewMenuGroups
void restoreDockAreasIndices()
static CIconProvider & iconProvider()
void registerDockContainer(CDockContainerWidget *DockContainer)
CDockOverlay * ContainerOverlay
static ConfigFlags configFlags()
CDockWidget * focusedDockWidget() const
const QList< CDockContainerWidget * > dockContainers() const
void perspectiveListChanged()
Declaration of CDockManager class.
void notifyWidgetOrAreaRelocation(QWidget *RelocatedWidget)
CDockAreaWidget * addDockWidget(DockWidgetArea area, CDockWidget *Dockwidget, CDockAreaWidget *DockAreaWidget=nullptr)
bool isRestoringState() const
Declaration of CIconProvider.
@ XmlAutoFormattingEnabled
If enabled, the XML writer automatically adds line-breaks and indentation to empty sections between e...
void removePerspective(const QString &Name)
void dockWidgetAboutToBeRemoved(ads::CDockWidget *DockWidget)
CFloatingDockContainer * addDockWidgetFloating(CDockWidget *Dockwidget)
void emitTopLevelEvents()
static const bool Restore
CDockWidget * findDockWidget(const QString &ObjectName) const
void markDockWidgetsDirty()
bool checkFormat(const QByteArray &state, int version)
@ FocusHighlighting
enables styling of focused dock widget tabs or floating widget titlebar
Declaration of CDockingStateReader.
friend class CFloatingDockContainer
CDockOverlay * DockAreaOverlay
QStringList perspectiveNames() const
void removeDockWidget(CDockWidget *Dockwidget)
CDockWidget * CentralWidget
CDockWidget * focusedDockWidget() const
void removeFloatingWidget(CFloatingDockContainer *FloatingWidget)
void notifyWidgetOrAreaRelocation(QWidget *RelocatedWidget)
QList< CDockContainerWidget * > Containers
CDockAreaWidget * setCentralWidget(CDockWidget *widget)
static bool testConfigFlag(eConfigFlag Flag)
static void setConfigFlags(const ConfigFlags Flags)
QAction * addToggleViewActionToMenu(QAction *ToggleViewAction, const QString &Group=QString(), const QIcon &GroupIcon=QIcon())
CDockFocusController * FocusController
static const bool RestoreTesting
void setFlag(T &Flags, typename T::enum_type flag, bool on=true)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44