#pragma once #include #include #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); 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 };