first commit
This commit is contained in:
11
contents/config/main.xml
Normal file
11
contents/config/main.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?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" >
|
||||||
|
<group name="General">
|
||||||
|
<entry name="savedCharacters" type="String">
|
||||||
|
<default>["Ä", "ä", "Å", "å", "Ö", "ö", "€"]</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
</kcfg>
|
||||||
187
contents/ui/main.qml
Normal file
187
contents/ui/main.qml
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
import org.kde.plasma.plasmoid
|
||||||
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
||||||
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
PlasmoidItem {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
// Data Management
|
||||||
|
ListModel {
|
||||||
|
id: charModel
|
||||||
|
Component.onCompleted: loadChars()
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadChars() {
|
||||||
|
charModel.clear()
|
||||||
|
var configStr = Plasmoid.configuration.savedCharacters || '[]'
|
||||||
|
try {
|
||||||
|
var chars = JSON.parse(configStr)
|
||||||
|
for (var i = 0; i < chars.length; i++) {
|
||||||
|
charModel.append({ "charText": chars[i] })
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error loading characters: " + e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveChars() {
|
||||||
|
var chars = []
|
||||||
|
for (var i = 0; i < charModel.count; i++) {
|
||||||
|
chars.push(charModel.get(i).charText)
|
||||||
|
}
|
||||||
|
Plasmoid.configuration.savedCharacters = JSON.stringify(chars)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetToDefaults() {
|
||||||
|
// Explicitly set to the defaults defined in your main.xml
|
||||||
|
Plasmoid.configuration.savedCharacters = '["Ä", "ä", "Å", "å", "Ö", "ö", "€"]'
|
||||||
|
loadChars()
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearAll() {
|
||||||
|
charModel.clear()
|
||||||
|
Plasmoid.configuration.savedCharacters = "[]"
|
||||||
|
}
|
||||||
|
|
||||||
|
function addChar(text) {
|
||||||
|
if (text.trim() === "") return
|
||||||
|
charModel.append({ "charText": text })
|
||||||
|
saveChars()
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeChar(index) {
|
||||||
|
charModel.remove(index)
|
||||||
|
saveChars()
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEdit {
|
||||||
|
id: clipboardHelper
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard(str) {
|
||||||
|
clipboardHelper.text = str
|
||||||
|
clipboardHelper.selectAll()
|
||||||
|
clipboardHelper.copy()
|
||||||
|
}
|
||||||
|
|
||||||
|
compactRepresentation: PlasmaComponents.Button {
|
||||||
|
icon.name: "accessories-character-map"
|
||||||
|
flat: true
|
||||||
|
padding: 0
|
||||||
|
onClicked: root.expanded = !root.expanded
|
||||||
|
}
|
||||||
|
|
||||||
|
fullRepresentation: Item {
|
||||||
|
implicitWidth: Kirigami.Units.gridUnit * 12
|
||||||
|
implicitHeight: Kirigami.Units.gridUnit * 14
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
|
// --- HEADER ---
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
text: "Quick Characters"
|
||||||
|
font.bold: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
// Reset to Defaults Button
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
icon.name: "edit-undo"
|
||||||
|
flat: true
|
||||||
|
onClicked: root.resetToDefaults()
|
||||||
|
display: PlasmaComponents.AbstractButton.IconOnly
|
||||||
|
|
||||||
|
// Use the standard ToolTip component
|
||||||
|
ToolTip.text: "Reset to defaults"
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
}
|
||||||
|
// Clear All Button
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
icon.name: "edit-clear-all"
|
||||||
|
flat: true
|
||||||
|
onClicked: root.clearAll()
|
||||||
|
display: PlasmaComponents.AbstractButton.IconOnly
|
||||||
|
|
||||||
|
ToolTip.text: "Clear all"
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- GRID & PLACEHOLDER ---
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
// Dimmed placeholder label
|
||||||
|
PlasmaComponents.Label {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "Add a character..."
|
||||||
|
opacity: 0.5
|
||||||
|
font.italic: true
|
||||||
|
visible: charModel.count === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: charModel.count > 0
|
||||||
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||||
|
|
||||||
|
GridView {
|
||||||
|
id: grid
|
||||||
|
model: charModel
|
||||||
|
cellWidth: 60
|
||||||
|
cellHeight: 60
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
delegate: Item {
|
||||||
|
width: grid.cellWidth
|
||||||
|
height: grid.cellHeight
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: 48
|
||||||
|
height: 48
|
||||||
|
text: model.charText
|
||||||
|
onClicked: {
|
||||||
|
copyToClipboard(model.charText)
|
||||||
|
root.expanded = false
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.RightButton
|
||||||
|
onClicked: root.removeChar(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- INPUT ---
|
||||||
|
RowLayout {
|
||||||
|
PlasmaComponents.TextField {
|
||||||
|
id: inputField
|
||||||
|
Layout.fillWidth: true
|
||||||
|
placeholderText: "Add..."
|
||||||
|
onAccepted: {
|
||||||
|
addChar(text)
|
||||||
|
text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlasmaComponents.Button {
|
||||||
|
icon.name: "list-add"
|
||||||
|
onClicked: {
|
||||||
|
addChar(inputField.text)
|
||||||
|
inputField.text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
metadata.json
Normal file
20
metadata.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"KPlugin": {
|
||||||
|
"Id": "org.hadak.kdequickchar",
|
||||||
|
"Name": "Quick Copy Character",
|
||||||
|
"Description": "Quickly copy saved characters to your clipboard.",
|
||||||
|
"Icon": "character-set",
|
||||||
|
"Authors": [
|
||||||
|
{
|
||||||
|
"Name": "Hans Kokx",
|
||||||
|
"Email": "hans.d.kokx@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Category": "Utilities",
|
||||||
|
"Version": "1.0",
|
||||||
|
"License": "GPL-3.0+",
|
||||||
|
"EnabledByDefault": true
|
||||||
|
},
|
||||||
|
"KPackageStructure": "Plasma/Applet",
|
||||||
|
"X-Plasma-API-Minimum-Version": "6.0"
|
||||||
|
}
|
||||||
11
refresh.sh
Executable file
11
refresh.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
rm -rf ~/.local/share/plasma/plasmoids/org.hadak.kdequickchar
|
||||||
|
|
||||||
|
# 1. Re-install the widget
|
||||||
|
kpackagetool6 --type Plasma/Applet --install .
|
||||||
|
|
||||||
|
# 2. Clear the cache
|
||||||
|
kbuildsycoca6
|
||||||
|
|
||||||
|
# 3. Restart the shell to see changes
|
||||||
|
kquitapp6 plasmashell && kstart plasmashell
|
||||||
Reference in New Issue
Block a user