mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Fix emission of viewToggled() signal for dock widgets that are not part of the state that is restored
This commit is contained in:
parent
664a1674ab
commit
156cc71040
@ -226,6 +226,13 @@ void MainWindowPrivate::createContent()
|
||||
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
|
||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
//DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
|
||||
|
||||
for (auto DockWidget : DockManager->dockWidgetsMap())
|
||||
{
|
||||
_this->connect(DockWidget, SIGNAL(viewToggled(bool)), SLOT(onViewToggled(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -375,3 +382,16 @@ void CMainWindow::savePerspective()
|
||||
d->savePerspectives();
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CMainWindow::onViewToggled(bool Open)
|
||||
{
|
||||
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
||||
if (!DockWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")";
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ private slots:
|
||||
void on_actionSaveState_triggered(bool);
|
||||
void on_actionRestoreState_triggered(bool);
|
||||
void savePerspective();
|
||||
void onViewToggled(bool Open);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -695,12 +695,13 @@ bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
|
||||
QWidget*& CreatedWidget, bool Testing)
|
||||
{
|
||||
bool Ok;
|
||||
#ifdef ADS_DEBUG_PRINT
|
||||
int Tabs = s.attributes().value("Tabs").toInt(&Ok);
|
||||
if (!Ok)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QString CurrentDockWidget = s.attributes().value("Current").toString();
|
||||
ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: "
|
||||
@ -745,8 +746,8 @@ bool DockContainerWidgetPrivate::restoreDockArea(QXmlStreamReader& s,
|
||||
DockArea->addDockWidget(DockWidget);
|
||||
DockWidget->setToggleViewActionChecked(!Closed);
|
||||
DockWidget->setClosedState(Closed);
|
||||
DockWidget->setProperty("closed", Closed);
|
||||
DockWidget->setProperty("dirty", false);
|
||||
DockWidget->setProperty(internal::ClosedProperty, Closed);
|
||||
DockWidget->setProperty(internal::DirtyProperty, false);
|
||||
}
|
||||
|
||||
if (Testing)
|
||||
|
@ -102,7 +102,7 @@ struct DockManagerPrivate
|
||||
|
||||
void hideFloatingWidgets()
|
||||
{
|
||||
// Hide updates of floating widgets from use
|
||||
// Hide updates of floating widgets from user
|
||||
for (auto FloatingWidget : FloatingWidgets)
|
||||
{
|
||||
FloatingWidget->hide();
|
||||
@ -221,7 +221,9 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
|
||||
}
|
||||
|
||||
bool Result = true;
|
||||
#ifdef ADS_DEBUG_PRINT
|
||||
int DockContainers = s.attributes().value("Containers").toInt();
|
||||
#endif
|
||||
ADS_PRINT(DockContainers);
|
||||
int DockContainerCount = 0;
|
||||
while (s.readNextStartElement())
|
||||
@ -262,13 +264,14 @@ void DockManagerPrivate::restoreDockWidgetsOpenState()
|
||||
// toggle view action the next time
|
||||
for (auto DockWidget : DockWidgetsMap)
|
||||
{
|
||||
if (DockWidget->property("dirty").toBool())
|
||||
if (DockWidget->property(internal::DirtyProperty).toBool())
|
||||
{
|
||||
DockWidget->flagAsUnassigned();
|
||||
emit DockWidget->viewToggled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DockWidget->toggleViewInternal(!DockWidget->property("closed").toBool());
|
||||
DockWidget->toggleViewInternal(!DockWidget->property(internal::ClosedProperty).toBool());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -373,6 +373,12 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
|
||||
void CFloatingDockContainer::hideEvent(QHideEvent *event)
|
||||
{
|
||||
Super::hideEvent(event);
|
||||
// Prevent toogleView() events during restore state
|
||||
if (d->DockManager->isRestoringState())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto DockArea : d->DockContainer->openedDockAreas())
|
||||
{
|
||||
for (auto DockWidget : DockArea->openedDockWidgets())
|
||||
|
@ -100,6 +100,8 @@ namespace internal
|
||||
{
|
||||
static const bool RestoreTesting = true;
|
||||
static const bool Restore = false;
|
||||
static const char* const ClosedProperty = "close";
|
||||
static const char* const DirtyProperty = "dirty";
|
||||
|
||||
/**
|
||||
* Replace the from widget in the given splitter with the To widget
|
||||
|
Loading…
Reference in New Issue
Block a user