mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-18 16:32:33 +02:00
Add a way easier way to debug wallpaper and widgets
This commit is contained in:
parent
9b606a79bc
commit
6b370d57ba
@ -1,6 +1,7 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>main.qml</file>
|
|
||||||
<file>assets/image/noisy-texture-3.png</file>
|
<file>assets/image/noisy-texture-3.png</file>
|
||||||
|
<file>test.qml</file>
|
||||||
|
<file>mainWidget.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
QT += quick qml quickcontrols2 core widgets gui
|
QT += quick qml quickcontrols2 core widgets gui
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
CONFIG += qtquickcompiler
|
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
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
# You can also make your code fail to compile if you use deprecated APIs.
|
|
||||||
# In order to do so, uncomment the following line.
|
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
src/widgetwindow.cpp
|
src/widgetwindow.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/widgetwindow.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
SPWidgetResources.qrc
|
SPWidgetResources.qrc
|
||||||
|
|
||||||
@ -42,19 +36,3 @@ install_it.path = $${OUT_PWD}/../ScreenPlaySDK
|
|||||||
}
|
}
|
||||||
QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK
|
QMAKE_LIBDIR += $$OUT_PWD/../ScreenPlaySDK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
|
||||||
# QML_DESIGNER_IMPORT_PATH =
|
|
||||||
QT_QUICK_CONTROLS_STYLE = "Material"
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
|
||||||
QML_IMPORT_PATH =
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
|
||||||
QML_DESIGNER_IMPORT_PATH =
|
|
||||||
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
src/widgetwindow.h
|
|
||||||
|
@ -14,12 +14,10 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
QStringList argumentList = app.arguments();
|
QStringList argumentList = app.arguments();
|
||||||
|
|
||||||
// If we start with only one argument (app path)
|
// If we start with only one argument (app path),
|
||||||
// It means we want to test a single widget
|
// it means we want to test a single widget
|
||||||
if (argumentList.length() == 1) {
|
if (argumentList.length() == 1) {
|
||||||
// Todo generic widget
|
WidgetWindow spwmw("test","appid" );
|
||||||
WidgetWindow spwmw("D:/672870/xkcd","appid" );
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import net.aimber.screenplaysdk 1.0
|
|
||||||
import QtQuick.Controls 2.3
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
|
import net.aimber.screenplaysdk 1.0
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: mainWindow
|
id: mainWindow
|
||||||
visible: true
|
visible: true
|
||||||
@ -22,27 +23,54 @@ Item {
|
|||||||
opacity: .05
|
opacity: .05
|
||||||
fillMode: Image.Tile
|
fillMode: Image.Tile
|
||||||
}
|
}
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
anchors.fill: parent
|
||||||
|
asynchronous: true
|
||||||
|
source: {
|
||||||
|
Qt.resolvedUrl(window.sourcePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
onStatusChanged: {
|
||||||
|
if (loader.status === Loader.Ready) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
onPressed: {
|
onPressed: {
|
||||||
backend.setClickPos(Qt.point(mouse.x, mouse.y))
|
window.setClickPos(Qt.point(mouse.x, mouse.y))
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChanged: {
|
onPositionChanged: {
|
||||||
backend.setPos(mouse.x, mouse.y)
|
window.setPos(mouse.x, mouse.y)
|
||||||
}
|
}
|
||||||
|
onClicked: {
|
||||||
|
|
||||||
|
if (mouse.button === Qt.RightButton) {
|
||||||
|
contextMenu.popup()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Menu {
|
||||||
|
id: contextMenu
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
text: qsTr("Close Widget")
|
||||||
|
onClicked: {
|
||||||
|
Qt.quit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: backend
|
target: window
|
||||||
|
|
||||||
onSetWidgetSource: {
|
|
||||||
loader.source = Qt.resolvedUrl("file:///" + source)
|
|
||||||
print(loader.source)
|
|
||||||
}
|
|
||||||
|
|
||||||
onQmlSceneValueReceived: {
|
onQmlSceneValueReceived: {
|
||||||
var obj2 = 'import QtQuick 2.12; Item {Component.onCompleted: loader.item.'
|
var obj2 = 'import QtQuick 2.12; Item {Component.onCompleted: loader.item.'
|
||||||
@ -52,14 +80,5 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
|
||||||
id: loader
|
|
||||||
anchors.fill: parent
|
|
||||||
asynchronous: true
|
|
||||||
onStatusChanged: {
|
|
||||||
if (loader.status === Loader.Ready) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,7 +13,14 @@ WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
|
|||||||
m_window.setWidth(300);
|
m_window.setWidth(300);
|
||||||
m_window.setHeight(300);
|
m_window.setHeight(300);
|
||||||
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::BypassWindowManagerHint | Qt::SplashScreen);
|
||||||
|
m_window.rootContext()->setContextProperty("window", this);
|
||||||
|
m_window.setColor(Qt::transparent);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
SetWindowBlur(m_hwnd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (projectPath != "test") {
|
||||||
QFile configTmp;
|
QFile configTmp;
|
||||||
QJsonDocument configJsonDocument;
|
QJsonDocument configJsonDocument;
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
@ -26,19 +33,19 @@ WidgetWindow::WidgetWindow(QString projectPath, QString appid, QObject* parent)
|
|||||||
if (!(parseError.error == QJsonParseError::NoError)) {
|
if (!(parseError.error == QJsonParseError::NoError)) {
|
||||||
qWarning("Settings Json Parse Error ");
|
qWarning("Settings Json Parse Error ");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_project = configJsonDocument.object();
|
m_project = configJsonDocument.object();
|
||||||
QString fullPath = projectPath + "/" + m_project.value("file").toString();
|
QString fullPath = "file:///" + projectPath + "/" + m_project.value("file").toString();
|
||||||
|
setSourcePath(fullPath);
|
||||||
m_window.rootContext()->setContextProperty("backend", this);
|
} else {
|
||||||
m_window.setColor(Qt::transparent);
|
setSourcePath("qrc:/test.qml");
|
||||||
|
}
|
||||||
m_window.setSource(QUrl("qrc:/main.qml"));
|
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||||
#ifdef Q_OS_WIN
|
// we can set it here once :)
|
||||||
SetWindowBlur(m_hwnd);
|
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||||
#endif
|
m_window.setSource(QUrl("qrc:/mainWidget.qml"));
|
||||||
m_window.show();
|
m_window.show();
|
||||||
|
|
||||||
emit setWidgetSource(fullPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetWindow::setSize(QSize size)
|
void WidgetWindow::setSize(QSize size)
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
|
#include <QQmlEngine>
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -28,6 +29,7 @@ public:
|
|||||||
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)
|
||||||
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
|
Q_PROPERTY(QString projectConfig READ projectConfig WRITE setProjectConfig NOTIFY projectConfigChanged)
|
||||||
|
Q_PROPERTY(QString sourcePath READ sourcePath WRITE setSourcePath NOTIFY sourcePathChanged)
|
||||||
|
|
||||||
QString appID() const
|
QString appID() const
|
||||||
{
|
{
|
||||||
@ -44,17 +46,24 @@ public:
|
|||||||
return m_projectConfig;
|
return m_projectConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString sourcePath() const
|
||||||
|
{
|
||||||
|
return m_sourcePath;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void appIDChanged(QString appID);
|
void appIDChanged(QString appID);
|
||||||
void typeChanged(QString type);
|
void typeChanged(QString type);
|
||||||
void projectConfigChanged(QString projectConfig);
|
void projectConfigChanged(QString projectConfig);
|
||||||
void setWidgetSource(QString source);
|
void sourcePathChanged(QString sourcePath);
|
||||||
|
|
||||||
void qmlSceneValueReceived(QString key, QString value);
|
void qmlSceneValueReceived(QString key, QString value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setSize(QSize size);
|
void setSize(QSize size);
|
||||||
void destroyThis();
|
void destroyThis();
|
||||||
void messageReceived(QString key, QString value);
|
void messageReceived(QString key, QString value);
|
||||||
|
|
||||||
void setAppID(QString appID)
|
void setAppID(QString appID)
|
||||||
{
|
{
|
||||||
if (m_appID == appID)
|
if (m_appID == appID)
|
||||||
@ -85,6 +94,15 @@ public slots:
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void SetWindowBlur(HWND hWnd);
|
void SetWindowBlur(HWND hWnd);
|
||||||
#endif
|
#endif
|
||||||
|
void setSourcePath(QString sourcePath)
|
||||||
|
{
|
||||||
|
if (m_sourcePath == sourcePath)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_sourcePath = sourcePath;
|
||||||
|
emit sourcePathChanged(m_sourcePath);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_appID;
|
QString m_appID;
|
||||||
QString m_type = "qmlWidget";
|
QString m_type = "qmlWidget";
|
||||||
@ -96,4 +114,5 @@ private:
|
|||||||
QPoint m_clickPos = { 0, 0 };
|
QPoint m_clickPos = { 0, 0 };
|
||||||
|
|
||||||
QQuickView m_window;
|
QQuickView m_window;
|
||||||
|
QString m_sourcePath;
|
||||||
};
|
};
|
||||||
|
25
ScreenPlayWidget/test.qml
Normal file
25
ScreenPlayWidget/test.qml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "#80000000"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: name
|
||||||
|
text: qsTr("This is a empty test widget. You can change the source in test.qml")
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 10
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*##^## Designer {
|
||||||
|
D{i:0;autoSize:true;height:480;width:640}
|
||||||
|
}
|
||||||
|
##^##*/
|
@ -1,5 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>qml/main.qml</file>
|
<file>mainWindow.qml</file>
|
||||||
|
<file>test.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -2,22 +2,28 @@ TEMPLATE = app
|
|||||||
QT += qml quick quickcontrols2 widgets core webengine
|
QT += qml quick quickcontrols2 widgets core webengine
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
msvc: LIBS += -luser32
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
TARGETPATH = ScreenPlayWindow
|
TARGETPATH = ScreenPlayWindow
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
#src/SPWmainwindow.cpp \
|
|
||||||
main.cpp \
|
main.cpp \
|
||||||
src/basewindow.cpp \
|
src/basewindow.cpp \
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
src/basewindow.h \
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
LIBS += -luser32
|
||||||
|
SOURCES += \
|
||||||
src/windowsdesktopproperties.cpp \
|
src/windowsdesktopproperties.cpp \
|
||||||
src/winwindow.cpp
|
src/winwindow.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
#src/SPWmainwindow.h \
|
|
||||||
src/basewindow.h \
|
|
||||||
src/windowsdesktopproperties.h \
|
src/windowsdesktopproperties.h \
|
||||||
src/winwindow.h
|
src/winwindow.h
|
||||||
|
|
||||||
|
}
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
SPWResources.qrc
|
SPWResources.qrc
|
||||||
|
|
||||||
@ -62,19 +68,3 @@ macx: {
|
|||||||
index.html
|
index.html
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
|
||||||
QML_IMPORT_PATH =
|
|
||||||
|
|
||||||
# Additional import path used to resolve QML modules just for Qt Quick Designer
|
|
||||||
QML_DESIGNER_IMPORT_PATH =
|
|
||||||
QT_QUICK_CONTROLS_STYLE = "Material"
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
|
||||||
# any feature of Qt which as been marked deprecated (the exact warnings
|
|
||||||
# depend on your compiler). Please consult the documentation of the
|
|
||||||
# deprecated API in order to know how to port your code away from it.
|
|
||||||
DEFINES += QT_DEPRECATED_WARNINGS
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
#include "../ScreenPlaySDK/screenplaysdk.h"
|
#include <QApplication>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QtWebEngine>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include "src/winwindow.h"
|
#include "src/winwindow.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <QApplication>
|
#if defined(Q_OS_OSX)
|
||||||
#include <QObject>
|
|
||||||
#include <QStringList>
|
// TODO MAC OSX PORT HERE
|
||||||
#include <QtWebEngine>
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../ScreenPlaySDK/screenplaysdk.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
@ -15,15 +22,22 @@ int main(int argc, char* argv[])
|
|||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QStringList argumentList = app.arguments();
|
|
||||||
|
// This gives us nice clickable output in QtCreator
|
||||||
|
qSetMessagePattern("%{if-category}%{category}: %{endif}%{message}\n Loc: [%{file}:%{line}]");
|
||||||
|
|
||||||
|
// Qt < 6.0 needs this init QtWebEngine
|
||||||
QtWebEngine::initialize();
|
QtWebEngine::initialize();
|
||||||
|
|
||||||
// If we start with only one argument (app path)
|
// If we start with only one argument (app path)
|
||||||
// It means we want to test a single wallpaper
|
// It means we want to test a single wallpaper
|
||||||
|
QStringList argumentList = app.arguments();
|
||||||
if (argumentList.length() == 1) {
|
if (argumentList.length() == 1) {
|
||||||
QVector<int> list;
|
QVector<int> list;
|
||||||
list.append(0);
|
list.append(0);
|
||||||
WinWindow window(list, "D:/672870/_tmp_135011", "appid", "1");
|
#if defined(Q_OS_WIN)
|
||||||
|
WinWindow window(list, "test", "appid", "1");
|
||||||
|
#endif
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,5 +80,13 @@ int main(int argc, char* argv[])
|
|||||||
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived);
|
QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &window, &WinWindow::messageReceived);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_OSX)
|
||||||
|
|
||||||
|
// TODO MAC OSX PORT HERE
|
||||||
|
// QObject::connect(&sdk, &ScreenPlaySDK::sdkDisconnected, &TODO, &TODO::destroyThis);
|
||||||
|
// QObject::connect(&sdk, &ScreenPlaySDK::incommingMessage, &TODO, &TODO::messageReceived);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -1,167 +0,0 @@
|
|||||||
import QtQuick 2.12
|
|
||||||
import QtWebEngine 1.7
|
|
||||||
import net.aimber.wallpaper 1.0
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
color: desktopProperties.color
|
|
||||||
|
|
||||||
property bool canFadeIn: true
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
WebEngine.settings.allowRunningInsecureContent = true
|
|
||||||
WebEngine.settings.accelerated2dCanvasEnabled = true
|
|
||||||
WebEngine.settings.javascriptCanOpenWindows = false
|
|
||||||
WebEngine.settings.printElementBackgrounds = false
|
|
||||||
WebEngine.settings.showScrollBars = false
|
|
||||||
WebEngine.settings.playbackRequiresUserGesture = false
|
|
||||||
|
|
||||||
switch (window.type) {
|
|
||||||
case Wallpaper.WallpaperType.Video:
|
|
||||||
webView.enabled = true
|
|
||||||
webView.url = Qt.resolvedUrl("file:///" + window.getApplicationPath(
|
|
||||||
) + "/index.html")
|
|
||||||
|
|
||||||
break
|
|
||||||
case Wallpaper.WallpaperType.Html:
|
|
||||||
webView.enabled = true
|
|
||||||
webView.url = Qt.resolvedUrl("file:///" + window.fullContentPath)
|
|
||||||
break
|
|
||||||
case Wallpaper.WallpaperType.ThreeJSScene:
|
|
||||||
webView.enabled = true
|
|
||||||
break
|
|
||||||
case Wallpaper.WallpaperType.Qml:
|
|
||||||
loader.source = Qt.resolvedUrl("file:///" + window.fullContentPath)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
fadeIn()
|
|
||||||
}
|
|
||||||
|
|
||||||
function fadeIn() {
|
|
||||||
window.setVisible(true)
|
|
||||||
if (canFadeIn) {
|
|
||||||
animFadeIn.start()
|
|
||||||
} else {
|
|
||||||
imgCover.opacity = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WebEngineView {
|
|
||||||
id: webView
|
|
||||||
enabled: false
|
|
||||||
anchors.fill: parent
|
|
||||||
onLoadProgressChanged: {
|
|
||||||
if (loadProgress === 100) {
|
|
||||||
|
|
||||||
var src = ""
|
|
||||||
src += "var videoPlayer = document.getElementById('videoPlayer');"
|
|
||||||
src += "var videoSource = document.getElementById('videoSource');"
|
|
||||||
src += "videoSource.src = 'file:///" + window.fullContentPath + "';"
|
|
||||||
src += "videoPlayer.load();"
|
|
||||||
src += "videoPlayer.volume = " + window.volume + ";"
|
|
||||||
src += "videoPlayer.play();"
|
|
||||||
|
|
||||||
webView.runJavaScript(src, function () {
|
|
||||||
fadeIn()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loader {
|
|
||||||
id: loader
|
|
||||||
anchors.fill: parent
|
|
||||||
}
|
|
||||||
|
|
||||||
OpacityAnimator {
|
|
||||||
id: animFadeIn
|
|
||||||
target: imgCover
|
|
||||||
from: 1
|
|
||||||
to: 0
|
|
||||||
duration: 300
|
|
||||||
easing.type: Easing.InCubic
|
|
||||||
running: true
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: imgCover
|
|
||||||
anchors.fill: parent
|
|
||||||
source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath)
|
|
||||||
Component.onCompleted: {
|
|
||||||
switch (desktopProperties.wallpaperStyle) {
|
|
||||||
case 10:
|
|
||||||
imgCover.fillMode = Image.PreserveAspectCrop
|
|
||||||
break
|
|
||||||
case 6:
|
|
||||||
imgCover.fillMode = Image.PreserveAspectFit
|
|
||||||
break
|
|
||||||
case 2:
|
|
||||||
break
|
|
||||||
case 0:
|
|
||||||
if (desktopProperties.isTiled) {
|
|
||||||
// Tiled
|
|
||||||
imgCover.fillMode = Image.Tile
|
|
||||||
} else {
|
|
||||||
// Center
|
|
||||||
imgCover.fillMode = Image.PreserveAspectFit
|
|
||||||
imgCover.anchors.centerIn = parent
|
|
||||||
imgCover.width = sourceSize.width
|
|
||||||
imgCover.height = sourceSize.height
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 22:
|
|
||||||
canFadeIn = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: window
|
|
||||||
|
|
||||||
onQmlExit: {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;")
|
|
||||||
window.destroyThis()
|
|
||||||
}
|
|
||||||
|
|
||||||
onQmlSceneValueReceived: {
|
|
||||||
var obj2 = 'import QtQuick 2.12; Item {Component.onCompleted: loader.item.'
|
|
||||||
+ key + ' = ' + value + '; }'
|
|
||||||
var newObject = Qt.createQmlObject(obj2.toString(), root, "err")
|
|
||||||
newObject.destroy(10000)
|
|
||||||
}
|
|
||||||
|
|
||||||
onLoopsChanged: {
|
|
||||||
if (webView.loadProgress === 100) {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.loop = " + loops + ";")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onVolumeChanged: {
|
|
||||||
if (webView.loadProgress === 100) {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = " + volume + ";")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onPlaybackRateChanged: {
|
|
||||||
if (webView.loadProgress === 100) {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.playbackRate = " + playbackRate + ";")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onIsPlayingChanged: {
|
|
||||||
if (webView.loadProgress === 100) {
|
|
||||||
if (isPlaying === "false") {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.play();")
|
|
||||||
} else {
|
|
||||||
webView.runJavaScript(
|
|
||||||
"var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.pause();")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,6 +11,12 @@ BaseWindow::BaseWindow(QString projectFilePath, QObject* parent)
|
|||||||
qRegisterMetaType<BaseWindow::WallpaperType>();
|
qRegisterMetaType<BaseWindow::WallpaperType>();
|
||||||
qmlRegisterType<BaseWindow>("net.aimber.wallpaper", 1, 0, "Wallpaper");
|
qmlRegisterType<BaseWindow>("net.aimber.wallpaper", 1, 0, "Wallpaper");
|
||||||
|
|
||||||
|
if (projectFilePath == "test") {
|
||||||
|
setType(BaseWindow::WallpaperType::Qml);
|
||||||
|
setFullContentPath("qrc:/test.qml");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QFile projectFile;
|
QFile projectFile;
|
||||||
QJsonDocument configJsonDocument;
|
QJsonDocument configJsonDocument;
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
@ -48,7 +54,7 @@ BaseWindow::BaseWindow(QString projectFilePath, QObject* parent)
|
|||||||
qFatal("No type was specified inside the json object!");
|
qFatal("No type was specified inside the json object!");
|
||||||
}
|
}
|
||||||
|
|
||||||
setFullContentPath(projectFilePath + "/" + projectObject.value("file").toString());
|
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
|
||||||
|
|
||||||
if (projectObject.value("type") == "video") {
|
if (projectObject.value("type") == "video") {
|
||||||
setType(BaseWindow::WallpaperType::Video);
|
setType(BaseWindow::WallpaperType::Video);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDebug>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QApplication>
|
|
||||||
#include <qqml.h>
|
#include <qqml.h>
|
||||||
|
|
||||||
class BaseWindow : public QObject {
|
class BaseWindow : public QObject {
|
||||||
@ -82,7 +82,11 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void destroyThis() {}
|
virtual void destroyThis() {}
|
||||||
virtual void setVisible(bool show) { Q_UNUSED(show) }
|
virtual void setVisible(bool show) { Q_UNUSED(show) }
|
||||||
virtual void messageReceived(QString key, QString value){Q_UNUSED(key);Q_UNUSED(value)}
|
virtual void messageReceived(QString key, QString value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(key);
|
||||||
|
Q_UNUSED(value)
|
||||||
|
}
|
||||||
|
|
||||||
QString getApplicationPath()
|
QString getApplicationPath()
|
||||||
{
|
{
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
#ifndef MACINTEGRATION_H
|
#pragma oncer
|
||||||
#define MACINTEGRATION_H
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
class MacIntegration : public QObject {
|
||||||
class MacIntegration : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit MacIntegration(QObject* parent);
|
explicit MacIntegration(QObject* parent);
|
||||||
void SetBackgroundLevel(QWindow* window);
|
void SetBackgroundLevel(QWindow* window);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MACINTEGRATION_H
|
|
||||||
|
@ -17,6 +17,10 @@ WinWindow::WinWindow(QVector<int>& activeScreensList, QString projectPath, QStri
|
|||||||
: BaseWindow(projectPath)
|
: BaseWindow(projectPath)
|
||||||
{
|
{
|
||||||
m_windowHandle = reinterpret_cast<HWND>(m_window.winId());
|
m_windowHandle = reinterpret_cast<HWND>(m_window.winId());
|
||||||
|
|
||||||
|
if(!IsWindow(m_windowHandle)){
|
||||||
|
qFatal("Could not get a valid window handle!");
|
||||||
|
}
|
||||||
setAppID(id);
|
setAppID(id);
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -50,16 +54,25 @@ WinWindow::WinWindow(QVector<int>& activeScreensList, QString projectPath, QStri
|
|||||||
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||||
m_window.rootContext()->setContextProperty("window", this);
|
m_window.rootContext()->setContextProperty("window", this);
|
||||||
m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);
|
m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);
|
||||||
m_window.setSource(QUrl("qrc:/qml/main.qml"));
|
// Instead of setting "renderType: Text.NativeRendering" every time
|
||||||
|
// we can set it here once :)
|
||||||
|
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||||
|
m_window.setSource(QUrl("qrc:/mainWindow.qml"));
|
||||||
|
|
||||||
// Let QML decide when were are read to show the window
|
// Let QML decide when were are read to show the window
|
||||||
ShowWindow(m_windowHandle, SW_HIDE);
|
//ShowWindow(m_windowHandle, SW_HIDE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinWindow::setVisible(bool show)
|
void WinWindow::setVisible(bool show)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (show) {
|
if (show) {
|
||||||
ShowWindow(m_windowHandle, SW_SHOW);
|
ShowWindow(m_windowHandle, SW_SHOW);
|
||||||
|
if(!IsWindowVisible(m_windowHandle)){
|
||||||
|
qFatal("Could net set window visible!");
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ShowWindow(m_windowHandle, SW_HIDE);
|
ShowWindow(m_windowHandle, SW_HIDE);
|
||||||
}
|
}
|
||||||
@ -79,7 +92,6 @@ void WinWindow::destroyThis()
|
|||||||
|
|
||||||
void WinWindow::messageReceived(QString key, QString value)
|
void WinWindow::messageReceived(QString key, QString value)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinWindow::calcOffsets()
|
void WinWindow::calcOffsets()
|
||||||
|
@ -7,16 +7,15 @@
|
|||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QVector>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "windowsdesktopproperties.h"
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
|
||||||
#include "basewindow.h"
|
#include "basewindow.h"
|
||||||
|
#include "windowsdesktopproperties.h"
|
||||||
|
|
||||||
class WinWindow : public BaseWindow {
|
class WinWindow : public BaseWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
25
ScreenPlayWindow/test.qml
Normal file
25
ScreenPlayWindow/test.qml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import QtQuick 2.12
|
||||||
|
import QtQuick.Controls.Material 2.12
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: Material.color(Material.Grey, Material.Shade800)
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: name
|
||||||
|
text: qsTr("This is a empty test window. You can change the source in test.qml")
|
||||||
|
font.pointSize: 32
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 10
|
||||||
|
color: "white"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*##^## Designer {
|
||||||
|
D{i:0;autoSize:true;height:480;width:640}
|
||||||
|
}
|
||||||
|
##^##*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user