diff options
author | Oleg Yadrov <oleg.yadrov@qt.io> | 2017-10-02 10:27:10 -0400 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2017-10-05 17:04:07 +0000 |
commit | 5ff9d6a470dbcf424f2f43206ab6ab6eb91edcc1 (patch) | |
tree | eb2424ff6dfb579aaa962f218e094b932fe41cec /src/widgets | |
parent | 08e083e682d92290e36e4fb09abaf0318575dd41 (diff) |
QMacStyle: smooth QMenu corners for real
It's been for years that QMenu's rounded corners in qmacstyle_mac were
done via QWidget::setMask(QRegion). Unfortunately, QRegion mask does not
work well with retina displays and also does not support translucency.
That's why in this change we explicitly make QMenu's background
transparent and then draw a rectangle with rounded corners in
QMacStyle::drawPrimitive(PE_PanelMenu). This not only gives much better
result than the mask-based approach, but also de-HIThemes QMenu.
As a consequence, QComboBoxPrivateContainer doesn't get any mask from
QMacStyle anymore. Therefore, when the mask is empty, we need to paint
PE_PanelMenu before invoking QFrame's paint event handler.
Made-with: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Change-Id: Ia9236176113f23b86e45507fa6ddf77236084ce3
Reviewed-by: Oleg Yadrov <oleg.yadrov@qt.io>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox_p.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 1338a496e6..9afb4b3ae6 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -428,6 +428,20 @@ void QComboBoxPrivateContainer::resizeEvent(QResizeEvent *e) QFrame::resizeEvent(e); } +void QComboBoxPrivateContainer::paintEvent(QPaintEvent *e) +{ + QStyleOptionComboBox cbOpt = comboStyleOption(); + if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &cbOpt, combo) + && mask().isEmpty()) { + QStyleOption opt; + opt.initFrom(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_PanelMenu, &opt, &p, this); + } + + QFrame::paintEvent(e); +} + void QComboBoxPrivateContainer::leaveEvent(QEvent *) { // On Mac using the Mac style we want to clear the selection diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 835bbf866e..3f75a357e4 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -248,6 +248,7 @@ protected: void timerEvent(QTimerEvent *timerEvent) override; void leaveEvent(QEvent *e) override; void resizeEvent(QResizeEvent *e) override; + void paintEvent(QPaintEvent *e) override; QStyleOptionComboBox comboStyleOption() const; Q_SIGNALS: |