diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/controls/ToolButton.qml | 16 | ||||
| -rw-r--r-- | src/private/qstyleitem.cpp | 3 | ||||
| -rw-r--r-- | src/styles/Desktop/ToolButtonStyle.qml | 17 |
3 files changed, 13 insertions, 23 deletions
diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 6f65de3b2..613f925e6 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -62,20 +62,18 @@ import "Styles/Settings.js" as Settings BasicButton { id: button - /*! The image label source. */ + /*! The image label source as file name or resource. */ property url iconSource + /*! The image label source as theme name. + When an icon from the platform icon theme is found this takes + precedence over iconSource. + */ + property url iconName + /*! The label text. */ property string text - Image { - id: image - anchors.centerIn: parent - source: button.iconSource - width: Math.min(button.width, image.implicitWidth) - height: Math.min(button.height, image.implicitHeight) - fillMode: Image.PreserveAspectFit - } Accessible.name: text style: Qt.createComponent(Settings.THEME_PATH + "/ToolButtonStyle.qml", button) diff --git a/src/private/qstyleitem.cpp b/src/private/qstyleitem.cpp index 5291bb68f..7de585aa3 100644 --- a/src/private/qstyleitem.cpp +++ b/src/private/qstyleitem.cpp @@ -255,6 +255,9 @@ void QStyleItem::initStyleOption() opt->subControls = QStyle::SC_ToolButton; opt->state |= QStyle::State_AutoRaise; opt->activeSubControls = QStyle::SC_ToolButton; + opt->icon = m_properties["icon"].value<QIcon>(); + int e = qApp->style()->pixelMetric(QStyle::PM_ToolBarIconSize, m_styleoption, 0); + opt->iconSize = QSize(e, e); } break; case ToolBar: { diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index 099253e07..3dbabc17d 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -54,22 +54,11 @@ Style { hasFocus: control.activeFocus hints: control.styleHints.concat([control.__position]) - contentWidth: Math.max(textitem.paintedWidth, 32) + contentWidth: 30 contentHeight: 30 - Image { - id: image - anchors.centerIn: parent - source: button.iconSource - sourceSize.width: Math.min(control.width, image.implicitWidth) - sourceSize.height: Math.min(control.height, image.implicitHeight) - } - - Text { - id: textitem - text: control.text - anchors.centerIn: parent - visible: control.iconSource.toString() === "" + properties: { + "icon": control.__action.__icon } } } |
