[Icons] Migrate UI glyphs to palette-token SVGs (#7595)

* [Icons] Migrate UI glyphs to palette-token SVGs

Runtime inversion is not a theming system: it rotates hue, breaks duotone art
and mishandles alpha, and a QPixmap snapshot cannot follow a palette change.
Redraw the top-level UI glyph set on a 24x24 grid with `currentColor` as the
paint token, drop Inkscape/Sodipodi cruft, and delete the icons whose metaphor
was duplicated (cogwheel/gear -> settings, scale_balanced -> scales,
update.png -> reload).

Load the glyphs through `loadThemedIcon` so the engine resolves the token from
the palette on every request, and let `themePixmap` use the same resolution for
one-shot pixmaps. `loadColorAdjustedPixmap` is gone; every caller now keeps a
QIcon, which `SettingsButtonWidget::setButtonIcon` accepts instead of a QPixmap.

Content art (mana, counters, countries) keeps its authored colors.

Add a render test covering aspect ratio, palette flips, icon modes and
high-DPI pixmaps.

* [Tests] Keep the icon render test QApplication alive until exit

Creating it as a function-local static tears it down before Qt's library statics
at exit, and libQt6Network then runs QObject destructors against freed memory —
a SEGV the sanitizer leg reports after the tests have already passed. Leak the
application instead, the usual pattern for a test binary.

* [Icons] Render lock and dropdown glyphs through the icon engine

Both generators rendered the sentinel SVG to a fixed height x height pixmap
at DPR 1. The pre-migration path rendered larger and let QIcon scale it, so
on a 2x display the games-list lock (13px) and the banner dropdown arrow
(24px) came back crisp; the new path hands the widget a DPR-1 bitmap that
gets upscaled and blurred.

- The games list asks the themed engine for `icons/lock` directly, so the
  item view paints it at the device pixel ratio and the lock also follows
  HighlightedText on a selected row.
- The dropdown goes through `loadThemedIcon(...).pixmap(size, dpr)`, which
  keeps the glyph's aspect ratio and renders at the requested ratio.
- LockPixmapGenerator has no consumer left, so it and its cache are gone.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-11-04 18:39:41 +01:00 • committed by GitHub
parent 020d9e8dcb
commit 627c7a83aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
97 changed files with 543 additions and 9711 deletions

View file

@ -1,7 +1,7 @@
#include "game_selector.h"
#include "../../../client/settings/cache_settings.h"
#include "../../pixel_map_generator.h"
#include "../../theme_icon.h"
#include "../interface/widgets/dialogs/dlg_create_game.h"
#include "../interface/widgets/dialogs/dlg_filter_games.h"
#include "../interface/widgets/tabs/tab_room.h"
@ -130,10 +130,10 @@ GameSelector::GameSelector(AbstractClient *_client,
}
filterButton = new QPushButton;
filterButton->setIcon(themePixmap(QStringLiteral("icons/search")));
filterButton->setIcon(loadThemedIcon(QStringLiteral("icons/search")));
connect(filterButton, &QPushButton::clicked, this, &GameSelector::actSetFilter);
clearFilterButton = new QPushButton;
clearFilterButton->setIcon(themePixmap(QStringLiteral("icons/clearsearch")));
clearFilterButton->setIcon(loadThemedIcon(QStringLiteral("icons/clearsearch")));
bool filtersSetToDefault = showFilters && gameListProxyModel->areFilterParametersSetToDefaults();
clearFilterButton->setEnabled(!filtersSetToDefault);
connect(clearFilterButton, &QPushButton::clicked, this, &GameSelector::actClearFilter);

View file

@ -1,6 +1,7 @@
#include "games_model.h"
#include "../../../client/settings/cache_settings.h"
#include "../../theme_icon.h"
#include "../interface/pixel_map_generator.h"
#include "libcockatrice/protocol/pb/serverinfo_user.pb.h"
#include "user/user_list_proxy.h"
@ -85,7 +86,8 @@ const QString GamesModel::getGameCreatedString(const int secs)
}
GamesModel::GamesModel(const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QObject *parent)
: QAbstractTableModel(parent), rooms(_rooms), gameTypes(_gameTypes)
: QAbstractTableModel(parent), rooms(_rooms), gameTypes(_gameTypes),
lockIcon(loadThemedIcon(QStringLiteral("icons/lock")))
{
}
@ -191,7 +193,9 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
return result.join(", ");
}
case Qt::DecorationRole: {
return gameentry.with_password() ? QIcon(LockPixmapGenerator::generatePixmap(13)) : QVariant();
// One engine per model: it is palette- and theme-aware and
// invalidates itself, so a repaint must not build a new one.
return gameentry.with_password() ? lockIcon : QVariant();
case Qt::TextAlignmentRole:
return Qt::AlignLeft;
default:

View file

@ -5,6 +5,7 @@
#include "game_type_map.h"
#include <QAbstractTableModel>
#include <QIcon>
#include <QList>
#include <QMap>
#include <QModelIndex>
@ -32,6 +33,7 @@ private:
QList<ServerInfo_Game> gameList; /**< List of games currently displayed. */
QMap<int, QString> rooms; /**< Map of room IDs to room names. */
QMap<int, GameTypeMap> gameTypes; /**< Map of room IDs to available game types. */
QIcon lockIcon; /**< Themed lock for password-protected games. */
static const int NUM_COLS = 8; /**< Number of columns in the table. */

View file

@ -1,6 +1,6 @@
#include "remote_replay_list_tree_widget.h"
#include "../../../pixel_map_generator.h"
#include "../../../theme_icon.h"
#include "libcockatrice/protocol/pb/response.pb.h"
#include "libcockatrice/protocol/pb/serverinfo_replay_match.pb.h"
@ -50,7 +50,7 @@ RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client,
QFileIconProvider fip;
dirIcon = fip.icon(QFileIconProvider::Folder);
fileIcon = fip.icon(QFileIconProvider::File);
lockIcon = themePixmap(QStringLiteral("icons/lock"));
lockIcon = loadThemedIcon(QStringLiteral("icons/lock"));
}
RemoteReplayList_TreeModel::~RemoteReplayList_TreeModel()