1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts
import Main
IconOnlyButton {
id: helpButton
visible: helpButton.desc.length > 0 || modelData.helpUrl?.length > 0 || (configCategory.length > 0 && !Array.isArray(configObject))
text: qsTr("Open help")
icon.source: App.faUrlBase + "question"
onClicked: helpButton.desc.length > 0 ? helpDlg.open() : helpButton.openSyncthingDocs()
CustomDialog {
id: helpDlg
title: modelData.label ?? helpButton.key
standardButtons: Dialog.NoButton
contentItem: Label {
text: helpButton.desc
wrapMode: Text.WordWrap
}
footer: DialogButtonBox {
Button {
text: qsTr("Close")
flat: true
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
}
Button {
text: qsTr("Details")
flat: true
enabled: helpButton.url.toString().length > 0
DialogButtonBox.buttonRole: DialogButtonBox.HelpRole
}
}
onHelpRequested: helpButton.openSyncthingDocs()
}
property string key: modelData.key
property string desc: modelData.desc
property string url: modelData.helpUrl ?? `https://docs.syncthing.net/users/config#${helpButton.configCategory}.${helpButton.key.toLowerCase()}`
property string configCategory
function openSyncthingDocs() {
App.requestOpeningUrl(helpButton.url);
}
}
|