From a1dfccd17958a1af13eb9bc628255fec1753e583 Mon Sep 17 00:00:00 2001 From: Denys Madureira Date: Wed, 31 Jul 2024 18:58:29 +0100 Subject: [PATCH] Feat: Add simple option to use custom URL --- contents/config/main.xml | 3 +++ contents/ui/ConfigGeneral.qml | 9 ++++++++ contents/ui/Header.qml | 42 +++++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/contents/config/main.xml b/contents/config/main.xml index 9164f5c..1506b4b 100644 --- a/contents/config/main.xml +++ b/contents/config/main.xml @@ -79,5 +79,8 @@ false + + false + diff --git a/contents/ui/ConfigGeneral.qml b/contents/ui/ConfigGeneral.qml index aa53048..951825a 100644 --- a/contents/ui/ConfigGeneral.qml +++ b/contents/ui/ConfigGeneral.qml @@ -20,6 +20,7 @@ KCM.SimpleKCM { property alias cfg_hideHeader: hideHeader.checked property alias cfg_hideGoToButton: hideGoToButton.checked property alias cfg_hideKeepOpen: hideKeepOpen.checked + property alias cfg_hideCustomURL: hideCustomURL.checked Kirigami.FormLayout { @@ -144,6 +145,14 @@ KCM.SimpleKCM { } } + RowLayout { + QQC2.CheckBox { + id: hideCustomURL + + text: qsTr("Hide \"Custom URL\" button") + } + } + Kirigami.InlineMessage { Layout.fillWidth: true text: 'You can still use the "Go back to ..." and "Keep open" actions by right-clicking the widget icon.' diff --git a/contents/ui/Header.qml b/contents/ui/Header.qml index 476c668..0e97f17 100644 --- a/contents/ui/Header.qml +++ b/contents/ui/Header.qml @@ -12,6 +12,7 @@ RowLayout { signal goBackToHomePage() property var models; + property bool showCustomURLInput: false; Plasmoid.contextualActions: [ PlasmaCore.Action { @@ -23,7 +24,7 @@ RowLayout { onTriggered: plasmoid.configuration.pin = checked }, PlasmaCore.Action { - text: "Go back to " + urlComboBox.currentText + text: "Go back to " + (showCustomURLInput ? "home" : urlComboBox.currentText) icon.name: "go-home-symbolic" priority: Plasmoid.LowPriorityAction onTriggered: goBackToHomePage() @@ -32,7 +33,7 @@ RowLayout { PlasmaComponents3.Button { icon.name: "go-home-symbolic" - text: "Go back to " + urlComboBox.currentText + text: "Go back to " + (showCustomURLInput ? "home" : urlComboBox.currentText) display: PlasmaComponents3.AbstractButton.IconOnly onClicked: goBackToHomePage() visible: !plasmoid.configuration.hideGoToButton @@ -44,6 +45,7 @@ RowLayout { PlasmaComponents3.ComboBox { id: urlComboBox + visible: !showCustomURLInput Layout.fillWidth: true @@ -70,6 +72,36 @@ RowLayout { } } + PlasmaComponents3.TextField { + id: customURLInput + visible: showCustomURLInput + Layout.fillWidth: true + text: plasmoid.configuration.url + onEditingFinished: { + plasmoid.configuration.url = text + + goBackToHomePage() + } + placeholderText: i18n("Custom chat URL") + } + + PlasmaComponents3.Button { + icon.name: "kdenlive-custom-effect-symbolic" + text: "Use custom URL" + display: PlasmaComponents3.AbstractButton.IconOnly + onClicked: { + showCustomURLInput = !showCustomURLInput + + if (!showCustomURLInput) { + handleModelSelection() + } + } + visible: !plasmoid.configuration.hideCustomURL + + PlasmaComponents3.ToolTip.text: text + PlasmaComponents3.ToolTip.delay: Kirigami.Units.toolTipDelay + PlasmaComponents3.ToolTip.visible: hovered + } PlasmaComponents3.Button { icon.name: "window-pin" @@ -85,6 +117,10 @@ RowLayout { PlasmaComponents3.ToolTip.visible: hovered } + Component.onCompleted: { + showCustomURLInput = !Boolean(models.find(model => model.url === plasmoid.configuration.url)) + } + Binding { target: root property: "hideOnWindowDeactivate" @@ -114,5 +150,7 @@ RowLayout { urlComboBox.displayText = urlComboBox.currentValue; plasmoid.configuration.url = models.find(model => model.text === selectedModel).url + + goBackToHomePage() } } \ No newline at end of file