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 00000000..3ef73675
Binary files /dev/null and b/ScreenPlayWidget/assets/image/noisy-texture-3.png differ
diff --git a/ScreenPlayWidget/main.qml b/ScreenPlayWidget/main.qml
index 928e4639..731d0caf 100644
--- a/ScreenPlayWidget/main.qml
+++ b/ScreenPlayWidget/main.qml
@@ -1,14 +1,42 @@
import QtQuick 2.9
import net.aimber.screenplaysdk 1.0
-import QtQuick.Window 2.3
import QtQuick.Controls 2.3
-Window {
+Item {
id: mainWindow
visible: true
- width: 250
- height: 250
- flags: Qt.SplashScreen | Qt.ToolTip | Qt.SplashScreen
+ anchors.fill: parent
+
+ Rectangle {
+ id:bgColor
+ anchors.fill: parent
+ color: "white"
+ //color: "#1A1F22"
+ opacity: .15
+ }
+
+ Image {
+ id: bg
+ source: "qrc:/assets/image/noisy-texture-3.png"
+ anchors.fill: parent
+ opacity: .05
+ fillMode: Image.Tile
+ }
+
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+
+ onPressed: {
+ backend.setClickPos(Qt.point(mouse.x, mouse.y))
+ }
+
+ onPositionChanged: {
+ backend.setPos(mouse.x, mouse.y)
+ }
+
+ }
ScreenPlaySDK {
id: spSDK
@@ -53,48 +81,4 @@ Window {
}
}
}
-
- Connections{
- target: loader.item
- ignoreUnknownSignals: true
- onSizeChanged:{
- print(size)
- mainWindow.width = size.width
- mainWindow.height = size.height
- }
- }
-
- MouseArea {
- property point clickPos: "1,1"
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- z:99
-
- onPressed: {
- clickPos = Qt.point(mouse.x, mouse.y)
- }
-
- onPositionChanged: {
- var delta = Qt.point(mouse.x - clickPos.x, mouse.y - clickPos.y)
- var new_x = mainWindow.x + delta.x
- var new_y = mainWindow.y + delta.y
- mainWindow.x = new_x
- mainWindow.y = new_y
- }
-
- onClicked: {
- if (mouse.button === Qt.RightButton) {
- contextMenu.popup()
- }
- }
- }
- Menu {
- id: contextMenu
- MenuItem {
- text: qsTr("Close")
- onClicked: {
- Qt.quit();
- }
- }
- }
}
diff --git a/ScreenPlayWidget/src/spwidgetmainwindow.cpp b/ScreenPlayWidget/src/spwidgetmainwindow.cpp
index 234fb47a..0338cc58 100644
--- a/ScreenPlayWidget/src/spwidgetmainwindow.cpp
+++ b/ScreenPlayWidget/src/spwidgetmainwindow.cpp
@@ -3,8 +3,15 @@
SPWidgetmainwindow::SPWidgetmainwindow(QString projectPath, QString appid, QScreen* parent)
: QWindow(parent)
{
+
m_appID = appid;
+ m_hwnd = (HWND)this->winId();
+ 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;
};