qtquick: Minor refactoring

Removed some hardcoded QLineEdit casts, that code is now generic.
This commit is contained in:
Sergio Martins
2020-11-27 18:47:03 +00:00
parent 8356bb0c3c
commit 953219f6f3
2 changed files with 24 additions and 11 deletions

View File

@@ -19,13 +19,10 @@
#include <QEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>
#include <QWindow>
#include <QAbstractButton>
#include <QLineEdit>
#if defined(Q_OS_WIN)
# include <QtGui/private/qhighdpiscaling_p.h>
@@ -252,14 +249,10 @@ bool WidgetResizeHandler::handleWindowsNativeEvent(FloatingWindow *w, const QByt
*result = HTRIGHT;
} else {
const QPoint globalPosQt = QHighDpi::fromNativePixels(QPoint(xPos, yPos), w->windowHandle());
const QRect htCaptionRect = w->dragRect(); // The rect on which we allow for Windows to do Ba native drag
const QRect htCaptionRect = w->dragRect(); // The rect on which we allow for Windows to do a native drag
if (globalPosQt.y() >= htCaptionRect.top() && globalPosQt.y() <= htCaptionRect.bottom() && globalPosQt.x() >= htCaptionRect.left() && globalPosQt.x() <= htCaptionRect.right()) {
WidgetType *hoveredWidget = KDDockWidgets::widgetAt(globalPosQt);
if (!qobject_cast<QAbstractButton*>(hoveredWidget) &&
!qobject_cast<QLineEdit*>(hoveredWidget)) { // User might have a line edit on the toolbar. TODO: Not so elegant fix, we should make the user's tabbar implement some virtual method...
// User clicked on the title bar, let's allow it, so we get Aero-Snap.
*result = HTCAPTION;
if (!KDDockWidgets::inDisallowDragWidget(globalPosQt)) { // Just makes sure the mouse isn't over the close button, we don't allow drag in that case.
*result = HTCAPTION;
}
}
}