Verified Commit a82076a6 authored by snooxx 💤's avatar snooxx 💤
Browse files

KShortcutsEditorDelegate: Fix HiDPI rendering of indicator arrows

Even with HiDPI rendering enabled in applications, the standard
"Configure Keyboard Shortcuts" dialog would still show pixelated
indicator arrows in the "Shortcut" and "Alternate" columns.

This is because the respective pixmap is only scaled up, but not
rendered appropriately sized from the beginning.

Setting the pixmap's `devicePixelRatio` and increasing its size fixes
the issue. `option.rect` is in device independent pixels, and therefore
should be kept as is.

Note: In order for the arrows to still get drawn in the right place,
additional fixes in `KExtendableItemDelegate` (i.e. the base class) are
necessary, see kitemviews!10.

BUG: 414904

Test Plan:
  - Launch `QT_SCALE_FACTOR=1.7 ./bin/kxmlguiwindowtest`.
  - Open "Configure Keyboard Shortcuts" dialog.
  - Arrows in "Shortcut" column should not be pixelated anymore, for
    both their expanded and collapsed states.
  - Test with `-style Fusion` and other scaling factors, too.
parent c7350f7d
Pipeline #153641 passed with stage
in 1 minute and 25 seconds
......@@ -27,11 +27,15 @@ KShortcutsEditorDelegate::KShortcutsEditorDelegate(QTreeWidget *parent, bool all
Q_ASSERT(qobject_cast<QAbstractItemView *>(parent));
QPixmap pixmap(16, 16);
const QSize indicatorSize(16, 16);
const qreal dpr = parent->devicePixelRatioF();
QPixmap pixmap(indicatorSize * dpr);
QPainter p(&pixmap);
QStyleOption option;
option.rect = pixmap.rect();
option.rect = QRect(QPoint(0, 0), indicatorSize);
bool isRtl = QApplication::isRightToLeft();
QApplication::style()->drawPrimitive(isRtl ? QStyle::PE_IndicatorArrowLeft : QStyle::PE_IndicatorArrowRight, &option, &p);
......@@ -39,6 +43,7 @@ KShortcutsEditorDelegate::KShortcutsEditorDelegate(QTreeWidget *parent, bool all
QApplication::style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &option, &p);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment