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

Usability fixes

parent 1ab3d012
/*
* Copyright 2017 Bernhard Friedreich <friesoft@gmail.com>
*
* 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.0
import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("Keys")
icon: "input-keyboard"
source: "configAppearance.qml"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="key" type="String">
<default>Caps Lock</default>
</entry>
</group>
</kcfg>
/*
* Copyright 2018 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* 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 QtQml.Models 2.2
import QtQuick.Controls 1.1 as Controls
import QtQuick.Layouts 1.1 as Layouts
Controls.GroupBox
{
signal configurationChanged
function saveConfig() {
plasmoid.nativeInterface.key = keysModel.get(keysCombo.currentIndex).name
plasmoid.nativeInterface.saveConfig();
plasmoid.nativeInterface.configChanged();
}
Component.onCompleted: {
for(var i=0; i<keysModel.count; ++i) {
if (keysModel.get(i).name === plasmoid.nativeInterface.key) {
keysCombo.currentIndex = i
}
}
}
title: i18n("Appearance")
flat: true
Layouts.ColumnLayout {
Controls.ComboBox {
id: keysCombo
textRole: "name"
model: ObjectModel {
id: keysModel
QtObject {
readonly property string name: "Caps Lock"
readonly property string text: i18n("Caps Lock")
}
QtObject {
readonly property string name: "Num Lock"
readonly property string text: i18n("Num Lock")
}
}
}
}
}
......@@ -26,21 +26,31 @@ import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: root
Plasmoid.onActivated: toggle()
PlasmaCore.DataSource {
readonly property QtObject source: PlasmaCore.DataSource {
id: keystateSource
engine: "keystate"
connectedSources: ["Caps Lock", "Num Lock"]
connectedSources: [plasmoid.configuration.key]
}
function translate(identifier) {
switch(identifier) {
case "CapsLock": return i18n("Caps Lock")
case "Num Lock": return i18n("Num Lock")
}
return identifier;
}
function icon(identifier) {
switch(identifier) {
case "CapsLock": return "input-caps-on"
}
return "emblem-locked";
}
readonly property bool capsLock: keystateSource.data["Caps Lock"]["Locked"]
readonly property bool numLock: keystateSource.data["Num Lock"]["Locked"]
readonly property string capsLockMessage: capsLock ? i18n("Caps Lock is on") : i18n("Caps Lock is off")
readonly property string numLockMessage: numLock ? i18n("Num Lock is on") : i18n("Num Lock is off")
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: capsLock ? "input-caps-on" : "input-keyboard"
Plasmoid.toolTipSubText: capsLockMessage + "\n" + numLockMessage
Plasmoid.icon: isLocked ? "input-caps-on" : ""
Plasmoid.title: message
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.fullRepresentation: PlasmaCore.ToolTipArea {
readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge
......@@ -48,20 +58,20 @@ Item {
|| plasmoid.location === PlasmaCore.Types.BottomEdge
|| plasmoid.location === PlasmaCore.Types.LeftEdge)
Layout.minimumWidth: units.iconSizes.small
Layout.minimumHeight: Layout.minimumWidth
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
icon: plasmoid.icon
icon: plasmoid.icon || "input-keyboard"
mainText: plasmoid.title
subText: plasmoid.toolTipSubText
PlasmaCore.IconItem {
anchors.fill: parent
source: plasmoid.icon
active: parent.containsMouse || root.capsLock
active: parent.containsMouse || root.isLocked
}
}
}
Supports Markdown
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