mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-13 16:42:06 +08:00
Properly implemented focusedDockWidgetChanged() signal
This commit is contained in:
parent
d360b4ced2
commit
f90f0b0427
@ -504,6 +504,7 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
|||||||
updateDockWidgetFocusStyle(FocusedDockWidget, false);
|
updateDockWidgetFocusStyle(FocusedDockWidget, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CDockWidget* old = FocusedDockWidget;
|
||||||
if (DockWidget != FocusedDockWidget)
|
if (DockWidget != FocusedDockWidget)
|
||||||
{
|
{
|
||||||
std::cout << "!!!!!!!!!!!! focusedDockWidgetChanged " << (FocusedDockWidget ? FocusedDockWidget->objectName().toStdString() : "-")
|
std::cout << "!!!!!!!!!!!! focusedDockWidgetChanged " << (FocusedDockWidget ? FocusedDockWidget->objectName().toStdString() : "-")
|
||||||
@ -554,6 +555,11 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
|
|||||||
updateFloatingWidgetFocusStyle(FloatingWidget, true);
|
updateFloatingWidgetFocusStyle(FloatingWidget, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (old != DockWidget)
|
||||||
|
{
|
||||||
|
emit _this->focusedDockWidgetChanged(old, DockWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -720,6 +726,10 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
|
|||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (d->FocusedDockWidget)
|
||||||
|
{
|
||||||
|
updateDockWidgetFocusStyle(d->FocusedDockWidget, false);
|
||||||
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1019,6 +1029,10 @@ CIconProvider& CDockManager::iconProvider()
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focusedNow)
|
void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focusedNow)
|
||||||
{
|
{
|
||||||
|
if (isRestoringState())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::cout << "CDockManager::onFocusChanged" << std::endl;
|
std::cout << "CDockManager::onFocusChanged" << std::endl;
|
||||||
Q_UNUSED(focusedOld)
|
Q_UNUSED(focusedOld)
|
||||||
if (!focusedNow)
|
if (!focusedNow)
|
||||||
@ -1060,6 +1074,11 @@ void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focus
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockManager::onFocusedDockAreaViewToggled(bool Open)
|
void CDockManager::onFocusedDockAreaViewToggled(bool Open)
|
||||||
{
|
{
|
||||||
|
if (isRestoringState())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(sender());
|
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(sender());
|
||||||
if (!DockArea || Open)
|
if (!DockArea || Open)
|
||||||
{
|
{
|
||||||
@ -1079,6 +1098,10 @@ void CDockManager::onFocusedDockAreaViewToggled(bool Open)
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockManager::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
|
void CDockManager::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
|
||||||
{
|
{
|
||||||
|
if (isRestoringState())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::cout << "\n\nCDockManager::notifyWidgetDrop" << std::endl;
|
std::cout << "\n\nCDockManager::notifyWidgetDrop" << std::endl;
|
||||||
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
|
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
|
||||||
if (DockWidget)
|
if (DockWidget)
|
||||||
@ -1104,7 +1127,7 @@ void CDockManager::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget)
|
|||||||
void CDockManager::notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget)
|
void CDockManager::notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget)
|
||||||
{
|
{
|
||||||
std::cout << "\n\nCDockManager::notifyFloatingWidgetDrop" << std::endl;
|
std::cout << "\n\nCDockManager::notifyFloatingWidgetDrop" << std::endl;
|
||||||
if (!FloatingWidget)
|
if (!FloatingWidget || isRestoringState())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -517,6 +517,13 @@ signals:
|
|||||||
* docking system but it is not deleted yet.
|
* docking system but it is not deleted yet.
|
||||||
*/
|
*/
|
||||||
void dockWidgetRemoved(CDockWidget* DockWidget);
|
void dockWidgetRemoved(CDockWidget* DockWidget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is emitted if the focused dock widget changed.
|
||||||
|
* Both old and now can be nullptr.
|
||||||
|
* The focused dock widget is the one that is highlighted in the GUI
|
||||||
|
*/
|
||||||
|
void focusedDockWidgetChanged(CDockWidget* old, CDockWidget* now);
|
||||||
}; // class DockManager
|
}; // class DockManager
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -466,7 +466,31 @@ void CDockWidgetTab::setActiveTab(bool active)
|
|||||||
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton);
|
||||||
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
|
||||||
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
||||||
|
|
||||||
|
/*if (d->IsActiveTab == active)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling) && !d->DockWidget->dockManager()->isRestoringState())
|
||||||
|
{
|
||||||
|
bool UpdateFocusStyle = false;
|
||||||
|
if (active && !hasFocus())
|
||||||
|
{
|
||||||
|
setFocus(Qt::OtherFocusReason);
|
||||||
|
UpdateFocusStyle = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (d->IsActiveTab == active)
|
if (d->IsActiveTab == active)
|
||||||
|
{
|
||||||
|
if (UpdateFocusStyle)
|
||||||
|
{
|
||||||
|
updateStyle();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (d->IsActiveTab == active)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user