Restore QGuiApplication::setOverrideCursor usage
QWindow::setCursor doesn't work as expected...
This commit is contained in:
parent
bcc333c2e1
commit
76457c1e52
|
@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_calls.h" // st::callShadow
|
#include "styles/style_calls.h" // st::callShadow
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -76,7 +77,7 @@ TitleWidgetQt::TitleWidgetQt(QWidget *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleWidgetQt::~TitleWidgetQt() {
|
TitleWidgetQt::~TitleWidgetQt() {
|
||||||
window()->windowHandle()->unsetCursor();
|
restoreCursor();
|
||||||
|
|
||||||
if (!_windowWasFrameless) {
|
if (!_windowWasFrameless) {
|
||||||
toggleFramelessWindow(false);
|
toggleFramelessWindow(false);
|
||||||
|
@ -259,6 +260,10 @@ bool TitleWidgetQt::eventFilter(QObject *obj, QEvent *e) {
|
||||||
return startResize(edges);
|
return startResize(edges);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (e->type() == QEvent::Leave) {
|
||||||
|
if (obj->isWidgetType() && window() == static_cast<QWidget*>(obj)) {
|
||||||
|
restoreCursor();
|
||||||
|
}
|
||||||
} else if (e->type() == QEvent::Move
|
} else if (e->type() == QEvent::Move
|
||||||
|| e->type() == QEvent::Resize) {
|
|| e->type() == QEvent::Resize) {
|
||||||
if (obj->isWidgetType() && window() == static_cast<QWidget*>(obj)) {
|
if (obj->isWidgetType() && window() == static_cast<QWidget*>(obj)) {
|
||||||
|
@ -365,18 +370,35 @@ Qt::Edges TitleWidgetQt::edgesFromPos(const QPoint &pos) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleWidgetQt::updateCursor(Qt::Edges edges) {
|
void TitleWidgetQt::updateCursor(Qt::Edges edges) {
|
||||||
|
if (!edges) {
|
||||||
|
restoreCursor();
|
||||||
|
return;
|
||||||
|
} else if (!QGuiApplication::overrideCursor()) {
|
||||||
|
_cursorOverriden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_cursorOverriden) {
|
||||||
|
_cursorOverriden = true;
|
||||||
|
QGuiApplication::setOverrideCursor(QCursor());
|
||||||
|
}
|
||||||
|
|
||||||
if (((edges & Qt::LeftEdge) && (edges & Qt::TopEdge))
|
if (((edges & Qt::LeftEdge) && (edges & Qt::TopEdge))
|
||||||
|| ((edges & Qt::RightEdge) && (edges & Qt::BottomEdge))) {
|
|| ((edges & Qt::RightEdge) && (edges & Qt::BottomEdge))) {
|
||||||
window()->windowHandle()->setCursor(QCursor(Qt::SizeFDiagCursor));
|
QGuiApplication::changeOverrideCursor(QCursor(Qt::SizeFDiagCursor));
|
||||||
} else if (((edges & Qt::LeftEdge) && (edges & Qt::BottomEdge))
|
} else if (((edges & Qt::LeftEdge) && (edges & Qt::BottomEdge))
|
||||||
|| ((edges & Qt::RightEdge) && (edges & Qt::TopEdge))) {
|
|| ((edges & Qt::RightEdge) && (edges & Qt::TopEdge))) {
|
||||||
window()->windowHandle()->setCursor(QCursor(Qt::SizeBDiagCursor));
|
QGuiApplication::changeOverrideCursor(QCursor(Qt::SizeBDiagCursor));
|
||||||
} else if ((edges & Qt::LeftEdge) || (edges & Qt::RightEdge)) {
|
} else if ((edges & Qt::LeftEdge) || (edges & Qt::RightEdge)) {
|
||||||
window()->windowHandle()->setCursor(QCursor(Qt::SizeHorCursor));
|
QGuiApplication::changeOverrideCursor(QCursor(Qt::SizeHorCursor));
|
||||||
} else if ((edges & Qt::TopEdge) || (edges & Qt::BottomEdge)) {
|
} else if ((edges & Qt::TopEdge) || (edges & Qt::BottomEdge)) {
|
||||||
window()->windowHandle()->setCursor(QCursor(Qt::SizeVerCursor));
|
QGuiApplication::changeOverrideCursor(QCursor(Qt::SizeVerCursor));
|
||||||
} else {
|
}
|
||||||
window()->windowHandle()->unsetCursor();
|
}
|
||||||
|
|
||||||
|
void TitleWidgetQt::restoreCursor() {
|
||||||
|
if (_cursorOverriden) {
|
||||||
|
_cursorOverriden = false;
|
||||||
|
QGuiApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
QMargins resizeArea() const;
|
QMargins resizeArea() const;
|
||||||
Qt::Edges edgesFromPos(const QPoint &pos) const;
|
Qt::Edges edgesFromPos(const QPoint &pos) const;
|
||||||
void updateCursor(Qt::Edges edges);
|
void updateCursor(Qt::Edges edges);
|
||||||
|
void restoreCursor();
|
||||||
bool startMove();
|
bool startMove();
|
||||||
bool startResize(Qt::Edges edges);
|
bool startResize(Qt::Edges edges);
|
||||||
|
|
||||||
|
@ -66,6 +67,7 @@ private:
|
||||||
bool _maximizedState = false;
|
bool _maximizedState = false;
|
||||||
bool _activeState = false;
|
bool _activeState = false;
|
||||||
bool _windowWasFrameless = false;
|
bool _windowWasFrameless = false;
|
||||||
|
bool _cursorOverriden = false;
|
||||||
bool _extentsSet = false;
|
bool _extentsSet = false;
|
||||||
bool _mousePressed = false;
|
bool _mousePressed = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue