Warning, /plasma/plasma-workspace/lookandfeel/sddm-theme/KeyboardButton.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2016 David Edmundson <davidedmundson@kde.org> 0003 SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 import QtQuick 2.15 0009 0010 import org.kde.plasma.components 3.0 as PlasmaComponents 0011 import org.kde.kirigami 2.20 as Kirigami 0012 0013 PlasmaComponents.ToolButton { 0014 id: root 0015 0016 property int currentIndex: keyboard.currentLayout 0017 onCurrentIndexChanged: keyboard.currentLayout = currentIndex 0018 0019 text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keyboard Layout: %1", keyboard.layouts[currentIndex].longName) 0020 visible: keyboard.layouts.length > 1 0021 0022 checkable: true 0023 checked: menu.opened 0024 onToggled: { 0025 if (checked) { 0026 menu.popup(root, 0, 0) 0027 } else { 0028 menu.dismiss() 0029 } 0030 } 0031 0032 signal keyboardLayoutChanged() 0033 0034 PlasmaComponents.Menu { 0035 id: menu 0036 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0037 Kirigami.Theme.inherit: false 0038 0039 onAboutToShow: { 0040 if (instantiator.model === null) { 0041 let layouts = keyboard.layouts; 0042 layouts.sort((a, b) => a.longName.localeCompare(b.longName)); 0043 instantiator.model = layouts; 0044 } 0045 } 0046 0047 Instantiator { 0048 id: instantiator 0049 model: null 0050 onObjectAdded: (index, object) => menu.insertItem(index, object) 0051 onObjectRemoved: (index, object) => menu.removeItem(object) 0052 delegate: PlasmaComponents.MenuItem { 0053 text: modelData.longName 0054 onTriggered: { 0055 keyboard.currentLayout = keyboard.layouts.indexOf(modelData) 0056 root.keyboardLayoutChanged() 0057 } 0058 } 0059 } 0060 } 0061 }