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>bb10
parent
b36e5faad4
commit
569171f620
|
|
@ -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, ©, 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, ©, 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;
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
QFusionStyle::drawControl(element, opt, p, w);
|
||||
|
|
|
|||
Loading…
Reference in New Issue