Clicking the Updates tab already triggered the check but showed a bare empty table until it completed, and an "Update all" button that stayed disabled for ever. The tab now shows a searching hint, reports "system is up to date" on an empty result, reloads by itself when the core frees up, and enables "Update all" without a row selection. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
81 lines
3.1 KiB
C++
81 lines
3.1 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);
|
|
// Rewrites the hint shown while the listing is empty, so a screen can walk the
|
|
// user through its states ("searching..." then "nothing found").
|
|
void setEmptyStateText(QStackedWidget* stack, const QString& hint);
|
|
|
|
// 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
|