mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
[Client] Alt badges, breadcrumb trail, investigate button (#7516)
* [Client] Alt badges, breadcrumb trail, investigate button AltTableDelegate paints palette-tinted match badges with paint-through selection, style warning/critical icons on nonzero counts, and font/elision handling. TabAlts gains a clickable breadcrumb trail, an Investigate-this-user button, and bold usernames. Async alts responses are guarded against stale investigations. * [Client] Fix alt badge and trail review findings - Drop the dead VPN warning branch: rowVisible() already hides IP rows above the threshold, so setVpnThreshold(), its member and the spin-box connect never took effect. - Dim IP rows at shared_count > 2 instead of > 1: the count already includes the investigated account, so every IP row was dimmed. - Truncate backStack when a breadcrumb is clicked instead of pushing the current user again, so the trail keeps a single path and Back works. - Word-wrap the trail label so a long chain cannot widen the tab. - Extract the status/match pill painting into widgets/utility/pill_painter and use it from both delegates instead of duplicating it. * [Client] Route investigate() through the trail helper --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
18f9b26a3d
commit
2fba13753b
8 changed files with 298 additions and 29 deletions
41
cockatrice/src/interface/widgets/utility/pill_painter.cpp
Normal file
41
cockatrice/src/interface/widgets/utility/pill_painter.cpp
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#include "pill_painter.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFontMetrics>
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QStyle>
|
||||
#include <QStyleOptionViewItem>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr qreal PILL_ALPHA = 0.30;
|
||||
} // namespace
|
||||
|
||||
bool pill_painter::paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option,
|
||||
QPalette::ColorRole tintRole,
|
||||
QPalette::ColorRole textRole,
|
||||
const QString &text)
|
||||
{
|
||||
const QRect pillRect = option.rect.adjusted(PAD_X / 2, PAD_Y / 2, -PAD_X / 2, -PAD_Y / 2);
|
||||
if (pillRect.width() <= 0 || pillRect.height() <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((option.state & QStyle::State_Selected) == 0) {
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
QColor pill = option.palette.color(tintRole);
|
||||
pill.setAlphaF(PILL_ALPHA);
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(pill);
|
||||
painter->drawRoundedRect(pillRect, pillRect.height() / 2.0, pillRect.height() / 2.0);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QStyle *style = option.widget != nullptr ? option.widget->style() : QApplication::style();
|
||||
const QString elided = option.fontMetrics.elidedText(text, option.textElideMode, pillRect.width());
|
||||
style->drawItemText(painter, pillRect, Qt::AlignCenter, option.palette, true, elided, textRole);
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue