create arrow on demand, layout it correctly
This commit is contained in:
parent
9b06cbc392
commit
2e06bb3214
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
|
import QtQuick.Controls 1.2 as QtControls
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
PlasmaComponents.Page {
|
PlasmaComponents.Page {
|
||||||
@ -105,6 +106,11 @@ PlasmaComponents.Page {
|
|||||||
iconSource: "konqueror"
|
iconSource: "konqueror"
|
||||||
|
|
||||||
Keys.onTabPressed: bt5.forceActiveFocus();
|
Keys.onTabPressed: bt5.forceActiveFocus();
|
||||||
|
menu: QtControls.Menu {
|
||||||
|
QtControls.MenuItem { text: "This Button" }
|
||||||
|
QtControls.MenuItem { text: "Happens To Have" }
|
||||||
|
QtControls.MenuItem { text: "A Menu Assigned" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.Button {
|
PlasmaComponents.Button {
|
||||||
|
@ -22,6 +22,7 @@ import QtQuick 2.0
|
|||||||
import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle
|
import QtQuick.Controls.Styles 1.1 as QtQuickControlStyle
|
||||||
|
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||||
|
|
||||||
import "../private" as Private
|
import "../private" as Private
|
||||||
@ -34,9 +35,9 @@ QtQuickControlStyle.ButtonStyle {
|
|||||||
|
|
||||||
label: Row {
|
label: Row {
|
||||||
id: buttonContent
|
id: buttonContent
|
||||||
spacing: icon.valid ? units.smallSpacing : 0
|
spacing: units.smallSpacing
|
||||||
|
|
||||||
property real minimumWidth: icon.width + label.implicitWidth + style.padding.left + style.padding.right + ((icon.valid) ? style.padding.left : 0)
|
property real minimumWidth: icon.width + label.implicitWidth + style.padding.left + style.padding.right + ((icon.valid) ? style.padding.left : 0) + (arrow.visible ? arrow.width : 0)
|
||||||
onMinimumWidthChanged: {
|
onMinimumWidthChanged: {
|
||||||
if (control.minimumWidth !== undefined) {
|
if (control.minimumWidth !== undefined) {
|
||||||
style.minimumWidth = minimumWidth;
|
style.minimumWidth = minimumWidth;
|
||||||
@ -73,7 +74,7 @@ QtQuickControlStyle.ButtonStyle {
|
|||||||
id: label
|
id: label
|
||||||
text: control.text
|
text: control.text
|
||||||
font: control.font
|
font: control.font
|
||||||
width: parent.width - icon.width - parent.spacing
|
width: parent.width - icon.width - parent.spacing - (arrow.visible ? arrow.width + parent.spacing : 0)
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: theme.buttonTextColor
|
color: theme.buttonTextColor
|
||||||
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
|
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter
|
||||||
@ -82,6 +83,24 @@ QtQuickControlStyle.ButtonStyle {
|
|||||||
onImplicitHeightChanged: style.labelImplicitHeight = implicitHeight
|
onImplicitHeightChanged: style.labelImplicitHeight = implicitHeight
|
||||||
onImplicitWidthChanged: style.labelImplicitWidth = implicitWidth
|
onImplicitWidthChanged: style.labelImplicitWidth = implicitWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlasmaExtras.ConditionalLoader {
|
||||||
|
id: arrow
|
||||||
|
when: control.menu !== null
|
||||||
|
visible: when
|
||||||
|
width: units.iconSizes.small
|
||||||
|
height: width
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
source: Component {
|
||||||
|
PlasmaCore.SvgItem {
|
||||||
|
visible: control.menu !== null
|
||||||
|
anchors.fill: parent
|
||||||
|
svg: PlasmaCore.Svg { imagePath: "widgets/arrows" }
|
||||||
|
elementId: "down-arrow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Item {
|
background: Item {
|
||||||
@ -156,19 +175,6 @@ QtQuickControlStyle.ButtonStyle {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
//TODO: create on demand?
|
|
||||||
PlasmaCore.SvgItem {
|
|
||||||
visible: control.menu !== null
|
|
||||||
width: units.iconSizes.small
|
|
||||||
height: width
|
|
||||||
anchors {
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: surfaceNormal.margins.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
}
|
|
||||||
svg: PlasmaCore.Svg { imagePath: "widgets/arrows" }
|
|
||||||
elementId: "down-arrow"
|
|
||||||
}
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
padding.top = surfaceNormal.margins.top
|
padding.top = surfaceNormal.margins.top
|
||||||
padding.left = surfaceNormal.margins.left
|
padding.left = surfaceNormal.margins.left
|
||||||
|
Loading…
x
Reference in New Issue
Block a user