diff --git a/applets/keyboardindicator/contents/config/main.xml b/applets/keyboardindicator/contents/config/main.xml
index e7109321a..19f7cf1b5 100644
--- a/applets/keyboardindicator/contents/config/main.xml
+++ b/applets/keyboardindicator/contents/config/main.xml
@@ -1,14 +1,14 @@
-
+
Caps Lock
diff --git a/applets/keyboardindicator/contents/ui/configAppearance.qml b/applets/keyboardindicator/contents/ui/configAppearance.qml
index 178aa8cd7..178f39186 100644
--- a/applets/keyboardindicator/contents/ui/configAppearance.qml
+++ b/applets/keyboardindicator/contents/ui/configAppearance.qml
@@ -1,53 +1,55 @@
/*
* Copyright 2018 Aleix Pol Gonzalez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.2
import QtQuick.Controls 2.2 as Controls
import QtQuick.Layouts 1.1
Item
{
id: root
signal configurationChanged
function saveConfig() {
- plasmoid.configuration.key = group.checkedButton.name
- }
-
- Controls.ButtonGroup {
- id: group
- buttons: layout.children
- onCheckedButtonChanged: root.configurationChanged()
+ var names = []
+ for(var i in layout.children) {
+ var cur = layout.children[i]
+ if (cur.checked)
+ names.push(cur.name)
+ }
+ plasmoid.configuration.key = names
}
ColumnLayout {
id: layout
- Controls.RadioButton {
+ Controls.CheckBox {
Layout.fillWidth: true
readonly property string name: "Caps Lock"
- checked: plasmoid.configuration.key === name
+ checked: plasmoid.configuration.key.indexOf(name) >= 0
text: i18n("Caps Lock")
+ onCheckedChanged: root.configurationChanged()
}
- Controls.RadioButton {
+ Controls.CheckBox {
Layout.fillWidth: true
readonly property string name: "Num Lock"
- checked: plasmoid.configuration.key === name
+ checked: plasmoid.configuration.key.indexOf(name) >= 0
text: i18n("Num Lock")
+ onCheckedChanged: root.configurationChanged()
}
}
}
diff --git a/applets/keyboardindicator/contents/ui/main.qml b/applets/keyboardindicator/contents/ui/main.qml
index ad9b5916c..76c0db493 100644
--- a/applets/keyboardindicator/contents/ui/main.qml
+++ b/applets/keyboardindicator/contents/ui/main.qml
@@ -1,84 +1,92 @@
/*
* Copyright 2018 Aleix Pol Gonzalez
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
import QtQuick 2.1
-import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: root
readonly property QtObject source: PlasmaCore.DataSource {
id: keystateSource
engine: "keystate"
- connectedSources: [plasmoid.configuration.key]
+ connectedSources: plasmoid.configuration.key
}
function translate(identifier) {
switch(identifier) {
case "Caps Lock": return i18n("Caps Lock")
case "Num Lock": return i18n("Num Lock")
}
return identifier;
}
+
function icon(identifier) {
switch(identifier) {
+ case "Num Lock": return "accessories-calculator"
case "Caps Lock": return "input-caps-on"
}
- return "emblem-locked";
+ return null
}
- function overlays(identifier) {
- switch(identifier) {
- case "Num Lock": return ["accessories-calculator"]
- default: return []
+ readonly property bool lockedCount: {
+ var ret = 0;
+ for (var v in keystateSource.connectedSources) {
+ ret += keystateSource.data[keystateSource.connectedSources[v]].Locked
}
+ return ret
}
- readonly property bool isLocked: keystateSource.data[plasmoid.configuration.key].Locked
- readonly property string message: isLocked ? i18n("%1 is locked", translate(plasmoid.configuration.key)) : i18n("%1 is unlocked", translate(plasmoid.configuration.key))
-
- Plasmoid.icon: isLocked ? icon(plasmoid.configuration.key) : ""
- Plasmoid.title: message
- Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
- Plasmoid.fullRepresentation: PlasmaCore.ToolTipArea {
- readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge
- || plasmoid.location === PlasmaCore.Types.RightEdge
- || plasmoid.location === PlasmaCore.Types.BottomEdge
- || plasmoid.location === PlasmaCore.Types.LeftEdge)
-
- Layout.minimumWidth: isLocked ? units.iconSizes.small : 0
- Layout.minimumHeight: isLocked ? Layout.minimumWidth : 0
-
- Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1
- Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1
+ Plasmoid.icon: {
+ for (var v in keystateSource.connectedSources) {
+ var source = keystateSource.connectedSources[v]
+ if (keystateSource.data[source].Locked)
+ return icon(source)
+ }
+ return "input-keyboard"
+ }
- icon: plasmoid.icon || "input-keyboard"
- mainText: plasmoid.title
- subText: plasmoid.toolTipSubText
+ Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
+ Plasmoid.compactRepresentation: PlasmaCore.IconItem {
+ source: plasmoid.icon
+ active: lockedCount>0
- PlasmaCore.IconItem {
+ MouseArea {
+ id: compactMouse
anchors.fill: parent
- source: plasmoid.icon
- active: parent.containsMouse || root.isLocked
- overlays: root.overlays(plasmoid.configuration.key)
+ hoverEnabled: true
+ acceptedButtons: null
+ }
+ }
+
+ Plasmoid.status: lockedCount>0 ? PlasmaCore.Types.ActiveStatus : PlasmaCore.Types.PassiveStatus
+ Plasmoid.toolTipSubText: {
+ var ret = "";
+ var found = false;
+ for (var v in keystateSource.connectedSources) {
+ var source = keystateSource.connectedSources[v]
+ if (keystateSource.data[source].Locked) {
+ found = true
+ ret+=i18n("%1: Locked\n", translate(source))
+ }
}
+ return found ? ret.trim() : i18n("Unlocked")
}
}
diff --git a/applets/keyboardindicator/metadata.desktop b/applets/keyboardindicator/metadata.desktop
index 196b1e2f8..4a9a56481 100644
--- a/applets/keyboardindicator/metadata.desktop
+++ b/applets/keyboardindicator/metadata.desktop
@@ -1,45 +1,46 @@
[Desktop Entry]
Name=Keyboard Indicator
Name[ca]=Indicador de teclat
Name[ca@valencia]=Indicador de teclat
Name[de]=Tastaturstatus
Name[en_GB]=Keyboard Indicator
Name[es]=Indicador del teclado
Name[fi]=Näppäimistöosoitin
Name[nl]=Toetsenbordindicator
Name[pl]=Wskaźnik klawiatury
Name[pt]=Indicador do Teclado
Name[pt_BR]=Indicador de teclado
Name[sv]=Tangentbordsindikator
Name[uk]=Індикатор клавіатури
Name[x-test]=xxKeyboard Indicatorxx
Name[zh_CN]=键盘指示器
Comment=Shows the state of the keyboard
Comment[ca]=Mostra l'estat del teclat
Comment[ca@valencia]=Mostra l'estat del teclat
Comment[de]=Zeigt den Status der Tastatur an
Comment[en_GB]=Shows the state of the keyboard
Comment[es]=Muestra el estado del teclado
Comment[fi]=Näyttää näppäimistön tilan
Comment[nl]=Toont de status van het toetsenbord
Comment[pl]=Pokazuje stan klawiatury
Comment[pt]=Mostra o estado do teclado
Comment[pt_BR]=Mostra o estado do teclado
Comment[sv]=Visar tangentbordets tillstånd
Comment[uk]=Показує стан клавіатури
Comment[x-test]=xxShows the state of the keyboardxx
Comment[zh_CN]=显示键盘的状态
Type=Service
Icon=input-keyboard
ServiceTypes=Plasma/Applet
X-KDE-ServiceTypes=Plasma/Applet
X-KDE-PluginInfo-Author=Aleix Pol Gonzalez
X-KDE-PluginInfo-Email=aleixpol@kde.org
X-KDE-PluginInfo-Name=org.kde.plasma.keyboardindicator
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-License=GPL-2.0+
X-KDE-PluginInfo-EnabledByDefault=true
+X-Plasma-NotificationArea=true
X-Plasma-MainScript=ui/main.qml
X-Plasma-API=declarativeappletscript