Warning, /network/neochat/src/qml/ManualUserDialog.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 import QtQuick 0005 import QtQuick.Layouts 0006 0007 import org.kde.kirigami as Kirigami 0008 import org.kde.kirigamiaddons.formcard as FormCard 0009 0010 import org.kde.neochat 0011 0012 Kirigami.Dialog { 0013 id: root 0014 0015 /** 0016 * @brief The connection for the current user. 0017 */ 0018 required property NeoChatConnection connection 0019 0020 /** 0021 * @brief Thrown when a user is selected. 0022 */ 0023 signal userSelected 0024 0025 title: i18nc("@title", "User ID") 0026 0027 width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 24) 0028 leftPadding: 0 0029 rightPadding: 0 0030 topPadding: 0 0031 bottomPadding: 0 0032 0033 standardButtons: Kirigami.Dialog.Cancel 0034 customFooterActions: [ 0035 Kirigami.Action { 0036 enabled: userIdText.isValidText 0037 text: i18n("OK") 0038 icon.name: "dialog-ok" 0039 onTriggered: { 0040 root.connection.openOrCreateDirectChat(userIdText.text); 0041 root.accept(); 0042 } 0043 } 0044 ] 0045 0046 contentItem: ColumnLayout { 0047 spacing: 0 0048 FormCard.FormTextFieldDelegate { 0049 id: userIdText 0050 property bool isValidText: text.match(/@(.+):(.+)/g) 0051 property bool correctStart: text.startsWith("@") 0052 0053 label: i18n("User ID:") 0054 statusMessage: { 0055 if (text.length > 0 && !correctStart) { 0056 return i18n("User IDs Must start with @"); 0057 } 0058 if (timer.running) { 0059 return ""; 0060 } 0061 if (text.length > 0 && !isValidText) { 0062 return i18n("The input is not a valid user ID"); 0063 } 0064 return correctStart ? "" : i18n("User IDs Must start with @"); 0065 } 0066 status: text.length > 0 ? Kirigami.MessageType.Error : Kirigami.MessageType.Information 0067 0068 onTextEdited: timer.restart() 0069 0070 Timer { 0071 id: timer 0072 interval: 1000 0073 } 0074 } 0075 } 0076 0077 onVisibleChanged: { 0078 userIdText.forceActiveFocus(); 0079 timer.restart(); 0080 } 0081 }