From 6f1220b7f3e8bf031f48995ff185fae8797e3097 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Fri, 27 Feb 2026 19:35:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore:=20assets=20&=20=E2=9C=A8?= =?UTF-8?q?=20feat:=20add=20restoreOnExit=20option,=20remove=20restoreOnCa?= =?UTF-8?q?ncel=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 +++--- WallReel/Assets/CMakeLists.txt | 13 +++++++++++++ WallReel/Assets/wallreel.desktop | 13 +++++++++++++ WallReel/Assets/wallreel.svg | 11 +++++++++++ WallReel/Core/CMakeLists.txt | 1 + WallReel/Core/Config/data.hpp | 4 ++-- WallReel/Core/Config/manager.cpp | 6 +++--- WallReel/Core/Service/manager.hpp | 13 +++++-------- WallReel/UI/CMakeLists.txt | 1 + WallReel/main.cpp | 16 ++++++++++++++++ 10 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 WallReel/Assets/CMakeLists.txt create mode 100644 WallReel/Assets/wallreel.desktop create mode 100644 WallReel/Assets/wallreel.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index 1346594..46ef26f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,9 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${CORELIB_NAME} + ${CORELIB_NAME}plugin ${UILIB_NAME} + ${UILIB_NAME}plugin ) target_include_directories(${EXECUTABLE_NAME} PRIVATE @@ -74,6 +76,4 @@ install(TARGETS ${EXECUTABLE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) -install(FILES ${CMAKE_CURRENT_LIST_DIR}/app/${EXECUTABLE_NAME}.desktop - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications -) +add_subdirectory(WallReel/Assets) diff --git a/WallReel/Assets/CMakeLists.txt b/WallReel/Assets/CMakeLists.txt new file mode 100644 index 0000000..9586b1f --- /dev/null +++ b/WallReel/Assets/CMakeLists.txt @@ -0,0 +1,13 @@ +qt_add_resources(${EXECUTABLE_NAME} "app_icons" + PREFIX "/" + FILES + ${EXECUTABLE_NAME}.svg +) + +install(FILES ${CMAKE_CURRENT_LIST_DIR}/${EXECUTABLE_NAME}.desktop + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications +) + +install(FILES ${CMAKE_CURRENT_LIST_DIR}/${EXECUTABLE_NAME}.svg + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps +) diff --git a/WallReel/Assets/wallreel.desktop b/WallReel/Assets/wallreel.desktop new file mode 100644 index 0000000..fb4006f --- /dev/null +++ b/WallReel/Assets/wallreel.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=WallReel +Icon=wallreel +GenericName=Animated wallpaper selector +TryExec=wallreel +Exec=wallreel +Comment=A small wallpaper utility made with Qt +Terminal=false +Categories=Application;Utility;DesktopSettings; +StartupNotify=true +Keywords=wallpaper;animated;utility;qt; diff --git a/WallReel/Assets/wallreel.svg b/WallReel/Assets/wallreel.svg new file mode 100644 index 0000000..5ad68bc --- /dev/null +++ b/WallReel/Assets/wallreel.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/WallReel/Core/CMakeLists.txt b/WallReel/Core/CMakeLists.txt index 3c3efc8..fb1d23a 100644 --- a/WallReel/Core/CMakeLists.txt +++ b/WallReel/Core/CMakeLists.txt @@ -1,4 +1,5 @@ qt_add_qml_module(${CORELIB_NAME} + STATIC URI ${COREMODULE_URI} VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR} SOURCES diff --git a/WallReel/Core/Config/data.hpp b/WallReel/Core/Config/data.hpp index b93d26d..6cc7a7f 100644 --- a/WallReel/Core/Config/data.hpp +++ b/WallReel/Core/Config/data.hpp @@ -38,7 +38,7 @@ // action.saveState[].timeout number 3000 Timeout for executing "cmd" in milliseconds. 0 or negative means no timeout // action.onRestore string "" Command to execute on restore ({{ key }} -> value defined or obtained in saveState) // action.quitOnSelected boolean false Whether to quit the application after confirming a wallpaper -// action.restoreOnCancel boolean true Whether to run the restore command after cancel without confirming a wallpaper +// action.restoreOnClose boolean true Whether to run the restore command after closing the application without confirming a wallpaper // // style.image_width number 320 Width of each image // style.image_height number 200 Height of each image @@ -106,7 +106,7 @@ struct ActionConfigItems { bool printSelected = true; bool printPreview = false; bool quitOnSelected = false; - bool restoreOnCancel = true; + bool restoreOnClose = true; }; struct StyleConfigItems { diff --git a/WallReel/Core/Config/manager.cpp b/WallReel/Core/Config/manager.cpp index 43a1e80..8125f65 100644 --- a/WallReel/Core/Config/manager.cpp +++ b/WallReel/Core/Config/manager.cpp @@ -242,10 +242,10 @@ void WallReel::Core::Config::Manager::_loadActionConfig(const QJsonObject& root) m_actionConfig.quitOnSelected = val.toBool(); } } - if (config.contains("restoreOnCancel")) { - const auto& val = config["restoreOnCancel"]; + if (config.contains("restoreOnClose")) { + const auto& val = config["restoreOnClose"]; if (val.isBool()) { - m_actionConfig.restoreOnCancel = val.toBool(); + m_actionConfig.restoreOnClose = val.toBool(); } } } diff --git a/WallReel/Core/Service/manager.hpp b/WallReel/Core/Service/manager.hpp index 49d9346..271df36 100644 --- a/WallReel/Core/Service/manager.hpp +++ b/WallReel/Core/Service/manager.hpp @@ -71,18 +71,13 @@ class Manager : public QObject { Q_INVOKABLE void cancel() { Logger::debug("ServiceManager", "Cancel action"); m_wallpaperService->stopAll(); - if (m_actionConfig.restoreOnCancel) { - connect(m_wallpaperService, &WallpaperService::restoreCompleted, this, [this]() { - emit cancelCompleted(); - }); - restore(); - } else { - emit cancelCompleted(); - } + emit cancelCompleted(); } bool isProcessing() const { return m_isProcessing; } + bool hasSelected() const { return m_hasSelected; } + public slots: void previewWallpaper() { @@ -101,6 +96,7 @@ class Manager : public QObject { void _onSelectCompleted() { Logger::debug("ServiceManager", "Select completed"); _onProcessCompleted(); + m_hasSelected = true; emit selectCompleted(); } @@ -129,6 +125,7 @@ class Manager : public QObject { Palette::Manager& m_paletteManager; bool m_isProcessing = false; + bool m_hasSelected = false; }; } // namespace WallReel::Core::Service diff --git a/WallReel/UI/CMakeLists.txt b/WallReel/UI/CMakeLists.txt index 4495cb1..3542a85 100644 --- a/WallReel/UI/CMakeLists.txt +++ b/WallReel/UI/CMakeLists.txt @@ -1,4 +1,5 @@ qt_add_qml_module(${UILIB_NAME} + STATIC URI ${UIMODULE_URI} VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR} QML_FILES diff --git a/WallReel/main.cpp b/WallReel/main.cpp index bd3271c..f556c96 100644 --- a/WallReel/main.cpp +++ b/WallReel/main.cpp @@ -3,6 +3,10 @@ #include #include #include +#include + +Q_IMPORT_QML_PLUGIN(WallReel_CorePlugin) +Q_IMPORT_QML_PLUGIN(WallReel_UIPlugin) #include "Cache/manager.hpp" #include "Core/Config/manager.hpp" @@ -25,6 +29,7 @@ int main(int argc, char* argv[]) { QApplication a(argc, argv); a.setApplicationName(APP_NAME); a.setApplicationVersion(APP_VERSION); + a.setWindowIcon(QIcon(QString(":/%1.svg").arg(APP_NAME))); Logger::init(); s_options.parseArgs(a); @@ -97,6 +102,17 @@ int main(int argc, char* argv[]) { &Service::Manager::cancelCompleted, &a, []() { QCoreApplication::quit(); }); + if (config->getActionConfig().restoreOnClose) { + QObject::connect( + &a, + &QApplication::aboutToQuit, + Service, + [Service]() { + if (!Service->hasSelected()) { + Service->restore(); + } + }); + } QObject::connect( &engine,