summaryrefslogtreecommitdiff
path: root/src/icondelegate.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-08 20:13:24 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-10 10:27:30 +0100
commit5fb590efe3f101d2a9d284232b6aa4b54a9d5de4 (patch)
tree873fa4c9760f91095cae2114f819412ad34a0ffa /src/icondelegate.cpp
parent7b684f4d15fa8f75fe802f9dd1534cf4ee2c25ea (diff)
Fix vertical alignment of icons.
Diffstat (limited to 'src/icondelegate.cpp')
-rw-r--r--src/icondelegate.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/icondelegate.cpp b/src/icondelegate.cpp
index 813395a2..7205ba62 100644
--- a/src/icondelegate.cpp
+++ b/src/icondelegate.cpp
@@ -49,6 +49,8 @@ void IconDelegate::paintIcons(
int iconWidth = icons.size() > 0 ? ((option.rect.width() / icons.size()) - 4) : 16;
iconWidth = std::min(16, iconWidth);
+ const int margin = (option.rect.height() - iconWidth) / 2;
+
painter->translate(option.rect.topLeft());
for (const QString &iconId : icons) {
if (iconId.isEmpty()) {
@@ -64,7 +66,7 @@ void IconDelegate::paintIcons(
}
QPixmapCache::insert(fullIconId, icon);
}
- painter->drawPixmap(x, 2, iconWidth, iconWidth, icon);
+ painter->drawPixmap(x, margin, iconWidth, iconWidth, icon);
x += iconWidth + 4;
}
@@ -79,6 +81,7 @@ void IconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
else {
QStyledItemDelegate::paint(painter, option, index);
}
+
paintIcons(painter, option, index, getIcons(index));
}