mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Fix massive widget movement jitter bug
This commit is contained in:
parent
5692d6cf6d
commit
970aeea99f
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent)
|
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QObject* parent)
|
||||||
: QWindow(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
m_appID = appid;
|
m_appID = appid;
|
||||||
|
|
||||||
m_hwnd = (HWND)this->winId();
|
m_hwnd = reinterpret_cast<HWND>(m_window.winId());
|
||||||
Qt::WindowFlags flags = this->flags();
|
Qt::WindowFlags flags = m_window.flags();
|
||||||
this->setWidth(500);
|
m_window.setWidth(500);
|
||||||
this->setHeight(300);
|
m_window.setHeight(300);
|
||||||
this->setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
||||||
|
|
||||||
QFile configTmp;
|
QFile configTmp;
|
||||||
QJsonDocument configJsonDocument;
|
QJsonDocument configJsonDocument;
|
||||||
@ -29,29 +29,23 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScre
|
|||||||
m_project = configJsonDocument.object();
|
m_project = configJsonDocument.object();
|
||||||
QString fullPath = projectPath + "/" + m_project.value("file").toString();
|
QString fullPath = projectPath + "/" + m_project.value("file").toString();
|
||||||
|
|
||||||
m_quickRenderer = QSharedPointer<QQuickView>(new QQuickView(this));
|
m_window.rootContext()->setContextProperty("backend", this);
|
||||||
m_quickRenderer.data()->rootContext()->setContextProperty("backend", this);
|
m_window.setColor(Qt::transparent);
|
||||||
m_quickRenderer.data()->setColor(Qt::transparent);
|
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||||
m_quickRenderer.data()->setWidth(this->width());
|
|
||||||
m_quickRenderer.data()->setHeight(this->height());
|
|
||||||
m_quickRenderer.data()->setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
|
||||||
|
|
||||||
m_quickRenderer.data()->setSource(QUrl("qrc:/main.qml"));
|
m_window.setSource(QUrl("qrc:/main.qml"));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
SetWindowBlur(m_hwnd);
|
SetWindowBlur(m_hwnd);
|
||||||
#endif
|
#endif
|
||||||
show();
|
m_window.show();
|
||||||
m_quickRenderer.data()->show();
|
|
||||||
|
|
||||||
emit setWidgetSource(fullPath);
|
emit setWidgetSource(fullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::setSize(QSize size)
|
void SPWidgetmainwindow::setSize(QSize size)
|
||||||
{
|
{
|
||||||
this->setWidth(size.width());
|
m_window.setWidth(size.width());
|
||||||
this->setHeight(size.height());
|
m_window.setHeight(size.height());
|
||||||
m_quickRenderer.data()->setWidth(size.width());
|
|
||||||
m_quickRenderer.data()->setHeight(size.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::destroyThis()
|
void SPWidgetmainwindow::destroyThis()
|
||||||
@ -68,13 +62,13 @@ void SPWidgetmainwindow::setPos(int xPos, int yPos)
|
|||||||
{
|
{
|
||||||
|
|
||||||
QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y()));
|
QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y()));
|
||||||
int new_x = x() + delta.x();
|
int new_x = m_window.x() + delta.x();
|
||||||
int new_y = y() + delta.y();
|
int new_y = m_window.y() + delta.y();
|
||||||
|
|
||||||
setPosition(QPoint(new_x, new_y));
|
m_window.setPosition(QPoint(new_x, new_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPWidgetmainwindow::setClickPos(const QPoint &clickPos)
|
void SPWidgetmainwindow::setClickPos(const QPoint& clickPos)
|
||||||
{
|
{
|
||||||
m_clickPos = clickPos;
|
m_clickPos = clickPos;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
typedef long HWND;
|
typedef long HWND;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SPWidgetmainwindow : public QWindow {
|
class SPWidgetmainwindow : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent = nullptr);
|
explicit SPWidgetmainwindow(QString projectPath, QString appid, QObject* parent = nullptr);
|
||||||
|
|
||||||
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
|
||||||
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
|
||||||
@ -93,5 +93,6 @@ private:
|
|||||||
HWND m_hwnd;
|
HWND m_hwnd;
|
||||||
QPoint m_clickPos = { 0, 0 };
|
QPoint m_clickPos = { 0, 0 };
|
||||||
|
|
||||||
QSharedPointer<QQuickView> m_quickRenderer;
|
QQuickView m_window;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user