1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-18 08:22:33 +02:00

Add explicit quit message send on close

This commit is contained in:
Elias Steurer 2021-09-10 10:43:22 +02:00
parent 7883a98181
commit bf4c5df556
5 changed files with 25 additions and 8 deletions

View File

@ -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<ScreenPlayWallpaper>& 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<ScreenPlayWidget>& 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();

View File

@ -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.
*/

View File

@ -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);

View File

@ -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));
}
/*!

View File

@ -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)