mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2025-02-01 04:51:48 +01:00
Fix widget moving jitter thanks to bardao https://stackoverflow.com/a/55367441/12619313
This commit is contained in:
parent
1c3d89cc2f
commit
369b01ac9b
@ -83,15 +83,21 @@ Item {
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
property var clickPos
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onPressed: {
|
||||
Widget.setClickPos(Qt.point(mouse.x, mouse.y))
|
||||
clickPos = {
|
||||
"x": mouse.x,
|
||||
"y": mouse.y
|
||||
}
|
||||
}
|
||||
|
||||
onPositionChanged: {
|
||||
if (mouseArea.pressed)
|
||||
Widget.setPos(mouse.x, mouse.y)
|
||||
if (mouseArea.pressed) {
|
||||
Widget.setPos(Widget.cursorPos().x - clickPos.x,
|
||||
Widget.cursorPos().y - clickPos.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,7 @@ void WidgetWindow::messageReceived(QString key, QString value)
|
||||
|
||||
void WidgetWindow::setPos(int xPos, int yPos)
|
||||
{
|
||||
|
||||
QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y()));
|
||||
int new_x = m_window.x() + delta.x();
|
||||
int new_y = m_window.y() + delta.y();
|
||||
|
||||
m_window.setPosition(QPoint(new_x, new_y));
|
||||
m_window.setPosition({ xPos, yPos });
|
||||
}
|
||||
|
||||
void WidgetWindow::setClickPos(const QPoint& clickPos)
|
||||
|
@ -102,6 +102,7 @@ public slots:
|
||||
emit sourcePathChanged(m_sourcePath);
|
||||
}
|
||||
|
||||
QPointF cursorPos() { return QCursor::pos(); }
|
||||
#ifdef Q_OS_WIN
|
||||
void setWindowBlur(unsigned int style = 3);
|
||||
#endif
|
||||
@ -114,6 +115,7 @@ private:
|
||||
|
||||
QJsonObject m_project;
|
||||
QPoint m_clickPos = { 0, 0 };
|
||||
QPoint m_lastPos = { 0, 0 };
|
||||
QQuickView m_window;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
Loading…
x
Reference in New Issue
Block a user