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.
60 lines
2.3 KiB
C++
60 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QWidget>
|
|
|
|
#include "app-core.h"
|
|
|
|
// One screen of the application. Each screen lives in its own file under
|
|
// pages/ and owns nothing but its own widgets: the frame (MainWindow) keeps the
|
|
// sidebar, the header, the status bar and every dialog, and the logic stays in
|
|
// AppCore.
|
|
//
|
|
// Adding a screen therefore means writing one Page subclass here and
|
|
// registering it in MainWindow::setupUI — no backend code involved.
|
|
class QMainWindow;
|
|
|
|
class Page : public QWidget {
|
|
Q_OBJECT
|
|
public:
|
|
explicit Page(AppCore* core, QWidget* parent = nullptr);
|
|
|
|
// Header text, asked by the frame whenever the screen is shown. A screen
|
|
// whose title depends on its state (the browse page shows search, installed
|
|
// or updates) just returns the current one.
|
|
virtual QString navTitle() const = 0;
|
|
virtual QString navSubtitle() const = 0;
|
|
|
|
// Called every time the screen becomes visible, so it can reload whatever
|
|
// may be stale. Default: nothing to reload.
|
|
virtual void refresh() {}
|
|
|
|
signals:
|
|
// Ask the frame to switch to another screen (dashboard shortcuts) or to run
|
|
// a request on the user's behalf.
|
|
void goToPage(const QString& pageId);
|
|
void requestStart(AppCore::StartResult result, const QString& title);
|
|
// Something the user should read in the status bar, with no operation
|
|
// behind it ("Aucune liste à exporter.", ...).
|
|
void message(const QString& text);
|
|
// The screen picked another sudo credential mode. The frame answers it
|
|
// rather than the screen writing the preference itself, because prompting
|
|
// for the password is the frame's job and the menu bar's checkmarks have to
|
|
// follow along.
|
|
void credentialModeRequested(bool atLaunch);
|
|
|
|
protected:
|
|
AppCore* core() const { return m_core; }
|
|
|
|
// Top-level window this screen is stacked in. Needed by the addon hook,
|
|
// which attaches a plugin's own UI to the main window.
|
|
QMainWindow* mainWindow() const;
|
|
|
|
// Hands a request to the frame: it owns the sudo-password and pacman-lock
|
|
// dialogs and replays the request once the user answered.
|
|
void start(const AppCore::StartResult& result, const QString& title);
|
|
|
|
private:
|
|
AppCore* m_core = nullptr; // non-owning: the frame owns the core
|
|
};
|