Commit f2e579f9 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Integrate the normal keyboard layout switcher

Summary:
This deprecates the SNI from KWin in favour of this plasmoid that will
allow doing the same as well as managing the different IME tech we
support.

This also changes the default panel layout to include kimpanel since it
will be useful in any language.

Related to D12069 and D14796

Test Plan:
I can switch between catalan and american keyboard, if ibus
is running I can do the same but through ibus.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D24503
parent 1449633f
......@@ -32,6 +32,8 @@ Item {
signal triggered(variant button);
property int iconSize: units.roundToIconSize(Math.min(parent.width, parent.height))
width: iconSize
height: iconSize
opacity: 'disable' == hint ? 0.3 : 1
function extractLabelString(l) {
......@@ -42,22 +44,9 @@ Item {
}
}
function iconPath(p) {
if (p.length > 0) {
if (p[0] === '/') {
return p;
} else {
return "image://icon/" + p;
}
}
return p;
}
PlasmaCore.IconItem {
id: imageIcon
anchors.centerIn: parent
width: iconSize
height: iconSize
anchors.fill: parent
scale: mouseArea.pressed ? 0.9 : 1
source: statusIcon.icon
visible: statusIcon.icon.length > 0
......@@ -66,12 +55,10 @@ Item {
}
PlasmaComponents.Label {
id: textIcon
anchors.centerIn: parent
width: iconSize
height: iconSize
anchors.fill: parent
scale: (mouseArea.pressed ? 0.9 : 1)
// a reasonable large size to make Text.Fit work
minimumPointSize: 0
minimumPointSize: theme.smallestFont.pointSize
font.pointSize: 1024
fontSizeMode: Text.Fit
verticalAlignment: Text.AlignVCenter
......
......@@ -22,6 +22,7 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.workspace.keyboardlayout 1.0
Item {
id: kimpanel
......@@ -43,11 +44,30 @@ Item {
id: items
width: parent.width
height: parent.height
x: (parent.width - childrenRect.width) / 2
y: (parent.height - childrenRect.height) / 2
anchors.centerIn: parent
flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom
property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height)))
property int iconSize: units.roundToIconSize(Math.min(width, height))
StatusIcon {
readonly property QtObject kl: KeyboardLayout {
id: layout
function nextLayout() {
var layouts = layout.layouts;
var index = (layouts.indexOf(layout.currentLayout)+1) % layouts.length;
layout.currentLayout = layouts[index];
}
}
width: visible ? items.iconSize : 0
height: items.iconSize
visible: list.count === 0
label: layout.currentLayout.substr(0, 2).toLowerCase()
tip: layout.currentLayout
onTriggered: if (button === Qt.LeftButton) {
layout.nextLayout()
}
}
Repeater {
model: ListModel {
......@@ -55,28 +75,20 @@ Item {
dynamicRoles: true
}
delegate: Item {
id: iconDelegate
width: items.iconSize
height: items.iconSize
StatusIcon {
id: statusIcon
anchors.centerIn: parent
width: items.iconSize
height: items.iconSize
label: model.label
tip: model.tip
icon: model.icon
hint: model.hint
onTriggered : {
if (button === Qt.LeftButton) {
clickHandler(model.key);
// clickHandler will trigger the menu, but we have to wait for
// the menu data. So we have to set the visual parent ahead.
actionMenu.visualParent = statusIcon;
} else {
contextMenu.open(statusIcon, {key: model.key, label: model.label});
}
delegate: StatusIcon {
id: statusIcon
label: model.label
tip: model.tip
icon: model.icon
hint: model.hint
onTriggered : {
if (button === Qt.LeftButton) {
clickHandler(model.key);
// clickHandler will trigger the menu, but we have to wait for
// the menu data. So we have to set the visual parent ahead.
actionMenu.visualParent = statusIcon;
} else {
contextMenu.open(statusIcon, {key: model.key, label: model.label});
}
}
}
......
......@@ -34,50 +34,7 @@ kickoff.writeConfig("global", "Alt+F1")
//panel.addWidget("org.kde.plasma.showActivityManager")
panel.addWidget("org.kde.plasma.pager")
panel.addWidget("org.kde.plasma.taskmanager")
/* Next up is determining whether to add the Input Method Panel
* widget to the panel or not. This is done based on whether
* the system locale's language id is a member of the following
* white list of languages which are known to pull in one of
* our supported IME backends when chosen during installation
* of common distributions. */
var langIds = ["as", // Assamese
"bn", // Bengali
"bo", // Tibetan
"brx", // Bodo
"doi", // Dogri
"gu", // Gujarati
"hi", // Hindi
"ja", // Japanese
"kn", // Kannada
"ko", // Korean
"kok", // Konkani
"ks", // Kashmiri
"lep", // Lepcha
"mai", // Maithili
"ml", // Malayalam
"mni", // Manipuri
"mr", // Marathi
"ne", // Nepali
"or", // Odia
"pa", // Punjabi
"sa", // Sanskrit
"sat", // Santali
"sd", // Sindhi
"si", // Sinhala
"ta", // Tamil
"te", // Telugu
"th", // Thai
"ur", // Urdu
"vi", // Vietnamese
"zh_CN", // Simplified Chinese
"zh_TW"] // Traditional Chinese
if (langIds.indexOf(languageId) != -1) {
panel.addWidget("org.kde.plasma.kimpanel");
}
panel.addWidget("org.kde.plasma.kimpanel");
panel.addWidget("org.kde.plasma.systemtray")
panel.addWidget("org.kde.plasma.digitalclock")
panel.addWidget("org.kde.plasma.showdesktop")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment