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.
46 lines
1.8 KiB
C++
46 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
class QTranslator;
|
|
|
|
// Installs the translation matching the language preference, and swaps it when
|
|
// the user picks another one on the Settings screen.
|
|
//
|
|
// The translation files are ordinary Qt .qm catalogues, looked up as
|
|
// "translations/pacmanager_<code>.qm" in, in order:
|
|
//
|
|
// 1. <AppSettings log directory>/translations (user's own, survives an update);
|
|
// 2. <AppDataLocation>/translations (next to the config);
|
|
// 3. <directory of the executable>/translations (running from a build tree).
|
|
//
|
|
// A code with no .qm on any of those paths simply stays untranslated: the
|
|
// interface is written in French, which is what apply() falls back to. That is
|
|
// deliberate — the setting is the plumbing, and shipping catalogues is a
|
|
// translation pass of its own.
|
|
class LanguageManager {
|
|
public:
|
|
// Resolves "system" to the desktop's language and falls back to the
|
|
// interface's own language when the desktop asks for something no catalogue
|
|
// covers.
|
|
static QString resolve(const QString& code);
|
|
|
|
// True when a catalogue is actually installed for `code`, so the Settings
|
|
// screen can say so instead of pretending a choice will change something.
|
|
static bool isTranslationAvailable(const QString& code);
|
|
|
|
// Where a catalogue is looked up, for the screen to display.
|
|
static QString searchPathHint();
|
|
|
|
// Installs the catalogue for `code` (see resolve) and asks every widget to
|
|
// retranslate itself. Returns true when a catalogue was installed.
|
|
static bool apply(const QString& code);
|
|
|
|
// Catalogue currently installed, empty when the interface is untranslated.
|
|
static QString activeCode();
|
|
|
|
// Directories actually searched, in order, existing ones only.
|
|
static QStringList searchPaths();
|
|
};
|