From c0a010acbb7f0045aa1ce33f82b0d537a715a886 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 4 Jul 2019 21:20:19 -0400 Subject: Fix deprecated function call issues with Qt 5.13 Update to mtxclient 0.3.0 --- src/ui/InfoMessage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/InfoMessage.cpp') diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp index e9de20cc..b18a80c4 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp @@ -22,7 +22,7 @@ InfoMessage::InfoMessage(QString msg, QWidget *parent) initFont(); QFontMetrics fm{font()}; - width_ = fm.width(msg_) + HPadding * 2; + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); @@ -64,7 +64,7 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) msg_ = datetime.toString(fmt); QFontMetrics fm{font()}; - width_ = fm.width(msg_) + HPadding * 2; + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); -- cgit 1.5.1 From 4c0d4f35fecbd53f9bea12abe50a14fb74820435 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Thu, 4 Jul 2019 22:58:06 -0400 Subject: Fix support for Qt versions < 5.11 --- src/RoomInfoListItem.cpp | 11 +++++++++-- src/TypingDisplay.cpp | 6 +++++- src/timeline/TimelineItem.cpp | 7 +++++-- src/timeline/widgets/AudioItem.cpp | 7 ++++++- src/timeline/widgets/FileItem.cpp | 7 ++++++- src/timeline/widgets/ImageItem.cpp | 7 +++++-- src/ui/InfoMessage.cpp | 16 ++++++++++++++-- src/ui/Painter.h | 7 ++++++- 8 files changed, 56 insertions(+), 12 deletions(-) (limited to 'src/ui/InfoMessage.cpp') diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp index c8924bed..9bcce134 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "Cache.h" #include "Config.h" @@ -182,9 +183,12 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) QFont tsFont; tsFont.setPointSizeF(tsFont.pointSizeF() * 0.9); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + const int msgStampWidth = QFontMetrics(tsFont).width(lastMsgInfo_.timestamp) + 4; +#else const int msgStampWidth = QFontMetrics(tsFont).horizontalAdvance(lastMsgInfo_.timestamp) + 4; - +#endif // We use the full width of the widget if there is no unread msg bubble. const int bottomLineWidthLimit = (unreadMsgCount_ > 0) ? msgStampWidth : 0; @@ -212,8 +216,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event) p.setFont(QFont{}); p.drawText(QPoint(2 * wm.padding + wm.iconSize, bottom_y), userName); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + int nameWidth = QFontMetrics(QFont{}).width(userName); +#else int nameWidth = QFontMetrics(QFont{}).horizontalAdvance(userName); - +#endif p.setFont(QFont{}); // The limit is the space between the end of the username and the start of diff --git a/src/TypingDisplay.cpp b/src/TypingDisplay.cpp index fc5e2df4..6059601d 100644 --- a/src/TypingDisplay.cpp +++ b/src/TypingDisplay.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "Config.h" #include "TypingDisplay.h" @@ -69,9 +70,12 @@ TypingDisplay::paintEvent(QPaintEvent *) text_ = fm.elidedText(text_, Qt::ElideRight, (double)(width() * 0.75)); QPainterPath path; +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + path.addRoundedRect(QRectF(0, 0, fm.width(text_) + 2 * LEFT_PADDING, height()), 3, 3); +#else path.addRoundedRect( QRectF(0, 0, fm.horizontalAdvance(text_) + 2 * LEFT_PADDING, height()), 3, 3); - +#endif p.fillPath(path, backgroundColor()); p.drawText(region, Qt::AlignVCenter, text_); } diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp index 2ec6bd81..22bdaaa2 100644 --- a/src/timeline/TimelineItem.cpp +++ b/src/timeline/TimelineItem.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "ChatPage.h" #include "Config.h" @@ -731,11 +732,13 @@ TimelineItem::generateUserName(const QString &user_id, const QString &displaynam userName_->setToolTipDuration(1500); userName_->setAttribute(Qt::WA_Hover); userName_->setAlignment(Qt::AlignLeft | Qt::AlignTop); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) // width deprecated in 5.13: - // userName_->setFixedWidth(QFontMetrics(userName_->font()).width(userName_->text())); + userName_->setFixedWidth(QFontMetrics(userName_->font()).width(userName_->text())); +#else userName_->setFixedWidth( QFontMetrics(userName_->font()).horizontalAdvance(userName_->text())); - +#endif // Set the user color asynchronously if it hasn't been generated yet, // otherwise this will just set it. refreshAuthorColor(); diff --git a/src/timeline/widgets/AudioItem.cpp b/src/timeline/widgets/AudioItem.cpp index 7ce9bf9a..5d6431ee 100644 --- a/src/timeline/widgets/AudioItem.cpp +++ b/src/timeline/widgets/AudioItem.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "Logging.h" #include "MatrixClient.h" @@ -162,10 +163,14 @@ AudioItem::resizeEvent(QResizeEvent *event) font.setWeight(QFont::Medium); QFontMetrics fm(font); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + const int computedWidth = std::min( + fm.width(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth); +#else const int computedWidth = std::min(fm.horizontalAdvance(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth); - +#endif resize(computedWidth, Height); event->accept(); diff --git a/src/timeline/widgets/FileItem.cpp b/src/timeline/widgets/FileItem.cpp index 3ae76913..1a555d1c 100644 --- a/src/timeline/widgets/FileItem.cpp +++ b/src/timeline/widgets/FileItem.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "Logging.h" #include "MatrixClient.h" @@ -153,10 +154,14 @@ FileItem::resizeEvent(QResizeEvent *event) font.setWeight(QFont::Medium); QFontMetrics fm(font); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + const int computedWidth = std::min( + fm.width(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth); +#else const int computedWidth = std::min(fm.horizontalAdvance(text_) + 2 * IconRadius + VerticalPadding * 2 + TextPadding, (double)MaxWidth); - +#endif resize(computedWidth, Height); event->accept(); diff --git a/src/timeline/widgets/ImageItem.cpp b/src/timeline/widgets/ImageItem.cpp index 79a66c4d..26c569d7 100644 --- a/src/timeline/widgets/ImageItem.cpp +++ b/src/timeline/widgets/ImageItem.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "Config.h" #include "ImageItem.h" @@ -191,9 +192,11 @@ ImageItem::paintEvent(QPaintEvent *event) if (image_.isNull()) { QString elidedText = metrics.elidedText(text_, Qt::ElideRight, max_width_ - 10); - +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + setFixedSize(metrics.width(elidedText), fontHeight); +#else setFixedSize(metrics.horizontalAdvance(elidedText), fontHeight); - +#endif painter.setFont(font); painter.setPen(QPen(QColor(66, 133, 244))); painter.drawText(QPoint(0, fontHeight / 2), elidedText); diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp index b18a80c4..fa575d76 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include constexpr int VPadding = 6; constexpr int HPadding = 12; @@ -22,7 +23,13 @@ InfoMessage::InfoMessage(QString msg, QWidget *parent) initFont(); QFontMetrics fm{font()}; - width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // width deprecated in 5.13 + width_ = fm.width(msg_) + HPadding * 2; +#else + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#endif + height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); @@ -64,7 +71,12 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) msg_ = datetime.toString(fmt); QFontMetrics fm{font()}; - width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // width deprecated in 5.13 + width_ = fm.width(msg_) + HPadding * 2; +#else + width_ = fm.horizontalAdvance(msg_) + HPadding * 2; +#endif height_ = fm.ascent() + 2 * VPadding; setFixedHeight(height_ + 2 * HMargin); diff --git a/src/ui/Painter.h b/src/ui/Painter.h index 8feed17b..1c1b17b0 100644 --- a/src/ui/Painter.h +++ b/src/ui/Painter.h @@ -3,6 +3,7 @@ #include #include #include +#include class Painter : public QPainter { @@ -21,8 +22,12 @@ public: { QFontMetrics m(fontMetrics()); if (textWidth < 0) { - // deprecated in 5.13: textWidth = m.width(text); +#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) + // deprecated in 5.13: + textWidth = m.width(text); +#else textWidth = m.horizontalAdvance(text); +#endif } drawText((outerw - x - textWidth), y + m.ascent(), text); } -- cgit 1.5.1 From 1c9cc33902d8242ec25b4416a1662ee6c9902583 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 28 Jul 2019 12:50:10 +0200 Subject: Try to localise timestamps I'm not sure, if that is the right way, but Qt doesn't really have a way to format custom localised dates, so I tried to find the closest approximations to what we currently have. Relates to #69 --- resources/langs/nheko_de.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_el.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_en.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_fr.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_nl.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_pl.ts | 101 +++++++++++++++++++++++++++++++--------- resources/langs/nheko_ru.ts | 103 ++++++++++++++++++++++++++++++++--------- resources/langs/nheko_zh_CN.ts | 101 +++++++++++++++++++++++++++++++--------- src/Utils.cpp | 20 ++++---- src/dialogs/MemberList.cpp | 4 +- src/dialogs/ReadReceipts.cpp | 12 +++-- src/timeline/TimelineItem.cpp | 2 +- src/ui/InfoMessage.cpp | 13 +++--- 13 files changed, 668 insertions(+), 193 deletions(-) (limited to 'src/ui/InfoMessage.cpp') diff --git a/resources/langs/nheko_de.ts b/resources/langs/nheko_de.ts index f592a4d8..8c92c084 100644 --- a/resources/langs/nheko_de.ts +++ b/resources/langs/nheko_de.ts @@ -4,7 +4,7 @@ AudioItem - + Save File In Datei speichern @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Hochladen der Bilddatei fehlgeschlagen. Bitte versuche es erneut. @@ -32,7 +32,7 @@ Hochladen der Videodatei fehlgeschlagen. Bitte versuche es erneut. - + Failed to restore OLM account. Please login again. Wiederherstellung des OLM Accounts fehlgeschlagen. Bitte logge dich erneut ein. @@ -42,7 +42,7 @@ Nachrichten konnten nicht aus dem Cache geladen werden. Bitte melde dich erneut an. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Erstellung des Schlüsselmaterials fehlgeschlagen. Antwort des Servers: %1 %2. Bitte versuche es später erneut. @@ -118,7 +118,7 @@ FileItem - + Save File Datei speichern @@ -126,7 +126,7 @@ ImageItem - + Save image Bild speichern @@ -205,8 +205,8 @@ Teilnehmerliste - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Raum verlassen - + Accept Akzeptieren @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Schreibe eine Nachricht... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Benutzer einladen @@ -460,7 +465,7 @@ TypingDisplay - + is typing tippt @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Ins Benachrichtigungsfeld minimieren @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Erscheinungsbild @@ -566,7 +576,7 @@ ALLGEMEINES - + Open Sessions File @@ -635,6 +645,14 @@ ANMELDEN + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Medien-Größe: %2 dialogs::ReadReceipts - + Read receipts Lesebestätigungen @@ -793,6 +811,19 @@ Medien-Größe: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1003,4 +1034,32 @@ Medien-Größe: %2 Flaggen + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_el.ts b/resources/langs/nheko_el.ts index 5a6be4cb..74b14266 100644 --- a/resources/langs/nheko_el.ts +++ b/resources/langs/nheko_el.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Αποθήκευση @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Αποθήκευση @@ -126,7 +126,7 @@ ImageItem - + Save image Αποθήκευση Εικόνας @@ -205,8 +205,8 @@ Μέλη - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Βγές - + Accept Αποδοχή @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Γράψε ένα μήνυμα... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Προσκάλεσε χρήστες @@ -460,7 +465,7 @@ TypingDisplay - + is typing πληκτρολογεί @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Ελαχιστοποίηση @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Φόντο @@ -566,7 +576,7 @@ ΓΕΝΙΚΑ - + Open Sessions File @@ -635,6 +645,14 @@ ΕΙΣΟΔΟΣ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -776,7 +794,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts @@ -791,6 +809,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1001,4 +1032,32 @@ Media size: %2 Σημαίες + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts index d8259dc5..5c4bad0e 100644 --- a/resources/langs/nheko_en.ts +++ b/resources/langs/nheko_en.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Save File @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Failed to upload image. Please try again. @@ -32,7 +32,7 @@ Failed to upload video. Please try again. - + Failed to restore OLM account. Please login again. Failed to restore OLM account. Please login again. @@ -42,7 +42,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. @@ -118,7 +118,7 @@ FileItem - + Save File Save File @@ -126,7 +126,7 @@ ImageItem - + Save image Save image @@ -205,8 +205,8 @@ Room members - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Leave room - + Accept Accept @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users @@ -460,7 +465,7 @@ TypingDisplay - + is typing @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme @@ -566,7 +576,7 @@ - + Open Sessions File @@ -635,6 +645,14 @@ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -776,7 +794,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts @@ -791,6 +809,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1001,4 +1032,32 @@ Media size: %2 Flags + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_fr.ts b/resources/langs/nheko_fr.ts index beab8752..f8425e26 100644 --- a/resources/langs/nheko_fr.ts +++ b/resources/langs/nheko_fr.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Enregistrer le fichier @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Enregistrer le fichier @@ -126,7 +126,7 @@ ImageItem - + Save image Enregistrer l'image @@ -205,8 +205,8 @@ Membres du salon - - ESC + + OK @@ -278,7 +278,7 @@ RoomInfo - + no version stored @@ -286,12 +286,12 @@ RoomInfoListItem - + Leave room Quitter le salon - + Accept Accepter @@ -332,7 +332,7 @@ StatusIndicator - + Encrypted @@ -355,13 +355,13 @@ TextInputWidget - + Send a file - + Write a message... Écrivez un message... @@ -425,7 +425,12 @@ - + + Mentions + + + + Invite users Inviter des utilisateurs @@ -461,7 +466,7 @@ TypingDisplay - + is typing est en train d'écrire @@ -482,7 +487,7 @@ UserSettingsPage - + Minimize to tray Réduire à la barre des tâches @@ -522,12 +527,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Thème @@ -567,7 +577,7 @@ GÉNÉRAL - + Open Sessions File @@ -636,6 +646,14 @@ CONNEXION + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -779,7 +797,7 @@ Taille du média : %2 dialogs::ReadReceipts - + Read receipts Accusés de lecture @@ -794,6 +812,19 @@ Taille du média : %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1004,4 +1035,32 @@ Taille du média : %2 Drapeaux + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_nl.ts b/resources/langs/nheko_nl.ts index 4c81ec76..51ec18fe 100644 --- a/resources/langs/nheko_nl.ts +++ b/resources/langs/nheko_nl.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Bestand opslaan @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Bestand opslaan @@ -126,7 +126,7 @@ ImageItem - + Save image Afbeelding opslaan @@ -205,8 +205,8 @@ Kamerleden - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Kamer verlaten - + Accept Accepteren @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Typ een bericht... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Gebruikers uitnodigen @@ -460,7 +465,7 @@ TypingDisplay - + is typing is aan het typen @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Minimaliseren naar systeemvak @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Thema @@ -566,7 +576,7 @@ ALGEMEEN - + Open Sessions File @@ -635,6 +645,14 @@ INLOGGEN + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Mediagrootte: %2 dialogs::ReadReceipts - + Read receipts Leesbevestigingen @@ -793,6 +811,19 @@ Mediagrootte: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1003,4 +1034,32 @@ Mediagrootte: %2 Vlaggen + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_pl.ts b/resources/langs/nheko_pl.ts index edea85b9..ca021554 100644 --- a/resources/langs/nheko_pl.ts +++ b/resources/langs/nheko_pl.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Zapisz plik @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Nie udało się wysłać obrazu. Spróbuj ponownie. @@ -32,7 +32,7 @@ Nie udało się wysłać filmu. Spróbuj ponownie. - + Failed to restore OLM account. Please login again. Nie udało się przywrócić konta OLM. Spróbuj zalogować się ponownie. @@ -42,7 +42,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. @@ -118,7 +118,7 @@ FileItem - + Save File Zapisz plik @@ -126,7 +126,7 @@ ImageItem - + Save image Zapisz obraz @@ -205,8 +205,8 @@ Członkowie pokoju - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Opuść pokój - + Accept Akceptuj @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted Szyfrowana @@ -354,13 +354,13 @@ TextInputWidget - + Send a file Wyślij plik - + Write a message... Napisz wiadomość… @@ -424,7 +424,12 @@ Ustawienia pokoju - + + Mentions + + + + Invite users Zaproś użytkowników @@ -460,7 +465,7 @@ TypingDisplay - + is typing pisze @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Zminimalizuj do paska zadań @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Motyw @@ -566,7 +576,7 @@ OGÓLNE - + Open Sessions File @@ -635,6 +645,14 @@ ZALOGUJ SIĘ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Rozmiar multimediów: %2 dialogs::ReadReceipts - + Read receipts Potwierdzenia przeczytania @@ -793,6 +811,19 @@ Rozmiar multimediów: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1006,4 +1037,32 @@ Rozmiar multimediów: %2 Flagi + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_ru.ts b/resources/langs/nheko_ru.ts index 4c157884..39cf7b72 100644 --- a/resources/langs/nheko_ru.ts +++ b/resources/langs/nheko_ru.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Сохранить файл @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Не удалось загрузить изображение. Пожалуйста, попробуйте еще раз. @@ -32,7 +32,7 @@ Не удалось загрузить видео. Пожалуйста, попробуйте еще раз. - + Failed to restore OLM account. Please login again. Не удалось восстановить учетную запись OLM. Пожалуйста, войдите снова. @@ -42,7 +42,7 @@ Не удалось восстановить сохраненные данные. Пожалуйста, войдите снова. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Не удалось настроить ключи шифрования. Ответ сервера:%1 %2. Пожалуйста, попробуйте позже. @@ -118,7 +118,7 @@ FileItem - + Save File Сохранить файл @@ -126,7 +126,7 @@ ImageItem - + Save image Сохранить изображение @@ -205,9 +205,9 @@ Участники комнаты - - ESC - + + OK + @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Покинуть комнату - + Accept Принять @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted Зашифровано @@ -354,13 +354,13 @@ TextInputWidget - + Send a file Отправить файл - + Write a message... Написать сообщение... @@ -424,7 +424,12 @@ Настройки комнаты - + + Mentions + + + + Invite users Пригласить пользователей @@ -460,7 +465,7 @@ TypingDisplay - + is typing печатает @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Сворачивать в системную панель @@ -521,12 +526,17 @@ Размер шрифта - + Font Family - + + Emoji Font Famly + + + + Theme Тема @@ -566,7 +576,7 @@ ГЛАВНОЕ - + Open Sessions File Открыть файл сеансов @@ -636,6 +646,14 @@ ВХОД + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -779,7 +797,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts Подтверждать прочтение @@ -794,6 +812,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1005,4 +1036,32 @@ Media size: %2 + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_zh_CN.ts b/resources/langs/nheko_zh_CN.ts index ca7c6e22..08463cd7 100644 --- a/resources/langs/nheko_zh_CN.ts +++ b/resources/langs/nheko_zh_CN.ts @@ -4,7 +4,7 @@ AudioItem - + Save File 保存文件 @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. 上传图像失败。请重试。 @@ -32,7 +32,7 @@ 上传视频失败。请重试。 - + Failed to restore OLM account. Please login again. 恢复 OLM 账户失败。请重新登录。 @@ -42,7 +42,7 @@ 恢复保存的数据失败。请重新登录。 - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File 保存文件 @@ -126,7 +126,7 @@ ImageItem - + Save image 保存图像 @@ -205,8 +205,8 @@ 聊天室成员 - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room 离开聊天室 - + Accept 接受 @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted 加密的 @@ -354,13 +354,13 @@ TextInputWidget - + Send a file 发送一个文件 - + Write a message... 写一条消息... @@ -424,7 +424,12 @@ 聊天室选项 - + + Mentions + + + + Invite users 邀请用户 @@ -460,7 +465,7 @@ TypingDisplay - + is typing 正在打字 @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray 最小化至托盘 @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme 主题 @@ -566,7 +576,7 @@ 通用 - + Open Sessions File 打开会话文件 @@ -635,6 +645,14 @@ 登录 + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts 阅读回执 @@ -793,6 +811,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1012,4 +1043,32 @@ Media size: %2 Flags + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/src/Utils.cpp b/src/Utils.cpp index d6b092b1..a3c15c96 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -99,13 +99,13 @@ utils::descriptiveTime(const QDateTime &then) const auto days = then.daysTo(now); if (days == 0) - return then.toString("HH:mm"); + return then.time().toString(Qt::DefaultLocaleShortDate); else if (days < 2) - return QString("Yesterday"); - else if (days < 365) - return then.toString("dd/MM"); + return QString(QCoreApplication::translate("descriptiveTime", "Yesterday")); + else if (days < 7) + return then.toString("dddd"); - return then.toString("dd/MM/yy"); + return then.date().toString(Qt::DefaultLocaleShortDate); } DescInfo @@ -147,7 +147,7 @@ utils::getMessageDescription(const TimelineEvent &event, DescInfo info; if (sender == localUser) - info.username = "You"; + info.username = QCoreApplication::translate("utils", "You"); else info.username = username; @@ -366,16 +366,16 @@ utils::getQuoteBody(const RelatedInfo &related) return markdownToHtml(related.quoted_body); } case MsgType::File: { - return QString("sent a file."); + return QString(QCoreApplication::translate("utils", "sent a file.")); } case MsgType::Image: { - return QString("sent an image."); + return QString(QCoreApplication::translate("utils", "sent an image.")); } case MsgType::Audio: { - return QString("sent an audio file."); + return QString(QCoreApplication::translate("utils", "sent an audio file.")); } case MsgType::Video: { - return QString("sent a video"); + return QString(QCoreApplication::translate("utils", "sent a video")); } default: { return related.quoted_body; diff --git a/src/dialogs/MemberList.cpp b/src/dialogs/MemberList.cpp index f4167143..3b957c15 100644 --- a/src/dialogs/MemberList.cpp +++ b/src/dialogs/MemberList.cpp @@ -97,7 +97,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) topLabel_->setAlignment(Qt::AlignCenter); topLabel_->setFont(font); - auto okBtn = new QPushButton("OK", this); + auto okBtn = new QPushButton(tr("OK"), this); auto buttonLayout = new QHBoxLayout(); buttonLayout->setSpacing(15); @@ -126,7 +126,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) qCritical() << e.what(); } - auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + auto closeShortcut = new QShortcut(QKeySequence("ESC"), this); connect(closeShortcut, &QShortcut::activated, this, &MemberList::close); connect(okBtn, &QPushButton::clicked, this, &MemberList::close); } diff --git a/src/dialogs/ReadReceipts.cpp b/src/dialogs/ReadReceipts.cpp index dc4145db..03ce3068 100644 --- a/src/dialogs/ReadReceipts.cpp +++ b/src/dialogs/ReadReceipts.cpp @@ -78,13 +78,15 @@ ReceiptItem::dateFormat(const QDateTime &then) const auto days = then.daysTo(now); if (days == 0) - return QString("Today %1").arg(then.toString("HH:mm")); + return tr("Today %1").arg(then.time().toString(Qt::DefaultLocaleShortDate)); else if (days < 2) - return QString("Yesterday %1").arg(then.toString("HH:mm")); - else if (days < 365) - return then.toString("dd/MM HH:mm"); + return tr("Yesterday %1").arg(then.time().toString(Qt::DefaultLocaleShortDate)); + else if (days < 7) + return QString("%1 %2") + .arg(then.toString("dddd")) + .arg(then.time().toString(Qt::DefaultLocaleShortDate)); - return then.toString("dd/MM/yy"); + return then.toString(Qt::DefaultLocaleShortDate); } ReadReceipts::ReadReceipts(QWidget *parent) diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp index e52dce7b..c0d7f97f 100644 --- a/src/timeline/TimelineItem.cpp +++ b/src/timeline/TimelineItem.cpp @@ -951,4 +951,4 @@ TimelineItem::openRawMessageViewer() const "failed to serialize event ({}, {})", room_id, event_id); } }); -} \ No newline at end of file +} diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp index fa575d76..27bc0a5f 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp @@ -2,6 +2,7 @@ #include "Config.h" #include +#include #include #include #include @@ -61,14 +62,14 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) { auto now = QDateTime::currentDateTime(); - QString fmt; + QString fmt = QLocale::system().dateFormat(QLocale::LongFormat); - if (now.date().year() != datetime.date().year()) - fmt = QString("ddd d MMMM yy"); - else - fmt = QString("ddd d MMMM"); + if (now.date().year() == datetime.date().year()) { + QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*"); + fmt = fmt.remove(rx); + } - msg_ = datetime.toString(fmt); + msg_ = datetime.date().toString(fmt); QFontMetrics fm{font()}; #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) -- cgit 1.5.1