Files
FWS-PacManage/pages/settings-page.h
BlackAngelTV aff959bc4b 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.
2026-09-28 20:44:21 +02:00

92 lines
2.7 KiB
C++

#pragma once
#include <QString>
#include "page.h"
class QCheckBox;
class QComboBox;
class QFrame;
class QLabel;
class QLineEdit;
class QPushButton;
class QVBoxLayout;
// The Settings screen: one card per family of preferences, each one writing
// straight to the model the rest of the app reads (AppSettings, and the core's
// credential mode), so nothing here holds a private copy of a value.
//
// Four families are the user's alone — the journal (where it is written, how big
// it may grow), drag & drop of Flatpak files, the language, and the app's own
// update policy. The fifth, the sudo credential mode, is not new: the screen
// drives the same AppCore::setCredentialMode() the Paramètres menu already did,
// and the two stay in step.
class SettingsPage : public Page {
Q_OBJECT
public:
explicit SettingsPage(AppCore* core, QWidget* parent = nullptr);
QString navTitle() const override;
QString navSubtitle() const override;
// Re-reads every control from the model, so a value changed elsewhere (the
// menu bar, a restored settings file) is reflected when the screen opens.
void refresh() override;
private:
// ---- Credentials ----
QFrame* buildCredentialsCard();
// ---- Journal ----
QFrame* buildLogCard();
void loadLogCard();
void chooseLogDirectory();
void openLogDirectory();
void resetLogDirectory();
void updateLogSizeLabel();
// ---- Drag & drop ----
QFrame* buildDragDropCard();
// ---- Language ----
QFrame* buildLanguageCard();
void loadLanguageCard();
// ---- Application updates ----
QFrame* buildUpdateCard();
void loadUpdateCard();
void applyUpdateBlock();
void clearUpdateBlock();
void updateUpdateHint();
// One titled card, the building block every section below is made of. The
// card's own vertical layout is handed back so a section can fill it
// without going through QWidget::layout(), which hides the typed layout.
QFrame* card(const QString& title, QVBoxLayout** layoutOut) const;
AppSettings* preferences() const;
// Credentials
QComboBox* m_credentialMode = nullptr;
QLabel* m_credentialHint = nullptr;
// Journal
QLineEdit* m_logDirectory = nullptr;
QComboBox* m_logMaxSize = nullptr;
QLabel* m_logSizeLabel = nullptr;
QPushButton* m_logResetButton = nullptr;
// Drag & drop
QCheckBox* m_dragDrop = nullptr;
// Language
QComboBox* m_language = nullptr;
QLabel* m_languageHint = nullptr;
// Application updates
QCheckBox* m_autoUpdateCheck = nullptr;
QComboBox* m_updateBlockDelay = nullptr;
QPushButton* m_updateBlockButton = nullptr;
QLabel* m_updateHint = nullptr;
};