Warning, /plasma/plasma-desktop/applets/kimpanel/package/contents/ui/StatusIcon.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2014 Weng Xuetian <wengxt@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.0 0008 import QtQuick.Layouts 1.1 0009 import org.kde.plasma.plasmoid 2.0 0010 import org.kde.plasma.core as PlasmaCore 0011 import org.kde.plasma.components 3.0 as PlasmaComponents3 0012 import org.kde.kquickcontrolsaddons 2.0 0013 import org.kde.kirigami 2.20 as Kirigami 0014 0015 Item { 0016 id: statusIcon 0017 property string icon; 0018 property string label; 0019 property string tip; 0020 property string hint; 0021 signal triggered(variant button); 0022 property int iconSize: Kirigami.Units.iconSizes.roundedIconSize(Math.min(width, height)) 0023 0024 opacity: 'disable' == hint ? 0.3 : 1 0025 0026 function extractLabelString(l) { 0027 if (l.length >= 2 && l.charCodeAt(0) < 127 && l.charCodeAt(1) < 127) { 0028 return l.substring(0, 2); 0029 } else { 0030 return l.substring(0, 1); 0031 } 0032 } 0033 0034 Kirigami.Icon { 0035 id: imageIcon 0036 anchors.centerIn: parent 0037 width: iconSize 0038 height: iconSize 0039 scale: mouseArea.pressed ? 0.9 : 1 0040 source: statusIcon.icon 0041 visible: statusIcon.icon.length > 0 0042 animated: false 0043 // active: mouseArea.containsMouse 0044 } 0045 PlasmaComponents3.Label { 0046 id: textIcon 0047 anchors.centerIn: parent 0048 width: iconSize 0049 height: iconSize 0050 scale: (mouseArea.pressed ? 0.9 : 1) 0051 // a reasonable large size to make Text.Fit work 0052 minimumPointSize: 0 0053 font.pointSize: 1024 0054 fontSizeMode: Text.Fit 0055 verticalAlignment: Text.AlignVCenter 0056 horizontalAlignment: Text.AlignHCenter 0057 text: extractLabelString(label) 0058 textFormat: Text.PlainText 0059 visible: icon.length == 0 0060 } 0061 0062 MouseArea { 0063 id: mouseArea 0064 anchors.fill: parent 0065 hoverEnabled: true 0066 acceptedButtons: Qt.LeftButton | Qt.RightButton 0067 onClicked: { 0068 statusIcon.triggered(mouse.button); 0069 } 0070 0071 PlasmaCore.ToolTipArea { 0072 anchors.fill: parent 0073 mainText: statusIcon.label 0074 subText: statusIcon.tip 0075 icon: statusIcon.icon 0076 } 0077 } 0078 }