diff --git a/ScreenPlayWallpaper/mainWindow.qml b/ScreenPlayWallpaper/mainWindow.qml index f12ddbf2..2e7c13ef 100644 --- a/ScreenPlayWallpaper/mainWindow.qml +++ b/ScreenPlayWallpaper/mainWindow.qml @@ -13,7 +13,6 @@ Rectangle { } } - property bool canFadeIn: true Component.onCompleted: { @@ -56,11 +55,8 @@ Rectangle { } } - - - Timer { - id:fadeInTimer + id: fadeInTimer interval: 50 onTriggered: fadeIn() } @@ -81,11 +77,9 @@ Rectangle { to: 1 duration: 800 easing.type: Easing.InOutQuad - onFinished: window.terminate() + onFinished: window.terminate() } - - WebEngineView { id: webView enabled: false @@ -118,9 +112,25 @@ Rectangle { Image { id: imgCover - anchors.fill: parent + anchors { + top: parent.top + topMargin: { + if(desktopProperties.windowsVersion >= 1903){ + return -(1080 / 9) + } else { + return 0; + } + } + + left: parent.left + right: parent.right + } + + sourceSize.width: root.width source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath) + Component.onCompleted: { + switch (desktopProperties.wallpaperStyle) { case 10: imgCover.fillMode = Image.PreserveAspectCrop @@ -156,7 +166,6 @@ Rectangle { webView.runJavaScript( "var videoPlayer = document.getElementById('videoPlayer'); videoPlayer.volume = 0;") animFadeOut.start() - } onQmlSceneValueReceived: { @@ -200,5 +209,4 @@ Rectangle { } } } - } diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index 39bf0233..34f06e63 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -12,6 +12,8 @@ BaseWindow::BaseWindow(QString projectFilePath, QObject* parent) qRegisterMetaType(); qmlRegisterType("ScreenPlay.Wallpaper", 1, 0, "Wallpaper"); + setOSVersion(QSysInfo::productVersion()); + if (projectFilePath == "test") { setType(BaseWindow::WallpaperType::Qml); setFullContentPath("qrc:/test.qml"); diff --git a/ScreenPlayWallpaper/src/basewindow.h b/ScreenPlayWallpaper/src/basewindow.h index 1fd3698f..f8325177 100644 --- a/ScreenPlayWallpaper/src/basewindow.h +++ b/ScreenPlayWallpaper/src/basewindow.h @@ -9,6 +9,7 @@ #include #include #include +#include class BaseWindow : public QObject { Q_OBJECT @@ -24,7 +25,9 @@ public: Q_PROPERTY(float volume READ volume WRITE setVolume NOTIFY volumeChanged) Q_PROPERTY(float playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged) Q_PROPERTY(WallpaperType type READ type WRITE setType NOTIFY typeChanged) + Q_PROPERTY(QString OSVersion READ OSVersion WRITE setOSVersion NOTIFY OSVersionChanged) + QSysInfo m_sysinfo; enum class WallpaperType { Video, Html, @@ -68,6 +71,11 @@ public: return m_appID; } + QString OSVersion() const + { + return m_OSVersion; + } + signals: void loopsChanged(bool loops); void volumeChanged(float volume); @@ -79,6 +87,8 @@ signals: void qmlExit(); void qmlSceneValueReceived(QString key, QString value); + void OSVersionChanged(QString OSVersion); + public slots: virtual void destroyThis() {} virtual void setVisible(bool show) { Q_UNUSED(show) } @@ -151,6 +161,15 @@ public slots: emit appIDChanged(m_appID); } + void setOSVersion(QString OSVersion) + { + if (m_OSVersion == OSVersion) + return; + + m_OSVersion = OSVersion; + emit OSVersionChanged(m_OSVersion); + } + private: bool m_loops = true; bool m_isPlaying = true; @@ -162,4 +181,5 @@ private: QString m_appID; WallpaperType m_type = BaseWindow::WallpaperType::Qml; + QString m_OSVersion; }; diff --git a/ScreenPlayWallpaper/src/windowsdesktopproperties.cpp b/ScreenPlayWallpaper/src/windowsdesktopproperties.cpp index 3ea5096b..3a591ee0 100644 --- a/ScreenPlayWallpaper/src/windowsdesktopproperties.cpp +++ b/ScreenPlayWallpaper/src/windowsdesktopproperties.cpp @@ -27,4 +27,8 @@ WindowsDesktopProperties::WindowsDesktopProperties(QObject* parent) int colorB = colorStringRGBList.at(2).toInt(); setColor(QColor::fromRgb(colorR, colorG, colorB)); } + + QSettings settingsWindowsVersion("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", QSettings::NativeFormat); + setWindowsVersion(settingsWindowsVersion.value("ReleaseId").toInt()); + qDebug() << settingsWindowsVersion.value("ReleaseId").toInt(); } diff --git a/ScreenPlayWallpaper/src/windowsdesktopproperties.h b/ScreenPlayWallpaper/src/windowsdesktopproperties.h index a0cea8ba..deaf7b9e 100644 --- a/ScreenPlayWallpaper/src/windowsdesktopproperties.h +++ b/ScreenPlayWallpaper/src/windowsdesktopproperties.h @@ -2,11 +2,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -16,6 +16,7 @@ class WindowsDesktopProperties : public QObject { public: explicit WindowsDesktopProperties(QObject* parent = nullptr); + Q_PROPERTY(int windowsVersion READ windowsVersion WRITE setWindowsVersion NOTIFY windowsVersionChanged) Q_PROPERTY(QString wallpaperPath READ wallpaperPath WRITE setWallpaperPath NOTIFY wallpaperPathChanged) Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged) Q_PROPERTY(bool isTiled READ isTiled WRITE setIsTiled NOTIFY isTiledChanged) @@ -56,6 +57,11 @@ public: return m_color; } + int windowsVersion() const + { + return m_windowsVersion; + } + signals: void wallpaperPathChanged(QString wallpaperPath); @@ -68,6 +74,8 @@ signals: void colorChanged(QColor color); + void windowsVersionChanged(int windowsVersion); + public slots: void setWallpaperPath(QString wallpaperPath) { @@ -111,10 +119,20 @@ public slots: emit colorChanged(m_color); } + void setWindowsVersion(int windowsVersion) + { + if (m_windowsVersion == windowsVersion) + return; + + m_windowsVersion = windowsVersion; + emit windowsVersionChanged(m_windowsVersion); + } + private: QString m_wallpaperPath; QPoint m_position; bool m_isTiled; int m_wallpaperStyle; QColor m_color; + int m_windowsVersion; };