use IconLoader
This commit is contained in:
parent
be1068709a
commit
f32fc24694
@ -105,16 +105,14 @@ Item {
|
||||
bottomMargin: surface.margins.bottom
|
||||
}
|
||||
|
||||
Image {
|
||||
IconLoader {
|
||||
id: icon
|
||||
|
||||
anchors {
|
||||
fill: label.text ? undefined : parent
|
||||
top: label.text ? parent.top : undefined
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: label.text ? parent.left : undefined
|
||||
bottom: label.text ? parent.bottom : undefined
|
||||
horizontalCenter: label.text ? undefined : parent.horizontalCenter
|
||||
}
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
Text {
|
||||
@ -123,7 +121,7 @@ Item {
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: icon.right
|
||||
left: icon.valid ? icon.right : parent.left
|
||||
right: parent.right
|
||||
}
|
||||
font.capitalization: theme.defaultFont.capitalization
|
||||
|
@ -24,21 +24,33 @@ import org.kde.qtextracomponents 0.1
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property string iconSource
|
||||
property bool valid: false
|
||||
|
||||
PlasmaCore.Svg {
|
||||
id: svgIcon
|
||||
}
|
||||
property string source
|
||||
|
||||
onIconSourceChanged: {
|
||||
svgIcon.imagePath = "icons/"+root.iconSource.split("-")[0]
|
||||
if (svgIcon.isValid() && svgIcon.hasElement(root.iconSource)) {
|
||||
onSourceChanged: {
|
||||
if (source == "") {
|
||||
imageLoader.sourceComponent = null
|
||||
valid = false
|
||||
}
|
||||
|
||||
svgIcon.imagePath = "icons/"+root.source.split("-")[0]
|
||||
if (svgIcon.isValid() && svgIcon.hasElement(root.source)) {
|
||||
imageLoader.sourceComponent = svgComponent
|
||||
} else if (root.iconSource.indexOf(".") == -1 && root.iconSource.indexOf(":") == -1) {
|
||||
} else if (root.source.indexOf(".") == -1 && root.source.indexOf(":") == -1) {
|
||||
imageLoader.sourceComponent = iconComponent
|
||||
} else {
|
||||
imageLoader.sourceComponent = imageComponent
|
||||
}
|
||||
valid = true
|
||||
}
|
||||
|
||||
//FIXME: iconloader sizes coming from plasma
|
||||
implicitWidth: 16
|
||||
implicitHeight: 16
|
||||
|
||||
PlasmaCore.Svg {
|
||||
id: svgIcon
|
||||
}
|
||||
|
||||
Loader {
|
||||
@ -50,7 +62,7 @@ Item {
|
||||
|
||||
PlasmaCore.SvgItem {
|
||||
svg: svgIcon
|
||||
elementId: root.iconSource
|
||||
elementId: root.source
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
@ -59,7 +71,7 @@ Item {
|
||||
id: iconComponent
|
||||
|
||||
QIconItem {
|
||||
icon: QIcon(root.iconSource)
|
||||
icon: QIcon(root.source)
|
||||
smooth: true
|
||||
anchors.fill: parent
|
||||
}
|
||||
@ -69,7 +81,7 @@ Item {
|
||||
id: imageComponent
|
||||
|
||||
Image {
|
||||
source: root.iconSource
|
||||
source: root.source
|
||||
sourceSize.width: width
|
||||
sourceSize.height: height
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
@ -51,7 +51,7 @@ Item {
|
||||
property bool checked: internal.tabGroup != null && internal.tabGroup.currentTab == tab
|
||||
property bool pressed: mouseArea.pressed == true && mouseArea.containsMouse
|
||||
property alias text: label.text
|
||||
property alias iconSource: imageLoader.iconSource
|
||||
property alias iconSource: imageLoader.source
|
||||
|
||||
signal clicked
|
||||
|
||||
|
@ -116,16 +116,14 @@ Item {
|
||||
bottomMargin: surface.margins.bottom
|
||||
}
|
||||
|
||||
Image {
|
||||
IconLoader {
|
||||
id: icon
|
||||
|
||||
anchors {
|
||||
fill: label.text ? undefined : parent
|
||||
top: label.text ? parent.top : undefined
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: label.text ? parent.left : undefined
|
||||
bottom: label.text ? parent.bottom : undefined
|
||||
horizontalCenter: label.text ? undefined : parent.horizontalCenter
|
||||
}
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
Text {
|
||||
@ -134,7 +132,7 @@ Item {
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: icon.right
|
||||
left: icon.valid ? icon.right : parent.left
|
||||
right: parent.right
|
||||
}
|
||||
font.capitalization: theme.defaultFont.capitalization
|
||||
|
Loading…
Reference in New Issue
Block a user