mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Add basic Gif and Website wallpaper
This commit is contained in:
parent
d3f2b7724a
commit
53f7b2757f
5
ScreenPlayWallpaper/GifWallpaper.qml
Normal file
5
ScreenPlayWallpaper/GifWallpaper.qml
Normal file
@ -0,0 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
|
||||
AnimatedImage {
|
||||
|
||||
}
|
@ -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>
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
34
ScreenPlayWallpaper/WebsiteWallpaper.qml
Normal file
34
ScreenPlayWallpaper/WebsiteWallpaper.qml
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user