mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-07 03:22:33 +01:00
Add removal of Wallpaper/Widget on crash
This commit is contained in:
parent
fa6b734820
commit
3be5ab032e
@ -154,6 +154,7 @@ void ScreenPlayManager::createWallpaper(
|
||||
m_settings->checkWallpaperVisible());
|
||||
|
||||
QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestSave, this, &ScreenPlayManager::requestSaveProfiles);
|
||||
QObject::connect(wallpaper.get(), &ScreenPlayWallpaper::requestClose, this, &ScreenPlayManager::removeApp);
|
||||
m_screenPlayWallpapers.append(wallpaper);
|
||||
m_monitorListModel->setWallpaperActiveMonitor(wallpaper, monitorIndex);
|
||||
increaseActiveWallpaperCounter();
|
||||
@ -195,6 +196,7 @@ void ScreenPlayManager::createWidget(
|
||||
type);
|
||||
|
||||
QObject::connect(widget.get(), &ScreenPlayWidget::requestSave, this, &ScreenPlayManager::requestSaveProfiles);
|
||||
QObject::connect(widget.get(), &ScreenPlayWidget::requestClose, this, &ScreenPlayManager::removeApp);
|
||||
increaseActiveWidgetsCounter();
|
||||
m_screenPlayWidgets.append(widget);
|
||||
}
|
||||
@ -269,15 +271,26 @@ bool ScreenPlayManager::removeWallpaperAt(int index)
|
||||
{
|
||||
|
||||
if (auto appID = m_monitorListModel->getAppIDByMonitorIndex(index)) {
|
||||
return removeApp(*appID);
|
||||
}
|
||||
if (m_telemetry) {
|
||||
m_telemetry->sendEvent("wallpaper", "error_removeWallpaperAt");
|
||||
}
|
||||
qWarning() << "Could not remove Wallpaper at index:" << index;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ScreenPlayManager::removeApp(const QString &appID)
|
||||
{
|
||||
emit requestSaveProfiles();
|
||||
|
||||
if (!closeWallpaper(*appID)) {
|
||||
if (!closeConnection(appID)) {
|
||||
qWarning() << "Could not close socket. Abort!";
|
||||
return false;
|
||||
}
|
||||
m_monitorListModel->closeWallpaper(*appID);
|
||||
m_monitorListModel->closeWallpaper(appID);
|
||||
|
||||
const QString appIDCopy = *appID;
|
||||
const QString appIDCopy = appID;
|
||||
if (!removeWallpaperByAppID(appIDCopy)) {
|
||||
if (m_telemetry) {
|
||||
m_telemetry->sendEvent("wallpaper", "error_removeWallpaperAt_removeWallpaperByAppID");
|
||||
@ -287,12 +300,6 @@ bool ScreenPlayManager::removeWallpaperAt(int index)
|
||||
}
|
||||
emit requestSaveProfiles();
|
||||
return true;
|
||||
}
|
||||
if (m_telemetry) {
|
||||
m_telemetry->sendEvent("wallpaper", "error_removeWallpaperAt");
|
||||
}
|
||||
qWarning() << "Could not remove Wallpaper at index:" << index;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -401,10 +408,10 @@ void ScreenPlayManager::closeAllWidgets()
|
||||
/*!
|
||||
\brief Closes a connection by type. Used only by closeAllWidgets() and closeAllWallpapers()
|
||||
*/
|
||||
void ScreenPlayManager::closeConntectionByType(const QStringList& list)
|
||||
void ScreenPlayManager::closeConntectionByType(const QStringList& types)
|
||||
{
|
||||
for (auto& client : m_clients) {
|
||||
if (list.contains(client->type(), Qt::CaseInsensitive)) {
|
||||
if (types.contains(client->type(), Qt::CaseInsensitive)) {
|
||||
client->close();
|
||||
m_clients.removeOne(client);
|
||||
}
|
||||
@ -412,15 +419,14 @@ void ScreenPlayManager::closeConntectionByType(const QStringList& list)
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Closes a wallpaper by the given \a appID.
|
||||
\brief Closes a Wallpaper or Widget connection by the given \a appID.
|
||||
*/
|
||||
bool ScreenPlayManager::closeWallpaper(const QString& appID)
|
||||
bool ScreenPlayManager::closeConnection(const QString& appID)
|
||||
{
|
||||
for (auto& client : m_clients) {
|
||||
if (client->appID() == appID) {
|
||||
client->close();
|
||||
m_clients.removeOne(client);
|
||||
return true;
|
||||
return m_clients.removeOne(client);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -100,7 +100,8 @@ private slots:
|
||||
|
||||
public slots:
|
||||
// moc needs full enum namespace info see QTBUG-58454
|
||||
void createWallpaper(const ScreenPlay::InstalledType::InstalledType type,
|
||||
void createWallpaper(
|
||||
const ScreenPlay::InstalledType::InstalledType type,
|
||||
const ScreenPlay::FillMode::FillMode fillMode,
|
||||
const QString& absoluteStoragePath,
|
||||
const QString& previewImage,
|
||||
@ -122,18 +123,19 @@ public slots:
|
||||
void removeAllWallpapers();
|
||||
void removeAllWidgets();
|
||||
bool removeWallpaperAt(const int index);
|
||||
bool removeApp(const QString& appID);
|
||||
|
||||
void requestProjectSettingsAtMonitorIndex(const int index);
|
||||
void setWallpaperValueAtMonitorIndex(const int index, const QString& key, const QString &value);
|
||||
void setWallpaperValueAtMonitorIndex(const int index, const QString& key, const QString& value);
|
||||
void setAllWallpaperValue(const QString& key, const QString& value);
|
||||
ScreenPlayWallpaper* getWallpaperByAppID(const QString& appID) const;
|
||||
|
||||
void newConnection();
|
||||
void closeAllWallpapers();
|
||||
void closeAllWidgets();
|
||||
void closeConntectionByType(const QStringList& list);
|
||||
bool closeWallpaper(const QString& appID);
|
||||
void setWallpaperValue(const QString& appID, const QString& key, const QString &value);
|
||||
void closeConntectionByType(const QStringList& types);
|
||||
bool closeConnection(const QString& appID);
|
||||
void setWallpaperValue(const QString& appID, const QString& key, const QString& value);
|
||||
|
||||
void setActiveWallpaperCounter(int activeWallpaperCounter)
|
||||
{
|
||||
|
@ -178,7 +178,8 @@ void ScreenPlayWallpaper::setSDKConnection(const std::shared_ptr<SDKConnection>&
|
||||
});
|
||||
|
||||
QObject::connect(&m_pingAliveTimer, &QTimer::timeout, this, [this]() {
|
||||
qInfo() << "For " << m_pingAliveTimer.interval() << "ms no alive signal received. This means the wallpaper is dead and likely crashed!";
|
||||
qInfo() << "For " << m_pingAliveTimer.interval() << "ms no alive signal received. This means the Wallpaper is dead and likely crashed!";
|
||||
emit requestClose(m_appID);
|
||||
});
|
||||
m_pingAliveTimer.start(16000);
|
||||
}
|
||||
|
@ -67,8 +67,10 @@ class ScreenPlayWallpaper : public QObject {
|
||||
Q_PROPERTY(InstalledType::InstalledType type READ type WRITE setType NOTIFY typeChanged)
|
||||
|
||||
public:
|
||||
ScreenPlayWallpaper(){}
|
||||
explicit ScreenPlayWallpaper(const QVector<int>& screenNumber,
|
||||
ScreenPlayWallpaper() { }
|
||||
|
||||
explicit ScreenPlayWallpaper(
|
||||
const QVector<int>& screenNumber,
|
||||
const std::shared_ptr<GlobalVariables>& globalVariables,
|
||||
const QString& appID,
|
||||
const QString& absolutePath,
|
||||
@ -80,7 +82,8 @@ public:
|
||||
const bool checkWallpaperVisible,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
void replace(const QString& absolutePath,
|
||||
void replace(
|
||||
const QString& absolutePath,
|
||||
const QString& previewImage,
|
||||
const QString& file,
|
||||
const float volume,
|
||||
@ -158,13 +161,15 @@ signals:
|
||||
void profileJsonObjectChanged(QJsonObject profileJsonObject);
|
||||
void volumeChanged(float volume);
|
||||
void isLoopingChanged(bool isLooping);
|
||||
void requestSave();
|
||||
void playbackRateChanged(float playbackRate);
|
||||
|
||||
void requestSave();
|
||||
void requestClose(const QString& appID);
|
||||
|
||||
public slots:
|
||||
void processExit(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void processError(QProcess::ProcessError error);
|
||||
void setWallpaperValue(const QString& key, const QString &value, const bool save = false);
|
||||
void setWallpaperValue(const QString& key, const QString& value, const bool save = false);
|
||||
|
||||
void setScreenNumber(QVector<int> screenNumber)
|
||||
{
|
||||
|
@ -83,7 +83,8 @@ void ScreenPlayWidget::setSDKConnection(const std::shared_ptr<SDKConnection>& co
|
||||
});
|
||||
|
||||
QObject::connect(&m_pingAliveTimer, &QTimer::timeout, this, [this]() {
|
||||
qInfo() << "For " << m_pingAliveTimer.interval() << "ms no alive signal received. This means the wallpaper is dead and likely crashed!";
|
||||
qInfo() << "For " << m_pingAliveTimer.interval() << "ms no alive signal received. This means the Widget is dead and likely crashed!";
|
||||
emit requestClose(m_appID);
|
||||
});
|
||||
m_pingAliveTimer.start(16000);
|
||||
}
|
||||
|
@ -155,7 +155,9 @@ signals:
|
||||
void appIDChanged(QString appID);
|
||||
void typeChanged(InstalledType::InstalledType type);
|
||||
void absolutePathChanged(QString absolutePath);
|
||||
|
||||
void requestSave();
|
||||
void requestClose(const QString& appID);
|
||||
|
||||
private:
|
||||
const std::shared_ptr<GlobalVariables> m_globalVariables;
|
||||
|
Loading…
Reference in New Issue
Block a user