Ticket #50183: patch-respect-buttonhaveicons.diff

File patch-respect-buttonhaveicons.diff, 2.3 KB (added by RJVB (René Bertin), 8 years ago)
  • qt5/style/qtcurve_api.cpp

    diff --git qt5/style/qtcurve_api.cpp qt5/style/qtcurve_api.cpp
    index 87a927f..02637d3 100644
    Style::drawControl(ControlElement element, const QStyleOption *option, 
    31973207            drawControl(CE_PushButtonBevel, btn, painter, widget);
    31983208
    31993209            QStyleOptionButton subopt(*btn);
     3210            if (!btn->icon.isNull()
     3211                && !(styleHint(SH_DialogButtonBox_ButtonsHaveIcons, btn, widget) || btn->text.isEmpty())) {
     3212                // remove the icon from our local QStyleOptionButton copy
     3213                subopt.icon = QIcon();
     3214            }
    32003215
    3201             subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
     3216            subopt.rect = subElementRect(SE_PushButtonContents, &subopt, widget);
    32023217            drawControl(CE_PushButtonLabel, &subopt, painter, widget);
    32033218
    32043219            if (state & State_HasFocus &&
    Style::drawControl(ControlElement element, const QStyleOption *option, 
    32513266            if (!styleHint(SH_UnderlineShortcut, button, widget))
    32523267                tf |= Qt::TextHideMnemonic;
    32533268
    3254             if (!button->icon.isNull())
     3269            if (!button->icon.isNull()
     3270                && (styleHint(SH_DialogButtonBox_ButtonsHaveIcons, button, widget) || button->text.isEmpty()))
    32553271            {
    32563272                //Center both icon and text
    32573273                QIcon::Mode mode(button->state&State_Enabled ? QIcon::Normal : QIcon::Disabled);
    QSize Style::sizeFromContents(ContentsType type, const QStyleOption *option, con 
    60336049            if (!opts.stdBtnSizes) {
    60346050                // Cant rely on AutoDefaultButton
    60356051                //   - as VirtualBox does not set this!!!
    6036                 if (qtcCheckType<QDialogButtonBox>(getParent(widget)) ||
    6037                     qtcCheckType(getParent(widget), "KFileWidget")) {
     6052                bool allowIcon = styleHint(SH_DialogButtonBox_ButtonsHaveIcons, btn, widget) || btn->text.isEmpty();
     6053                if (allowIcon && (qtcCheckType<QDialogButtonBox>(getParent(widget)) ||
     6054                    qtcCheckType(getParent(widget), "KFileWidget"))) {
    60386055                    int iconHeight = (btn->icon.isNull() ?
    60396056                                      btn->iconSize.height() : 16);
    60406057                    if (size.height() < iconHeight + 2) {