Warning, /frameworks/syntax-highlighting/examples/qml/example.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15
0009 import QtQuick.Layouts 1.15
0010 import org.kde.syntaxhighlighting 1.0
0011 
0012 ApplicationWindow {
0013     visible: true
0014     width: 1024
0015     height: 720
0016 
0017     ColumnLayout {
0018         anchors.fill: parent
0019         RowLayout {
0020             Label { text: "Syntax" }
0021             ComboBox {
0022                 Layout.fillWidth: true
0023                 model: Repository.definitions
0024                 displayText: currentValue.translatedName + " (" + currentValue.translatedSection + ")"
0025                 textRole: "translatedName"
0026                 onCurrentIndexChanged: highlighter.definition = currentValue
0027             }
0028         }
0029         RowLayout {
0030             Label { text: "Theme" }
0031             ComboBox {
0032                 Layout.fillWidth: true
0033                 model: Repository.themes
0034                 displayText: currentValue.translatedName
0035                 textRole: "translatedName"
0036                 onCurrentIndexChanged: highlighter.theme = currentValue
0037             }
0038             Button {
0039                 text: "Light"
0040                 onClicked: highlighter.theme = Repository.defaultTheme(Repository.LightTheme).name
0041             }
0042             Button {
0043                 text: "Dark"
0044                 onClicked: highlighter.theme = Repository.DarkTheme
0045             }
0046         }
0047         TextArea {
0048             Layout.fillHeight: true
0049             Layout.fillWidth: true
0050             id: myText
0051 
0052             text: "Text {\n text: \"Hello World!\"\n width: 42\n}"
0053 
0054             SyntaxHighlighter {
0055                 id: highlighter
0056                 textEdit: myText
0057                 repository: Repository
0058                 // work around for QML not repainting a re-highlighted document...
0059                 onDefinitionChanged: { myText.selectAll(); myText.deselect(); }
0060                 onThemeChanged: { myText.selectAll(); myText.deselect(); }
0061             }
0062         }
0063         Label {
0064             text: "Syntax: " + highlighter.definition.translatedSection + "/" + highlighter.definition.translatedName + "  Theme: " + highlighter.theme.translatedName
0065         }
0066     }
0067 
0068     Component.onCompleted: {
0069         highlighter.definition = Repository.definitionForFileName("example.qml")
0070     }
0071 }