summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2017-08-04 09:21:46 +0200
committerJędrzej Nowacki <jedrzej.nowacki@qt.io>2017-08-04 12:19:45 +0000
commit569171f620db433233df49661c4f8ff22c26fc67 (patch)
treecb56a586fbe72559b5ddde311c9c47a7117ffc77 /src/widgets
parentb36e5faad49009778cea873ab30906bf212fc8b8 (diff)
Android: Fix push button label duplication with stylesheets
In the Android style, we matched both the full CE_PushButton, and the individual, decomposed CE_PushButtonBevel and CE_PushButtonLabel (and similar for other controls) to the same drawing code which draws both the label and the bevel. When used together with the style sheet style, this caused the label of the button to be drawn multiple times in different locations. For labels, we now skip the part which draws the actual control, and for the non-textual parts of the controls, we skip drawing the label. [ChangeLog][QtWidgets][Android] Fixed label duplication for buttons when using style sheets with the Android style. Task-number: QTBUG-48639 Change-Id: I1a1cdb0a82870cebd0438c5c72199afc3192938c Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qandroidstyle.cpp77
1 files changed, 44 insertions, 33 deletions
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index 110153d0f6..55f125c6b5 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -333,41 +333,52 @@ void QAndroidStyle::drawControl(QStyle::ControlElement element,
: m_androidControlsHash.end();
if (it != m_androidControlsHash.end()) {
AndroidControl *androidControl = it.value();
- androidControl->drawControl(opt, p, w);
- switch (itemType) {
- case QC_Button:
- if (const QStyleOptionButton *buttonOption =
- qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QMargins padding = androidControl->padding();
- QStyleOptionButton copy(*buttonOption);
- copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
- QFusionStyle::drawControl(CE_PushButtonLabel, &copy, p, w);
- }
- break;
- case QC_Checkbox:
- case QC_RadioButton:
- if (const QStyleOptionButton *btn =
- qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- const bool isRadio = (element == CE_RadioButton);
- QStyleOptionButton subopt(*btn);
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, btn, w);
- QFusionStyle::drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, w);
- }
- break;
- case QC_Combobox:
- if (const QStyleOptionComboBox *comboboxOption =
- qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- QMargins padding = androidControl->padding();
- QStyleOptionComboBox copy (*comboboxOption);
- copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
- QFusionStyle::drawControl(CE_ComboBoxLabel, comboboxOption, p, w);
+ if (element != QStyle::CE_CheckBoxLabel
+ && element != QStyle::CE_PushButtonLabel
+ && element != QStyle::CE_RadioButtonLabel
+ && element != QStyle::CE_TabBarTabLabel
+ && element != QStyle::CE_ProgressBarLabel) {
+ androidControl->drawControl(opt, p, w);
+ }
+
+ if (element != QStyle::CE_PushButtonBevel
+ && element != QStyle::CE_TabBarTabShape
+ && element != QStyle::CE_ProgressBarGroove) {
+ switch (itemType) {
+ case QC_Button:
+ if (const QStyleOptionButton *buttonOption =
+ qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QMargins padding = androidControl->padding();
+ QStyleOptionButton copy(*buttonOption);
+ copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
+ QFusionStyle::drawControl(CE_PushButtonLabel, &copy, p, w);
+ }
+ break;
+ case QC_Checkbox:
+ case QC_RadioButton:
+ if (const QStyleOptionButton *btn =
+ qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ const bool isRadio = (element == CE_RadioButton);
+ QStyleOptionButton subopt(*btn);
+ subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
+ : SE_CheckBoxContents, btn, w);
+ QFusionStyle::drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, w);
+ }
+ break;
+ case QC_Combobox:
+ if (const QStyleOptionComboBox *comboboxOption =
+ qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ QMargins padding = androidControl->padding();
+ QStyleOptionComboBox copy (*comboboxOption);
+ copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
+ QFusionStyle::drawControl(CE_ComboBoxLabel, comboboxOption, p, w);
+ }
+ break;
+ default:
+ QFusionStyle::drawControl(element, opt, p, w);
+ break;
}
- break;
- default:
- QFusionStyle::drawControl(element, opt, p, w);
- break;
}
} else {
QFusionStyle::drawControl(element, opt, p, w);