mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +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
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
|
|
||||||
@ -42,7 +43,6 @@ struct DockAreaWidgetPrivate;
|
|||||||
class CDockManager;
|
class CDockManager;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
struct DockContainerWidgetPrivate;
|
struct DockContainerWidgetPrivate;
|
||||||
class CDockWidget;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,6 +206,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void saveState(QXmlStreamWriter& Stream) const;
|
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:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* This activates the tab for the given tab index.
|
* 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
|
} // namespace ads
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
#include "ads_globals.h"
|
#include "ads_globals.h"
|
||||||
|
#include "DockWidget.h"
|
||||||
|
|
||||||
class QXmlStreamWriter;
|
class QXmlStreamWriter;
|
||||||
class QXmlStreamReader;
|
class QXmlStreamReader;
|
||||||
@ -206,6 +206,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
void dumpLayout();
|
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:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if one or multiple dock areas has been added to
|
* This signal is emitted if one or multiple dock areas has been added to
|
||||||
|
@ -91,6 +91,17 @@ struct FloatingDockContainerPrivate
|
|||||||
{
|
{
|
||||||
DraggingState = StateId;
|
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
|
// struct FloatingDockContainerPrivate
|
||||||
|
|
||||||
@ -250,6 +261,10 @@ CFloatingDockContainer::CFloatingDockContainer(CDockAreaWidget* DockArea) :
|
|||||||
CFloatingDockContainer(DockArea->dockManager())
|
CFloatingDockContainer(DockArea->dockManager())
|
||||||
{
|
{
|
||||||
d->DockContainer->addDockArea(DockArea);
|
d->DockContainer->addDockArea(DockArea);
|
||||||
|
if (!DockArea->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||||
|
{
|
||||||
|
d->disableCloseButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -258,6 +273,10 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget* DockWidget) :
|
|||||||
CFloatingDockContainer(DockWidget->dockManager())
|
CFloatingDockContainer(DockWidget->dockManager())
|
||||||
{
|
{
|
||||||
d->DockContainer->addDockWidget(CenterDockWidgetArea, DockWidget);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!d->DockContainer->features().testFlag(CDockWidget::DockWidgetClosable))
|
||||||
|
{
|
||||||
|
d->disableCloseButton();
|
||||||
|
}
|
||||||
onDockAreasAddedOrRemoved();
|
onDockAreasAddedOrRemoved();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user