diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 6694e60..28eca88 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -299,6 +299,10 @@ CMainWindow::CMainWindow(QWidget *parent) : d->ui.setupUi(this); d->createActions(); + // uncomment the following line if the tab close button should be + // a QToolButton instead of a QPushButton + //CDockManager::setConfigFlags(CDockManager::configFlags() | CDockManager::TabCloseButtonIsToolButton); + // Now create the dock manager and its content d->DockManager = new CDockManager(this); diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index b1b0446..64e6bab 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -95,7 +95,7 @@ struct DockAreaTitleBarPrivate */ bool testConfigFlag(CDockManager::eConfigFlag Flag) const { - return DockArea->dockManager()->configFlags().testFlag(Flag); + return CDockManager::configFlags().testFlag(Flag); } /** diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 66e8852..2fe5505 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -269,7 +269,7 @@ public: CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr) { CDockSplitter* s = new CDockSplitter(orientation, parent); - s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize)); + s->setOpaqueResize(CDockManager::configFlags().testFlag(CDockManager::OpaqueSplitterResize)); s->setChildrenCollapsible(false); return s; } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index ff69319..34e6e58 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -56,6 +56,8 @@ namespace ads { +static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultConfig; + /** * Private data class of CDockManager class (pimpl) */ @@ -72,7 +74,6 @@ struct DockManagerPrivate QMenu* ViewMenu; CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted; bool RestoringState = false; - CDockManager::ConfigFlags ConfigFlags = CDockManager::DefaultConfig; /** * Private data constructor @@ -498,7 +499,8 @@ QByteArray CDockManager::saveState(int version) const { QByteArray xmldata; QXmlStreamWriter s(&xmldata); - s.setAutoFormatting(d->ConfigFlags.testFlag(XmlAutoFormattingEnabled)); + auto ConfigFlags = CDockManager::configFlags(); + s.setAutoFormatting(ConfigFlags.testFlag(XmlAutoFormattingEnabled)); s.writeStartDocument(); s.writeStartElement("QtAdvancedDockingSystem"); s.writeAttribute("Version", QString::number(version)); @@ -511,7 +513,8 @@ QByteArray CDockManager::saveState(int version) const s.writeEndElement(); s.writeEndDocument(); - return d->ConfigFlags.testFlag(XmlCompressionEnabled) ? qCompress(xmldata, 9) : xmldata; + return ConfigFlags.testFlag(XmlCompressionEnabled) + ? qCompress(xmldata, 9) : xmldata; } @@ -762,16 +765,16 @@ int CDockManager::startDragDistance() //=========================================================================== -CDockManager::ConfigFlags CDockManager::configFlags() const +CDockManager::ConfigFlags CDockManager::configFlags() { - return d->ConfigFlags; + return StaticConfigFlags; } //=========================================================================== void CDockManager::setConfigFlags(const ConfigFlags Flags) { - d->ConfigFlags = Flags; + StaticConfigFlags = Flags; } diff --git a/src/DockManager.h b/src/DockManager.h index 15a1641..63e1237 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -151,13 +151,13 @@ public: /** * This function returns the global configuration flags */ - ConfigFlags configFlags() const; + static ConfigFlags configFlags(); /** * Sets the global configuration flags for the whole docking system. * Call this function before you create your first dock widget. */ - void setConfigFlags(const ConfigFlags Flags); + static void setConfigFlags(const ConfigFlags Flags); /** * Adds dockwidget into the given area. diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index d4036e2..0d890c4 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -119,7 +119,7 @@ struct DockWidgetTabPrivate */ bool testConfigFlag(CDockManager::eConfigFlag Flag) const { - return DockArea->dockManager()->configFlags().testFlag(Flag); + return CDockManager::configFlags().testFlag(Flag); } /**