From 92c09aa2bd64fdd00dc7dc555c8d66c0b6df1bef Mon Sep 17 00:00:00 2001 From: kelteseth Date: Fri, 26 Oct 2018 19:28:40 +0200 Subject: [PATCH] Add nice blurry background on windows 10 --- ScreenPlayWidget/SPWidgetResources.qrc | 1 + ScreenPlayWidget/ScreenPlayWidget.pro | 4 +- .../assets/image/noisy-texture-3.png | Bin 0 -> 9172 bytes ScreenPlayWidget/main.qml | 82 +++++++----------- ScreenPlayWidget/src/spwidgetmainwindow.cpp | 82 +++++++++++++++++- ScreenPlayWidget/src/spwidgetmainwindow.h | 16 +++- 6 files changed, 128 insertions(+), 57 deletions(-) create mode 100644 ScreenPlayWidget/assets/image/noisy-texture-3.png diff --git a/ScreenPlayWidget/SPWidgetResources.qrc b/ScreenPlayWidget/SPWidgetResources.qrc index 5f6483ac..466227d4 100644 --- a/ScreenPlayWidget/SPWidgetResources.qrc +++ b/ScreenPlayWidget/SPWidgetResources.qrc @@ -1,5 +1,6 @@ main.qml + assets/image/noisy-texture-3.png diff --git a/ScreenPlayWidget/ScreenPlayWidget.pro b/ScreenPlayWidget/ScreenPlayWidget.pro index c448b48b..76b3a4ed 100644 --- a/ScreenPlayWidget/ScreenPlayWidget.pro +++ b/ScreenPlayWidget/ScreenPlayWidget.pro @@ -1,5 +1,5 @@ -QT += quick -CONFIG += c++11 +QT += quick qml quickcontrols2 core charts widgets gui +CONFIG += c++17 CONFIG += qtquickcompiler # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings diff --git a/ScreenPlayWidget/assets/image/noisy-texture-3.png b/ScreenPlayWidget/assets/image/noisy-texture-3.png new file mode 100644 index 0000000000000000000000000000000000000000..3ef73675148575efb61b1adc02939822499820a8 GIT binary patch literal 9172 zcmWk!bzDe$LNQiXD7^4x8*ytQcNq0+22m+(KySoH_Lr_pkK$_750YQmTijpFN z?|uK+c0Zpz_nhbX#&gcyPLiR%1_c=l84eB(g_b4^0em|B|3yLsy!(F3Gr_^(z|n%K zn1q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z?+sPsAZDV=q~|V3$XZrlF+MCq@4@BlRwWHzgTS~s9=DlKhZux^bzCs4G*^-S)go+N zEKHC&?W|rG8R*+>31gN+pJS=nW&~Edzh|)J6qXA&ER-BHxFq_Uu;4XS|MXRFao)i#P8UBFJPM06YKE=(Nys_nKhNS#qc+ae3=YWJhxy=KCr6;Z3u@ilgYgS`J_qar7kv_M3WYlBg^6w^> zIRg>@O>f0J2v`uugHZI&vd146Z0Bbpl_#e_hJ^utO5Y=yXH7CYZ-TJ&G|sr(`>$?e zkrRr7!c9pYiTjvN*_Pw`yL9^_d9x3uyLFu0&P%d(li#46PfgP5>cLW-teul&KdT<9 zmoR4qW@X2B#?ag$L8?JByiRXvaO(FJzr5bkV);>uVhzBze(`xmhqmwGFQ_O!*B%$GS< zI~D@q@XB74EQ3Rr`oEkS_vmfL7faw8Tm9D*^&j2kHSkrv1BUTG9Z~tegB6dH*619e ztiOyh$+`!CH8@y7+Lgm$sM~xREzzc_L(L~sKO1{k+>Q=!@B~N4{+2vQ5a)ff=Mzvq zyy>rCMQEzd%f)AvH4^Yd#>`%~$IS+u893kl?qoQ3utJHOg2Q;}&2fEYn=B*a63+s8 zBOV>zEYxm=QNHv=O4t!zszw?`|Ek{hpHP(o9V$cBS4cM=WwinId(); + Qt::WindowFlags flags = this->flags(); + this->setWidth(500); + this->setHeight(300); + this->setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen); + QFile configTmp; QJsonDocument configJsonDocument; QJsonParseError parseError; @@ -20,11 +27,80 @@ SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScre m_project = configJsonDocument.object(); QString fullPath = projectPath + "/" + m_project.value("file").toString(); - m_quickRenderer = QSharedPointer(new QQmlApplicationEngine()); + m_quickRenderer = QSharedPointer(new QQuickView(this)); m_quickRenderer.data()->rootContext()->setContextProperty("backend", this); - m_quickRenderer.data()->load(QUrl("qrc:/main.qml")); + m_quickRenderer.data()->setColor(Qt::transparent); + 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")); +#ifdef Q_OS_WIN + SetWindowBlur(m_hwnd); +#endif + show(); + m_quickRenderer.data()->show(); emit setWidgetSource(fullPath); - } +void SPWidgetmainwindow::setSize(QSize size) +{ + this->setWidth(size.width()); + this->setHeight(size.height()); + m_quickRenderer.data()->setWidth(size.width()); + m_quickRenderer.data()->setHeight(size.height()); +} + +void SPWidgetmainwindow::setPos(int xPos, int yPos) +{ + + QPoint delta((xPos - m_clickPos.x()), (yPos - m_clickPos.y())); + int new_x = x() + delta.x(); + int new_y = y() + delta.y(); + + setPosition(QPoint(new_x, new_y)); +} + +void SPWidgetmainwindow::setClickPos(const QPoint &clickPos) +{ + m_clickPos = clickPos; +} + +void SPWidgetmainwindow::SetWindowBlur(HWND hWnd) +{ +#ifdef Q_OS_WIN + + const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll")); + if (hModule) { + struct ACCENTPOLICY { + int nAccentState; + int nFlags; + int nColor; + int nAnimationId; + }; + struct WINCOMPATTRDATA { + int nAttribute; + PVOID pData; + ULONG ulDataSize; + }; + enum class Accent { + DISABLED = 0, + GRADIENT = 1, + TRANSPARENTGRADIENT = 2, + BLURBEHIND = 3, + ACRYLIC = 4, + INVALID = 5 + }; + typedef BOOL(WINAPI * pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*); + const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute"); + if (SetWindowCompositionAttribute) { + ACCENTPOLICY policy = { (int)Accent::BLURBEHIND, 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3... + WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19 + SetWindowCompositionAttribute(hWnd, &data); + } + FreeLibrary(hModule); + } + +#endif +} diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.h b/ScreenPlayWidget/src/spwidgetmainwindow.h index 41f91c4f..1872ff1b 100644 --- a/ScreenPlayWidget/src/spwidgetmainwindow.h +++ b/ScreenPlayWidget/src/spwidgetmainwindow.h @@ -6,12 +6,15 @@ #include #include #include +#include #include -#include +#include +#include +#include #include #include #include -#include +#include class SPWidgetmainwindow : public QWindow { Q_OBJECT @@ -45,6 +48,7 @@ signals: void setWidgetSource(QString source); public slots: + void setSize(QSize size); void setAppID(QString appID) { if (m_appID == appID) @@ -70,11 +74,17 @@ public slots: emit projectConfigChanged(m_projectConfig); } + void setPos(int xPos, int yPos); + void setClickPos(const QPoint& clickPos); + void SetWindowBlur(HWND hWnd); + private: QString m_appID; QString m_type = "qmlWidget"; QString m_projectConfig; QJsonObject m_project; + HWND m_hwnd; + QPoint m_clickPos = { 0, 0 }; - QSharedPointer m_quickRenderer = nullptr; + QSharedPointer m_quickRenderer; };