Commit 818c841b authored by Kai Uwe Broulik's avatar Kai Uwe Broulik

[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
parent 2dc2ed5f
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QStylePainter> #include <QStylePainter>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
#include <QApplication> #include <QApplication>
#include <QProxyStyle>
#include <QStyleOption> #include <QStyleOption>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
...@@ -159,6 +160,24 @@ public: ...@@ -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 struct KisColorFilterCombo::Private
{ {
LabelFilteringModel *filteringModel; LabelFilteringModel *filteringModel;
...@@ -171,6 +190,10 @@ KisColorFilterCombo::KisColorFilterCombo(QWidget *parent) ...@@ -171,6 +190,10 @@ KisColorFilterCombo::KisColorFilterCombo(QWidget *parent)
QStandardItemModel *newModel = new QStandardItemModel(this); QStandardItemModel *newModel = new QStandardItemModel(this);
setModel(newModel); setModel(newModel);
PopupComboBoxStyle *proxyStyle = new PopupComboBoxStyle(style());
proxyStyle->setParent(this);
setStyle(proxyStyle);
setView(new FullSizedListView); setView(new FullSizedListView);
m_eventFilters.append(new ComboEventFilter(this)); m_eventFilters.append(new ComboEventFilter(this));
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