From f21819d81332581c82f276b24c70f8e8f7f8ac5c Mon Sep 17 00:00:00 2001 From: Chris Holland Date: Mon, 11 Mar 2024 04:29:57 -0400 Subject: [PATCH] Delete old QQC1 config lib --- package/contents/ui/lib/AppletVersion.qml | 50 --------- package/contents/ui/lib/ConfigCheckBox.qml | 13 --- package/contents/ui/lib/ConfigColor.qml | 111 ------------------- package/contents/ui/lib/ConfigComboBox.qml | 106 ------------------ package/contents/ui/lib/ConfigFontFamily.qml | 20 ---- package/contents/ui/lib/ConfigPage.qml | 41 ------- package/contents/ui/lib/ConfigSpinBox.qml | 74 ------------- package/contents/ui/lib/ConfigTextAlign.qml | 72 ------------ package/contents/ui/lib/ConfigTextFormat.qml | 72 ------------ package/contents/ui/lib/ConfigVertAlign.qml | 64 ----------- 10 files changed, 623 deletions(-) delete mode 100644 package/contents/ui/lib/AppletVersion.qml delete mode 100644 package/contents/ui/lib/ConfigCheckBox.qml delete mode 100644 package/contents/ui/lib/ConfigColor.qml delete mode 100644 package/contents/ui/lib/ConfigComboBox.qml delete mode 100644 package/contents/ui/lib/ConfigFontFamily.qml delete mode 100644 package/contents/ui/lib/ConfigPage.qml delete mode 100644 package/contents/ui/lib/ConfigSpinBox.qml delete mode 100644 package/contents/ui/lib/ConfigTextAlign.qml delete mode 100644 package/contents/ui/lib/ConfigTextFormat.qml delete mode 100644 package/contents/ui/lib/ConfigVertAlign.qml diff --git a/package/contents/ui/lib/AppletVersion.qml b/package/contents/ui/lib/AppletVersion.qml deleted file mode 100644 index 1e18b2e..0000000 --- a/package/contents/ui/lib/AppletVersion.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import org.kde.plasma.plasmoid -import org.kde.plasma.core as PlasmaCore -import org.kde.plasma.components as PlasmaComponent - -Item { - implicitWidth: label.implicitWidth - implicitHeight: label.implicitHeight - - property string version: "?" - property string metadataFilepath: plasmoid.file("", "../metadata.desktop") - - PlasmaCore.DataSource { - id: executable - engine: "executable" - connectedSources: [] - onNewData: { - var exitCode = data["exit code"] - var exitStatus = data["exit status"] - var stdout = data["stdout"] - var stderr = data["stderr"] - exited(exitCode, exitStatus, stdout, stderr) - disconnectSource(sourceName) // cmd finished - } - function exec(cmd) { - connectSource(cmd) - } - signal exited(int exitCode, int exitStatus, string stdout, string stderr) - } - - Connections { - target: executable - onExited: { - version = stdout.replace('\n', ' ').trim() - } - } - - Label { - id: label - text: i18n("Version: %1", version) - } - - Component.onCompleted: { - var cmd = 'kreadconfig5 --file "' + metadataFilepath + '" --group "Desktop Entry" --key "X-KDE-PluginInfo-Version"' - executable.exec(cmd) - } - -} diff --git a/package/contents/ui/lib/ConfigCheckBox.qml b/package/contents/ui/lib/ConfigCheckBox.qml deleted file mode 100644 index e814521..0000000 --- a/package/contents/ui/lib/ConfigCheckBox.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -import ".." - -CheckBox { - id: configCheckBox - - property string configKey: '' - checked: plasmoid.configuration[configKey] - onClicked: plasmoid.configuration[configKey] = !plasmoid.configuration[configKey] -} diff --git a/package/contents/ui/lib/ConfigColor.qml b/package/contents/ui/lib/ConfigColor.qml deleted file mode 100644 index 1243090..0000000 --- a/package/contents/ui/lib/ConfigColor.qml +++ /dev/null @@ -1,111 +0,0 @@ -// Version 2 - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtQuick.Dialogs -import QtQuick.Window - -import org.kde.plasma.core as PlasmaCore -import org.kde.plasma.components as PlasmaComponents - -import ".." - -RowLayout { - id: configColor - spacing: 2 - // Layout.fillWidth: true - Layout.maximumWidth: 300 * Screen.devicePixelRatio - - property alias label: label.text - property alias horizontalAlignment: label.horizontalAlignment - - property string configKey: '' - property string defaultColor: '' - property string value: { - if (configKey) { - return plasmoid.configuration[configKey] - } else { - return "#000" - } - } - - readonly property color defaultColorValue: defaultColor - readonly property color valueColor: { - if (value == '' && defaultColor) { - return defaultColor - } else { - return value - } - } - - onValueChanged: { - if (!textField.activeFocus) { - textField.text = configColor.value - } - if (configKey) { - if (value == defaultColorValue) { - plasmoid.configuration[configKey] = "" - } else { - plasmoid.configuration[configKey] = value - } - } - } - - function setValue(newColor) { - textField.text = newColor - } - - Label { - id: label - text: "Label" - Layout.fillWidth: horizontalAlignment == Text.AlignRight - horizontalAlignment: Text.AlignLeft - } - - MouseArea { - id: mouseArea - width: textField.height - height: textField.height - hoverEnabled: true - - onClicked: dialog.open() - - Rectangle { - anchors.fill: parent - color: configColor.valueColor - border.width: 2 - border.color: parent.containsMouse ? Kirigami.Theme.highlightColor : "#BB000000" - } - } - - TextField { - id: textField - placeholderText: defaultColor ? defaultColor : "#AARRGGBB" - Layout.fillWidth: label.horizontalAlignment == Text.AlignLeft - onTextChanged: { - // Make sure the text is: - // Empty (use default) - // or #123 or #112233 or #11223344 before applying the color. - if (text.length === 0 - || (text.indexOf('#') === 0 && (text.length == 4 || text.length == 7 || text.length == 9)) - ) { - configColor.value = text - } - } - } - - ColorDialog { - id: dialog - visible: false - modality: Qt.WindowModal - title: configColor.label - options: ColorDialog.ShowAlphaChannel - selectedColor: configColor.valueColor - onAccepted: { - if (visible && color != currentColor) { - configColor.value = currentColor - } - } - } -} diff --git a/package/contents/ui/lib/ConfigComboBox.qml b/package/contents/ui/lib/ConfigComboBox.qml deleted file mode 100644 index e0571e5..0000000 --- a/package/contents/ui/lib/ConfigComboBox.qml +++ /dev/null @@ -1,106 +0,0 @@ -// Version 4 - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -/* -** Example: -** -ConfigComboBox { - configKey: "appDescription" - model: [ - { value: "a", text: i18n("A") }, - { value: "b", text: i18n("B") }, - { value: "c", text: i18n("C") }, - ] -} -*/ -RowLayout { - id: configComboBox - - property string configKey: '' - readonly property var currentItem: comboBox.model[comboBox.currentIndex] - readonly property string value: comboBox.currentIndex >= 0 && currentItem[valueRole] ? currentItem[valueRole] : "" - readonly property string configValue: configKey ? plasmoid.configuration[configKey] : "" - onConfigValueChanged: { - if (!comboBox.focus && value != configValue) { - selectValue(configValue) - } - } - - property alias textRole: comboBox.textRole - property alias valueRole: comboBox.valueRole - property alias model: comboBox.model - - property alias before: labelBefore.text - property alias after: labelAfter.text - - signal populate() - property bool populated: false - - Label { - id: labelBefore - text: "" - visible: text - } - - ComboBox { - id: comboBox - textRole: "text" // Doesn't autodeduce from model if we manually populate it - valueRole: "value" - - model: [] - - Component.onCompleted: { - populate() - selectValue(configValue) - } - - onCurrentIndexChanged: { - if (typeof model !== 'number' && 0 <= currentIndex && currentIndex < count) { - var item = model[currentIndex] - if (typeof item !== "undefined") { - var val = item[valueRole] - if (configKey && (typeof val !== "undefined") && populated) { - plasmoid.configuration[configKey] = val - } - } - } - } - } - - Label { - id: labelAfter - text: "" - visible: text - } - - function size() { - if (typeof model === "number") { - return model - } else if (typeof model.count === "number") { - return model.count - } else if (typeof model.length === "number") { - return model.length - } else { - return 0 - } - } - - function findValue(val) { - for (var i = 0; i < size(); i++) { - if (model[i][valueRole] == val) { - return i - } - } - return -1 - } - - function selectValue(val) { - var index = findValue(val) - if (index >= 0) { - comboBox.currentIndex = index - } - } -} diff --git a/package/contents/ui/lib/ConfigFontFamily.qml b/package/contents/ui/lib/ConfigFontFamily.qml deleted file mode 100644 index e651477..0000000 --- a/package/contents/ui/lib/ConfigFontFamily.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -ConfigComboBox { - id: configFontFamily - - // Based on: org.kde.plasma.digitalclock - onPopulate: { - var arr = [] // Use temp array to avoid constant binding stuff - arr.push({ text: i18nc("Use default font", "Default"), value: "" }) - - var fonts = Qt.fontFamilies() - for (var i = 0; i < fonts.length; i++) { - arr.push({ text: fonts[i], value: fonts[i] }) - } - model = arr - populated = true - } -} diff --git a/package/contents/ui/lib/ConfigPage.qml b/package/contents/ui/lib/ConfigPage.qml deleted file mode 100644 index 3f6c59b..0000000 --- a/package/contents/ui/lib/ConfigPage.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Version 3 - -import QtQuick -import QtQuick.Layouts - -import org.kde.plasma.plasmoid -import org.kde.plasma.core as PlasmaCore -import org.kde.plasma.components as PlasmaComponent - -Item { - id: page - Layout.fillWidth: true - default property alias _contentChildren: content.data - implicitHeight: content.implicitHeight - - ColumnLayout { - id: content - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - - // Workaround for crash when using default on a Layout. - // https://bugreports.qt.io/browse/QTBUG-52490 - // Still affecting Qt 5.7.0 - Component.onDestruction: { - while (children.length > 0) { - children[children.length - 1].parent = page; - } - } - } - - property alias showAppletVersion: appletVersionLoader.active - Loader { - id: appletVersionLoader - active: false - visible: active - source: "AppletVersion.qml" - anchors.right: parent.right - anchors.bottom: parent.top - } -} diff --git a/package/contents/ui/lib/ConfigSpinBox.qml b/package/contents/ui/lib/ConfigSpinBox.qml deleted file mode 100644 index cac8e50..0000000 --- a/package/contents/ui/lib/ConfigSpinBox.qml +++ /dev/null @@ -1,74 +0,0 @@ -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -RowLayout { - id: configSpinBox - - property string configKey: '' - property alias decimals: spinBox.decimals - property alias maximumValue: spinBox.to - property alias minimumValue: spinBox.from - property alias stepSize: spinBox.stepSize - property alias suffix: spinBox.suffix - property alias value: spinBox.value - - property alias before: labelBefore.text - property alias after: labelAfter.text - - Label { - id: labelBefore - text: "" - visible: text - } - - SpinBox { - id: spinBox - - value: plasmoid.configuration[configKey] - // onValueChanged: plasmoid.configuration[configKey] = value - onValueChanged: serializeTimer.start() - to: 2147483647 - - property string suffix: "" - - /* copied from https://doc.qt.io/qt-6/qml-qtquick-controls-spinbox.html - * because QtQuick 6.0 does not include properties that where in QtQuick.Controls 1.2 */ - property int decimals: 2 - property real realValue: value / decimalFactor - readonly property int decimalFactor: Math.pow(10, decimals) - - function decimalToInt(decimal) { - return decimal * decimalFactor - } - - validator: DoubleValidator { - bottom: Math.min(spinBox.from, spinBox.to) - top: Math.max(spinBox.from, spinBox.to) - decimals: spinBox.decimals - notation: DoubleValidator.StandardNotation - } - - textFromValue: function(value, locale) { - return (suffix == "" ? qsTr("%1") : qsTr("%1 " + suffix)).arg( - Number(value / decimalFactor).toLocaleString(locale, 'f', spinBox.decimals)) - } - - valueFromText: function(text, locale) { - return Math.round(Number.fromLocaleString(locale, text) * decimalFactor) - } - - } - - Label { - id: labelAfter - text: "" - visible: text - } - - Timer { // throttle - id: serializeTimer - interval: 300 - onTriggered: plasmoid.configuration[configKey] = value - } -} diff --git a/package/contents/ui/lib/ConfigTextAlign.qml b/package/contents/ui/lib/ConfigTextAlign.qml deleted file mode 100644 index 2118ec6..0000000 --- a/package/contents/ui/lib/ConfigTextAlign.qml +++ /dev/null @@ -1,72 +0,0 @@ -// Version 2 - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -RowLayout { - id: configTextAlign - - property string configKey: '' - readonly property string configValue: configKey ? plasmoid.configuration[configKey] : "" - - property alias before: labelBefore.text - property alias after: labelAfter.text - - function setValue(val) { - if (configKey) { - plasmoid.configuration[configKey] = val - } - updateChecked() - } - - function updateChecked() { - // button.checked bindings are unbound when clicked - justifyLeftButton.checked = Qt.binding(function(){ return configValue == Text.AlignLeft }) - justifyCenterButton.checked = Qt.binding(function(){ return configValue == Text.AlignHCenter }) - justifyRightButton.checked = Qt.binding(function(){ return configValue == Text.AlignRight }) - justifyFillButton.checked = Qt.binding(function(){ return configValue == Text.AlignJustify }) - } - - Component.onCompleted: updateChecked() - - Label { - id: labelBefore - text: "" - visible: text - } - - Button { - id: justifyLeftButton - icon.name: "format-justify-left-symbolic" - checkable: true - onClicked: setValue(Text.AlignLeft) - } - - Button { - id: justifyCenterButton - icon.name: "format-justify-center-symbolic" - checkable: true - onClicked: setValue(Text.AlignHCenter) - } - - Button { - id: justifyRightButton - icon.name: "format-justify-right-symbolic" - checkable: true - onClicked: setValue(Text.AlignRight) - } - - Button { - id: justifyFillButton - icon.name: "format-justify-fill-symbolic" - checkable: true - onClicked: setValue(Text.AlignJustify) - } - - Label { - id: labelAfter - text: "" - visible: text - } -} diff --git a/package/contents/ui/lib/ConfigTextFormat.qml b/package/contents/ui/lib/ConfigTextFormat.qml deleted file mode 100644 index c7018b9..0000000 --- a/package/contents/ui/lib/ConfigTextFormat.qml +++ /dev/null @@ -1,72 +0,0 @@ -// Version 2 - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -import org.kde.kirigami as Kirigami -import org.kde.plasma.core as PlasmaCore - -RowLayout { - id: configTextFormat - - property alias boldConfigKey: configBold.configKey - property alias italicConfigKey: configItalic.configKey - property alias underlineConfigKey: configUnderline.configKey - property alias alignConfigKey: configTextAlign.configKey - property alias vertAlignConfigKey: configVertAlign.configKey - - Button { - id: configBold - property string configKey: '' - visible: configKey - icon.name: 'format-text-bold-symbolic' - checkable: true - checked: configKey ? plasmoid.configuration[configKey] : false - onClicked: plasmoid.configuration[configKey] = checked - } - - Button { - id: configItalic - property string configKey: '' - visible: configKey - icon.name: 'format-text-italic-symbolic' - checkable: true - checked: configKey ? plasmoid.configuration[configKey] : false - onClicked: plasmoid.configuration[configKey] = checked - } - - Button { - id: configUnderline - property string configKey: '' - visible: configKey - icon.name: 'format-text-underline-symbolic' - checkable: true - checked: configKey ? plasmoid.configuration[configKey] : false - onClicked: plasmoid.configuration[configKey] = checked - } - - Item { - Layout.preferredWidth: Kirigami.Units.smallSpacing - readonly property bool groupBeforeVisible: configBold.visible || configItalic.visible || configUnderline.visible - readonly property bool groupAfterVisible: configTextAlign.visible - visible: groupBeforeVisible && groupAfterVisible - } - - ConfigTextAlign { - id: configTextAlign - visible: configKey - } - - Item { - Layout.preferredWidth: Kirigami.Units.smallSpacing - readonly property bool groupBeforeVisible: configBold.visible || configItalic.visible || configUnderline.visible || configTextAlign.visible - readonly property bool groupAfterVisible: configVertAlign.visible - visible: groupBeforeVisible && groupAfterVisible - } - - ConfigVertAlign { - id: configVertAlign - visible: configKey - } -} diff --git a/package/contents/ui/lib/ConfigVertAlign.qml b/package/contents/ui/lib/ConfigVertAlign.qml deleted file mode 100644 index 4cfaa74..0000000 --- a/package/contents/ui/lib/ConfigVertAlign.qml +++ /dev/null @@ -1,64 +0,0 @@ -// Version 3 - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts - -RowLayout { - id: configTextAlign - - property string configKey: '' - readonly property string configValue: configKey ? plasmoid.configuration[configKey] : "" - - property alias before: labelBefore.text - property alias after: labelAfter.text - - function setValue(val) { - if (configKey) { - plasmoid.configuration[configKey] = val - } - updateChecked() - } - - function updateChecked() { - // button.checked bindings are unbound when clicked - vertTopButton.checked = Qt.binding(function(){ return configValue == Text.AlignTop }) - vertCenterButton.checked = Qt.binding(function(){ return configValue == Text.AlignVCenter }) - vertBottomButton.checked = Qt.binding(function(){ return configValue == Text.AlignBottom }) - } - - Component.onCompleted: updateChecked() - - Label { - id: labelBefore - text: "" - visible: text - } - - Button { - id: vertTopButton - icon.name: "align-vertical-top" - checkable: true - onClicked: setValue(Text.AlignTop) - } - - Button { - id: vertCenterButton - icon.name: "align-vertical-center" - checkable: true - onClicked: setValue(Text.AlignVCenter) - } - - Button { - id: vertBottomButton - icon.name: "align-vertical-bottom" - checkable: true - onClicked: setValue(Text.AlignBottom) - } - - Label { - id: labelAfter - text: "" - visible: text - } -}