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

First approach to a plasmoid that can display the state of caps lock

Reviewers: #plasma, jriddell

Subscribers: graesslin, abetts, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10337
parent 5bf2d077
plasma_install_package(activitypager org.kde.plasma.activitypager)
plasma_install_package(kickerdash org.kde.plasma.kickerdash)
plasma_install_package(konsoleprofiles/package org.kde.plasma.konsoleprofiles)
plasma_install_package(keyboardindicator org.kde.plasma.keyboardindicator)
add_subdirectory(binary-clock)
add_subdirectory(calculator)
......
/*
* 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 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
Plasmoid.onActivated: toggle()
PlasmaCore.DataSource {
id: keystateSource
engine: "keystate"
connectedSources: ["Caps Lock", "Num Lock"]
}
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")
Plasmoid.icon: capsLock ? "input-caps-on" : "input-keyboard"
Plasmoid.toolTipSubText: capsLockMessage + "\n" + numLockMessage
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: units.iconSizes.small
Layout.minimumHeight: Layout.minimumWidth
Layout.maximumWidth: inPanel ? units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel ? units.iconSizeHints.panel : -1
icon: plasmoid.icon
mainText: plasmoid.title
subText: plasmoid.toolTipSubText
PlasmaCore.IconItem {
anchors.fill: parent
source: plasmoid.icon
active: parent.containsMouse || root.capsLock
}
}
}
[Desktop Entry]
Name=Keyboard Indicator
Comment=Shows the state of the keyboard
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-MainScript=ui/main.qml
X-Plasma-API=declarativeappletscript
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