Warning, /plasma/latte-dock/containment/package/contents/ui/applet/ShortcutBadge.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2019 Michail Vourlakos <mvourlakos@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.1 0007 import QtGraphicalEffects 1.0 0008 0009 import org.kde.latte.components 1.0 as LatteComponents 0010 0011 Loader{ 0012 id: appletNumberLoader 0013 0014 active: appletItem.canShowAppletNumberBadge && 0015 (appletItem.shortcuts.showPositionShortcutBadges 0016 || appletItem.shortcuts.showAppletShortcutBadges 0017 || appletItem.shortcuts.showMetaBadge && applet.id===appletItem.shortcuts.applicationLauncherId) 0018 0019 asynchronous: true 0020 visible: badgeString!=="" 0021 0022 property int fixedIndex: -1 0023 property string badgeString: "" 0024 0025 onActiveChanged: { 0026 if (active && appletItem.shortcuts.showPositionShortcutBadges && appletItem.shortcuts.unifiedGlobalShortcuts) { 0027 fixedIndex = appletItem.indexer.visibleIndex(index); 0028 } else { 0029 fixedIndex = -1; 0030 } 0031 } 0032 0033 Component.onCompleted: { 0034 if (active && appletItem.shortcuts.showPositionShortcutBadges && appletItem.shortcuts.unifiedGlobalShortcuts) { 0035 fixedIndex = appletItem.indexer.visibleIndex(index); 0036 } else { 0037 fixedIndex = -1; 0038 } 0039 } 0040 0041 Binding{ 0042 target: appletNumberLoader 0043 property:"badgeString" 0044 when: appletItem.shortcuts.showMetaBadge || appletItem.shortcuts.showAppletShortcutBadges 0045 value: { 0046 if (appletItem.shortcuts.showMetaBadge && applet && applet.id === appletItem.shortcuts.applicationLauncherId) { 0047 return '\u2318'; 0048 } 0049 0050 if (appletItem.shortcuts.showAppletShortcutBadges) { 0051 var plasmaShortcut = applet ? shortcutsEngine.appletShortcutBadge(applet.id) : ""; 0052 0053 if (plasmaShortcut !== "") { 0054 return plasmaShortcut; 0055 } 0056 } 0057 0058 if (appletNumberLoader.fixedIndex>=1 && appletNumberLoader.fixedIndex<20) { 0059 return appletItem.shortcuts.badges[appletNumberLoader.fixedIndex-1]; 0060 } else { 0061 return ""; 0062 } 0063 } 0064 } 0065 0066 sourceComponent: Item{ 0067 Loader{ 0068 anchors.fill: appletNumber 0069 active: appletItem.myView.itemShadow.isEnabled 0070 && appletItem.environment.isGraphicsSystemAccelerated 0071 0072 sourceComponent: DropShadow{ 0073 color: appletItem.myView.itemShadow.shadowColor 0074 fast: true 0075 samples: 2 * radius 0076 source: appletNumber 0077 radius: appletItem.myView.itemShadow.size/2 0078 verticalOffset: 2 0079 } 0080 } 0081 0082 LatteComponents.BadgeText { 0083 id: appletNumber 0084 0085 // when iconSize < 48, height is always = 24, height / iconSize > 50% 0086 // we prefer center aligned badges to top-left aligned ones 0087 property bool centerInParent: appletItem.metrics.iconSize < 48 0088 0089 anchors.left: centerInParent? undefined : parent.left 0090 anchors.top: centerInParent? undefined : parent.top 0091 anchors.centerIn: centerInParent? parent : undefined 0092 minimumWidth: 0.4 * (wrapper.zoomScale * appletItem.metrics.iconSize) 0093 height: Math.max(24, 0.4 * (wrapper.zoomScale * appletItem.metrics.iconSize)) 0094 0095 borderColor: colorizerManager.originalLightTextColor 0096 proportion: 0 0097 radiusPerCentage: 100 0098 showNumber: false 0099 showText: true 0100 textValue: appletNumberLoader.badgeString 0101 0102 style3d: appletItem.myView.badgesIn3DStyle 0103 } 0104 } 0105 }