From 68b2f6cb4f05d427e037760b6124531211de2095 Mon Sep 17 00:00:00 2001 From: Kirillpt Date: Tue, 1 Dec 2020 01:30:33 +0300 Subject: [PATCH] Improve Register page (#346) * add username error label, add word wrapping for error labels * make lint * last commits * remove font, and remove some lambdas * add QRegularExpression for regex * improve review things * add isModified() for checkFields() * add check isModified() for all fields in checkFields * Update src/RegisterPage.cpp Co-authored-by: DeepBlueV7.X * remove emit call for showError Co-authored-by: DeepBlueV7.X --- resources/langs/nheko_cs.ts | 51 +++++++------- resources/langs/nheko_de.ts | 53 +++++++------- resources/langs/nheko_el.ts | 53 +++++++------- resources/langs/nheko_en.ts | 53 +++++++------- resources/langs/nheko_eo.ts | 51 +++++++------- resources/langs/nheko_et.ts | 53 +++++++------- resources/langs/nheko_fi.ts | 53 +++++++------- resources/langs/nheko_fr.ts | 53 +++++++------- resources/langs/nheko_it.ts | 53 +++++++------- resources/langs/nheko_ja.ts | 53 +++++++------- resources/langs/nheko_nl.ts | 53 +++++++------- resources/langs/nheko_pl.ts | 53 +++++++------- resources/langs/nheko_pt_PT.ts | 51 +++++++------- resources/langs/nheko_ro.ts | 51 +++++++------- resources/langs/nheko_ru.ts | 53 +++++++------- resources/langs/nheko_si.ts | 51 +++++++------- resources/langs/nheko_sv.ts | 51 +++++++------- resources/langs/nheko_zh_CN.ts | 53 +++++++------- src/LoginPage.cpp | 58 ++++++++------- src/LoginPage.h | 6 +- src/MainWindow.cpp | 2 +- src/RegisterPage.cpp | 125 ++++++++++++++++++++++++++++----- src/RegisterPage.h | 10 ++- src/ui/TextField.cpp | 25 +++++-- src/ui/TextField.h | 3 + 25 files changed, 648 insertions(+), 523 deletions(-) diff --git a/resources/langs/nheko_cs.ts b/resources/langs/nheko_cs.ts index 3f353b51..6e18cca0 100644 --- a/resources/langs/nheko_cs.ts +++ b/resources/langs/nheko_cs.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2059,7 +2060,7 @@ Media size: %2 - + End-to-End Encryption @@ -2069,7 +2070,7 @@ Media size: %2 - + Respond to key requests @@ -2081,7 +2082,7 @@ Media size: %2 - + %n member(s) @@ -2090,7 +2091,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_de.ts b/resources/langs/nheko_de.ts index 91d687e6..34c3b0bc 100644 --- a/resources/langs/nheko_de.ts +++ b/resources/langs/nheko_de.ts @@ -49,17 +49,17 @@ - + Invited user: %1 Eingeladener Benutzer: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. Das Migrieren des Caches auf die aktuelle Version ist fehlgeschlagen. Das kann verschiedene Gründe als Ursache haben. Bitte melde den Fehler und verwende in der Zwischenzeit eine ältere Version. Alternativ kannst du das Cache manuell löschen. - + Room %1 created. Raum %1 erzeugt. @@ -139,7 +139,7 @@ Verbannung von %1 wurde aufgehoben. - + Cache migration failed! Cache migration fehlgeschlagen! @@ -164,7 +164,7 @@ Gespeicherte Nachrichten konnten nicht wiederhergestellt werden. Bitte melde Dich erneut an. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Fehler beim Setup der Verschlüsselungsschlüssel. Servermeldung: %1 %2. Bitte versuche es später erneut. @@ -261,7 +261,7 @@ EditModal - + Apply Anwenden @@ -473,7 +473,7 @@ Matrix-ID - + e.g @joe:matrix.org z.B. @joe:matrix.org @@ -512,7 +512,7 @@ Beispiel: https://mein.server:8787 - + LOGIN ANMELDEN @@ -547,12 +547,12 @@ Beispiel: https://mein.server:8787 SSO ANMELDUNG - + Empty password Leeres Passwort - + SSO login failed SSO Anmeldung fehlgeschlagen @@ -752,22 +752,23 @@ Beispiel: https://mein.server:8787 RegisterPage - + Username Benutzername - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. Der Benutzername sollte nicht leer sein und nur aus a-z, 0-9, ., _, =, - und / bestehen. - + Password Passwort - + Please choose a secure password. The exact requirements for password strength may depend on your server. Bitte wähle ein sicheres Passwort. Die genauen Anforderungen bestimmt dein Server. @@ -787,32 +788,32 @@ Beispiel: https://mein.server:8787 Ein Server, der Registrierungen zulässt. Weil Matrix ein dezentralisiertes Protokoll ist, musst du erst einen Server ausfindig machen oder einen persönlichen Server aufsetzen. - + REGISTER REGISTRIEREN - + No supported registration flows! Keine unterstützten Registrierungsmethoden! - - Invalid username - Ungültiger Benutzername + + Regisration Failed + - + Password is not long enough (min 8 chars) Passwort nicht lang genug (mind. 8 Zeichen) - + Passwords don't match Passwörter stimmen nicht überein - + Invalid server name Ungültiger Servername @@ -2064,7 +2065,7 @@ Medien-Größe: %2 Verschlüsselung - + End-to-End Encryption Ende-zu-Ende Verschlüsselung @@ -2074,7 +2075,7 @@ Medien-Größe: %2 Verschlüsselung befindet sich momentan in einem experimentellen Stadium, unerwartete Fehler können auftreten. <br>Sie kann anschließend nicht wieder deaktiviert werden. - + Respond to key requests Schlüsselnfrage beantworten @@ -2086,7 +2087,7 @@ Medien-Größe: %2 Ob nheko automatisch auf Anfragen mit Sessionschlüsseln antworten soll, oder nicht. Bitte mit Vorsicht nutzen, da dies eine temporäre Massnahme ist. Sie dient dem Test von E2E Verschlüsselung, bis die Geräteverifikation fertig gestellt ist. - + %n member(s) %n Teilnehmer @@ -2094,7 +2095,7 @@ Medien-Größe: %2 - + Failed to enable encryption: %1 Aktivierung der Verschlüsselung fehlgeschlagen: %1 diff --git a/resources/langs/nheko_el.ts b/resources/langs/nheko_el.ts index 60c6b591..717ca38e 100644 --- a/resources/langs/nheko_el.ts +++ b/resources/langs/nheko_el.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ Matrix ID - + e.g @joe:matrix.org π.χ @john:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN ΕΙΣΟΔΟΣ @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password Κενός κωδικός - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username Όνομα χρήστη - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password Κωδικός - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER ΕΓΓΡΑΦΗ - + No supported registration flows! - - Invalid username - Μη έγκυρο όνομα χρήστη + + Regisration Failed + - + Password is not long enough (min 8 chars) Ο κωδικός δεν αποτελείται από αρκετους χαρακτήρες - + Passwords don't match Οι κωδικοί δεν ταιριίαζουν - + Invalid server name Λανθασμένο όνομα διακομιστή @@ -2058,7 +2059,7 @@ Media size: %2 - + End-to-End Encryption @@ -2068,7 +2069,7 @@ Media size: %2 - + Respond to key requests @@ -2080,7 +2081,7 @@ Media size: %2 - + %n member(s) @@ -2088,7 +2089,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts index 9859ba78..18d7118a 100644 --- a/resources/langs/nheko_en.ts +++ b/resources/langs/nheko_en.ts @@ -49,17 +49,17 @@ - + Invited user: %1 Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. Room %1 created. @@ -139,7 +139,7 @@ Unbanned user: %1 - + Cache migration failed! Cache migration failed! @@ -164,7 +164,7 @@ Failed to restore save data. Please login again. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply Apply @@ -473,7 +473,7 @@ Matrix ID - + e.g @joe:matrix.org e.g @joe:matrix.org @@ -512,7 +512,7 @@ Example: https://server.my:8787 - + LOGIN LOGIN @@ -547,12 +547,12 @@ Example: https://server.my:8787 SSO LOGIN - + Empty password Empty password - + SSO login failed SSO login failed @@ -752,22 +752,23 @@ Example: https://server.my:8787 RegisterPage - + Username Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -787,32 +788,32 @@ Example: https://server.my:8787 A server that allows registration. Since matrix is decentralized, you need to first find a server you can register on or host your own. - + REGISTER REGISTER - + No supported registration flows! No supported registration flows! - - Invalid username - Invalid username + + Regisration Failed + - + Password is not long enough (min 8 chars) Password is not long enough (min 8 chars) - + Passwords don't match Passwords don't match - + Invalid server name Invalid server name @@ -2072,7 +2073,7 @@ Media size: %2 Encryption - + End-to-End Encryption End-to-End Encryption @@ -2082,7 +2083,7 @@ Media size: %2 Encryption is currently experimental and things might break unexpectedly. <br>Please take note that it can't be disabled afterwards. - + Respond to key requests Respond to key requests @@ -2096,7 +2097,7 @@ Media size: %2 E2E implementation until device verification is completed. - + %n member(s) %n member @@ -2104,7 +2105,7 @@ Media size: %2 - + Failed to enable encryption: %1 Failed to enable encryption: %1 diff --git a/resources/langs/nheko_eo.ts b/resources/langs/nheko_eo.ts index 6cc748f7..8f63d4ef 100644 --- a/resources/langs/nheko_eo.ts +++ b/resources/langs/nheko_eo.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. I believe that the -at ending is correct here. Ĉambro %1 farit. @@ -140,7 +140,7 @@ - + Cache migration failed! @@ -165,7 +165,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -262,7 +262,7 @@ EditModal - + Apply @@ -474,7 +474,7 @@ - + e.g @joe:matrix.org @@ -512,7 +512,7 @@ Ekzemplo: https://servisto.mia:8787 - + LOGIN Maybe shouldn't be imperative? ENSALUTU @@ -548,12 +548,12 @@ Ekzemplo: https://servisto.mia:8787 SSO ENSALUTU - + Empty password - + SSO login failed @@ -753,22 +753,23 @@ Ekzemplo: https://servisto.mia:8787 RegisterPage - + Username Uzantnomo - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -788,32 +789,32 @@ Ekzemplo: https://servisto.mia:8787 - + REGISTER REGISTRU - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2069,7 +2070,7 @@ Media size: %2 - + End-to-End Encryption @@ -2079,7 +2080,7 @@ Media size: %2 - + Respond to key requests @@ -2091,7 +2092,7 @@ Media size: %2 - + %n member(s) @@ -2099,7 +2100,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_et.ts b/resources/langs/nheko_et.ts index f4516f5d..fd033423 100644 --- a/resources/langs/nheko_et.ts +++ b/resources/langs/nheko_et.ts @@ -49,17 +49,17 @@ - + Invited user: %1 Kutsutud kasutaja: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. Puhverdatud andmete muutmine sobivaks rakenduse praeguse versiooniga ei õnnestunud. Sellel võib olla erinevaid põhjuseid. Palun saada meile veateade ja seni kasuta vanemat rakenduse versiooni. Aga kui sa soovid proovida, siis kustuta puhverdatud andmed käsitsi. - + Room %1 created. %1 jututuba on loodud. @@ -139,7 +139,7 @@ Suhtluskeeld eemaldatud: %1 - + Cache migration failed! Puhvri versiooniuuendus ebaõnnestus! @@ -164,7 +164,7 @@ Salvestatud andmete taastamine ei õnnestunud. Palun logi uuesti sisse. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Krüptovõtmete kasutusele võtmine ei õnnestunud. Koduserveri vastus päringule: %1 %2. Palun proovi hiljem uuesti. @@ -261,7 +261,7 @@ EditModal - + Apply Rakenda @@ -473,7 +473,7 @@ Matrix'i kasutajatunnus - + e.g @joe:matrix.org näiteks @kadri:matrix.org @@ -512,7 +512,7 @@ Näiteks: https://server.minu:8787 - + LOGIN LOGI SISSE @@ -547,12 +547,12 @@ Näiteks: https://server.minu:8787 ÜHEKORDNE SISSELOGIMINE - + Empty password Tühi salasõna - + SSO login failed Ühekordne sisselogimine ei õnnestunud @@ -752,22 +752,23 @@ Näiteks: https://server.minu:8787 RegisterPage - + Username Kasutajanimi - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. Kasutajanimi ei tohi olla tühi ning võib sisaldada vaid a-z, 0-9, ., _, =, -, / tähemärke. - + Password Salasõna - + Please choose a secure password. The exact requirements for password strength may depend on your server. Palun vali tutvaline salasõna. Täpsemad nõuded salasõnale sõltuvad sinu koduserveri seadistustest. @@ -787,32 +788,32 @@ Näiteks: https://server.minu:8787 See on server, kus sa oma kasutajakonto registreerid. Kuna Matrix on hajutatud suhtlusvõrk, siis esmalt pead leidma sulle sobiliku koduserveri või panema püsti täitsa oma enda koduserveri. - + REGISTER REGISTREERI - + No supported registration flows! Selline registreerimise töövoog pole toetatud! - - Invalid username - Vigane kasutajanimi + + Regisration Failed + - + Password is not long enough (min 8 chars) Salasõna pole piisavalt pikk (vähemalt 8 tähemärki) - + Passwords don't match Salasõnad ei klapi omavahel - + Invalid server name Vigane koduserveri nimi @@ -2072,7 +2073,7 @@ Meedia suurus: %2 Krüptimine - + End-to-End Encryption Läbiv krüptimine @@ -2082,7 +2083,7 @@ Meedia suurus: %2 Krüptimine on nhekos hetkel veel katseline ning nii mõndagi võib ootamatult katki minna. <br>Palun arvesta, et krüptimist ei saa hiljem enam välja lülitada. - + Respond to key requests Vasta krüptovõtmete päringutele @@ -2096,7 +2097,7 @@ Meedia suurus: %2 testimiseks seni, kuni terviklik seadmete verifitseerimine on implementeeritud. - + %n member(s) %n kasutaja @@ -2104,7 +2105,7 @@ Meedia suurus: %2 - + Failed to enable encryption: %1 Krüptimise kasutuselevõtmine ei õnnestunud: %1 diff --git a/resources/langs/nheko_fi.ts b/resources/langs/nheko_fi.ts index 5860a7b0..b5b84dd4 100644 --- a/resources/langs/nheko_fi.ts +++ b/resources/langs/nheko_fi.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ Tallennettujen tietojen palauttaminen epäonnistui. Ole hyvä ja kirjaudu sisään uudelleen. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Salausavainten lähetys epäonnistui. Palvelimen vastaus: %1 %2. Ole hyvä ja yritä uudelleen myöhemmin. @@ -261,7 +261,7 @@ EditModal - + Apply Tallenna @@ -473,7 +473,7 @@ Matrix-tunnus - + e.g @joe:matrix.org esim. @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN KIRJAUDU @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password Tyhjä salasana - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username Käyttäjänimi - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password Salasana - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER REKISTERÖIDY - + No supported registration flows! - - Invalid username - Epäkelpo käyttäjänimi + + Regisration Failed + - + Password is not long enough (min 8 chars) Salasana ei ole tarpeeksi pitkä (vähintään 8 merkkiä) - + Passwords don't match Salasanat eivät täsmää - + Invalid server name Epäkelpo palvelimen nimi @@ -2060,7 +2061,7 @@ Median koko: %2 Salaus - + End-to-End Encryption Päästä-päähän-salaus @@ -2070,7 +2071,7 @@ Median koko: %2 Salaus on tällä hetkellä kokeellinen ja asiat saattavat mennä rikki odottamattomasti.<br>Huomaa, ettei sitä voi poistaa käytöstä jälkikäteen. - + Respond to key requests Vastaa avainpyyntöihin @@ -2084,7 +2085,7 @@ Median koko: %2 kunnes laitteiden vahvistus on valmis. - + %n member(s) %n käyttäjä @@ -2092,7 +2093,7 @@ Median koko: %2 - + Failed to enable encryption: %1 Salauksen aktivointi epäonnistui: %1 diff --git a/resources/langs/nheko_fr.ts b/resources/langs/nheko_fr.ts index 8da64a1b..5af59137 100644 --- a/resources/langs/nheko_fr.ts +++ b/resources/langs/nheko_fr.ts @@ -49,17 +49,17 @@ - + Invited user: %1 %1 a été invité(e) - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. La migration du cache vers la version actuelle a échoué. Cela peut arriver pour différentes raisons. Signalez le problème et essayez d'utiliser une ancienne version en attendant. Vous pouvez également supprimer le cache manuellement. - + Room %1 created. Salon %1 créé. @@ -139,7 +139,7 @@ %1 n'est plus banni(e) - + Cache migration failed! Échec de la migration du cache ! @@ -164,7 +164,7 @@ Échec de la restauration des données sauvegardées. Veuillez vous reconnecter. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Échec de la configuration des clés de chiffrement. Réponse du serveur : %1 %2. Veuillez réessayer plus tard. @@ -261,7 +261,7 @@ EditModal - + Apply Appliquer @@ -473,7 +473,7 @@ Identifiant Matrix - + e.g @joe:matrix.org ex : @joe:matrix.org @@ -512,7 +512,7 @@ Exemple : https ://monserveur.example.com :8787 - + LOGIN CONNEXION @@ -547,12 +547,12 @@ Exemple : https ://monserveur.example.com :8787 CONNEXION SSO - + Empty password Mot de passe vide - + SSO login failed Échec de la connexion SSO @@ -752,22 +752,23 @@ Exemple : https ://monserveur.example.com :8787 RegisterPage - + Username Nom d'utilisateur - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. Le nom d'utilisateur ne doit pas être vide, et ne peut contenir que les caractères a à z, 0 à 9, et « . _ = - / ». - + Password Mot de passe - + Please choose a secure password. The exact requirements for password strength may depend on your server. Veuillez choisir un mot de passe fort. Les demandes exactes sur la robustesse du mot de passe peuvent dépendre de votre serveur. @@ -787,32 +788,32 @@ Exemple : https ://monserveur.example.com :8787 Un serveur qui autorise les créations de compte. Matrix étant décentralisé, vous devez tout d'abord trouver un serveur sur lequel vous pouvez vous inscrire, ou bien héberger le vôtre. - + REGISTER S'ENREGISTRER - + No supported registration flows! Pas de méthode d'inscription supportée ! - - Invalid username - Nom d'utilisateur invalide + + Regisration Failed + - + Password is not long enough (min 8 chars) Le mot de passe n'est pas assez long (8 caractères minimum) - + Passwords don't match Les mots de passe ne sont pas identiques - + Invalid server name Le nom du serveur est invalide @@ -2073,7 +2074,7 @@ Taille du média : %2 Chiffrement - + End-to-End Encryption Chiffrement bout-à-bout @@ -2084,7 +2085,7 @@ Taille du média : %2 Veuillez noter qu'il n'est pas possible de le désactiver ultérieurement. - + Respond to key requests Répondre aux requêtes de clés @@ -2099,7 +2100,7 @@ temporaire pour valider l'implémentation du chiffrement de bout en bout en attendant que la vérification des appareils soit opérationnelle. - + %n member(s) %n membre @@ -2107,7 +2108,7 @@ attendant que la vérification des appareils soit opérationnelle. - + Failed to enable encryption: %1 Échec de l'activation du chiffrement  : %1 diff --git a/resources/langs/nheko_it.ts b/resources/langs/nheko_it.ts index 8fe4120c..fd89a13c 100644 --- a/resources/langs/nheko_it.ts +++ b/resources/langs/nheko_it.ts @@ -49,17 +49,17 @@ - + Invited user: %1 Invitato utente: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. Migrazione della cache alla versione corrente fallita. Questo può avere diverse cause. Per favore apri una issue e nel frattempo prova ad usare una versione più vecchia. In alternativa puoi provare a cancellare la cache manualmente. - + Room %1 created. Stanza %1 creata. @@ -139,7 +139,7 @@ Rimosso il ban dall'utente: %1 - + Cache migration failed! Migrazione della cache fallita! @@ -164,7 +164,7 @@ Impossibile ripristinare i dati salvati. Per favore accedi nuovamente. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Impossibile configurare le chiavi crittografiche. Risposta del server: %1 %2. Per favore riprova in seguito. @@ -261,7 +261,7 @@ EditModal - + Apply Applica @@ -473,7 +473,7 @@ ID Matrix - + e.g @joe:matrix.org es. @joe:matrix.org @@ -512,7 +512,7 @@ Esempio: https://server.mio:8787 - + LOGIN ACCEDI @@ -547,12 +547,12 @@ Esempio: https://server.mio:8787 ACCESSO SSO - + Empty password Password vuota - + SSO login failed Accesso SSO fallito @@ -752,22 +752,23 @@ Esempio: https://server.mio:8787 RegisterPage - + Username Nome utente - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. Il nome utente non deve essere vuoto e deve contenere solo i caratteri a-z, 0-9, ., _, =, -, e /. - + Password Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. Per favore scegli una password sicura. I requisiti di robustezza della password potrebbero dipendere dal server. @@ -787,32 +788,32 @@ Esempio: https://server.mio:8787 Un server che consente la registrazione. Siccome matrix è decentralizzata, devi prima trovare un server su cui registrarti o ospitarne uno tuo. - + REGISTER REGISTRATI - + No supported registration flows! Non ci sono processi di registrazione supportati! - - Invalid username - Nome utente non valido + + Regisration Failed + - + Password is not long enough (min 8 chars) La password non è abbastanza lunga (minimo 8 caratteri) - + Passwords don't match Le password non corrispondono - + Invalid server name Nome del server non valido @@ -2064,7 +2065,7 @@ Peso media: %2 Crittografia - + End-to-End Encryption Crittografia End-to-End @@ -2074,7 +2075,7 @@ Peso media: %2 La crittografia è ancora sperimentale e le cose potrebbero rompersi inaspettatamente. <br>Per favore prendi nota che in seguito non potrà essere disabilitata. - + Respond to key requests Rispondi alle richieste di chiavi @@ -2088,7 +2089,7 @@ Peso media: %2 l'implementazione di E2E fino al completamento della verifica dei dispositivi. - + %n member(s) %n membro @@ -2096,7 +2097,7 @@ Peso media: %2 - + Failed to enable encryption: %1 Impossibile abilitare la crittografia: %1 diff --git a/resources/langs/nheko_ja.ts b/resources/langs/nheko_ja.ts index 273f3662..dbd3b066 100644 --- a/resources/langs/nheko_ja.ts +++ b/resources/langs/nheko_ja.ts @@ -49,17 +49,17 @@ - + Invited user: %1 招待されたユーザー: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ 永久追放を解除されたユーザー: %1 - + Cache migration failed! @@ -164,7 +164,7 @@ セーブデータを復元できませんでした。もう一度ログインして下さい。 - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. 暗号化鍵を設定できませんでした。サーバーの応答: %1 %2. 後でやり直して下さい。 @@ -261,7 +261,7 @@ EditModal - + Apply 適用 @@ -473,7 +473,7 @@ Matrix ID - + e.g @joe:matrix.org 例 @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN ログイン @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password パスワードが入力されていません - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username ユーザー名 - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password パスワード - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER 登録 - + No supported registration flows! - - Invalid username - 無効なユーザー名です + + Regisration Failed + - + Password is not long enough (min 8 chars) パスワード長が不足しています (最小8文字) - + Passwords don't match パスワードが一致しません - + Invalid server name 無効なサーバー名です @@ -2059,7 +2060,7 @@ Media size: %2 暗号化 - + End-to-End Encryption エンドツーエンド暗号化 @@ -2069,7 +2070,7 @@ Media size: %2 暗号化機能は実験段階にあるので、予期せずに壊れるかもしれません。 <br>この機能を後から無効にできないことに注意して下さい。 - + Respond to key requests 鍵の要求に応答する @@ -2083,14 +2084,14 @@ Media size: %2 これを利用する際は注意して下さい。 - + %n member(s) %n人 - + Failed to enable encryption: %1 暗号化を有効にできませんでした: %1 diff --git a/resources/langs/nheko_nl.ts b/resources/langs/nheko_nl.ts index 5888b7ea..5778c5e3 100644 --- a/resources/langs/nheko_nl.ts +++ b/resources/langs/nheko_nl.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ Matrix-id - + e.g @joe:matrix.org b.v @jan:matrix.org< @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN INLOGGEN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password Leeg wachtwoord - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username Gebruikersnaam - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password Wachtwoord - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER REGISTREREN - + No supported registration flows! - - Invalid username - Ongeldige gebruikersnaam + + Regisration Failed + - + Password is not long enough (min 8 chars) Het wachtwoord is niet lang genoeg (minimaal 8 tekens) - + Passwords don't match De wachtwoorden komen niet overeen - + Invalid server name Ongeldige servernaam @@ -2060,7 +2061,7 @@ Mediagrootte: %2 - + End-to-End Encryption @@ -2070,7 +2071,7 @@ Mediagrootte: %2 - + Respond to key requests @@ -2082,7 +2083,7 @@ Mediagrootte: %2 - + %n member(s) @@ -2090,7 +2091,7 @@ Mediagrootte: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_pl.ts b/resources/langs/nheko_pl.ts index 4c765b46..05046626 100644 --- a/resources/langs/nheko_pl.ts +++ b/resources/langs/nheko_pl.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ Nie udało się przywrócić zapisanych danych. Spróbuj zalogować się ponownie. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ ID Matrixa - + e.g @joe:matrix.org np. @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN ZALOGUJ @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password Puste hasło - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username Nazwa użytkownika - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password Hasło - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER ZAREJESTRUJ - + No supported registration flows! - - Invalid username - Nieprawidłowa nazwa użytkownika + + Regisration Failed + - + Password is not long enough (min 8 chars) Hasło jest zbyt krótkie (min. 8 znaków) - + Passwords don't match Hasła nie pasują do siebie - + Invalid server name Nieprawidłowa nazwa serwera @@ -2061,7 +2062,7 @@ Rozmiar multimediów: %2 Szyfrowanie - + End-to-End Encryption Szyfrowanie end-to-end @@ -2071,7 +2072,7 @@ Rozmiar multimediów: %2 Szyfrowanie jest obecnie eksperymentalne i może spowodować nieoczekiwane błędy. <br>Zapamiętaj, że nie może zostać później wyłączona. - + Respond to key requests Odpowiadaj na żądania o klucze @@ -2085,7 +2086,7 @@ Rozmiar multimediów: %2 do testowania implementacji E2E, zanim weryfikacja urządzeń będzie ukończona. - + %n member(s) %n członek @@ -2094,7 +2095,7 @@ Rozmiar multimediów: %2 - + Failed to enable encryption: %1 Nie udało się włączyć szyfrowania: %1 diff --git a/resources/langs/nheko_pt_PT.ts b/resources/langs/nheko_pt_PT.ts index 88876456..fc002bd9 100644 --- a/resources/langs/nheko_pt_PT.ts +++ b/resources/langs/nheko_pt_PT.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2058,7 +2059,7 @@ Media size: %2 - + End-to-End Encryption @@ -2068,7 +2069,7 @@ Media size: %2 - + Respond to key requests @@ -2080,7 +2081,7 @@ Media size: %2 - + %n member(s) @@ -2088,7 +2089,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_ro.ts b/resources/langs/nheko_ro.ts index 1b0adc84..cb92fb8e 100644 --- a/resources/langs/nheko_ro.ts +++ b/resources/langs/nheko_ro.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2059,7 +2060,7 @@ Media size: %2 - + End-to-End Encryption @@ -2069,7 +2070,7 @@ Media size: %2 - + Respond to key requests @@ -2081,7 +2082,7 @@ Media size: %2 - + %n member(s) @@ -2090,7 +2091,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_ru.ts b/resources/langs/nheko_ru.ts index 0d4e9181..0c883cc6 100644 --- a/resources/langs/nheko_ru.ts +++ b/resources/langs/nheko_ru.ts @@ -49,17 +49,17 @@ - + Invited user: %1 Приглашённый пользователь: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. Миграция кэша для текущей версии не удалась. Это может происходить по разным причинам. Пожалуйста сообщите о проблеме и попробуйте временно использовать старую версию. Так-же вы можете попробовать удалить кэш самостоятельно. - + Room %1 created. Комната %1 создана. @@ -139,7 +139,7 @@ Разблокированный пользователь: %1 - + Cache migration failed! Миграция кэша не удалась! @@ -164,7 +164,7 @@ Не удалось восстановить сохраненные данные. Пожалуйста, войдите снова. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Не удалось настроить ключи шифрования. Ответ сервера:%1 %2. Пожалуйста, попробуйте позже. @@ -261,7 +261,7 @@ EditModal - + Apply Применить @@ -473,7 +473,7 @@ Идентификатор Matrix - + e.g @joe:matrix.org Пример: @joe:matrix.org @@ -512,7 +512,7 @@ Example: https://server.my:8787 - + LOGIN ВОЙТИ @@ -547,12 +547,12 @@ Example: https://server.my:8787 - + Empty password Пустой пароль - + SSO login failed SSO вход не удался @@ -752,22 +752,23 @@ Example: https://server.my:8787 RegisterPage - + Username Имя пользователя - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. Имя пользователя не должно быть пустым и должно содержать только символы a-z, 0-9, ., _, =, -, and /. - + Password Пароль - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -787,32 +788,32 @@ Example: https://server.my:8787 - + REGISTER РЕГИСТРАЦИЯ - + No supported registration flows! - - Invalid username - Некорректное имя пользователя + + Regisration Failed + - + Password is not long enough (min 8 chars) Слишком короткий пароль (минимум 8 символов) - + Passwords don't match Пароли не совпадают - + Invalid server name Неверное имя сервера @@ -2066,7 +2067,7 @@ Media size: %2 Шифрование - + End-to-End Encryption Сквозное шифрование @@ -2076,7 +2077,7 @@ Media size: %2 Шифрование в настоящее время является экспериментальным, поэтому возможны сбои. <br>Пожалуйста, имейте ввиду, что его нельзя отключить впоследствии. - + Respond to key requests @@ -2088,7 +2089,7 @@ Media size: %2 - + %n member(s) %n участник @@ -2097,7 +2098,7 @@ Media size: %2 - + Failed to enable encryption: %1 Не удалось включить шифрование: %1 diff --git a/resources/langs/nheko_si.ts b/resources/langs/nheko_si.ts index 5e6d5218..e995cf59 100644 --- a/resources/langs/nheko_si.ts +++ b/resources/langs/nheko_si.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2058,7 +2059,7 @@ Media size: %2 - + End-to-End Encryption @@ -2068,7 +2069,7 @@ Media size: %2 - + Respond to key requests @@ -2080,7 +2081,7 @@ Media size: %2 - + %n member(s) @@ -2088,7 +2089,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_sv.ts b/resources/langs/nheko_sv.ts index ae1f3f12..4c4e2230 100644 --- a/resources/langs/nheko_sv.ts +++ b/resources/langs/nheko_sv.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER - + No supported registration flows! - - Invalid username + + Regisration Failed - + Password is not long enough (min 8 chars) - + Passwords don't match - + Invalid server name @@ -2058,7 +2059,7 @@ Media size: %2 - + End-to-End Encryption @@ -2068,7 +2069,7 @@ Media size: %2 - + Respond to key requests @@ -2080,7 +2081,7 @@ Media size: %2 - + %n member(s) @@ -2088,7 +2089,7 @@ Media size: %2 - + Failed to enable encryption: %1 diff --git a/resources/langs/nheko_zh_CN.ts b/resources/langs/nheko_zh_CN.ts index ac3411a7..dd0a6b76 100644 --- a/resources/langs/nheko_zh_CN.ts +++ b/resources/langs/nheko_zh_CN.ts @@ -49,17 +49,17 @@ - + Invited user: %1 - + Migrating the cache to the current version failed. This can have different reasons. Please open an issue and try to use an older version in the mean time. Alternatively you can try deleting the cache manually. - + Room %1 created. @@ -139,7 +139,7 @@ - + Cache migration failed! @@ -164,7 +164,7 @@ 恢复保存的数据失败。请重新登录。 - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -261,7 +261,7 @@ EditModal - + Apply @@ -473,7 +473,7 @@ - + e.g @joe:matrix.org 例如 @joe:matrix.org @@ -508,7 +508,7 @@ Example: https://server.my:8787 - + LOGIN 登录 @@ -543,12 +543,12 @@ Example: https://server.my:8787 - + Empty password 空密码 - + SSO login failed @@ -748,22 +748,23 @@ Example: https://server.my:8787 RegisterPage - + Username 用户名 - + + The username must not be empty, and must contain only the characters a-z, 0-9, ., _, =, -, and /. - + Password 密码 - + Please choose a secure password. The exact requirements for password strength may depend on your server. @@ -783,32 +784,32 @@ Example: https://server.my:8787 - + REGISTER 注册 - + No supported registration flows! - - Invalid username - 无效的用户名 + + Regisration Failed + - + Password is not long enough (min 8 chars) 密码不够长(至少8个字符) - + Passwords don't match 密码不匹配 - + Invalid server name 无效的服务器名 @@ -2059,7 +2060,7 @@ Media size: %2 加密 - + End-to-End Encryption 端到端加密 @@ -2069,7 +2070,7 @@ Media size: %2 加密正在实验阶段,可能会意外地坏掉。<br>请注意此后无法禁用。 - + Respond to key requests 回应密钥请求 @@ -2083,14 +2084,14 @@ Media size: %2 这是一个临时的测试端到端加密的方案。 - + %n member(s) %n 成员 - + Failed to enable encryption: %1 启用加密失败:%1 diff --git a/src/LoginPage.cpp b/src/LoginPage.cpp index ac625db1..8076d6d6 100644 --- a/src/LoginPage.cpp +++ b/src/LoginPage.cpp @@ -90,6 +90,7 @@ LoginPage::LoginPage(QWidget *parent) matrixid_input_ = new TextField(this); matrixid_input_->setLabel(tr("Matrix ID")); + matrixid_input_->setRegexp(QRegularExpression("@.+?:.{3,}")); matrixid_input_->setPlaceholderText(tr("e.g @joe:matrix.org")); matrixid_input_->setToolTip( tr("Your login name. A mxid should start with @ followed by the user id. After the user " @@ -175,7 +176,6 @@ LoginPage::LoginPage(QWidget *parent) connect(this, &LoginPage::versionOkCb, this, &LoginPage::versionOk); connect(this, &LoginPage::versionErrorCb, this, &LoginPage::versionError); - connect(this, &LoginPage::loginErrorCb, this, &LoginPage::loginError); connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked())); connect(login_button_, SIGNAL(clicked()), this, SLOT(onLoginButtonClicked())); @@ -186,32 +186,24 @@ LoginPage::LoginPage(QWidget *parent) connect(matrixid_input_, SIGNAL(editingFinished()), this, SLOT(onMatrixIdEntered())); connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered())); } - void -LoginPage::loginError(const QString &msg) +LoginPage::showError(const QString &msg) { auto rect = QFontMetrics(font()).boundingRect(msg); int width = rect.width(); int height = rect.height(); - error_label_->setFixedHeight(qCeil(width / 200) * height); + error_label_->setFixedHeight((int)qCeil(width / 200.0) * height); error_label_->setText(msg); } void -LoginPage::matrixIdError(const QString &msg) +LoginPage::showError(QLabel *label, const QString &msg) { - error_matrixid_label_->show(); - error_matrixid_label_->setText(msg); - matrixid_input_->setValid(false); -} - -bool -LoginPage::isMatrixIdValid() -{ - QRegularExpressionValidator v(QRegularExpression("@.+?:.{3,}"), this); - QString s = matrixid_input_->text(); - int pos = 0; - return v.validate(s, pos) == QValidator::Acceptable; + auto rect = QFontMetrics(font()).boundingRect(msg); + int width = rect.width(); + int height = rect.height(); + label->setFixedHeight((int)qCeil(width / 200.0) * height); + label->setText(msg); } void @@ -221,19 +213,21 @@ LoginPage::onMatrixIdEntered() User user; - if (!isMatrixIdValid()) { - matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); + if (!matrixid_input_->isValid()) { + error_matrixid_label_->show(); + showError(error_matrixid_label_, + "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; } else { error_matrixid_label_->setText(""); error_matrixid_label_->hide(); - matrixid_input_->setValid(true); } try { user = parse(matrixid_input_->text().toStdString()); } catch (const std::exception &e) { - matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); + showError(error_matrixid_label_, + "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; } @@ -345,7 +339,7 @@ LoginPage::onServerAddressEntered() void LoginPage::versionError(const QString &error) { - loginError(error); + showError(error_label_, error); serverInput_->show(); spinner_->stop(); @@ -383,25 +377,27 @@ LoginPage::onLoginButtonClicked() User user; - if (!isMatrixIdValid()) { - matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); + if (!matrixid_input_->isValid()) { + error_matrixid_label_->show(); + showError(error_matrixid_label_, + "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; } else { error_matrixid_label_->setText(""); error_matrixid_label_->hide(); - matrixid_input_->setValid(true); } try { user = parse(matrixid_input_->text().toStdString()); } catch (const std::exception &e) { - matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); + showError(error_matrixid_label_, + "You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; } if (loginMethod == LoginMethod::Password) { if (password_input_->text().isEmpty()) - return loginError(tr("Empty password")); + return showError(error_label_, tr("Empty password")); http::client()->login( user.localpart(), @@ -410,7 +406,8 @@ LoginPage::onLoginButtonClicked() : deviceName_->text().toStdString(), [this](const mtx::responses::Login &res, mtx::http::RequestErr err) { if (err) { - emit loginError(QString::fromStdString(err->matrix_error.error)); + showError(error_label_, + QString::fromStdString(err->matrix_error.error)); emit errorOccurred(); return; } @@ -435,7 +432,8 @@ LoginPage::onLoginButtonClicked() http::client()->login( req, [this](const mtx::responses::Login &res, mtx::http::RequestErr err) { if (err) { - emit loginError( + showError( + error_label_, QString::fromStdString(err->matrix_error.error)); emit errorOccurred(); return; @@ -453,7 +451,7 @@ LoginPage::onLoginButtonClicked() sso->deleteLater(); }); connect(sso, &SSOHandler::ssoFailed, this, [this, sso]() { - emit loginError(tr("SSO login failed")); + showError(error_label_, tr("SSO login failed")); emit errorOccurred(); sso->deleteLater(); }); diff --git a/src/LoginPage.h b/src/LoginPage.h index 92b60afe..5ed21dec 100644 --- a/src/LoginPage.h +++ b/src/LoginPage.h @@ -56,7 +56,6 @@ signals: //! Used to trigger the corresponding slot outside of the main thread. void versionErrorCb(const QString &err); - void loginErrorCb(const QString &err); void versionOkCb(LoginPage::LoginMethod method); void loginOk(const mtx::responses::Login &res); @@ -66,8 +65,8 @@ protected: public slots: // Displays errors produced during the login. - void loginError(const QString &msg); - void matrixIdError(const QString &msg); + void showError(const QString &msg); + void showError(QLabel *label, const QString &msg); private slots: // Callback for the back button. @@ -88,7 +87,6 @@ private slots: void versionOk(LoginPage::LoginMethod method); private: - bool isMatrixIdValid(); void checkHomeserverVersion(); std::string initialDeviceName() { diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 37b54151..60b5168b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -108,7 +108,7 @@ MainWindow::MainWindow(const QString profile, QWidget *parent) connect(chat_page_, &ChatPage::unreadMessages, this, &MainWindow::setWindowTitle); connect(chat_page_, SIGNAL(unreadMessages(int)), trayIcon_, SLOT(setUnreadCount(int))); connect(chat_page_, &ChatPage::showLoginPage, this, [this](const QString &msg) { - login_page_->loginError(msg); + login_page_->showError(msg); showLoginPage(); }); diff --git a/src/RegisterPage.cpp b/src/RegisterPage.cpp index b8fe93b5..26a66ab7 100644 --- a/src/RegisterPage.cpp +++ b/src/RegisterPage.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -86,13 +87,13 @@ RegisterPage::RegisterPage(QWidget *parent) username_input_ = new TextField(); username_input_->setLabel(tr("Username")); - username_input_->setValidator( - new QRegularExpressionValidator(QRegularExpression("[a-z0-9._=/-]+"), this)); + username_input_->setRegexp(QRegularExpression("[a-z0-9._=/-]+")); username_input_->setToolTip(tr("The username must not be empty, and must contain only the " "characters a-z, 0-9, ., _, =, -, and /.")); password_input_ = new TextField(); password_input_->setLabel(tr("Password")); + password_input_->setRegexp(QRegularExpression("^.{8,}$")); password_input_->setEchoMode(QLineEdit::Password); password_input_->setToolTip(tr("Please choose a secure password. The exact requirements " "for password strength may depend on your server.")); @@ -107,19 +108,32 @@ RegisterPage::RegisterPage(QWidget *parent) tr("A server that allows registration. Since matrix is decentralized, you need to first " "find a server you can register on or host your own.")); + error_username_label_ = new QLabel(this); + error_username_label_->setWordWrap(true); + error_username_label_->hide(); + + error_password_label_ = new QLabel(this); + error_password_label_->setWordWrap(true); + error_password_label_->hide(); + + error_password_confirmation_label_ = new QLabel(this); + error_password_confirmation_label_->setWordWrap(true); + error_password_confirmation_label_->hide(); + form_layout_->addWidget(username_input_, Qt::AlignHCenter); + form_layout_->addWidget(error_username_label_, Qt::AlignHCenter); form_layout_->addWidget(password_input_, Qt::AlignHCenter); + form_layout_->addWidget(error_password_label_, Qt::AlignHCenter); form_layout_->addWidget(password_confirmation_, Qt::AlignHCenter); + form_layout_->addWidget(error_password_confirmation_label_, Qt::AlignHCenter); form_layout_->addWidget(server_input_, Qt::AlignHCenter); button_layout_ = new QHBoxLayout(); button_layout_->setSpacing(0); button_layout_->setMargin(0); - QFont font; - error_label_ = new QLabel(this); - error_label_->setFont(font); + error_label_->setWordWrap(true); register_button_ = new RaisedButton(tr("REGISTER"), this); register_button_->setMinimumSize(350, 65); @@ -135,17 +149,24 @@ RegisterPage::RegisterPage(QWidget *parent) top_layout_->addLayout(form_wrapper_); top_layout_->addStretch(1); top_layout_->addLayout(button_layout_); - top_layout_->addStretch(1); top_layout_->addWidget(error_label_, 0, Qt::AlignHCenter); + top_layout_->addStretch(1); connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked())); connect(register_button_, SIGNAL(clicked()), this, SLOT(onRegisterButtonClicked())); connect(username_input_, SIGNAL(returnPressed()), register_button_, SLOT(click())); + connect(username_input_, &TextField::editingFinished, this, &RegisterPage::checkFields); connect(password_input_, SIGNAL(returnPressed()), register_button_, SLOT(click())); + connect(password_input_, &TextField::editingFinished, this, &RegisterPage::checkFields); connect(password_confirmation_, SIGNAL(returnPressed()), register_button_, SLOT(click())); + connect( + password_confirmation_, &TextField::editingFinished, this, &RegisterPage::checkFields); connect(server_input_, SIGNAL(returnPressed()), register_button_, SLOT(click())); - connect(this, &RegisterPage::registerErrorCb, this, &RegisterPage::registerError); + connect(server_input_, &TextField::editingFinished, this, &RegisterPage::checkFields); + connect(this, &RegisterPage::registerErrorCb, this, [this](const QString &msg) { + showError(msg); + }); connect( this, &RegisterPage::registrationFlow, @@ -299,25 +320,93 @@ RegisterPage::onBackButtonClicked() } void -RegisterPage::registerError(const QString &msg) +RegisterPage::showError(const QString &msg) { emit errorOccurred(); + auto rect = QFontMetrics(font()).boundingRect(msg); + int width = rect.width(); + int height = rect.height(); + error_label_->setFixedHeight(qCeil(width / 200.0) * height); error_label_->setText(msg); } +void +RegisterPage::showError(QLabel *label, const QString &msg) +{ + emit errorOccurred(); + auto rect = QFontMetrics(font()).boundingRect(msg); + int width = rect.width(); + int height = rect.height(); + label->setFixedHeight((int)qCeil(width / 200.0) * height); + label->setText(msg); +} + +bool +RegisterPage::checkOneField(QLabel *label, const TextField *t_field, const QString &msg) +{ + if (t_field->isValid()) { + label->setText(""); + label->hide(); + return true; + } else { + label->show(); + showError(label, msg); + return false; + } +} + +bool +RegisterPage::checkFields() +{ + error_label_->setText(""); + error_username_label_->setText(""); + error_password_label_->setText(""); + error_password_confirmation_label_->setText(""); + + error_username_label_->hide(); + error_password_label_->hide(); + error_password_confirmation_label_->hide(); + + password_confirmation_->setValid(true); + server_input_->setValid(true); + + bool all_fields_good = true; + if (username_input_->isModified() && + !checkOneField(error_username_label_, + username_input_, + tr("The username must not be empty, and must contain only the " + "characters a-z, 0-9, ., _, =, -, and /."))) { + all_fields_good = false; + } else if (password_input_->isModified() && + !checkOneField(error_password_label_, + password_input_, + tr("Password is not long enough (min 8 chars)"))) { + all_fields_good = false; + } else if (password_confirmation_->isModified() && + password_input_->text() != password_confirmation_->text()) { + error_password_confirmation_label_->show(); + showError(error_password_confirmation_label_, tr("Passwords don't match")); + password_confirmation_->setValid(false); + all_fields_good = false; + } else if (server_input_->isModified() && + (!server_input_->hasAcceptableInput() || server_input_->text().isEmpty())) { + showError(tr("Invalid server name")); + server_input_->setValid(false); + all_fields_good = false; + } + if (!username_input_->isModified() || !password_input_->isModified() || + !password_confirmation_->isModified() || !server_input_->isModified()) { + all_fields_good = false; + } + return all_fields_good; +} + void RegisterPage::onRegisterButtonClicked() { - error_label_->setText(""); - - if (!username_input_->hasAcceptableInput()) { - registerError(tr("Invalid username")); - } else if (!password_input_->hasAcceptableInput()) { - registerError(tr("Password is not long enough (min 8 chars)")); - } else if (password_input_->text() != password_confirmation_->text()) { - registerError(tr("Passwords don't match")); - } else if (!server_input_->hasAcceptableInput()) { - registerError(tr("Invalid server name")); + if (!checkFields()) { + showError(error_label_, tr("One or more fields have invalid inputs. Please correct those issues and try again.")); + return; } else { auto username = username_input_->text().toStdString(); auto password = password_input_->text().toStdString(); diff --git a/src/RegisterPage.h b/src/RegisterPage.h index 59ba3d1d..6d212955 100644 --- a/src/RegisterPage.h +++ b/src/RegisterPage.h @@ -57,10 +57,13 @@ private slots: void onBackButtonClicked(); void onRegisterButtonClicked(); - // Display registration specific errors to the user. - void registerError(const QString &msg); + // function for showing different errors + void showError(const QString &msg); private: + bool checkOneField(QLabel *label, const TextField *t_field, const QString &msg); + bool checkFields(); + void showError(QLabel *label, const QString &msg); QVBoxLayout *top_layout_; QHBoxLayout *back_layout_; @@ -69,6 +72,9 @@ private: QLabel *logo_; QLabel *error_label_; + QLabel *error_username_label_; + QLabel *error_password_label_; + QLabel *error_password_confirmation_label_; FlatButton *back_button_; RaisedButton *register_button_; diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index 941d00a3..055fe73b 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -6,6 +6,7 @@ #include #include #include +#include TextField::TextField(QWidget *parent) : QLineEdit(parent) @@ -70,18 +71,24 @@ TextField::hasLabel() const return show_label_; } -bool -TextField::isValid() const -{ - return is_valid_; -} - void TextField::setValid(bool valid) { is_valid_ = valid; } +bool +TextField::isValid() const +{ + QString s = text(); + int pos = 0; + if (regexp_.pattern().isEmpty()) { + return is_valid_; + } + QRegularExpressionValidator v(QRegularExpression(regexp_), 0); + return v.validate(s, pos) == QValidator::Acceptable; +} + void TextField::setLabelFontSize(qreal size) { @@ -156,6 +163,12 @@ TextField::setUnderlineColor(const QColor &color) update(); } +void +TextField::setRegexp(const QRegularExpression ®exp) +{ + regexp_ = regexp; +} + QColor TextField::underlineColor() const { diff --git a/src/ui/TextField.h b/src/ui/TextField.h index 966155f4..01fd5782 100644 --- a/src/ui/TextField.h +++ b/src/ui/TextField.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,7 @@ public: void setLabelFontSize(qreal size); void setShowLabel(bool value); void setUnderlineColor(const QColor &color); + void setRegexp(const QRegularExpression ®exp); void setValid(bool valid); QColor inkColor() const; @@ -56,6 +58,7 @@ private: TextFieldLabel *label_; TextFieldStateMachine *state_machine_; bool show_label_; + QRegularExpression regexp_; bool is_valid_; qreal label_font_size_; };