mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 18:52:30 +01:00
Fix replacing wallpaper from different types
This commit is contained in:
parent
02042f060f
commit
1fe1fb2c4b
@ -38,11 +38,28 @@ Rectangle {
|
||||
newObject.destroy(10000)
|
||||
}
|
||||
|
||||
function onReloadQML() {
|
||||
// Replace wallpaper with QML Scene
|
||||
function onReloadQML(oldType) {
|
||||
|
||||
loader.sourceComponent = undefined
|
||||
loader.source = ""
|
||||
Wallpaper.clearComponentCache()
|
||||
root.init()
|
||||
if (oldType === Wallpaper.WallpaperType.QML)
|
||||
Wallpaper.clearComponentCache()
|
||||
|
||||
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
||||
}
|
||||
|
||||
// This function only gets called here (the same function
|
||||
// is inside the WebView.qml) when the previous Wallpaper type
|
||||
// was not a video
|
||||
function onReloadVideo(oldType) {
|
||||
// We need to check if the old type
|
||||
// was also Video not get called twice
|
||||
if (oldType === Wallpaper.WallpaperType.Video)
|
||||
return
|
||||
|
||||
imgCover.state = "in"
|
||||
loader.source = "qrc:/WebView.qml"
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,12 +71,12 @@ Rectangle {
|
||||
case Wallpaper.WallpaperType.Html:
|
||||
loader.webViewUrl = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
||||
loader.source = "qrc:/WebView.qml"
|
||||
fadeIn()
|
||||
fadeIn()
|
||||
break
|
||||
case Wallpaper.WallpaperType.Qml:
|
||||
loader.source = Qt.resolvedUrl(Wallpaper.fullContentPath)
|
||||
imgCover.state = "out"
|
||||
fadeIn()
|
||||
fadeIn()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ Item {
|
||||
Connections {
|
||||
target: Wallpaper
|
||||
|
||||
function onReloadVideo() {
|
||||
function onReloadVideo(oldType) {
|
||||
|
||||
webView.runJavaScript(root.getSetVideoCommand())
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
|
||||
QApplication::instance()->installEventFilter(this);
|
||||
|
||||
qRegisterMetaType<BaseWindow::WallpaperType>();
|
||||
|
||||
qmlRegisterType<BaseWindow>("ScreenPlay.Wallpaper", 1, 0, "Wallpaper");
|
||||
|
||||
setOSVersion(QSysInfo::productVersion());
|
||||
@ -66,8 +67,9 @@ BaseWindow::BaseWindow(QString projectFilePath, const QVector<int> activeScreens
|
||||
setBasePath(projectFilePath);
|
||||
setFullContentPath("file:///" + projectFilePath + "/" + projectObject.value("file").toString());
|
||||
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &BaseWindow::reloadQML);
|
||||
QObject::connect(&m_fileSystemWatcher, &QFileSystemWatcher::fileChanged, this, &BaseWindow::reloadQML);
|
||||
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();
|
||||
@ -143,6 +145,7 @@ void BaseWindow::replaceWallpaper(
|
||||
const QString type,
|
||||
const bool checkWallpaperVisible)
|
||||
{
|
||||
const WallpaperType oldType = this->type();
|
||||
setCheckWallpaperVisible(checkWallpaperVisible);
|
||||
setVolume(volume);
|
||||
setFillMode(fillMode);
|
||||
@ -151,10 +154,10 @@ void BaseWindow::replaceWallpaper(
|
||||
qInfo() << file;
|
||||
|
||||
if (m_type == WallpaperType::Qml || m_type == WallpaperType::Html)
|
||||
emit reloadQML();
|
||||
emit reloadQML(oldType);
|
||||
|
||||
if (m_type == WallpaperType::Video)
|
||||
emit reloadVideo();
|
||||
emit reloadVideo(oldType);
|
||||
}
|
||||
|
||||
// Used for loading shader
|
||||
|
@ -106,7 +106,7 @@ public:
|
||||
return m_playbackRate;
|
||||
}
|
||||
|
||||
WallpaperType type() const
|
||||
BaseWindow::WallpaperType type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
@ -178,14 +178,14 @@ public:
|
||||
|
||||
signals:
|
||||
void qmlExit();
|
||||
void reloadQML();
|
||||
void reloadVideo();
|
||||
void reloadQML(const BaseWindow::WallpaperType oldType);
|
||||
void reloadVideo(const BaseWindow::WallpaperType oldType);
|
||||
|
||||
void loopsChanged(bool loops);
|
||||
void volumeChanged(float volume);
|
||||
void isPlayingChanged(bool isPlaying);
|
||||
void playbackRateChanged(float playbackRate);
|
||||
void typeChanged(WallpaperType type);
|
||||
void typeChanged(BaseWindow::WallpaperType type);
|
||||
void fullContentPathChanged(QString fullContentPath);
|
||||
void appIDChanged(QString appID);
|
||||
void qmlSceneValueReceived(QString key, QString value);
|
||||
@ -259,7 +259,7 @@ public slots:
|
||||
emit playbackRateChanged(m_playbackRate);
|
||||
}
|
||||
|
||||
void setType(WallpaperType type)
|
||||
void setType(BaseWindow::WallpaperType type)
|
||||
{
|
||||
if (m_type == type)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user