Disabled setFocus in CDockWidget::setActiveTab

This commit is contained in:
Uwe Kindler 2020-06-03 19:49:57 +02:00
parent adb72737e8
commit a3e979a8ad
4 changed files with 26 additions and 10 deletions

View File

@ -571,6 +571,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
// dock widget. // dock widget.
// CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true); // CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true);
//CDockManager::setConfigFlag(CDockManager::AlwaysShowTabs, true);
CDockManager::setConfigFlag(CDockManager::FocusStyling, true); CDockManager::setConfigFlag(CDockManager::FocusStyling, true);
// Now create the dock manager and its content // Now create the dock manager and its content
@ -664,7 +665,7 @@ void CMainWindow::onViewVisibilityChanged(bool Visible)
return; return;
} }
qDebug() << DockWidget->objectName() << " visibilityChanged(" << Visible << ")"; //qDebug() << DockWidget->objectName() << " visibilityChanged(" << Visible << ")";
} }

View File

@ -267,11 +267,16 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
} }
ADS_PRINT(s.attributes().value("UserVersion")); ADS_PRINT(s.attributes().value("UserVersion"));
// Older files do not support UserVersion so we skip this if the file does
// not have this attribute
if (!s.attributes().value("UserVersion").isEmpty())
{
v = s.attributes().value("UserVersion").toInt(&ok); v = s.attributes().value("UserVersion").toInt(&ok);
if (!ok || v != version) if (!ok || v != version)
{ {
return false; return false;
} }
}
s.setFileVersion(v); s.setFileVersion(v);
bool Result = true; bool Result = true;
@ -498,6 +503,12 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
{ {
updateDockWidgetFocusStyle(FocusedDockWidget, false); updateDockWidgetFocusStyle(FocusedDockWidget, false);
} }
if (DockWidget != FocusedDockWidget)
{
std::cout << "!!!!!!!!!!!! focusedDockWidgetChanged " << (FocusedDockWidget ? FocusedDockWidget->objectName().toStdString() : "-")
<< " -> " << (DockWidget ? DockWidget->objectName().toStdString() : "-") << std::endl;
}
FocusedDockWidget = DockWidget; FocusedDockWidget = DockWidget;
updateDockWidgetFocusStyle(FocusedDockWidget, true); updateDockWidgetFocusStyle(FocusedDockWidget, true);
NewFocusedDockArea = FocusedDockWidget->dockAreaWidget(); NewFocusedDockArea = FocusedDockWidget->dockAreaWidget();
@ -567,7 +578,7 @@ CDockManager::CDockManager(QWidget *parent) :
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling)) if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
{ {
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)),
this, SLOT(onFocusChanged(QWidget*, QWidget*))); this, SLOT(onApplicationFocusChanged(QWidget*, QWidget*)));
} }
} }
@ -1006,7 +1017,7 @@ CIconProvider& CDockManager::iconProvider()
//=========================================================================== //===========================================================================
void CDockManager::onFocusChanged(QWidget* focusedOld, QWidget* focusedNow) void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focusedNow)
{ {
std::cout << "CDockManager::onFocusChanged" << std::endl; std::cout << "CDockManager::onFocusChanged" << std::endl;
Q_UNUSED(focusedOld) Q_UNUSED(focusedOld)
@ -1033,8 +1044,10 @@ void CDockManager::onFocusChanged(QWidget* focusedOld, QWidget* focusedNow)
return; return;
} }
#else #else
if (!DockWidget || !DockWidget->tabWidget()->isVisible()) if (!DockWidget || DockWidget->tabWidget()->isHidden())
{ {
std::cout << "!DockWidget || !DockWidget->tabWidget()->isVisible() " << (DockWidget ? DockWidget->objectName().toStdString() : "0") << std::endl;
std::cout << "DockWidget->tabWidget()->isHidden() " << (DockWidget ? DockWidget->tabWidget()->isHidden() : false) << std::endl;
return; return;
} }
#endif #endif
@ -1066,9 +1079,11 @@ void CDockManager::onFocusedDockAreaViewToggled(bool Open)
//=========================================================================== //===========================================================================
void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget) void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget)
{ {
std::cout << "CDockManager::emitWidgetDroppedSignals" << std::endl;
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget); CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
if (DockWidget) if (DockWidget)
{ {
std::cout << "CDockManager::setWidgetFocus " << DockWidget->objectName().toStdString() << std::endl;
CDockManager::setWidgetFocus(DockWidget->tabWidget()); CDockManager::setWidgetFocus(DockWidget->tabWidget());
emit dockWidgetDropped(DockWidget); emit dockWidgetDropped(DockWidget);
return; return;

View File

@ -85,7 +85,7 @@ private:
friend class CDockAreaTitleBar; friend class CDockAreaTitleBar;
private slots: private slots:
void onFocusChanged(QWidget *old, QWidget *now); void onApplicationFocusChanged(QWidget *old, QWidget *now);
void onFocusedDockAreaViewToggled(bool Open); void onFocusedDockAreaViewToggled(bool Open);
protected: protected:

View File

@ -472,7 +472,7 @@ void CDockWidgetTab::setActiveTab(bool active)
bool UpdateFocusStyle = false; bool UpdateFocusStyle = false;
if (active && !hasFocus()) if (active && !hasFocus())
{ {
setFocus(Qt::OtherFocusReason); //setFocus(Qt::OtherFocusReason);
UpdateFocusStyle = true; UpdateFocusStyle = true;
} }