Skip to content

Commit 9b56ca0

Browse files
Changes to work around new QT issues in non client area code that comes with the new Qt version 5.12.2
1 parent 49a7682 commit 9b56ca0

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/FloatingDockContainer.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,10 @@ void CFloatingDockContainer::closeEvent(QCloseEvent *event)
320320
// https://bugreports.qt.io/browse/QTBUG-73295
321321
// The following code is a workaround for Qt versions > 5.9.2 that seems
322322
// to work
323-
#if (QT_VERSION > 0x050902)
323+
// Starting from Qt version 5.12.2 this seems to work again. But
324+
// now the QEvent::NonClientAreaMouseButtonPress function returns always
325+
// Qt::RightButton even if the left button was pressed
326+
#if (QT_VERSION > QT_VERSION_CHECK(5, 9, 2) && QT_VERSION < QT_VERSION_CHECK(5, 12, 2))
324327
event->ignore();
325328
this->hide();
326329
#else
@@ -352,13 +355,6 @@ void CFloatingDockContainer::hideEvent(QHideEvent *event)
352355
void CFloatingDockContainer::showEvent(QShowEvent *event)
353356
{
354357
Super::showEvent(event);
355-
/*for (auto DockArea : d->DockContainer->openedDockAreas())
356-
{
357-
for (auto DockWidget : DockArea->openedDockWidgets())
358-
{
359-
DockWidget->setToggleViewActionChecked(true);
360-
}
361-
}*/
362358
}
363359

364360

@@ -368,11 +364,28 @@ bool CFloatingDockContainer::event(QEvent *e)
368364
switch (d->DraggingState)
369365
{
370366
case DraggingInactive:
371-
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons() == Qt::LeftButton)
367+
{
368+
// Normally we would check here, if the left mouse button is pressed.
369+
// But from QT version 5.12.2 on the mouse events from
370+
// QEvent::NonClientAreaMouseButtonPress return the wrong mouse button
371+
// The event always returns Qt::RightButton even if the left button
372+
// is clicked.
373+
// It is really great to work around the whole NonClientMouseArea
374+
// bugs
375+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
376+
if (e->type() == QEvent::NonClientAreaMouseButtonPress /*&& QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/)
377+
{
378+
qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type();
379+
d->setState(DraggingMousePressed);
380+
}
381+
#else
382+
if (e->type() == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons().testFlag(Qt::LeftButton))
372383
{
373384
qDebug() << "FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type();
374385
d->setState(DraggingMousePressed);
375386
}
387+
#endif
388+
}
376389
break;
377390

378391
case DraggingMousePressed:

0 commit comments

Comments
 (0)