Files
FWS-PacManage/pages/ui-kit.h
T
BlackAngelTV 897c174925 refactor(arch): split the app into a logic core and per-screen pages
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>
2026-09-13 11:45:48 +02:00

78 lines
2.8 KiB
C++

#pragma once
#include <QFrame>
#include <QIcon>
#include <QLabel>
#include <QPixmap>
#include <QString>
#include <QStringList>
#include <memory>
#include "package-manager.h"
#include "plugin-manager.h"
class QStackedWidget;
class QTableWidget;
// Small widget helpers shared by the screens. They exist so a screen file shows
// its layout and its wording instead of repeating the same table, card and pill
// setup — the look itself is still driven by the application stylesheet (see
// MainWindow::setupUI).
namespace ui {
// One of the embedded SVG icons (resources/resources.qrc).
QIcon icon(const QString& name);
QPixmap iconPixmap(const QString& name, int size);
// Rounded status pill (coloured background + foreground).
QLabel* badge(const QString& text, const QString& background, const QString& foreground);
// Plain raised surface, and the coloured stat card used by the dashboard.
QFrame* card();
QFrame* statCard(const QString& iconName, const QString& title, const QString& accent,
QLabel** valueOut);
// Listing used by every screen: no frame, alternating rows, and the name column
// taking the free space (every column when allStretch).
QTableWidget* table(const QStringList& headers, bool allStretch = false);
// Wraps a listing in a stack that swaps in a centered hint while it is empty,
// so a screen with no result explains itself instead of showing a bare header.
QStackedWidget* withEmptyState(QTableWidget* table, const QString& hint);
void showEmptyState(QStackedWidget* stack, bool empty);
// Small grey counter ("12 paquet(s)").
QLabel* countLabel();
// Display names of every provider offering a package (the Fournisseur column).
QString providersLabel(const PluginManager* plugins, const PackageInfo& pkg);
// Human-readable status of a package row, shared by the table and the exports.
QString packageStatusText(const PackageInfo& pkg);
// Quotes a CSV field when it contains the separator, a quote or a newline, so
// exported lists stay importable in a spreadsheet.
QString csvField(const QString& value);
// Fills a table in one repaint batch, with its signals muted: without it every
// setItem() repaints the viewport, and on the browse page each selection change
// fires the pacman queries behind the details panel (a thousand rows meant a
// thousand repaints and a pacman call in the middle of the fill).
class TableFillBatch {
public:
explicit TableFillBatch(QTableWidget* table);
~TableFillBatch();
// Called before selecting a row: that selection is what refreshes the
// details panel, so it has to be seen by the table's signals. Idempotent,
// which lets the destructor cover an early return too.
void release();
TableFillBatch(const TableFillBatch&) = delete;
TableFillBatch& operator=(const TableFillBatch&) = delete;
private:
struct Impl;
std::unique_ptr<Impl> m_impl;
};
} // namespace ui