Commit 6ce046bd authored by Kai Uwe Broulik's avatar Kai Uwe Broulik Committed by Boudewijn Rempt

[KisColorFilterCombo] Force ComboBox popup

Only in this mode will Qt respect the contents of the ComboBox popup. This is what Fusion uses.

BUG: 406595

Differential Revision: https://phabricator.kde.org/D25739

(cherry picked from commit 818c841b)
parent 49395275
......@@ -22,6 +22,7 @@
#include <QStylePainter>
#include <QtCore/qmath.h>
#include <QApplication>
#include <QProxyStyle>
#include <QStyleOption>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
......@@ -159,6 +160,24 @@ public:
}
};
class PopupComboBoxStyle : public QProxyStyle
{
public:
PopupComboBoxStyle(QStyle *baseStyle = nullptr) : QProxyStyle(baseStyle) {}
int styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const override
{
// This flag makes ComboBox popup float ontop of its parent ComboBox, like in Fusion style.
// Only when this hint is set will Qt respect combobox popup size hints, otherwise the popup
// can never exceed the width of its parent ComboBox, like in Breeze style.
if (hint == QStyle::SH_ComboBox_Popup) {
return true;
}
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
};
struct KisColorFilterCombo::Private
{
LabelFilteringModel *filteringModel;
......@@ -171,6 +190,10 @@ KisColorFilterCombo::KisColorFilterCombo(QWidget *parent)
QStandardItemModel *newModel = new QStandardItemModel(this);
setModel(newModel);
PopupComboBoxStyle *proxyStyle = new PopupComboBoxStyle(style());
proxyStyle->setParent(this);
setStyle(proxyStyle);
setView(new FullSizedListView);
m_eventFilters.append(new ComboEventFilter(this));
m_eventFilters.append(new ComboEventFilter(this));
......
Markdown is supported
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