support display property for Buttons
tested on buttons, toolbuttons and tabbuttons
This commit is contained in:
parent
014c3fd104
commit
2b78afd921
@ -42,7 +42,8 @@ T.Button {
|
||||
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
|
||||
Kirigami.MnemonicData.label: control.text
|
||||
|
||||
contentItem: RowLayout {
|
||||
contentItem: GridLayout {
|
||||
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
|
||||
PlasmaCore.IconItem {
|
||||
id: icon
|
||||
Layout.fillWidth: true
|
||||
|
@ -18,10 +18,12 @@
|
||||
*/
|
||||
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.2
|
||||
import QtQuick.Controls @QQC2_VERSION@
|
||||
import QtQml.Models 2.1
|
||||
import QtQuick.Templates @QQC2_VERSION@ as T
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.kirigami 2.5 as Kirigami
|
||||
|
||||
T.TabButton {
|
||||
id: control
|
||||
@ -34,14 +36,33 @@ T.TabButton {
|
||||
|
||||
hoverEnabled: true
|
||||
|
||||
contentItem: Label {
|
||||
text: control.text
|
||||
font: control.font
|
||||
elide: Text.ElideRight
|
||||
opacity: enabled ? 1 : 0.3
|
||||
color: PlasmaCore.ColorScope.textColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
Kirigami.MnemonicData.enabled: control.enabled && control.visible
|
||||
Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl
|
||||
Kirigami.MnemonicData.label: control.text
|
||||
|
||||
contentItem: GridLayout {
|
||||
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
|
||||
PlasmaCore.IconItem {
|
||||
id: icon
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
colorGroup: PlasmaCore.Theme.ButtonColorGroup
|
||||
visible: source.length > 0
|
||||
source: control.icon ? (control.icon.name || control.icon.source) : ""
|
||||
status: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal
|
||||
}
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
visible: text.length > 0
|
||||
text: control.Kirigami.MnemonicData.richTextLabel
|
||||
font: control.font
|
||||
opacity: enabled || control.highlighted || control.checked ? 1 : 0.4
|
||||
color: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.down ? theme.highlightedTextColor : theme.buttonTextColor
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
background: Item {}
|
||||
|
@ -45,18 +45,17 @@ T.ToolButton {
|
||||
|
||||
flat: true
|
||||
|
||||
contentItem: RowLayout {
|
||||
contentItem: GridLayout {
|
||||
columns: control.display == T.AbstractButton.TextBesideIcon ? 2 : 1
|
||||
PlasmaCore.IconItem {
|
||||
id: icon
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
colorGroup: PlasmaCore.Theme.ButtonColorGroup
|
||||
visible: source.length > 0
|
||||
Layout.fillWidth: control.icon.width <= 0
|
||||
Layout.fillHeight: control.icon.height <= 0
|
||||
Layout.preferredWidth: control.icon.width > 0 ? control.icon.width : -1
|
||||
Layout.preferredHeight: control.icon.height > 0 ? control.icon.height : -1
|
||||
colorGroup: PlasmaCore.ColorScope.colorGroup
|
||||
source: control.icon ? (control.icon.name || control.icon.source) : ""
|
||||
status: buttonSvg.hasElement("hint-focus-highlighted-background") && control.activeFocus && !control.pressed && !control.checked ? PlasmaCore.Svg.Selected : PlasmaCore.Svg.Normal
|
||||
}
|
||||
//NOTE: this is used only to check element's existence
|
||||
PlasmaCore.FrameSvgItem {
|
||||
id: buttonsurfaceChecker
|
||||
visible: false
|
||||
|
Loading…
Reference in New Issue
Block a user