refactor(pages): group the screens by what the user is doing
pages/ was a flat row of eight screens, so a change to one meant scanning the whole folder to see what else was in it. The screens now sit in packages/ (browse, cleanup), overview/ (dashboard, history), system/ (logs, settings) and extensions/ (plugins), with the scaffolding they all build on — the Page base and the shared widgets — in base/.
This commit is contained in:
19 files changed
+19
-19
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#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
|
||||
};
|
||||
Reference in new issue
Block a user