feat(settings): add a dedicated screen for every user preference
The preferences used to be spread across a menu entry and hardcoded paths, so the user could not see them, let alone change them: where the journal goes, whether a dropped Flatpak file is accepted, and when the app checks its own version were all decided in code. They now live in AppSettings, one model the rest of the app already reads, and the new Settings screen only writes to it. Nothing keeps a second copy of a value, so a change is visible everywhere at once — switching directory moves the journal, unchecking drag & drop makes the window refuse the drop, blocking the update has the manual check say why instead of silently doing nothing. The update block is deliberately limited to PacManager itself: blocking a system package update is a decision the app has no business making. The language setting installs a Qt catalogue and asks every widget to retranslate. The interface is still written in French with QStringLiteral, so no catalogue ships yet; a language with none is shown in the list but disabled rather than silently doing nothing, and Qt Linguist stays optional so the build does not depend on it.
This commit is contained in:
27 files changed
+1906
-27
No files matched your search
+41
-2
@@ -32,6 +32,8 @@ set(SOURCES
|
||||
src/package-model.cpp
|
||||
src/update-manager.cpp
|
||||
src/app-logging.cpp
|
||||
src/app-settings.cpp
|
||||
src/language-manager.cpp
|
||||
# Logic layer: background workers, the plugin shop and the controller the
|
||||
# screens delegate to.
|
||||
src/workers.cpp
|
||||
@@ -47,6 +49,7 @@ set(SOURCES
|
||||
src/log-manager.cpp
|
||||
pages/logs-page.cpp
|
||||
pages/plugins-page.cpp
|
||||
pages/settings-page.cpp
|
||||
resources/resources.qrc
|
||||
)
|
||||
|
||||
@@ -60,6 +63,8 @@ set(HEADERS
|
||||
include/package-model.h
|
||||
include/update-manager.h
|
||||
include/app-logging.h
|
||||
include/app-settings.h
|
||||
include/language-manager.h
|
||||
include/workers.h
|
||||
include/progress-tracker.h
|
||||
include/plugin-shop.h
|
||||
@@ -73,6 +78,7 @@ set(HEADERS
|
||||
pages/history-page.h
|
||||
pages/logs-page.h
|
||||
pages/plugins-page.h
|
||||
pages/settings-page.h
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
|
||||
@@ -189,15 +195,48 @@ add_executable(app-core-test tests/app-core.test.cpp
|
||||
src/app-core.cpp src/workers.cpp src/pacman-manager.cpp
|
||||
src/plugin-manager.cpp src/history-manager.cpp src/update-manager.cpp
|
||||
src/plugin-shop.cpp
|
||||
src/app-logging.cpp src/log-manager.cpp
|
||||
src/app-logging.cpp src/log-manager.cpp src/app-settings.cpp
|
||||
include/app-core.h include/workers.h include/update-manager.h
|
||||
include/plugin-shop.h include/log-manager.h)
|
||||
include/plugin-shop.h include/log-manager.h include/app-settings.h)
|
||||
target_include_directories(app-core-test PRIVATE include)
|
||||
target_link_libraries(app-core-test PRIVATE Qt6::Core Qt6::Network)
|
||||
target_compile_definitions(app-core-test PRIVATE
|
||||
FWSPACMANAGE_VERSION="${PACMANAGER_VERSION}")
|
||||
add_test(NAME app-core-test COMMAND app-core-test)
|
||||
|
||||
# AppSettings: the whole preferences model, exercised against a temporary
|
||||
# settings file. The static policy (what a block lasts, when it is in force, what
|
||||
# a cap or a directory is worth) is pure and needs no clock.
|
||||
add_executable(app-settings-test tests/app-settings.test.cpp
|
||||
src/app-settings.cpp src/log-manager.cpp include/app-settings.h
|
||||
include/log-manager.h)
|
||||
target_include_directories(app-settings-test PRIVATE include)
|
||||
target_link_libraries(app-settings-test PRIVATE Qt6::Core)
|
||||
add_test(NAME app-settings-test COMMAND app-settings-test)
|
||||
|
||||
# ---- Translations ----
|
||||
#
|
||||
# The language setting loads Qt catalogues named pacmanager_<code>.qm, looked up
|
||||
# at runtime next to the settings or next to the binary (see
|
||||
# src/language-manager.cpp). Compiling the .ts sources into .qm needs Qt
|
||||
# Linguist, which is not always installed: when it is missing the app simply
|
||||
# runs untranslated, so the build must not depend on it.
|
||||
find_package(Qt6 QUIET COMPONENTS LinguistTools)
|
||||
if(Qt6LinguistTools_FOUND AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/translations)
|
||||
file(GLOB PACMANAGER_TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts)
|
||||
if(PACMANAGER_TS_FILES)
|
||||
qt_add_translation(PACMANAGER_QM_FILES ${PACMANAGER_TS_FILES})
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>/translations
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${PACMANAGER_QM_FILES}
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>/translations/)
|
||||
install(FILES ${PACMANAGER_QM_FILES}
|
||||
DESTINATION bin/translations)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(update-manager-test tests/update-manager.test.cpp
|
||||
src/update-manager.cpp src/app-logging.cpp include/update-manager.h)
|
||||
target_include_directories(update-manager-test PRIVATE include)
|
||||
|
||||
Reference in new issue
Block a user