Warning, /utilities/vail/src/ui/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 Felipe Kinoshita <kinofhek@gmail.com>
0002 // SPDX-License-Identifier: GPL-3.0-or-later
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Controls 2.15 as QQC2
0006 import QtQuick.Layouts 1.15
0007 import org.kde.kirigami 2.19 as Kirigami
0008 
0009 import org.kde.vail 1.0
0010 
0011 Kirigami.ApplicationWindow {
0012     id: root
0013 
0014     title: i18n("Vail")
0015 
0016     width: Kirigami.Units.gridUnit * 34
0017     height: Kirigami.Units.gridUnit * 21
0018     minimumWidth: Kirigami.Units.gridUnit * 20
0019     minimumHeight: Kirigami.Units.gridUnit * 20
0020 
0021     Timer {
0022         id: saveWindowGeometryTimer
0023         interval: 1000
0024         onTriggered: App.saveWindowGeometry(root)
0025     }
0026 
0027     Connections {
0028         id: saveWindowGeometryConnections
0029         enabled: false // Disable on startup to avoid writing wrong values if the window is hidden
0030         target: root
0031 
0032         function onClosing() { App.saveWindowGeometry(root); }
0033         function onWidthChanged() { saveWindowGeometryTimer.restart(); }
0034         function onHeightChanged() { saveWindowGeometryTimer.restart(); }
0035         function onXChanged() { saveWindowGeometryTimer.restart(); }
0036         function onYChanged() { saveWindowGeometryTimer.restart(); }
0037     }
0038 
0039     Loader {
0040         active: !Kirigami.Settings.isMobile
0041         sourceComponent: GlobalMenu {}
0042     }
0043 
0044     pageStack.initialPage: Kirigami.Page {
0045         id: page
0046 
0047         padding: Kirigami.Units.gridUnit
0048         titleDelegate: PageHeader {}
0049 
0050         ColumnLayout {
0051             anchors.fill: parent
0052 
0053             Kirigami.Heading {
0054                 text: i18n("Message:")
0055                 type: Kirigami.Heading.Primary
0056             }
0057 
0058             QQC2.ScrollView {
0059                 Layout.fillWidth: true
0060                 Layout.fillHeight: true
0061 
0062                 QQC2.TextArea {
0063                     id: messageTextarea
0064 
0065                     focus: !Kirigami.InputMethod.willShowOnActive
0066 
0067                     wrapMode: Text.Wrap
0068 
0069                     onTextChanged: {
0070                         Translator.translate(text)
0071                     }
0072                 }
0073             }
0074 
0075             Item {
0076                 Layout.preferredHeight: Kirigami.Units.largeSpacing
0077             }
0078 
0079             Kirigami.Heading {
0080                 text: i18n("Morse Code:")
0081                 type: Kirigami.Heading.Primary
0082             }
0083 
0084             QQC2.ScrollView {
0085                 Layout.fillWidth: true
0086                 Layout.fillHeight: true
0087 
0088                 QQC2.TextArea {
0089                     id: morseTextarea
0090 
0091                     Layout.fillWidth: true
0092                     Layout.fillHeight: true
0093 
0094                     readOnly: true
0095                     wrapMode: Text.Wrap
0096 
0097                     Connections {
0098                         target: Translator
0099 
0100                         function onTranslation(translation) {
0101                             morseTextarea.text = translation
0102                         }
0103                     }
0104                 }
0105             }
0106         }
0107     }
0108 
0109     Component.onCompleted: {
0110         if (!Kirigami.Settings.isMobile) {
0111             saveWindowGeometryConnections.enabled = true
0112         }
0113     }
0114 }