1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02: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 {
top: parent.top
topMargin: {
return 0;
if(desktopProperties.windowsVersion >= 1903){
var ratio = root.width / root.height
ratio = Math.round(ratio * 100) / 100
var ratio = window.width / window.height
ratio = Math.round(ratio * 10) / 10
print("size: ",window.width,window.height,ratio)
// 4:3
if (ratio === 1,3) {
print("4:3")
}
// 16:10
if (ratio === 1,6) {
print("16:10")
}
// 16:9
if (ratio === 1,77) {
return -(root.height / 9)
if (ratio === 1,7) {
print("16:9")
var margin = window.height / 9
//margin = 140
print(margin)
return margin
}
// 21:9
if (ratio === 2,37) {
return -((root.height / 9) / 3)
if (ratio === 2,3) {
print("21:9")
return -((window.height / 9) / 3)
}
// 32:9
if (ratio === 3,55) {
if (ratio === 3,5) {
print("32:9")
}
} else {
@ -153,7 +159,8 @@ Rectangle {
right: parent.right
}
sourceSize.width: root.width
sourceSize.width: window.width
sourceSize.height: window.height
source: Qt.resolvedUrl("file:///" + desktopProperties.wallpaperPath)
Component.onCompleted: {

View File

@ -18,6 +18,9 @@ public:
BaseWindow(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 fullContentPath READ fullContentPath WRITE setFullContentPath NOTIFY fullContentPathChanged)
@ -44,8 +47,6 @@ public:
};
Q_ENUM(WallpaperType)
bool loops() const
{
return m_loops;
@ -106,6 +107,16 @@ public:
return m_fillMode;
}
int width() const
{
return m_width;
}
int height() const
{
return m_height;
}
signals:
void loopsChanged(bool loops);
void volumeChanged(float volume);
@ -121,8 +132,9 @@ signals:
void currentTimeChanged(float currentTime);
void canFadeChanged(bool canFade);
void fillModeChanged(QString fillMode);
void widthChanged(int width);
void heightChanged(int height);
public slots:
virtual void destroyThis() {}
@ -144,7 +156,7 @@ public slots:
}
void setVolume(float volume)
{
if(volume < 0.0f || volume > 1.0f)
if (volume < 0.0f || volume > 1.0f)
return;
if (qFuzzyCompare(m_volume, volume))
@ -163,7 +175,7 @@ public slots:
}
void setPlaybackRate(float playbackRate)
{
if(playbackRate < 0.0f || playbackRate > 1.0f)
if (playbackRate < 0.0f || playbackRate > 1.0f)
return;
if (qFuzzyCompare(m_playbackRate, playbackRate))
@ -244,22 +256,39 @@ public slots:
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"
<< "Provided: " << fillMode
<< "Available: " << availableFillModes;
return;
}
// Actual web fillmodes are lowercase
// https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
m_fillMode = fillMode.toLower();
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:
bool m_loops { true };
bool m_isPlaying { true };
@ -276,4 +305,6 @@ private:
WallpaperType m_type = BaseWindow::WallpaperType::Qml;
QString m_OSVersion;
QString m_fillMode;
int m_width { 0 };
int m_height { 0 };
};

View File

@ -108,6 +108,9 @@ WinWindow::WinWindow(
setupWallpaperForMultipleScreens(activeScreensList);
}
setWidth(m_window.width());
setHeight(m_window.height());
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
m_window.rootContext()->setContextProperty("window", this);
m_window.rootContext()->setContextProperty("desktopProperties", &m_windowsDesktopProperties);