File: HelpButton.qml

package info (click to toggle)
syncthingtray 2.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,124 kB
  • sloc: cpp: 34,081; xml: 1,705; java: 1,258; sh: 97; javascript: 54; makefile: 25
file content (46 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download
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);
    }
}