1
0
Fork 0
forked from blue/squawk

context menu to trust or distrust keys

This commit is contained in:
Blue 2023-01-15 21:17:38 +03:00
parent b72a837754
commit 73d83f55af
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
5 changed files with 144 additions and 18 deletions

View file

@ -43,6 +43,12 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
QRect r;
int maxRight = 0;
int leftOrigin = option.rect.left() + margin;
QColor q = painter->pen().color();
q.setAlpha(180);
QRect rect = option.rect;
bool hover = option.state & QStyle::State_MouseOver;
if (hover) {
painter->save();
@ -50,13 +56,15 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
painter->restore();
}
QRect r;
int maxRight = 0;
int leftOrigin = option.rect.left() + margin;
QColor q = painter->pen().color();
q.setAlpha(180);
QVariant dirtyV = index.data(UI::KeysModel::Dirty);
if (dirtyV.isValid() && dirtyV.toBool()) {
painter->save();
rect.setWidth(margin / 2);
painter->fillRect(rect, option.palette.brush(QPalette::Active, QPalette::Highlight));
rect.setWidth(option.rect.width());
painter->restore();
}
QRect rect = option.rect;
rect.adjust(margin, margin, -margin, -margin);
QVariant labelV = index.data(UI::KeysModel::Label);
if (labelV.isValid()) {
@ -167,6 +175,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
firstLine = parts;
width = std::max(width, firstLine * fingerPrintMetrics.horizontalAdvance(hex, partSize) + (firstLine - 1) * spaceWidth);
width += 1; //there is a mistake somewhere, this the cheapest way to compensate it
}
QVariant lastV = index.data(UI::KeysModel::LastInteraction);
if (lastV.isValid()) {
@ -186,6 +195,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
width += margin;
width += defaultMetrics.horizontalAdvance(levelName);
width += 1; //there is a mistake somewhere, this the cheapest way to compensate it
}
mw += width;