Use correct window for getting ComboBox current icon pixmap

In widgets:
* windowHandle() only works for top level widgets (windows), so we need to first get the actual window() as windowHandle() is always
  nullptr for controls like ComboBox

In QtQuick Controls:
* we would just blow up for accessing widget which is null here. Use the QQuickWindow of the QQuickItem, if any. Given how long this
  went unnoticed shows that Qt *never* ever had icons working in ComboBoxes in QtQuick...

Differential Revision: https://phabricator.kde.org/D18655
wilder-5.17
Kai Uwe Broulik 7 years ago
parent 2750e07e4e
commit afef901a2a
  1. 15
      kstyle/breezestyle.cpp

@ -60,6 +60,10 @@
#include <QTreeView>
#include <QWidgetAction>
#if BREEZE_HAVE_QTQUICK
#include <QQuickWindow>
#endif
namespace BreezePrivate
{
@ -4570,7 +4574,16 @@ namespace Breeze
mode = QIcon::Disabled;
}
const auto pixmap = cb->currentIcon.pixmap(widget->windowHandle(), cb->iconSize, mode);
QWindow *window = nullptr;
if (widget && widget->window()) {
window = widget->window()->windowHandle();
#if BREEZE_HAVE_QTQUICK
} else if (QQuickItem *quickItem = qobject_cast<QQuickItem *>(option->styleObject)) {
window = quickItem->window();
#endif
}
const auto pixmap = cb->currentIcon.pixmap(window, cb->iconSize, mode);
auto iconRect(editRect);
iconRect.setWidth(cb->iconSize.width() + 4);
iconRect = alignedRect(cb->direction,

Loading…
Cancel
Save