Fixed #527 - updateDockWidgetFocusStyle() function error

This commit is contained in:
Uwe Kindler 2023-06-23 21:06:52 +02:00
parent 36cdf4a252
commit 34cc91a9af
4 changed files with 30 additions and 2 deletions

View File

@ -49,6 +49,7 @@ struct DockFocusControllerPrivate
#endif
CDockManager* DockManager;
bool ForceFocusChangedSignal = false;
bool TabPressed = false;
/**
* Private data constructor
@ -267,7 +268,9 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
{
Q_UNUSED(focusedOld);
if (d->DockManager->isRestoringState())
// Ignore focus changes if we are restoring state, or if user clicked
// a tab wich in turn caused the focus change
if (d->DockManager->isRestoringState() || d->TabPressed)
{
return;
}
@ -418,6 +421,12 @@ CDockWidget* CDockFocusController::focusedDockWidget() const
return d->FocusedDockWidget.data();
}
//==========================================================================
void CDockFocusController::setDockWidgetTabPressed(bool Value)
{
d->TabPressed = Value;
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@ -80,6 +80,12 @@ public:
*/
void clearDockWidgetFocus(CDockWidget* dockWidget);
/**
* Notifies the dock focus controller, that a the mouse is pressed or
* released
*/
void setDockWidgetTabPressed(bool Value);
public Q_SLOTS:
/**
* Request a focus change to the given dock widget

View File

@ -79,6 +79,7 @@ struct DockWidgetTabPrivate
QSpacerItem* IconTextSpacer;
QPoint TabDragStartPosition;
QSize IconSize;
bool MousePressed = false;
/**
* Private data constructor
@ -372,10 +373,12 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
if (ev->button() == Qt::LeftButton)
{
ev->accept();
d->MousePressed = true;
d->saveDragStartMousePosition(internal::globalPositionOf(ev));
d->DragState = DraggingMousePressed;
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
{
d->focusController()->setDockWidgetTabPressed(true);
d->focusController()->setDockWidgetTabFocused(this);
}
Q_EMIT clicked();
@ -391,6 +394,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
{
if (ev->button() == Qt::LeftButton)
{
d->MousePressed = false;
auto CurrentDragState = d->DragState;
d->GlobalDragStartMousePosition = QPoint();
d->DragStartMousePosition = QPoint();
@ -412,7 +416,9 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
d->FloatingWidget->finishDragging();
break;
default:; // do nothing
default:
d->focusController()->setDockWidgetTabPressed(false);
break; // do nothing
}
}
else if (ev->button() == Qt::MiddleButton)
@ -802,6 +808,7 @@ void CDockWidgetTab::setIconSize(const QSize& Size)
d->IconSize = Size;
d->updateIcon();
}
} // namespace ads
//---------------------------------------------------------------------------
// EOF DockWidgetTab.cpp

View File

@ -178,6 +178,12 @@ public:
*/
void setIconSize(const QSize& Size);
/**
* Returns true, if the tab has been clicked and the mouse is currently
* pressed.
*/
bool mousePressed() const;
public Q_SLOTS:
virtual void setVisible(bool visible) override;