🔧 chore: assets & feat: add restoreOnExit option, remove restoreOnCancel options

This commit is contained in:
2026-02-27 19:35:58 +01:00
parent 1ccb26f42b
commit 6f1220b7f3
10 changed files with 68 additions and 16 deletions
+3 -3
View File
@@ -60,7 +60,9 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES
target_link_libraries(${EXECUTABLE_NAME} PRIVATE target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CORELIB_NAME} ${CORELIB_NAME}
${CORELIB_NAME}plugin
${UILIB_NAME} ${UILIB_NAME}
${UILIB_NAME}plugin
) )
target_include_directories(${EXECUTABLE_NAME} PRIVATE target_include_directories(${EXECUTABLE_NAME} PRIVATE
@@ -74,6 +76,4 @@ install(TARGETS ${EXECUTABLE_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
install(FILES ${CMAKE_CURRENT_LIST_DIR}/app/${EXECUTABLE_NAME}.desktop add_subdirectory(WallReel/Assets)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications
)
+13
View File
@@ -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
)
+13
View File
@@ -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;
+11
View File
@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="256" height="256">
<g fill="#89b4fa">
<rect x="10" y="35" width="24" height="50" rx="4" opacity="0.4" />
<rect x="86" y="35" width="24" height="50" rx="4" opacity="0.4" />
<rect x="42" y="20" width="36" height="80" rx="6" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 326 B

+1
View File
@@ -1,4 +1,5 @@
qt_add_qml_module(${CORELIB_NAME} qt_add_qml_module(${CORELIB_NAME}
STATIC
URI ${COREMODULE_URI} URI ${COREMODULE_URI}
VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR} VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}
SOURCES SOURCES
+2 -2
View File
@@ -38,7 +38,7 @@
// action.saveState[].timeout number 3000 Timeout for executing "cmd" in milliseconds. 0 or negative means no timeout // 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.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.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_width number 320 Width of each image
// style.image_height number 200 Height of each image // style.image_height number 200 Height of each image
@@ -106,7 +106,7 @@ struct ActionConfigItems {
bool printSelected = true; bool printSelected = true;
bool printPreview = false; bool printPreview = false;
bool quitOnSelected = false; bool quitOnSelected = false;
bool restoreOnCancel = true; bool restoreOnClose = true;
}; };
struct StyleConfigItems { struct StyleConfigItems {
+3 -3
View File
@@ -242,10 +242,10 @@ void WallReel::Core::Config::Manager::_loadActionConfig(const QJsonObject& root)
m_actionConfig.quitOnSelected = val.toBool(); m_actionConfig.quitOnSelected = val.toBool();
} }
} }
if (config.contains("restoreOnCancel")) { if (config.contains("restoreOnClose")) {
const auto& val = config["restoreOnCancel"]; const auto& val = config["restoreOnClose"];
if (val.isBool()) { if (val.isBool()) {
m_actionConfig.restoreOnCancel = val.toBool(); m_actionConfig.restoreOnClose = val.toBool();
} }
} }
} }
+4 -7
View File
@@ -71,18 +71,13 @@ class Manager : public QObject {
Q_INVOKABLE void cancel() { Q_INVOKABLE void cancel() {
Logger::debug("ServiceManager", "Cancel action"); Logger::debug("ServiceManager", "Cancel action");
m_wallpaperService->stopAll(); m_wallpaperService->stopAll();
if (m_actionConfig.restoreOnCancel) {
connect(m_wallpaperService, &WallpaperService::restoreCompleted, this, [this]() {
emit cancelCompleted(); emit cancelCompleted();
});
restore();
} else {
emit cancelCompleted();
}
} }
bool isProcessing() const { return m_isProcessing; } bool isProcessing() const { return m_isProcessing; }
bool hasSelected() const { return m_hasSelected; }
public slots: public slots:
void previewWallpaper() { void previewWallpaper() {
@@ -101,6 +96,7 @@ class Manager : public QObject {
void _onSelectCompleted() { void _onSelectCompleted() {
Logger::debug("ServiceManager", "Select completed"); Logger::debug("ServiceManager", "Select completed");
_onProcessCompleted(); _onProcessCompleted();
m_hasSelected = true;
emit selectCompleted(); emit selectCompleted();
} }
@@ -129,6 +125,7 @@ class Manager : public QObject {
Palette::Manager& m_paletteManager; Palette::Manager& m_paletteManager;
bool m_isProcessing = false; bool m_isProcessing = false;
bool m_hasSelected = false;
}; };
} // namespace WallReel::Core::Service } // namespace WallReel::Core::Service
+1
View File
@@ -1,4 +1,5 @@
qt_add_qml_module(${UILIB_NAME} qt_add_qml_module(${UILIB_NAME}
STATIC
URI ${UIMODULE_URI} URI ${UIMODULE_URI}
VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR} VERSION ${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}
QML_FILES QML_FILES
+16
View File
@@ -3,6 +3,10 @@
#include <QApplication> #include <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include <QtQml/QQmlExtensionPlugin>
Q_IMPORT_QML_PLUGIN(WallReel_CorePlugin)
Q_IMPORT_QML_PLUGIN(WallReel_UIPlugin)
#include "Cache/manager.hpp" #include "Cache/manager.hpp"
#include "Core/Config/manager.hpp" #include "Core/Config/manager.hpp"
@@ -25,6 +29,7 @@ int main(int argc, char* argv[]) {
QApplication a(argc, argv); QApplication a(argc, argv);
a.setApplicationName(APP_NAME); a.setApplicationName(APP_NAME);
a.setApplicationVersion(APP_VERSION); a.setApplicationVersion(APP_VERSION);
a.setWindowIcon(QIcon(QString(":/%1.svg").arg(APP_NAME)));
Logger::init(); Logger::init();
s_options.parseArgs(a); s_options.parseArgs(a);
@@ -97,6 +102,17 @@ int main(int argc, char* argv[]) {
&Service::Manager::cancelCompleted, &Service::Manager::cancelCompleted,
&a, &a,
[]() { QCoreApplication::quit(); }); []() { QCoreApplication::quit(); });
if (config->getActionConfig().restoreOnClose) {
QObject::connect(
&a,
&QApplication::aboutToQuit,
Service,
[Service]() {
if (!Service->hasSelected()) {
Service->restore();
}
});
}
QObject::connect( QObject::connect(
&engine, &engine,