aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/textEditStatusSwitch.qml
blob: ad292204821f44cadd7cc6bb561a36d52c96d4e1 (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) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick

//! [0]
TextEdit {
    id: edit
    width: 300
    height: 200
    textFormat: TextEdit.MarkdownText
    textDocument.source: "example.md"
    wrapMode: TextEdit.WordWrap

    Text {
        anchors {
            bottom: parent.bottom
            right: parent.right
        }
        color: edit.textDocument.status === TextDocument.Loaded ? "darkolivegreen" : "tomato"
        text:
            switch (edit.textDocument.status) {
            case TextDocument.Loading:
                return qsTr("Loading ") + edit.textDocument.source
            case TextDocument.Loaded:
                return qsTr("Loaded ") + edit.textDocument.source
            default:
                return edit.textDocument.errorString
            }
    }
}
//! [0]