https://bugs.kde.org/show_bug.cgi?id=523503

            Bug ID: 523503
           Summary: KPageView: selected item is invisible with the Windows
                    11 style
    Classification: Frameworks and Libraries
           Product: frameworks-kwidgetsaddons
      Version First unspecified
       Reported In:
          Platform: Microsoft Windows
                OS: Microsoft Windows
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 194613
  --> https://bugs.kde.org/attachment.cgi?id=194613&action=edit
styles comparison

SUMMARY
On Windows 11 with the default (windows11) style, the selected entry of the
KPageView icon list is painted with no selection background at all, while its
label is drawn in QPalette::HighlightedText. The result is white text on the
white page background: the selected entry appears empty. This affects the
sidebar and the settings dialog (KPageDialog) of any KDE application on
Windows.

STEPS TO REPRODUCE
1. On Windows 11, start a KDE application whose UI uses KPageView — for example
KMyMoney 5.2.70, whose main window sidebar is a KPageView — with the default
style.
2. Click an entry in the sidebar, or open Settings → Configure and select a
page.

OBSERVED RESULT
The selected entry gets no highlight and its label disappears. Sampling the
pixels of the selected item: background (255,255,255), label (255,255,255).
Starting the same application with -style fusion paints it correctly:
background (240,240,240), label (171,96,0). See attached comparison (left:
default/windows11 style, right: Fusion).

EXPECTED RESULT
The selected entry is highlighted and its label stays readable, as it does with
every other style.

SOFTWARE/OS VERSIONS
Windows: 11
Qt Version: 6.9.x
KWidgetsAddons: master (also affects released versions; the code is unchanged)

ADDITIONAL INFORMATION
KPageListViewDelegate::paint() draws the item background with
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
without setting opt.backgroundBrush, and then paints the label with
QPalette::HighlightedText (src/kpageview_p.cpp:420-423).

QCommonStyle::drawPrimitive() fills the item with the Highlight brush for
selected items, which is why this works everywhere else.
QWindows11Style::drawPrimitive() however implements PE_PanelItemViewItem as
"fill with vopt->backgroundBrush if one is set, otherwise do nothing" (qtbase,
src/plugins/styles/modernwindows/qwindows11style.cpp, Qt 6.9); the Windows 11
selection rectangle is painted in CE_ItemViewItem, which a custom delegate
never goes through. With no brush set nothing is drawn, and the white
HighlightedText ends up on the white background.

Setting the brush explicitly fixes it, and is a no-op for the other styles
since QCommonStyle uses the Highlight brush for selected items regardless of
backgroundBrush:
if (option.state & QStyle::State_Selected) {
    opt.backgroundBrush = option.palette.brush(cg, QPalette::Highlight);
}
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
The same mechanism affected KMyMoney's ledger (bug 510312) and was fixed there
in exactly this way, in commit d9fda54779320e7c1cd84eedf9f4bcdeabd5f052.
Comment #22 of that report identifies the remaining sidebar problem as
belonging to KPageView.

The same pattern exists in KColorComboDelegate::paint()
(src/kcolorcombo.cpp:79) and in KDateTable::paintCell()
(src/kdatetable.cpp:402). The latter puts the cell colour into opt.palette's
Highlight role and relies on PE_PanelItemViewItem to paint it, so date picker
cell backgrounds are probably lost on Windows 11 as well. I have not been able
to verify those two, so this report and the patch cover KPageView only.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to