summaryrefslogtreecommitdiffstats
path: root/Usage.qml
blob: 65e3a8befb16e7995ed3a04318aeec277cb5efdd (plain)
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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

GroupBox {
    implicitWidth: parent.width
    implicitHeight: 180
    title: "Usage"

    ScrollView {
        anchors.fill: parent
        contentWidth: textArea.implicitWidth
        TextArea {
            id: textArea
            readonly property int slashIndex: bridge.targetDirectory.lastIndexOf("/")
            readonly property string importPath: bridge.targetDirectory.slice(0, slashIndex)
            readonly property string styleName: bridge.targetDirectory.slice(slashIndex + 1)
            readOnly: true
            wrapMode: TextEdit.Wrap
            textFormat: TextEdit.RichText
            text: slashIndex === -1 || importPath === "" || styleName === ""
                  ? "You first need to set a valid target directory!"
                  : bridge.howToText()
            .replace(/@styleName@/g, styleName)
            .replace(/@importPath@/g, importPath)
        }
    }
}