Warning, /plasma/plasma-desktop/applets/keyboardlayout/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2020 Andrey Butirsky <butirsky@gmail.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 import QtQuick 2.15 0007 import Qt.labs.platform 1.1 0008 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.plasma.workspace.components 2.0 0013 import org.kde.plasma.private.kcm_keyboard as KCMKeyboard 0014 import org.kde.kirigami 2.20 as Kirigami 0015 0016 PlasmoidItem { 0017 id: root 0018 0019 signal layoutSelected(int layoutIndex) 0020 0021 preferredRepresentation: fullRepresentation 0022 toolTipMainText: Plasmoid.title 0023 toolTipSubText: fullRepresentationItem ? fullRepresentationItem.layoutNames.longName : "" 0024 0025 fullRepresentation: KeyboardLayoutSwitcher { 0026 id: switcher 0027 0028 hoverEnabled: true 0029 Plasmoid.status: hasMultipleKeyboardLayouts ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.HiddenStatus 0030 0031 PlasmaCore.ToolTipArea { 0032 anchors.fill: parent 0033 mainText: root.toolTipMainText 0034 subText: root.toolTipSubText 0035 } 0036 0037 Instantiator { 0038 id: actionsInstantiator 0039 model: switcher.keyboardLayout.layoutsList 0040 delegate: PlasmaCore.Action { 0041 text: modelData.longName 0042 icon.icon: KCMKeyboard.Flags.getIcon(modelData.shortName) 0043 onTriggered: { 0044 layoutSelected(index); 0045 } 0046 } 0047 onObjectAdded: (index, object) => { 0048 Plasmoid.contextualActions.push(object) 0049 } 0050 onObjectRemoved: (index, object) => { 0051 Plasmoid.contextualActions.splice(Plasmoid.contextualActions.indexOf(object), 1) 0052 } 0053 } 0054 Connections { 0055 target: switcher.keyboardLayout 0056 0057 function onLayoutChanged() { 0058 root.Plasmoid.activated(); 0059 } 0060 } 0061 0062 Connections { 0063 target: root 0064 0065 function onLayoutSelected(layoutIndex) { 0066 switcher.keyboardLayout.layout = layoutIndex; 0067 } 0068 } 0069 0070 Kirigami.Icon { 0071 id: flag 0072 0073 anchors.fill: parent 0074 0075 visible: valid && (Plasmoid.configuration.displayStyle === 1 || Plasmoid.configuration.displayStyle === 2) 0076 0077 active: containsMouse 0078 source: KCMKeyboard.Flags.getIcon(layoutNames.shortName) 0079 0080 BadgeOverlay { 0081 anchors.bottom: parent.bottom 0082 anchors.right: parent.right 0083 0084 visible: !countryCode.visible && Plasmoid.configuration.displayStyle === 2 0085 0086 text: countryCode.text 0087 icon: flag 0088 } 0089 } 0090 0091 PlasmaComponents3.Label { 0092 id: countryCode 0093 anchors.fill: parent 0094 visible: Plasmoid.configuration.displayStyle === 0 || !flag.valid 0095 0096 font.pointSize: height 0097 fontSizeMode: Text.Fit 0098 horizontalAlignment: Text.AlignHCenter 0099 verticalAlignment: Text.AlignVCenter 0100 text: layoutNames.displayName || layoutNames.shortName 0101 textFormat: Text.PlainText 0102 } 0103 } 0104 0105 function actionTriggered(actionName) { 0106 const layoutIndex = parseInt(actionName); 0107 if (!isNaN(layoutIndex)) { 0108 layoutSelected(layoutIndex); 0109 } 0110 } 0111 }