DockManager configFlags functions are now static because the configuration flags are global, added support for QToolButton as tab close button

This commit is contained in:
Uwe Kindler 2019-09-12 21:15:35 +02:00
parent dae677e479
commit bed99eacc2
6 changed files with 18 additions and 11 deletions

View File

@ -299,6 +299,10 @@ CMainWindow::CMainWindow(QWidget *parent) :
d->ui.setupUi(this); d->ui.setupUi(this);
d->createActions(); 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 // Now create the dock manager and its content
d->DockManager = new CDockManager(this); d->DockManager = new CDockManager(this);

View File

@ -95,7 +95,7 @@ struct DockAreaTitleBarPrivate
*/ */
bool testConfigFlag(CDockManager::eConfigFlag Flag) const bool testConfigFlag(CDockManager::eConfigFlag Flag) const
{ {
return DockArea->dockManager()->configFlags().testFlag(Flag); return CDockManager::configFlags().testFlag(Flag);
} }
/** /**

View File

@ -269,7 +269,7 @@ public:
CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr) CDockSplitter* newSplitter(Qt::Orientation orientation, QWidget* parent = nullptr)
{ {
CDockSplitter* s = new CDockSplitter(orientation, parent); CDockSplitter* s = new CDockSplitter(orientation, parent);
s->setOpaqueResize(DockManager->configFlags().testFlag(CDockManager::OpaqueSplitterResize)); s->setOpaqueResize(CDockManager::configFlags().testFlag(CDockManager::OpaqueSplitterResize));
s->setChildrenCollapsible(false); s->setChildrenCollapsible(false);
return s; return s;
} }

View File

@ -56,6 +56,8 @@
namespace ads namespace ads
{ {
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultConfig;
/** /**
* Private data class of CDockManager class (pimpl) * Private data class of CDockManager class (pimpl)
*/ */
@ -72,7 +74,6 @@ struct DockManagerPrivate
QMenu* ViewMenu; QMenu* ViewMenu;
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted; CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
bool RestoringState = false; bool RestoringState = false;
CDockManager::ConfigFlags ConfigFlags = CDockManager::DefaultConfig;
/** /**
* Private data constructor * Private data constructor
@ -498,7 +499,8 @@ QByteArray CDockManager::saveState(int version) const
{ {
QByteArray xmldata; QByteArray xmldata;
QXmlStreamWriter s(&xmldata); QXmlStreamWriter s(&xmldata);
s.setAutoFormatting(d->ConfigFlags.testFlag(XmlAutoFormattingEnabled)); auto ConfigFlags = CDockManager::configFlags();
s.setAutoFormatting(ConfigFlags.testFlag(XmlAutoFormattingEnabled));
s.writeStartDocument(); s.writeStartDocument();
s.writeStartElement("QtAdvancedDockingSystem"); s.writeStartElement("QtAdvancedDockingSystem");
s.writeAttribute("Version", QString::number(version)); s.writeAttribute("Version", QString::number(version));
@ -511,7 +513,8 @@ QByteArray CDockManager::saveState(int version) const
s.writeEndElement(); s.writeEndElement();
s.writeEndDocument(); 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) void CDockManager::setConfigFlags(const ConfigFlags Flags)
{ {
d->ConfigFlags = Flags; StaticConfigFlags = Flags;
} }

View File

@ -151,13 +151,13 @@ public:
/** /**
* This function returns the global configuration flags * This function returns the global configuration flags
*/ */
ConfigFlags configFlags() const; static ConfigFlags configFlags();
/** /**
* Sets the global configuration flags for the whole docking system. * Sets the global configuration flags for the whole docking system.
* Call this function before you create your first dock widget. * 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. * Adds dockwidget into the given area.

View File

@ -119,7 +119,7 @@ struct DockWidgetTabPrivate
*/ */
bool testConfigFlag(CDockManager::eConfigFlag Flag) const bool testConfigFlag(CDockManager::eConfigFlag Flag) const
{ {
return DockArea->dockManager()->configFlags().testFlag(Flag); return CDockManager::configFlags().testFlag(Flag);
} }
/** /**