mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Added proper support for closable feature, now the close button is disabled for floating widgets
This commit is contained in:
parent
11e5f9c95a
commit
8637c89a6b
@ -654,6 +654,19 @@ CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockWidget::DockWidgetFeatures CDockAreaWidget::features() const
|
||||
{
|
||||
CDockWidget::DockWidgetFeatures Features;
|
||||
for (const auto DockWidget : dockWidgets())
|
||||
{
|
||||
Features &= DockWidget->features();
|
||||
}
|
||||
|
||||
return Features;
|
||||
}
|
||||
|
||||
} // namespace ads
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QFrame>
|
||||
|
||||
#include "ads_globals.h"
|
||||
#include "DockWidget.h"
|
||||
|
||||
class QXmlStreamWriter;
|
||||
|
||||
@ -42,7 +43,6 @@ struct DockAreaWidgetPrivate;
|
||||
class CDockManager;
|
||||
class CDockContainerWidget;
|
||||
struct DockContainerWidgetPrivate;
|
||||
class CDockWidget;
|
||||
|
||||
|
||||
/**
|
||||
@ -206,6 +206,15 @@ public:
|
||||
*/
|
||||
void saveState(QXmlStreamWriter& Stream) const;
|
||||
|
||||
/**
|
||||
* This functions returns the dock widget features of all dock widget in
|
||||
* this area.
|
||||
* A bitwise and is used to combine the flags of all dock widgets. That
|
||||
* means, if only dock widget does not support a certain flag, the whole
|
||||
* dock are does not support the flag.
|
||||
*/
|
||||
CDockWidget::DockWidgetFeatures features() const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* This activates the tab for the given tab index.
|
||||
|
@ -1153,6 +1153,19 @@ QList<CDockWidget*> CDockContainerWidget::dockWidgets() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
||||
{
|
||||
CDockWidget::DockWidgetFeatures Features;
|
||||
for (const auto DockArea : d->DockAreas)
|
||||
{
|
||||
Features &= DockArea->features();
|
||||
}
|
||||
|
||||
return Features;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ads
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <QFrame>
|
||||
|
||||
#include "ads_globals.h"
|
||||
|
||||
#include "DockWidget.h"
|
||||
|
||||
class QXmlStreamWriter;
|
||||
class QXmlStreamReader;
|
||||
@ -206,6 +206,15 @@ public:
|
||||
*/
|
||||
void dumpLayout();
|
||||
|
||||
/**
|
||||
* This functions returns the dock widget features of all dock widget in
|
||||
* this container.
|
||||
* A bitwise and is used to combine the flags of all dock widgets. That
|
||||
* means, if only dock widget does not support a certain flag, the whole
|
||||
* dock are does not support the flag.
|
||||
*/
|
||||
CDockWidget::DockWidgetFeatures features() const;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted if one or multiple dock areas has been added to
|
||||
|
@ -91,6 +91,17 @@ struct FloatingDockContainerPrivate
|
||||
{
|
||||
DraggingState = StateId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the window close button if the content is not closable
|
||||
*/
|
||||
void disableCloseButton()
|
||||
{
|
||||
auto Flags = _this->windowFlags();
|
||||
Flags |= Qt::CustomizeWindowHint;
|
||||
Flags &= ~Qt::WindowCloseButtonHint;
|
||||
_this->setWindowFlags(Flags);
|
||||
}
|
||||
};
|
||||
// struct FloatingDockContainerPrivate
|
||||
|
||||
@ -250,6 +261,10 @@ CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
|
||||
CFloatingDockContainer(DockArea->dockManager())
|
||||
{
|
||||
d->DockContainer->addDockArea(DockArea);
|
||||
if (!DockArea->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||
{
|
||||
d->disableCloseButton();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -258,6 +273,10 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) :
|
||||
CFloatingDockContainer(DockWidget->dockManager())
|
||||
{
|
||||
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
|
||||
if (!DockWidget->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||
{
|
||||
d->disableCloseButton();
|
||||
}
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
@ -515,6 +534,10 @@ bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!d->DockContainer->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||
{
|
||||
d->disableCloseButton();
|
||||
}
|
||||
onDockAreasAddedOrRemoved();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user