1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Add basic Gif and Website wallpaper

This commit is contained in:
Elias Steurer 2020-12-28 17:26:56 +01:00
parent d3f2b7724a
commit 53f7b2757f
5 changed files with 75 additions and 10 deletions

View File

@ -0,0 +1,5 @@
import QtQuick 2.0
AnimatedImage {
}

View File

@ -6,5 +6,7 @@
<file>qtquickcontrols2.conf</file>
<file>WebView.qml</file>
<file>index.html</file>
<file>GifWallpaper.qml</file>
<file>WebsiteWallpaper.qml</file>
</qresource>
</RCC>

View File

@ -79,6 +79,20 @@ Rectangle {
imgCover.state = "out"
fadeIn()
break
case Wallpaper.WallpaperType.Website:
loader.setSource("qrc:/WebsiteWallpaper.qml", {
"source": Qt.resolvedUrl(
Wallpaper.fullContentPath)
})
fadeIn()
break
case Wallpaper.WallpaperType.Gif:
loader.setSource("qrc:/GifWallpaper.qml", {
"source": Qt.resolvedUrl(
Wallpaper.fullContentPath)
})
fadeIn()
break
}
}

View File

@ -0,0 +1,34 @@
import QtQuick 2.14
import QtWebEngine 1.8
import ScreenPlayWallpaper 1.0
Item {
id: root
property alias url: webView.url
signal requestFadeIn
Component.onCompleted: {
WebEngine.settings.localContentCanAccessFileUrls = true
WebEngine.settings.localContentCanAccessRemoteUrls = true
WebEngine.settings.allowRunningInsecureContent = true
WebEngine.settings.accelerated2dCanvasEnabled = true
WebEngine.settings.javascriptCanOpenWindows = false
WebEngine.settings.showScrollBars = false
WebEngine.settings.playbackRequiresUserGesture = false
WebEngine.settings.focusOnNavigationEnabled = true
}
WebEngineView {
id: webView
anchors.fill: parent
onJavaScriptConsoleMessage: print(lineNumber, message)
onLoadProgressChanged: {
if ((loadProgress === 100)) {
root.requestFadeIn()
}
}
}
}

View File

@ -42,6 +42,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
* "previewGIF": "preview.gif",
* "previewWEBM": "preview.webm",
* "type": "videoWallpaper"
* "url": "https://www.golem.de/" //websiteWallpaper only
*}
*/
@ -51,27 +52,36 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
qFatal("Settings Json Parse Error. Exiting now!");
}
QJsonObject projectObject = configJsonDocument.object();
const QJsonObject projectObject = configJsonDocument.object();
if (!projectObject.contains("type")) {
qFatal("No type was specified inside the json object!");
QApplication::exit(-3);
}
setType(parseWallpaperType(projectObject.value("type").toString().toLower()));
if (!projectObject.contains("file")) {
qFatal("No file was specified inside the json object!");
}
if (!projectObject.contains("type")) {
qFatal("No type was specified inside the json object!");
}
setBasePath(QUrl::fromUserInput(projectFilePath).toLocalFile());
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
if (m_type == WallpaperType::Website) {
if (!projectObject.contains("url")) {
qFatal("No url was specified for a websiteWallpaper!");
QApplication::exit(-4);
}
setFullContentPath(projectObject.value("url").toString());
qInfo() << fullContentPath();
} else {
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
}
auto reloadQMLLambda = [this]() { emit reloadQML(type()); };
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, reloadQMLLambda);
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, reloadQMLLambda);
m_fileSystemWatcher.addPaths({ projectFilePath, projectFilePath + "/" + projectObject.value("file").toString() });
QString type = projectObject.value("type").toString().toLower();
setType(parseWallpaperType(type));
}
void BaseWindow::messageReceived(QString key, QString value)