2 * Copyright (C) 2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Lomiri.Components 1.3
19import Lomiri.Components.ListItems 1.3
20import Lomiri.SystemSettings.LanguagePlugin 1.0
22import AccountsService 0.1
23import Lomiri.InputInfo 0.1
24import QtMir.Application 0.1
25import ".." as LocalComponents
26import "../../Components"
29 objectName: "keyboardPage"
31 title: i18n.tr("Select Keyboard")
32 forwardButtonSourceComponent: forwardButton
34 skip: keyboardsModel.count == 0
37 LomiriLanguagePlugin {
41 KeyboardLayoutsModel {
43 language: selectedLanguage
48 deviceFilter: InputInfo.Keyboard
49 Component.onCompleted: skipValid = true;
52 readonly property string selectedLanguage: langPlugin.languageCodes[langSelector.selectedIndex].split(".")[0] // chop off the codeset (.UTF-8)
54 property string selectedKeymap: ""
62 leftMargin: wideMode ? parent.leftMargin : staticMargin
63 rightMargin: wideMode ? parent.rightMargin : staticMargin
64 topMargin: staticMargin
69 anchors.left: parent.left
70 anchors.right: parent.right
71 text: i18n.tr("Keyboard language")
72 font.weight: Font.Normal
76 LocalComponents.WizardItemSelector {
78 objectName: "langSelector"
79 anchors.left: parent.left
80 anchors.right: parent.right
81 model: langPlugin.languageNames
82 selectedIndex: langPlugin.languageCodes.indexOf(i18n.language)
83 onSelectedIndexChanged: {
84 keyboardListView.currentIndex = -1;
91 anchors.left: parent.left
92 anchors.right: parent.right
93 text: i18n.tr("Keyboard layout")
94 font.weight: Font.Normal
101 anchors.left: parent.left
102 anchors.right: parent.right
103 snapMode: ListView.SnapToItem
106 opacity: langSelector.expanded ? 0.5 : 1
107 height: column.height - label1.height - langSelector.height - label2.height - column.spacing * 3
108 enabled: !langSelector.expanded
109 Behavior on opacity {
110 LomiriNumberAnimation {}
115 objectName: "kbdDelegate" + index
116 height: layout.height + (divider.visible ? divider.height : 0)
117 readonly property bool isCurrent: index === ListView.view.currentIndex
118 highlightColor: backgroundColor
119 divider.colorFrom: dividerColor
120 divider.colorTo: backgroundColor
124 title.text: displayName
125 title.color: textColor
126 subtitle.text: layoutId
127 subtitle.color: textColor
128 padding.leading: -units.gu(1)
129 padding.trailing: -units.gu(1)
131 SlotsLayout.position: SlotsLayout.Trailing
132 SlotsLayout.overrideVerticalPositioning: true
133 fillMode: Image.PreserveAspectFit
134 anchors.verticalCenter: parent.verticalCenter
135 height: units.gu(1.5)
136 source: "data/Tick@30.png"
137 visible: itemDelegate.isCurrent
142 keyboardListView.currentIndex = index;
143 selectedKeymap = layoutId;
151 LocalComponents.StackButton {
152 text: keyboardListView.currentIndex != -1 ? i18n.tr("Next") : i18n.tr("Skip")
154 if (keyboardListView.currentIndex != -1) {
155 AccountsService.keymaps = selectedKeymap;