Warning, /plasma/lightdm-kde-greeter/themes/userbar/contents/ui/private/IconLoader.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright (C) 2011 by Marco MArtin <mart@kde.org>
0003 *
0004 * This program is free software; you can redistribute it and/or modify
0005 * it under the terms of the GNU Library General Public License as
0006 * published by the Free Software Foundation; either version 2, or
0007 * (at your option) any later version.
0008 *
0009 * This program is distributed in the hope that it will be useful,
0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0012 * GNU Library General Public License for more details
0013 *
0014 * You should have received a copy of the GNU Library General Public
0015 * License along with this program; if not, write to the
0016 * Free Software Foundation, Inc.,
0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018 */
0019
0020 /**Documented API
0021 Inherits:
0022 Item
0023
0024 Imports:
0025 QtQuick 1.1
0026 org.kde.plasma.core
0027 org.kde.qtextracomponents
0028
0029 Description:
0030 TODO i need more info here
0031
0032 Properties:
0033 bool valid:
0034 Returns if the icon is valid or not.
0035
0036 string source:
0037 Returns the dir,in which the icon exists.
0038 **/
0039
0040 import QtQuick 1.1
0041 import org.kde.plasma.core 0.1 as PlasmaCore
0042 import org.kde.qtextracomponents 0.1
0043
0044 Item {
0045 id: root
0046
0047 property bool valid: false
0048
0049 property variant source
0050
0051 onSourceChanged: {
0052 //is it a qicon?
0053 if (typeof source != "string") {
0054 imageLoader.sourceComponent = iconComponent
0055 valid = true
0056 return
0057 } else if (source == "") {
0058 imageLoader.sourceComponent = null
0059 valid = false
0060 return
0061 }
0062
0063 svgIcon.imagePath = "toolbar-icons/"+root.source.split("-")[0]
0064 if (!svgIcon.isValid() || !svgIcon.hasElement(root.source)) {
0065 svgIcon.imagePath = "icons/"+root.source.split("-")[0]
0066 }
0067
0068 if (svgIcon.isValid() && svgIcon.hasElement(root.source)) {
0069 imageLoader.sourceComponent = svgComponent
0070 } else if ((root.source.indexOf(".") == -1 && root.source.indexOf(":") == -1)) {
0071 imageLoader.sourceComponent = iconComponent
0072 } else {
0073 imageLoader.sourceComponent = imageComponent
0074 }
0075 valid = true
0076 }
0077
0078 implicitWidth: theme.smallIconSize
0079 implicitHeight: theme.smallIconSize
0080
0081 PlasmaCore.Svg {
0082 id: svgIcon
0083 }
0084
0085 function roundToStandardSize(size)
0086 {
0087 if (size >= theme.enormousIconSize) {
0088 return theme.enormousIconSize
0089 } else if (size >= theme.hugeIconSize) {
0090 return theme.hugeIconSize
0091 } else if (size >= theme.largeIconSize) {
0092 return theme.largeIconSize
0093 } else if (size >= theme.mediumIconSize) {
0094 return theme.mediumIconSize
0095 } else if (size >= theme.smallMediumIconSize) {
0096 return theme.smallMediumIconSize
0097 } else {
0098 return theme.smallIconSize
0099 }
0100 }
0101
0102 Loader {
0103 id: imageLoader
0104 anchors.fill: parent
0105
0106 Component {
0107 id: svgComponent
0108
0109 PlasmaCore.SvgItem {
0110 svg: svgIcon
0111 elementId: root.source
0112 anchors.fill: parent
0113 smooth: true
0114 }
0115 }
0116
0117 Component {
0118 id: iconComponent
0119
0120 QIconItem {
0121 icon: (typeof source == "string") ? QIcon(root.source) : root.source
0122 smooth: true
0123 anchors.fill: parent
0124 }
0125 }
0126
0127 Component {
0128 id: imageComponent
0129
0130 Image {
0131 source: root.source
0132 sourceSize.width: width
0133 sourceSize.height: height
0134 fillMode: Image.PreserveAspectFit
0135 smooth: true
0136 anchors.fill: parent
0137 }
0138 }
0139 }
0140 }