1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-26 04:33:06 +01:00

Fix windows 10 version >= 1903 topmargin. They changed the topmargin to 10% of the monitor height. Dunno why...

This commit is contained in:
Elias 2019-07-26 17:28:30 +02:00
parent bc99ead6c7
commit 9211441b1f
5 changed files with 64 additions and 12 deletions

View File

@ -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 {
}
}
}
}

View File

@ -12,6 +12,8 @@ BaseWindow::BaseWindow(QString projectFilePath, QObject* parent)
qRegisterMetaType<BaseWindow::WallpaperType>();
qmlRegisterType<BaseWindow>("ScreenPlay.Wallpaper", 1, 0, "Wallpaper");
setOSVersion(QSysInfo::productVersion());
if (projectFilePath == "test") {
setType(BaseWindow::WallpaperType::Qml);
setFullContentPath("qrc:/test.qml");

View File

@ -9,6 +9,7 @@
#include <QObject>
#include <QString>
#include <QtQml>
#include <QSysInfo>
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;
};

View File

@ -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();
}

View File

@ -2,11 +2,11 @@
#include <QColor>
#include <QDebug>
#include <QList>
#include <QObject>
#include <QPoint>
#include <QSettings>
#include <QString>
#include <QList>
#include <qqml.h>
#include <qt_windows.h>
@ -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;
};