Skip to content

Commit

Permalink
Feat: Add simple option to use custom URL
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysMb committed Jul 31, 2024
1 parent bdf0251 commit a1dfccd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
3 changes: 3 additions & 0 deletions contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,8 @@
<entry name="hideKeepOpen" type="Bool">
<default>false</default>
</entry>
<entry name="hideCustomURL" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>
9 changes: 9 additions & 0 deletions contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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.'
Expand Down
42 changes: 40 additions & 2 deletions contents/ui/Header.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RowLayout {
signal goBackToHomePage()

property var models;
property bool showCustomURLInput: false;

Plasmoid.contextualActions: [
PlasmaCore.Action {
Expand All @@ -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()
Expand All @@ -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
Expand All @@ -44,6 +45,7 @@ RowLayout {

PlasmaComponents3.ComboBox {
id: urlComboBox
visible: !showCustomURLInput

Layout.fillWidth: true

Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -114,5 +150,7 @@ RowLayout {
urlComboBox.displayText = urlComboBox.currentValue;

plasmoid.configuration.url = models.find(model => model.text === selectedModel).url

goBackToHomePage()
}
}

0 comments on commit a1dfccd

Please sign in to comment.