1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Elias Steurer 2019-10-23 17:09:22 +02:00
commit bbb70ece42
3 changed files with 61 additions and 20 deletions

View File

@ -118,30 +118,36 @@ Rectangle {
anchors { anchors {
top: parent.top top: parent.top
topMargin: { topMargin: {
return 0;
if(desktopProperties.windowsVersion >= 1903){ if(desktopProperties.windowsVersion >= 1903){
var ratio = root.width / root.height var ratio = window.width / window.height
ratio = Math.round(ratio * 100) / 100 ratio = Math.round(ratio * 10) / 10
print("size: ",window.width,window.height,ratio)
// 4:3 // 4:3
if (ratio === 1,3) { if (ratio === 1,3) {
print("4:3")
} }
// 16:10 // 16:10
if (ratio === 1,6) { if (ratio === 1,6) {
print("16:10")
} }
// 16:9 // 16:9
if (ratio === 1,77) { if (ratio === 1,7) {
return -(root.height / 9) print("16:9")
var margin = window.height / 9
//margin = 140
print(margin)
return margin
} }
// 21:9 // 21:9
if (ratio === 2,37) { if (ratio === 2,3) {
return -((root.height / 9) / 3) print("21:9")
return -((window.height / 9) / 3)
} }
// 32:9 // 32:9
if (ratio === 3,55) { if (ratio === 3,5) {
print("32:9")
} }
} else { } else {
@ -153,7 +159,8 @@ Rectangle {
right: parent.right right: parent.right
} }
sourceSize.width: root.width sourceSize.width: window.width
sourceSize.height: window.height
source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath) source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath)
Component.onCompleted: { Component.onCompleted: {

View File

@ -18,6 +18,9 @@ public:
BaseWindow(QObject* parent = nullptr); BaseWindow(QObject* parent = nullptr);
BaseWindow(QString projectFilePath, QObject* parent = nullptr); BaseWindow(QString projectFilePath, QObject* parent = nullptr);
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged) Q_PROPERTY(QString appID READ appID WRITE setAppID NOTIFY appIDChanged)
Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged) Q_PROPERTY(QString fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
@ -44,8 +47,6 @@ public:
}; };
Q_ENUM(WallpaperType) Q_ENUM(WallpaperType)
bool loops() const bool loops() const
{ {
return m_loops; return m_loops;
@ -106,6 +107,16 @@ public:
return m_fillMode; return m_fillMode;
} }
int width() const
{
return m_width;
}
int height() const
{
return m_height;
}
signals: signals:
void loopsChanged(bool loops); void loopsChanged(bool loops);
void volumeChanged(float volume); void volumeChanged(float volume);
@ -121,8 +132,9 @@ signals:
void currentTimeChanged(float currentTime); void currentTimeChanged(float currentTime);
void canFadeChanged(bool canFade); void canFadeChanged(bool canFade);
void fillModeChanged(QString fillMode); void fillModeChanged(QString fillMode);
void widthChanged(int width);
void heightChanged(int height);
public slots: public slots:
virtual void destroyThis() {} virtual void destroyThis() {}
@ -144,7 +156,7 @@ public slots:
} }
void setVolume(float volume) void setVolume(float volume)
{ {
if(volume < 0.0f || volume > 1.0f) if (volume < 0.0f || volume > 1.0f)
return; return;
if (qFuzzyCompare(m_volume, volume)) if (qFuzzyCompare(m_volume, volume))
@ -163,7 +175,7 @@ public slots:
} }
void setPlaybackRate(float playbackRate) void setPlaybackRate(float playbackRate)
{ {
if(playbackRate < 0.0f || playbackRate > 1.0f) if (playbackRate < 0.0f || playbackRate > 1.0f)
return; return;
if (qFuzzyCompare(m_playbackRate, playbackRate)) if (qFuzzyCompare(m_playbackRate, playbackRate))
@ -244,22 +256,39 @@ public slots:
fillMode = fillMode.toLower(); fillMode = fillMode.toLower();
QStringList availableFillModes {"stretch", "fill", "contain", "cover", "scale-down"}; QStringList availableFillModes { "stretch", "fill", "contain", "cover", "scale-down" };
if(!availableFillModes.contains(fillMode)) { if (!availableFillModes.contains(fillMode)) {
qWarning() << "Unable to set fillmode, the provided value did not match the available values" qWarning() << "Unable to set fillmode, the provided value did not match the available values"
<< "Provided: " << fillMode << "Provided: " << fillMode
<< "Available: " << availableFillModes; << "Available: " << availableFillModes;
return; return;
} }
// Actual web fillmodes are lowercase // Actual web fillmodes are lowercase
// https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit // https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
m_fillMode = fillMode.toLower(); m_fillMode = fillMode.toLower();
emit fillModeChanged(m_fillMode); emit fillModeChanged(m_fillMode);
} }
void setWidth(int width)
{
if (m_width == width)
return;
m_width = width;
emit widthChanged(m_width);
}
void setHeight(int height)
{
if (m_height == height)
return;
m_height = height;
emit heightChanged(m_height);
}
private: private:
bool m_loops { true }; bool m_loops { true };
bool m_isPlaying { true }; bool m_isPlaying { true };
@ -276,4 +305,6 @@ private:
WallpaperType m_type = BaseWindow::WallpaperType::Qml; WallpaperType m_type = BaseWindow::WallpaperType::Qml;
QString m_OSVersion; QString m_OSVersion;
QString m_fillMode; QString m_fillMode;
int m_width { 0 };
int m_height { 0 };
}; };

View File

@ -108,6 +108,9 @@ WinWindow::WinWindow(
setupWallpaperForMultipleScreens(activeScreensList); setupWallpaperForMultipleScreens(activeScreensList);
} }
setWidth(m_window.width());
setHeight(m_window.height());
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);