diff --git a/ScreenPlay/inc/public/ScreenPlay/screenplaymanager.h b/ScreenPlay/inc/public/ScreenPlay/screenplaymanager.h index f33a9b7f..28b7e709 100644 --- a/ScreenPlay/inc/public/ScreenPlay/screenplaymanager.h +++ b/ScreenPlay/inc/public/ScreenPlay/screenplaymanager.h @@ -35,8 +35,8 @@ public: const std::shared_ptr& mlm, const std::shared_ptr& settings); - Q_INVOKABLE QCoro::QmlTask removeAllWallpapers(bool saveToProfile = false); - Q_INVOKABLE bool removeAllWidgets(bool saveToProfile = false); + Q_INVOKABLE QCoro::QmlTask removeAllRunningWallpapers(bool saveToProfile = false); + Q_INVOKABLE bool removeAllRunningWidgets(bool saveToProfile = false); Q_INVOKABLE QCoro::QmlTask removeWallpaperAt(const int timelineIndex, const QString timelineIdentifier, const int monitorIndex); Q_INVOKABLE ScreenPlayWallpaper* getWallpaperByAppID(const QString& appID); diff --git a/ScreenPlay/qml/Components/Timeline.qml b/ScreenPlay/qml/Components/Timeline.qml index 5d3084da..65f56801 100644 --- a/ScreenPlay/qml/Components/Timeline.qml +++ b/ScreenPlay/qml/Components/Timeline.qml @@ -470,23 +470,37 @@ Control { } ToolButton { - text: "❌ Reset" //qsTr("Remove all timeline ranges") + id: btnReset + text: resetting ? qsTr("Reseting...") : qsTr("❌ Reset") + property bool resetting: false + enabled: !resetting z: 99 anchors { right: parent.right top: parent.top } onClicked: { - timeline.removeAll(); - App.screenPlayManager.removeAllTimlineSections().then(result => { + console.log("resetting", btnReset.resetting); + btnReset.resetting = true; + App.screenPlayManager.removeAllRunningWallpapers().then(result => { if (!result.success) { console.error("removeAllTimlineSections failed"); + btnReset.resetting = false; return; } - const position = 1.0; - const identifier = App.util.generateRandomString(4); - const sectionObject = timeline.addSection(identifier, position); - App.screenPlayManager.addTimelineAt(sectionObject.index, sectionObject.relativeLinePosition, sectionObject.identifier); + App.screenPlayManager.removeAllTimlineSections().then(result => { + if (!result.success) { + console.error("removeAllTimlineSections failed"); + btnReset.resetting = false; + return; + } + timeline.removeAll(); + const position = 1.0; + const identifier = App.util.generateRandomString(4); + const sectionObject = timeline.addSection(identifier, position); + App.screenPlayManager.addTimelineAt(sectionObject.index, sectionObject.relativeLinePosition, sectionObject.identifier); + btnReset.resetting = false; + }); }); } anchors { diff --git a/ScreenPlay/qml/ContentSettings/ContentSettingsView.qml b/ScreenPlay/qml/ContentSettings/ContentSettingsView.qml index 35fd5621..b8c41d27 100644 --- a/ScreenPlay/qml/ContentSettings/ContentSettingsView.qml +++ b/ScreenPlay/qml/ContentSettings/ContentSettingsView.qml @@ -189,7 +189,7 @@ Util.Popup { font.family: App.settings.font enabled: App.screenPlayManager.activeWallpaperCounter > 0 onClicked: { - if (!App.screenPlayManager.removeAllWallpapers(true)) + if (!App.screenPlayManager.removeAllRunningWallpapers(true)) print("Unable to close all wallpaper!"); } } @@ -204,7 +204,7 @@ Util.Popup { font.family: App.settings.font enabled: App.screenPlayManager.activeWidgetsCounter > 0 onClicked: { - if (!App.screenPlayManager.removeAllWidgets()) + if (!App.screenPlayManager.removeAllRunningWidgets()) print("Unable to close all widgets!"); } } diff --git a/ScreenPlay/qml/Navigation/Navigation.qml b/ScreenPlay/qml/Navigation/Navigation.qml index 8b25ae93..91561518 100644 --- a/ScreenPlay/qml/Navigation/Navigation.qml +++ b/ScreenPlay/qml/Navigation/Navigation.qml @@ -285,14 +285,15 @@ Rectangle { icon.width: root.iconWidth icon.height: root.iconHeight onClicked: { - App.screenPlayManager.removeAllWallpapers(true); - App.screenPlayManager.removeAllWidgets(true); + App.screenPlayManager.removeAllRunningWidgets(false); + // Saves profiles.json + App.screenPlayManager.removeAllRunningWallpapers(true); miStopAll.isPlaying = true; miMuteAll.soundEnabled = true; } hoverEnabled: true - ToolTip.text: qsTr("Close All Content") + ToolTip.text: qsTr("Stop All Running Content") ToolTip.visible: hovered } } diff --git a/ScreenPlay/src/app.cpp b/ScreenPlay/src/app.cpp index a71187f6..5fad0e6c 100644 --- a/ScreenPlay/src/app.cpp +++ b/ScreenPlay/src/app.cpp @@ -125,7 +125,7 @@ void App::init() // m_monitorListModel.get(), // &MonitorListModel::monitorConfigurationChanged, // m_screenPlayManager.get(), [this]() { - // m_screenPlayManager->removeAllWallpapers(true); + // m_screenPlayManager->removeAllRunningWallpapers(true); // }); } @@ -140,8 +140,8 @@ QString App::version() const */ void App::exit() { - m_screenPlayManager->removeAllWallpapers(false); - m_screenPlayManager->removeAllWidgets(false); + m_screenPlayManager->removeAllRunningWallpapers(false); + m_screenPlayManager->removeAllRunningWidgets(false); // Must be called inside a separate event loop otherwise we // would kill the qml engine while it is calling this function. // A single shot timer is a handy woraround for this. diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 1b924f83..e1a95b78 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -165,13 +165,14 @@ void ScreenPlayManager::setSelectedTimelineIndex(const int selectedTimelineIndex /*! \brief Removes all wallpaper entries in the profiles.json. */ -QCoro::QmlTask ScreenPlayManager::removeAllWallpapers(bool saveToProfile) +QCoro::QmlTask ScreenPlayManager::removeAllRunningWallpapers(bool saveToProfile) { - return QCoro::QmlTask([this]() -> QCoro::Task { + return QCoro::QmlTask([this, saveToProfile]() -> QCoro::Task { // call with coro const bool success = co_await m_screenPlayTimelineManager.removeAllWallpaperFromActiveTimlineSections(); qDebug() << "Task: removeAllWallpaperFromActiveTimlineSections" << success; - // emit requestSaveProfiles(); + if (saveToProfile) + emit requestSaveProfiles(); co_return Result { success }; }()); } @@ -179,7 +180,7 @@ QCoro::QmlTask ScreenPlayManager::removeAllWallpapers(bool saveToProfile) /*! \brief Removes all widgets and resets the activeWidgetCounter to 0. */ -bool ScreenPlayManager::removeAllWidgets(bool saveToProfile) +bool ScreenPlayManager::removeAllRunningWidgets(bool saveToProfile) { if (m_screenPlayWidgets.empty()) { return false; @@ -229,6 +230,7 @@ bool ScreenPlayManager::requestProjectSettingsAtMonitorIndex(const int index) if (!activeTimelineSection) { return false; } + // TODO CHANGE TO WP SECTION for (const auto& wallpaper : std::as_const(activeTimelineSection->activeWallpaperList)) { if (wallpaper->monitors()[0] == index) { @@ -328,7 +330,7 @@ QCoro::QmlTask ScreenPlayManager::removeAllTimlineSections() const bool success = co_await m_screenPlayTimelineManager.removeAllTimlineSections(); qDebug() << "Task: removeAllTimlineSections" << success; // emit requestSaveProfiles(); - // removeAllWallpapers(); + // removeAllRunningWallpapers(); co_return Result { success }; }()); } diff --git a/ScreenPlay/src/wallpapertimelinesection.cpp b/ScreenPlay/src/wallpapertimelinesection.cpp index 29189503..ad7cc37e 100644 --- a/ScreenPlay/src/wallpapertimelinesection.cpp +++ b/ScreenPlay/src/wallpapertimelinesection.cpp @@ -100,7 +100,9 @@ bool WallpaperTimelineSection::activateTimeline() QCoro::Task WallpaperTimelineSection::deactivateTimeline() { - + if (activeWallpaperList.empty()) { + co_return true; + } status = Status::Closing; for (auto& activeWallpaper : activeWallpaperList) { activeWallpaper->close();