qt5base-lts/src
Volker Hilsheimer 3e9895f3de Support checkable QComboBox items with styles using a popup dropdown
The dropdown of a combobox is rendered using menu items when the style
request it to do so via the SH_ComboBox_Popup style hint.

In that case, checkable items were not supported; the QComboBox didn't
pass the checked state correctly to the style, and the delegate used
for rendering the items into the list view did not implement modifying
the checked state of the item.

However, the QStyleOptionMenuItem's checked state and checkType members
were set anyway, as on e.g. macOS style we use a checkmark to show
which item is currently selected in the combobox.

The QStyle::State enum defines State_On and State_Off for toggleable
things, so in addition to setting QStyleOptionMenuItem::checked, we are
now also adding State_On or State_Off if the model provides a valid
checked/unchecked state. Otherwise, we only set the checked state if
the item is currently selected.

In addition, we implement the delegate to support toggling of checkable
model data with mouse and keyboard, using a simplified version of the
QItemDelegate implementation. To avoid spurious item toggles when the
popup is opened, we only handle mouse releases when the press was on
the same row.

In the fusion style, we ignore the workaround to let QtQuickControls
render comboboxes if State_On or State_Off are set.

[ChangeLog][QtWidgets][QComboBox] Support checkable items in styles
that use a popup for the dropdown.

Change-Id: Ia01519694b0419d777dc66b1ef683482fb01754c
Fixes: QTBUG-60310
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2019-12-11 13:12:31 +01:00
..
3rdparty Merge remote-tracking branch 'origin/5.14' into 5.15 2019-11-15 16:29:40 +01:00
android Android: Implement MaximizeUsingFullscreenGeometryHint 2019-11-08 07:04:43 +01:00
angle Disable debug-and-release builds for MinGW 2019-09-18 06:28:16 +00:00
concurrent QtConcurrent: fix warning about function parameters shadowing class members 2019-10-08 23:21:14 +02:00
corelib MIME: Make the internal database direct content, not a Qt resource 2019-12-10 15:56:09 -08:00
dbus Tidy nullptr usage 2019-12-06 12:13:20 +01:00
gui Avoid initializing QFlags with 0 or nullptr in macOS-specific code 2019-12-11 09:49:51 +01:00
network Tidy nullptr usage 2019-12-06 12:13:20 +01:00
opengl Merge remote-tracking branch 'origin/5.14' into 5.15 2019-12-04 01:00:07 +01:00
openglextensions QtGui: Disable Windows on ARM64 preprocessor conflict in QtOpenGL 2019-10-21 09:14:18 -04:00
platformheaders Tidy nullptr usage 2019-12-06 12:13:20 +01:00
platformsupport Tidy nullptr usage 2019-12-06 12:13:20 +01:00
plugins Avoid initializing QFlags with 0 or nullptr in macOS-specific code 2019-12-11 09:49:51 +01:00
printsupport Tidy nullptr usage 2019-12-06 12:13:20 +01:00
sql Tidy nullptr usage 2019-12-06 12:13:20 +01:00
testlib Merge remote-tracking branch 'origin/5.14' into 5.15 2019-12-10 13:51:40 +02:00
tools Tidy nullptr usage 2019-12-06 12:13:20 +01:00
widgets Support checkable QComboBox items with styles using a popup dropdown 2019-12-11 13:12:31 +01:00
winmain Merge remote-tracking branch 'origin/5.13' into dev 2019-05-27 15:34:10 +02:00
xml Port QDomDocument to QXmlStreamReader 2019-11-26 09:07:26 +01:00
src.pro MIME: Make the internal database direct content, not a Qt resource 2019-12-10 15:56:09 -08:00