diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 7110c713..89c5f6a3 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -423,10 +423,11 @@ bool ScreenPlayManager::removeWallpaper(const QString& appID) std::remove_if( m_screenPlayWallpapers.begin(), m_screenPlayWallpapers.end(), - [this, appID](auto& wallpaper) { + [this, appID](std::shared_ptr& wallpaper) { if (wallpaper->appID() != appID) { return false; } + wallpaper->messageQuit(); qInfo() << "Remove wallpaper " << wallpaper->file() << "at monitor " << wallpaper->screenNumber(); @@ -457,12 +458,14 @@ bool ScreenPlayManager::removeWidget(const QString& appID) std::remove_if( m_screenPlayWidgets.begin(), m_screenPlayWidgets.end(), - [this, appID](auto& widget) { + [this, appID](std::shared_ptr& widget) { if (widget->appID() != appID) { qInfo() << "No match " << widget->appID(); return false; } + widget->messageQuit(); + qInfo() << "Remove widget " << appID; decreaseActiveWidgetsCounter(); @@ -578,6 +581,7 @@ bool ScreenPlayManager::loadProfiles() return false; } } + for (QJsonValueRef wallpaper : wallpaper.toObject().value("wallpaper").toArray()) { QJsonObject wallpaperObj = wallpaper.toObject(); diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 384e6064..7513330e 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -10,7 +10,6 @@ namespace ScreenPlay { This class is only for managing the QProcess to an extern ScreenPlayWallpaper! */ - /*! \brief Constructor for ScreenPlayWallpaper. */ @@ -135,6 +134,15 @@ QJsonObject ScreenPlayWallpaper::getActiveSettingsJson() return obj; } +/*! + \brief Sends command quit to the wallpaper. +*/ +void ScreenPlayWallpaper::messageQuit() +{ + QJsonObject obj; + obj.insert("command", "quit"); + m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact)); +} /*! \brief Prints the exit code if != 0. */ diff --git a/ScreenPlay/src/screenplaywallpaper.h b/ScreenPlay/src/screenplaywallpaper.h index 4abfecb5..557921f1 100644 --- a/ScreenPlay/src/screenplaywallpaper.h +++ b/ScreenPlay/src/screenplaywallpaper.h @@ -66,7 +66,7 @@ class ScreenPlayWallpaper : public QObject { Q_PROPERTY(InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged) public: - // Default constructor for qml engine + // Default constructor needed for qml engine ScreenPlayWallpaper() { } explicit ScreenPlayWallpaper( @@ -127,6 +127,7 @@ signals: void error(const QString& msg); public slots: + void messageQuit(); void processExit(int exitCode, QProcess::ExitStatus exitStatus); void processError(QProcess::ProcessError error); bool setWallpaperValue(const QString& key, const QString& value, const bool save = false); diff --git a/ScreenPlay/src/screenplaywidget.cpp b/ScreenPlay/src/screenplaywidget.cpp index 0ecedce8..b08c0c1b 100644 --- a/ScreenPlay/src/screenplaywidget.cpp +++ b/ScreenPlay/src/screenplaywidget.cpp @@ -70,10 +70,14 @@ bool ScreenPlayWidget::start() return success; } -ScreenPlayWidget::~ScreenPlayWidget() +/*! + \brief Sends command quit to the widget. +*/ +void ScreenPlayWidget::messageQuit() { - qInfo() << "Remove widget " << m_appID; - m_connection->close(); + QJsonObject obj; + obj.insert("command", "quit"); + m_connection->sendMessage(QJsonDocument(obj).toJson(QJsonDocument::Compact)); } /*! diff --git a/ScreenPlay/src/screenplaywidget.h b/ScreenPlay/src/screenplaywidget.h index d6852092..7a10340c 100644 --- a/ScreenPlay/src/screenplaywidget.h +++ b/ScreenPlay/src/screenplaywidget.h @@ -69,7 +69,6 @@ public: const QString& absolutePath, const QString& previewImage, const QJsonObject& properties, const InstalledType::InstalledType type); - ~ScreenPlayWidget(); bool start(); @@ -86,6 +85,7 @@ public: ProjectSettingsListModel* getProjectSettingsListModel() { return &m_projectSettingsListModel; } public slots: + void messageQuit(); QJsonObject getActiveSettingsJson(); void setPreviewImage(QString previewImage)