Changeset View
Changeset View
Standalone View
Standalone View
plugin/kquickstyleitem.cpp
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Line(s) | 180 | case Button: { | |||
---|---|---|---|---|---|
185 | opt->text = text(); | 185 | opt->text = text(); | ||
186 | 186 | | |||
187 | const QVariant icon = m_properties[QStringLiteral("icon")]; | 187 | const QVariant icon = m_properties[QStringLiteral("icon")]; | ||
188 | if (icon.canConvert<QIcon>()) { | 188 | if (icon.canConvert<QIcon>()) { | ||
189 | opt->icon = icon.value<QIcon>(); | 189 | opt->icon = icon.value<QIcon>(); | ||
190 | } else if (icon.canConvert<QString>()) { | 190 | } else if (icon.canConvert<QString>()) { | ||
191 | opt->icon = m_theme->iconFromTheme(icon.value<QString>(), m_properties[QStringLiteral("iconColor")].value<QColor>()); | 191 | opt->icon = m_theme->iconFromTheme(icon.value<QString>(), m_properties[QStringLiteral("iconColor")].value<QColor>()); | ||
192 | } | 192 | } | ||
193 | auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(), m_properties[QStringLiteral("iconHeight")].toInt()); | ||||
apol: Can we be a bit smarter here? If the size is present maybe we wouldn't have to check the… | |||||
194 | if (iconSize.isEmpty()) { | ||||
193 | int e = qApp->style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr); | 195 | int e = qApp->style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr); | ||
194 | opt->iconSize = QSize(e, e); | 196 | if (iconSize.width() <= 0) { | ||
197 | iconSize.setWidth(e); | ||||
198 | } | ||||
199 | if (iconSize.height() <= 0) { | ||||
200 | iconSize.setHeight(e); | ||||
201 | } | ||||
202 | } | ||||
203 | opt->iconSize = iconSize; | ||||
195 | opt->features = activeControl() == QLatin1String("default") ? | 204 | opt->features = activeControl() == QLatin1String("default") ? | ||
196 | QStyleOptionButton::DefaultButton : | 205 | QStyleOptionButton::DefaultButton : | ||
197 | QStyleOptionButton::None; | 206 | QStyleOptionButton::None; | ||
198 | if (m_properties[QStringLiteral("flat")].toBool()) { | 207 | if (m_properties[QStringLiteral("flat")].toBool()) { | ||
199 | opt->features |= QStyleOptionButton::Flat; | 208 | opt->features |= QStyleOptionButton::Flat; | ||
200 | } | 209 | } | ||
201 | const QFont font = qApp->font("QPushButton"); | 210 | const QFont font = qApp->font("QPushButton"); | ||
202 | opt->fontMetrics = QFontMetrics(font); | 211 | opt->fontMetrics = QFontMetrics(font); | ||
▲ Show 20 Lines • Show All 1512 Lines • Show Last 20 Lines |
Can we be a bit smarter here? If the size is present maybe we wouldn't have to check the pixelMetric.