Warning, /plasma/plasma-workspace/applets/manage-inputmethod/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.1 0008 import QtQuick.Layouts 1.1 0009 0010 import org.kde.plasma.plasmoid 2.0 0011 import org.kde.plasma.core as PlasmaCore 0012 import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards 0013 import org.kde.kcmutils // KCMLauncher 0014 import org.kde.kirigami 2.20 as Kirigami 0015 0016 PlasmoidItem { 0017 id: root 0018 0019 Plasmoid.onActivated: { 0020 if (!Keyboards.KWinVirtualKeyboard.available) { 0021 settingsAction.trigger() 0022 } else if (unsupportedState.when) { 0023 Keyboards.KWinVirtualKeyboard.forceActivate() 0024 } else if (Keyboards.KWinVirtualKeyboard.visible) { 0025 Keyboards.KWinVirtualKeyboard.active = false 0026 } else { 0027 Keyboards.KWinVirtualKeyboard.enabled = !Keyboards.KWinVirtualKeyboard.enabled 0028 } 0029 } 0030 preferredRepresentation: fullRepresentation 0031 fullRepresentation: Kirigami.Icon { 0032 activeFocusOnTab: true 0033 source: Plasmoid.icon 0034 active: compactMouse.containsMouse 0035 0036 Keys.onPressed: event => { 0037 switch (event.key) { 0038 case Qt.Key_Space: 0039 case Qt.Key_Enter: 0040 case Qt.Key_Return: 0041 case Qt.Key_Select: 0042 Plasmoid.activated(); 0043 break; 0044 } 0045 } 0046 Accessible.name: Plasmoid.title 0047 Accessible.description: toolTipSubText 0048 Accessible.role: Accessible.Button 0049 0050 MouseArea { 0051 id: compactMouse 0052 anchors.fill: parent 0053 hoverEnabled: true 0054 onClicked: Plasmoid.activated() 0055 } 0056 Kirigami.Icon { 0057 anchors { 0058 right: parent.right 0059 bottom: parent.bottom 0060 } 0061 width: Kirigami.Units.iconSizes.small / 2 0062 height: width 0063 visible: root.state === "unavailable" 0064 source: visible ? "emblem-unavailable" : "" 0065 } 0066 } 0067 0068 PlasmaCore.Action { 0069 id: settingsAction 0070 text: i18ndc("plasma_applet_org.kde.plasma.manageinputmethod", "Opens the system settings module", "Configure Virtual Keyboards...") 0071 icon.name: "settings-configure" 0072 onTriggered: KCMLauncher.openSystemSettings("kcm_virtualkeyboard") 0073 } 0074 Component.onCompleted: { 0075 Plasmoid.setInternalAction("configure", settingsAction) 0076 } 0077 0078 states: [ 0079 State { 0080 name: "unavailable" 0081 when: !Keyboards.KWinVirtualKeyboard.available 0082 PropertyChanges { 0083 target: Plasmoid 0084 icon: "input-keyboard-virtual-off" 0085 status: PlasmaCore.Types.HiddenStatus 0086 } 0087 PropertyChanges { 0088 target: root 0089 toolTipSubText: i18nd("plasma_applet_org.kde.plasma.manageinputmethod", "Virtual Keyboard: unavailable") 0090 } 0091 }, 0092 State { 0093 name: "disabled" 0094 when: Keyboards.KWinVirtualKeyboard.available && !Keyboards.KWinVirtualKeyboard.enabled 0095 PropertyChanges { 0096 target: Plasmoid 0097 icon: "input-keyboard-virtual-off" 0098 status: PlasmaCore.Types.ActiveStatus 0099 } 0100 PropertyChanges { 0101 target: root 0102 toolTipSubText: i18nd("plasma_applet_org.kde.plasma.manageinputmethod", "Virtual Keyboard: disabled") 0103 } 0104 }, 0105 State { 0106 id: unsupportedState 0107 name: "unsupported" 0108 when: Keyboards.KWinVirtualKeyboard.available && !Keyboards.KWinVirtualKeyboard.activeClientSupportsTextInput 0109 // When the current client doesn't support input methods, we can force 0110 // the display of the virtual keyboard so it emulates a hardware keyboard instead 0111 PropertyChanges { 0112 target: Plasmoid 0113 icon: "arrow-up" 0114 status: Kirigami.Settings.tabletMode ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus 0115 } 0116 PropertyChanges { 0117 target: root 0118 toolTipSubText: i18nd("plasma_applet_org.kde.plasma.manageinputmethod", "Show Virtual Keyboard") 0119 } 0120 }, 0121 State { 0122 name: "visible" 0123 when: Keyboards.KWinVirtualKeyboard.available && Keyboards.KWinVirtualKeyboard.visible 0124 PropertyChanges { 0125 target: Plasmoid 0126 icon: "arrow-down" 0127 // Because the keyboard can become visible with a touch input when 0128 // while not explicitly in Touch Mode 0129 status: Kirigami.Settings.hasTransientTouchInput ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus 0130 } 0131 PropertyChanges { 0132 target: root 0133 toolTipSubText: i18nd("plasma_applet_org.kde.plasma.manageinputmethod", "Virtual Keyboard: visible") 0134 } 0135 }, 0136 State { 0137 name: "idle" 0138 when: Keyboards.KWinVirtualKeyboard.available && Keyboards.KWinVirtualKeyboard.enabled && !Keyboards.KWinVirtualKeyboard.visible 0139 PropertyChanges { 0140 target: Plasmoid 0141 icon: "input-keyboard-virtual-on" 0142 // It's only relevant in tablet mode 0143 status: Kirigami.Settings.tabletMode ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus 0144 } 0145 PropertyChanges { 0146 target: root 0147 toolTipSubText: i18nd("plasma_applet_org.kde.plasma.manageinputmethod", "Virtual Keyboard: enabled") 0148 } 0149 } 0150 ] 0151 }