1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Rewrite and make FormFolderDelegate functional

Also adds a "open folder" button which is super handy
This commit is contained in:
Joshua Goins 2023-09-20 15:57:27 -04:00
parent 7db9cdeb42
commit ac543a7ab3
2 changed files with 51 additions and 6 deletions

View file

@ -2,23 +2,66 @@
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import QtCore import QtCore
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Dialogs import QtQuick.Dialogs
import QtQuick.Layouts
import org.kde.kirigamiaddons.labs.mobileform as MobileForm import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.formcard as FormCard
MobileForm.FormButtonDelegate { FormCard.AbstractFormDelegate {
id: control id: root
property string folder property string folder
icon.name: "document-open-folder" signal accepted(string folder)
description: folder
onClicked: dialog.open() onClicked: dialog.open()
contentItem: RowLayout {
ColumnLayout {
Layout.fillWidth: true
QQC2.Label {
text: root.text
Layout.fillWidth: true
}
QQC2.Label {
text: root.folder
elide: Text.ElideRight
maximumLineCount: 1
color: Kirigami.Theme.disabledTextColor
Layout.fillWidth: true
}
}
QQC2.ToolButton {
text: i18n("Open Folder")
icon.name: "document-open-folder"
display: QQC2.AbstractButton.IconOnly
onClicked: Qt.openUrlExternally("file://" + root.folder)
QQC2.ToolTip.text: text
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
QQC2.ToolTip.visible: hovered
}
FormCard.FormArrow {
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
direction: FormCard.FormArrow.Right
}
}
FolderDialog { FolderDialog {
id: dialog id: dialog
currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0] currentFolder: "file://" + root.folder
selectedFolder: "file://" + root.folder
onAccepted: root.accepted(decodeURIComponent(selectedFolder.toString().replace("file://", "")))
} }
} }

View file

@ -44,6 +44,8 @@ FormCard.FormCardPage {
text: i18n("Game Path") text: i18n("Game Path")
folder: page.profile.gamePath folder: page.profile.gamePath
onAccepted: (folder) => page.profile.gamePath = folder
} }
FormCard.FormDelegateSeparator { FormCard.FormDelegateSeparator {