mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
Fixed update of floating widget window title, make disabled close button look nicer, fixed restoring of floating dock container, change save and restore functionality of dock area to save the current dock widget name instead of the current index to ensure that the right dock widget is active in an area if the number of dock widgets changes for some reasons (i.e. in plugin based applications)
This commit is contained in:
parent
a9246f7ce4
commit
bc6ffcc02c
@ -1,3 +1,5 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include <MainWindow.h>
|
#include <MainWindow.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -35,6 +37,8 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
std::shared_ptr<int> b;
|
std::shared_ptr<int> b;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
a.setQuitOnLastWindowClosed(true);
|
a.setQuitOnLastWindowClosed(true);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStyleOptionButton>
|
#include <QStyleOptionButton>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
@ -61,6 +62,8 @@ struct DockAreaTitleBarPrivate
|
|||||||
* Creates the internal TabBar
|
* Creates the internal TabBar
|
||||||
*/
|
*/
|
||||||
void createTabBar();
|
void createTabBar();
|
||||||
|
|
||||||
|
QPixmap createTransparentPixmap(const QPixmap& Source);
|
||||||
};// struct DockAreaTitleBarPrivate
|
};// struct DockAreaTitleBarPrivate
|
||||||
|
|
||||||
|
|
||||||
@ -73,6 +76,18 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
QPixmap DockAreaTitleBarPrivate::createTransparentPixmap(const QPixmap& Source)
|
||||||
|
{
|
||||||
|
QPixmap disabledPixmap(Source.size());
|
||||||
|
disabledPixmap.fill(Qt::transparent);
|
||||||
|
QPainter p(&disabledPixmap);
|
||||||
|
p.setOpacity(0.25);
|
||||||
|
p.drawPixmap(0, 0, Source);
|
||||||
|
return disabledPixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void DockAreaTitleBarPrivate::createButtons()
|
void DockAreaTitleBarPrivate::createButtons()
|
||||||
{
|
{
|
||||||
@ -94,8 +109,13 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
CloseButton = new tTileBarButton();
|
CloseButton = new tTileBarButton();
|
||||||
CloseButton->setObjectName("closeButton");
|
CloseButton->setObjectName("closeButton");
|
||||||
CloseButton->setAutoRaise(true);
|
CloseButton->setAutoRaise(true);
|
||||||
QIcon CloseIcon(":/ads/close-button.svg");
|
|
||||||
CloseIcon.addFile(":/ads/close-button-disabled.svg", QSize(), QIcon::Disabled);
|
// The standard icons do does not look good on high DPI screens
|
||||||
|
QIcon CloseIcon = _this->style()->standardIcon(QStyle::SP_TitleBarCloseButton);
|
||||||
|
QPixmap normalPixmap = _this->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, CloseButton);
|
||||||
|
QPixmap disabledPixmap = createTransparentPixmap(normalPixmap);
|
||||||
|
CloseIcon.addPixmap(disabledPixmap, QIcon::Disabled);
|
||||||
|
|
||||||
CloseButton->setIcon(CloseIcon);
|
CloseButton->setIcon(CloseIcon);
|
||||||
CloseButton->setToolTip(QObject::tr("Close"));
|
CloseButton->setToolTip(QObject::tr("Close"));
|
||||||
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
|
@ -373,6 +373,7 @@ void CDockAreaWidget::insertDockWidget(int index, CDockWidget* DockWidget,
|
|||||||
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
||||||
{
|
{
|
||||||
qDebug() << "CDockAreaWidget::removeDockWidget";
|
qDebug() << "CDockAreaWidget::removeDockWidget";
|
||||||
|
std::cout << "CDockAreaWidget::removeDockWidget" << std::endl;
|
||||||
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
|
auto NextOpenDockWidget = nextOpenDockWidget(DockWidget);
|
||||||
|
|
||||||
d->ContentsLayout->removeWidget(DockWidget);
|
d->ContentsLayout->removeWidget(DockWidget);
|
||||||
@ -398,7 +399,11 @@ void CDockAreaWidget::removeDockWidget(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->updateTabBar();
|
d->updateTabBar();
|
||||||
DockWidget->setDockArea(nullptr);
|
auto TopLevelDockWidget = dockContainer()->topLevelDockWidget();
|
||||||
|
if (TopLevelDockWidget)
|
||||||
|
{
|
||||||
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
#if (ADS_DEBUG_LEVEL > 0)
|
#if (ADS_DEBUG_LEVEL > 0)
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
|
@ -759,8 +759,7 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p
|
|||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
d(new DockContainerWidgetPrivate(this))
|
d(new DockContainerWidgetPrivate(this))
|
||||||
{
|
{
|
||||||
d->isFloating = dynamic_cast<CFloatingDockContainer*>(parent) != 0;
|
d->isFloating = floatingWidget() != nullptr;
|
||||||
|
|
||||||
d->DockManager = DockManager;
|
d->DockManager = DockManager;
|
||||||
if (DockManager != this)
|
if (DockManager != this)
|
||||||
{
|
{
|
||||||
@ -986,8 +985,9 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
|||||||
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
CDockAreaWidget* DockArea = dockAreaAt(TargetPos);
|
||||||
auto dropArea = InvalidDockWidgetArea;
|
auto dropArea = InvalidDockWidgetArea;
|
||||||
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
|
||||||
CDockWidget* TopLevelDockWidget = FloatingWidget->hasTopLevelDockWidget() ?
|
CDockWidget* FloatingTopLevelDockWidget = FloatingWidget->topLevelDockWidget();
|
||||||
FloatingWidget->topLevelDockWidget() : nullptr;
|
CDockWidget* TopLevelDockWidget = topLevelDockWidget();
|
||||||
|
|
||||||
if (DockArea)
|
if (DockArea)
|
||||||
{
|
{
|
||||||
auto dropOverlay = d->DockManager->dockAreaOverlay();
|
auto dropOverlay = d->DockManager->dockAreaOverlay();
|
||||||
@ -1017,12 +1017,19 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we drop a floating widget with only one single dock widget, then we
|
// If there was a top level widget before the drop, then it is not top
|
||||||
// drop a top level widget that changes from floating to docked now
|
// level widget anymore
|
||||||
if (TopLevelDockWidget)
|
if (TopLevelDockWidget)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget->emitTopLevelChanged(false);
|
TopLevelDockWidget->emitTopLevelChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we drop a floating widget with only one single dock widget, then we
|
||||||
|
// drop a top level widget that changes from floating to docked now
|
||||||
|
if (FloatingTopLevelDockWidget)
|
||||||
|
{
|
||||||
|
FloatingTopLevelDockWidget->emitTopLevelChanged(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1052,7 +1059,7 @@ void CDockContainerWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
s.writeAttribute("Floating", QString::number(isFloating() ? 1 : 0));
|
s.writeAttribute("Floating", QString::number(isFloating() ? 1 : 0));
|
||||||
if (isFloating())
|
if (isFloating())
|
||||||
{
|
{
|
||||||
CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(this);
|
CFloatingDockContainer* FloatingWidget = floatingWidget();
|
||||||
QByteArray Geometry = FloatingWidget->saveGeometry();
|
QByteArray Geometry = FloatingWidget->saveGeometry();
|
||||||
s.writeTextElement("Geometry", Geometry.toHex(' '));
|
s.writeTextElement("Geometry", Geometry.toHex(' '));
|
||||||
}
|
}
|
||||||
@ -1091,7 +1098,7 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
|||||||
|
|
||||||
if (!Testing)
|
if (!Testing)
|
||||||
{
|
{
|
||||||
CFloatingDockContainer* FloatingWidget = internal::findParent<CFloatingDockContainer*>(this);
|
CFloatingDockContainer* FloatingWidget = floatingWidget();
|
||||||
FloatingWidget->restoreGeometry(Geometry);
|
FloatingWidget->restoreGeometry(Geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1118,6 +1125,40 @@ bool CDockContainerWidget::restoreState(QXmlStreamReader& s, bool Testing)
|
|||||||
d->RootSplitter = dynamic_cast<QSplitter*>(NewRootSplitter);
|
d->RootSplitter = dynamic_cast<QSplitter*>(NewRootSplitter);
|
||||||
OldRoot->deleteLater();
|
OldRoot->deleteLater();
|
||||||
|
|
||||||
|
// All dock widgets, that have not been processed in the restore state
|
||||||
|
// function are invisible to the user now and have no assigned dock area
|
||||||
|
// They do not belong to any dock container, until the user toggles the
|
||||||
|
// toggle view action the next time
|
||||||
|
for (auto DockWidget : dockWidgets())
|
||||||
|
{
|
||||||
|
if (DockWidget->property("dirty").toBool())
|
||||||
|
{
|
||||||
|
DockWidget->flagAsUnassigned();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DockWidget->toggleViewInternal(!DockWidget->property("closed").toBool());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally we need to send the topLevelChanged() signals for all dock
|
||||||
|
// widgets if top level changed
|
||||||
|
CDockWidget* TopLevelDockWidget = topLevelDockWidget();
|
||||||
|
if (TopLevelDockWidget)
|
||||||
|
{
|
||||||
|
TopLevelDockWidget->emitTopLevelChanged(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto DockArea : d->DockAreas)
|
||||||
|
{
|
||||||
|
for (auto DockWidget : DockArea->dockWidgets())
|
||||||
|
{
|
||||||
|
DockWidget->emitTopLevelChanged(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,6 +1191,11 @@ CDockAreaWidget* CDockContainerWidget::lastAddedDockAreaWidget(DockWidgetArea ar
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
bool CDockContainerWidget::hasTopLevelDockWidget() const
|
bool CDockContainerWidget::hasTopLevelDockWidget() const
|
||||||
{
|
{
|
||||||
|
if (!isFloating())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
auto DockAreas = openedDockAreas();
|
auto DockAreas = openedDockAreas();
|
||||||
if (DockAreas.count() != 1)
|
if (DockAreas.count() != 1)
|
||||||
{
|
{
|
||||||
@ -1163,19 +1209,38 @@ bool CDockContainerWidget::hasTopLevelDockWidget() const
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidget* CDockContainerWidget::topLevelDockWidget() const
|
CDockWidget* CDockContainerWidget::topLevelDockWidget() const
|
||||||
{
|
{
|
||||||
auto DockAreas = openedDockAreas();
|
auto TopLevelDockArea = topLevelDockArea();
|
||||||
if (DockAreas.count() != 1)
|
if (!TopLevelDockArea)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DockWidgets = DockAreas[0]->openedDockWidgets();
|
auto DockWidgets = TopLevelDockArea->openedDockWidgets();
|
||||||
if (DockWidgets.count() != 1)
|
if (DockWidgets.count() != 1)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DockWidgets[0];
|
return DockWidgets[0];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaWidget* CDockContainerWidget::topLevelDockArea() const
|
||||||
|
{
|
||||||
|
if (!isFloating())
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DockAreas = openedDockAreas();
|
||||||
|
if (DockAreas.count() != 1)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DockAreas[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1204,6 +1269,14 @@ CDockWidget::DockWidgetFeatures CDockContainerWidget::features() const
|
|||||||
return Features;
|
return Features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CFloatingDockContainer* CDockContainerWidget::floatingWidget() const
|
||||||
|
{
|
||||||
|
return internal::findParent<CFloatingDockContainer*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
#include "moc_DockContainerWidget.cpp"
|
#include "moc_DockContainerWidget.cpp"
|
||||||
|
@ -127,6 +127,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
CDockWidget* topLevelDockWidget() const;
|
CDockWidget* topLevelDockWidget() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the top level dock area.
|
||||||
|
*/
|
||||||
|
CDockAreaWidget* topLevelDockArea() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns a list of all dock widgets in this floating widget.
|
* This function returns a list of all dock widgets in this floating widget.
|
||||||
* It may be possible, depending on the implementation, that dock widgets,
|
* It may be possible, depending on the implementation, that dock widgets,
|
||||||
@ -216,6 +221,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
CDockWidget::DockWidgetFeatures features() const;
|
CDockWidget::DockWidgetFeatures features() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this dock container is in a floating widget, this function returns
|
||||||
|
* the floating widget.
|
||||||
|
* Else, it returns a nullptr.
|
||||||
|
*/
|
||||||
|
CFloatingDockContainer* floatingWidget() 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
|
||||||
|
@ -141,16 +141,27 @@ bool DockManagerPrivate::restoreContainer(int Index, QXmlStreamReader& stream, b
|
|||||||
Index = 0;
|
Index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Result = false;
|
||||||
if (Index >= Containers.count())
|
if (Index >= Containers.count())
|
||||||
{
|
{
|
||||||
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(_this);
|
CFloatingDockContainer* FloatingWidget = new CFloatingDockContainer(_this);
|
||||||
return FloatingWidget->restoreState(stream, Testing);
|
Result = FloatingWidget->restoreState(stream, Testing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "d->Containers[i]->restoreState ";
|
qDebug() << "d->Containers[i]->restoreState ";
|
||||||
return Containers[Index]->restoreState(stream, Testing);
|
auto Container = Containers[Index];
|
||||||
|
if (Container->isFloating())
|
||||||
|
{
|
||||||
|
Result = Container->floatingWidget()->restoreState(stream, Testing);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = Container->restoreState(stream, Testing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -242,23 +253,6 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All dock widgets, that have not been processed in the restore state
|
|
||||||
// function are invisible to the user now and have no assigned dock area
|
|
||||||
// They do not belong to any dock container, until the user toggles the
|
|
||||||
// toggle view action the next time
|
|
||||||
for (auto DockWidget : DockWidgetsMap)
|
|
||||||
{
|
|
||||||
if (DockWidget->property("dirty").toBool())
|
|
||||||
{
|
|
||||||
DockWidget->flagAsUnassigned();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DockWidget->toggleViewInternal(!DockWidget->property("closed").toBool());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Now all dock areas are properly restored and we setup the index of
|
// Now all dock areas are properly restored and we setup the index of
|
||||||
// The dock areas because the previous toggleView() action has changed
|
// The dock areas because the previous toggleView() action has changed
|
||||||
// the dock area index
|
// the dock area index
|
||||||
@ -281,7 +275,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
|
|||||||
|
|
||||||
// Finally we need to send the topLevelChanged() signals for all dock
|
// Finally we need to send the topLevelChanged() signals for all dock
|
||||||
// widgets if top level changed
|
// widgets if top level changed
|
||||||
for (auto DockContainer : Containers)
|
/*for (auto DockContainer : Containers)
|
||||||
{
|
{
|
||||||
CDockWidget* TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
CDockWidget* TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
||||||
if (TopLevelDockWidget)
|
if (TopLevelDockWidget)
|
||||||
@ -299,7 +293,7 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -434,17 +434,11 @@ void CDockWidget::toggleView(bool Open)
|
|||||||
void CDockWidget::toggleViewInternal(bool Open)
|
void CDockWidget::toggleViewInternal(bool Open)
|
||||||
{
|
{
|
||||||
CDockContainerWidget* DockContainer = dockContainer();
|
CDockContainerWidget* DockContainer = dockContainer();
|
||||||
CDockWidget* TopLevelDockWidget = nullptr;
|
CDockWidget* TopLevelDockWidgetBefore = DockContainer
|
||||||
CDockWidget* TopLevelDockWidgetBefore = nullptr;
|
? DockContainer->topLevelDockWidget() : nullptr;
|
||||||
|
|
||||||
if (DockContainer)
|
|
||||||
{
|
|
||||||
TopLevelDockWidgetBefore = DockContainer->topLevelDockWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Open)
|
if (Open)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget = TopLevelDockWidgetBefore;
|
|
||||||
d->showDockWidget();
|
d->showDockWidget();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -460,31 +454,19 @@ void CDockWidget::toggleViewInternal(bool Open)
|
|||||||
d->DockArea->toggleDockWidgetView(this, Open);
|
d->DockArea->toggleDockWidgetView(this, Open);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Open && DockContainer)
|
if (Open && TopLevelDockWidgetBefore)
|
||||||
{
|
{
|
||||||
TopLevelDockWidget = DockContainer->topLevelDockWidget();
|
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidgetBefore, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TopLevelDockWidget)
|
CDockWidget* TopLevelDockWidgetAfter = DockContainer
|
||||||
{
|
? DockContainer->topLevelDockWidget() : nullptr;
|
||||||
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidget, !Open);
|
CDockWidget::emitTopLevelEventForWidget(TopLevelDockWidgetAfter, true);
|
||||||
}
|
CFloatingDockContainer* FloatingContainer = DockContainer->floatingWidget();
|
||||||
|
|
||||||
CDockWidget* TopLevelDockWidgetAfter = nullptr;
|
|
||||||
if (DockContainer)
|
|
||||||
{
|
|
||||||
TopLevelDockWidgetAfter = DockContainer->topLevelDockWidget();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (TopLevelDockWidgetAfter != TopLevelDockWidgetBefore)
|
|
||||||
{
|
|
||||||
CFloatingDockContainer* FloatingContainer = qobject_cast<CFloatingDockContainer*>(DockContainer->parentWidget());
|
|
||||||
if (FloatingContainer)
|
if (FloatingContainer)
|
||||||
{
|
{
|
||||||
FloatingContainer->updateWindowTitle(TopLevelDockWidgetAfter ? TopLevelDockWidgetAfter->windowTitle() : "");
|
FloatingContainer->updateWindowTitle();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!Open)
|
if (!Open)
|
||||||
{
|
{
|
||||||
|
@ -466,9 +466,11 @@ bool CFloatingDockContainer::isClosable() const
|
|||||||
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
||||||
{
|
{
|
||||||
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
|
qDebug() << "CFloatingDockContainer::onDockAreasAddedOrRemoved()";
|
||||||
if (d->DockContainer->visibleDockAreaCount() == 1)
|
std::cout << "CFloatingDockContainer::onDockAreasAddedOrRemoved()" << std::endl;
|
||||||
|
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
||||||
|
if (TopLevelDockArea)
|
||||||
{
|
{
|
||||||
d->SingleDockArea = d->DockContainer->openedDockAreas()[0];
|
d->SingleDockArea = TopLevelDockArea;
|
||||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
connect(d->SingleDockArea, SIGNAL(currentChanged(int)), this,
|
||||||
SLOT(onDockAreaCurrentChanged(int)));
|
SLOT(onDockAreaCurrentChanged(int)));
|
||||||
@ -487,15 +489,16 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CFloatingDockContainer::updateWindowTitle(const QString& Title)
|
void CFloatingDockContainer::updateWindowTitle()
|
||||||
{
|
{
|
||||||
if (Title.isEmpty())
|
auto TopLevelDockArea = d->DockContainer->topLevelDockArea();
|
||||||
|
if (TopLevelDockArea)
|
||||||
{
|
{
|
||||||
this->setWindowTitle(qApp->applicationDisplayName());
|
this->setWindowTitle(TopLevelDockArea->currentDockWidget()->windowTitle());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->setWindowTitle(Title);
|
this->setWindowTitle(qApp->applicationDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,6 +507,8 @@ void CFloatingDockContainer::updateWindowTitle(const QString& Title)
|
|||||||
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
void CFloatingDockContainer::onDockAreaCurrentChanged(int Index)
|
||||||
{
|
{
|
||||||
Q_UNUSED(Index);
|
Q_UNUSED(Index);
|
||||||
|
std::cout << "CFloatingDockContainer::onDockAreaCurrentChanged "
|
||||||
|
<< Index << std::endl;
|
||||||
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
this->setWindowTitle(d->SingleDockArea->currentDockWidget()->windowTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,6 +520,8 @@ bool CFloatingDockContainer::restoreState(QXmlStreamReader& Stream, bool Testing
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Dockarea count " << d->DockContainer->dockAreaCount() << std::endl;
|
||||||
onDockAreasAddedOrRemoved();
|
onDockAreasAddedOrRemoved();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -533,6 +540,7 @@ CDockWidget* CFloatingDockContainer::topLevelDockWidget() const
|
|||||||
return d->DockContainer->topLevelDockWidget();
|
return d->DockContainer->topLevelDockWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
QList<CDockWidget*> CFloatingDockContainer::dockWidgets() const
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* Call this function to update the window title
|
* Call this function to update the window title
|
||||||
*/
|
*/
|
||||||
void updateWindowTitle(const QString& Title ="");
|
void updateWindowTitle();
|
||||||
|
|
||||||
|
|
||||||
protected: // reimplements QWidget
|
protected: // reimplements QWidget
|
||||||
|
Loading…
Reference in New Issue
Block a user