All the business logic now lives in AppCore (providers, workers, history, plugins, sudo and pacman-lock handling), freed from any widget so it runs headless and is testable on its own. The Qt window becomes a thin frame around one file per screen under pages/, wired through a common Page contract and a shared ui-kit. CMake gains the app-core-test target, which links Qt Core only to enforce the headless guarantee. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
55 lines
2.0 KiB
C++
55 lines
2.0 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);
|
|
|
|
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
|
|
};
|