Skip to content

Commit 34cc91a

Browse files
Fixed #527 - updateDockWidgetFocusStyle() function error
1 parent 36cdf4a commit 34cc91a

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

src/DockFocusController.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct DockFocusControllerPrivate
4949
#endif
5050
CDockManager* DockManager;
5151
bool ForceFocusChangedSignal = false;
52+
bool TabPressed = false;
5253

5354
/**
5455
* Private data constructor
@@ -267,7 +268,9 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
267268
{
268269
Q_UNUSED(focusedOld);
269270

270-
if (d->DockManager->isRestoringState())
271+
// Ignore focus changes if we are restoring state, or if user clicked
272+
// a tab wich in turn caused the focus change
273+
if (d->DockManager->isRestoringState() || d->TabPressed)
271274
{
272275
return;
273276
}
@@ -418,6 +421,12 @@ CDockWidget* CDockFocusController::focusedDockWidget() const
418421
return d->FocusedDockWidget.data();
419422
}
420423

424+
425+
//==========================================================================
426+
void CDockFocusController::setDockWidgetTabPressed(bool Value)
427+
{
428+
d->TabPressed = Value;
429+
}
421430
} // namespace ads
422431

423432
//---------------------------------------------------------------------------

src/DockFocusController.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ private Q_SLOTS:
8080
*/
8181
void clearDockWidgetFocus(CDockWidget* dockWidget);
8282

83+
/**
84+
* Notifies the dock focus controller, that a the mouse is pressed or
85+
* released
86+
*/
87+
void setDockWidgetTabPressed(bool Value);
88+
8389
public Q_SLOTS:
8490
/**
8591
* Request a focus change to the given dock widget

src/DockWidgetTab.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct DockWidgetTabPrivate
7979
QSpacerItem* IconTextSpacer;
8080
QPoint TabDragStartPosition;
8181
QSize IconSize;
82+
bool MousePressed = false;
8283

8384
/**
8485
* Private data constructor
@@ -372,10 +373,12 @@ void CDockWidgetTab::mousePressEvent(QMouseEvent* ev)
372373
if (ev->button() == Qt::LeftButton)
373374
{
374375
ev->accept();
376+
d->MousePressed = true;
375377
d->saveDragStartMousePosition(internal::globalPositionOf(ev));
376378
d->DragState = DraggingMousePressed;
377379
if (CDockManager::testConfigFlag(CDockManager::FocusHighlighting))
378380
{
381+
d->focusController()->setDockWidgetTabPressed(true);
379382
d->focusController()->setDockWidgetTabFocused(this);
380383
}
381384
Q_EMIT clicked();
@@ -391,6 +394,7 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
391394
{
392395
if (ev->button() == Qt::LeftButton)
393396
{
397+
d->MousePressed = false;
394398
auto CurrentDragState = d->DragState;
395399
d->GlobalDragStartMousePosition = QPoint();
396400
d->DragStartMousePosition = QPoint();
@@ -412,7 +416,9 @@ void CDockWidgetTab::mouseReleaseEvent(QMouseEvent* ev)
412416
d->FloatingWidget->finishDragging();
413417
break;
414418

415-
default:; // do nothing
419+
default:
420+
d->focusController()->setDockWidgetTabPressed(false);
421+
break; // do nothing
416422
}
417423
}
418424
else if (ev->button() == Qt::MiddleButton)
@@ -802,6 +808,7 @@ void CDockWidgetTab::setIconSize(const QSize& Size)
802808
d->IconSize = Size;
803809
d->updateIcon();
804810
}
811+
805812
} // namespace ads
806813
//---------------------------------------------------------------------------
807814
// EOF DockWidgetTab.cpp

src/DockWidgetTab.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ private Q_SLOTS:
178178
*/
179179
void setIconSize(const QSize& Size);
180180

181+
/**
182+
* Returns true, if the tab has been clicked and the mouse is currently
183+
* pressed.
184+
*/
185+
bool mousePressed() const;
186+
181187
public Q_SLOTS:
182188
virtual void setVisible(bool visible) override;
183189

0 commit comments

Comments
 (0)