diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/m_email/EMailHelper.cpp | 12 | ||||
| -rw-r--r-- | src/m_email/EMailModule.cpp | 6 | ||||
| -rw-r--r-- | src/m_email/EMailPageView.cpp | 64 | ||||
| -rw-r--r-- | src/m_email/EMailViewLayout.cpp | 10 | ||||
| -rw-r--r-- | src/m_email/test/EMailSdkStubs.cpp | 4 | ||||
| -rw-r--r-- | src/m_email/test/EMailSecretTest.cpp | 20 | ||||
| -rw-r--r-- | src/m_email/test/EMailViewLayoutTest.cpp | 19 |
7 files changed, 71 insertions, 64 deletions
diff --git a/src/m_email/EMailHelper.cpp b/src/m_email/EMailHelper.cpp index d699d63..a3d8636 100644 --- a/src/m_email/EMailHelper.cpp +++ b/src/m_email/EMailHelper.cpp @@ -41,6 +41,8 @@ #include <algorithm> #include <limits> +using namespace Qt::StringLiterals; + namespace { MimeLogFn g_mime_log_sink = nullptr; } // namespace @@ -559,18 +561,18 @@ auto SplitExtension(const QString& name) -> QPair<QString, QString> { auto SuggestedEMailFileName(const QString& subject) -> QString { const auto trimmed = subject.trimmed(); - if (trimmed.isEmpty()) return QStringLiteral("untitled.eml"); + if (trimmed.isEmpty()) return u"untitled.eml"_s; // Capped before sanitizing rather than after: the sanitizer's own length cap // is a filesystem limit, and a name that long is unusable as a suggestion // long before it is illegal. auto name = SanitizeAttachmentFileName(trimmed.left(kSuggestedNameLength), - QStringLiteral("message/rfc822")); + u"message/rfc822"_s); // The sanitizer guarantees a non-empty name but not this extension -- a // subject that was entirely path separators comes back as "attachment". - if (!name.endsWith(QStringLiteral(".eml"), Qt::CaseInsensitive)) { - name += QStringLiteral(".eml"); + if (!name.endsWith(u".eml"_s, Qt::CaseInsensitive)) { + name += u".eml"_s; } return name; } @@ -2334,7 +2336,7 @@ auto PartDescription(const vmime::shared_ptr<const vmime::bodyPart>& part) auto IsSignerPublicKeyPart(const vmime::shared_ptr<vmime::bodyPart>& part) -> bool { return PartContentType(part) == "application/pgp-keys" && - PartDescription(part) == QLatin1String(kSignerKeyDescription); + PartDescription(part) == QLatin1StringView(kSignerKeyDescription); } /// Replaces every Content-* field of @p dst with the ones @p src carries. diff --git a/src/m_email/EMailModule.cpp b/src/m_email/EMailModule.cpp index 3cfd8b0..63c56e4 100644 --- a/src/m_email/EMailModule.cpp +++ b/src/m_email/EMailModule.cpp @@ -82,6 +82,8 @@ #include "EMailVerificationPayload.h" #include "GFModuleTr.h" +using namespace Qt::StringLiterals; + namespace { // Build one Info Board card object (title/status/fields) in the JSON shape the @@ -616,7 +618,7 @@ auto OpenRawAsEMailTab(const QByteArray& raw, const QString& title) -> bool { // arrived with, and a PGP/MIME signature covers the exact octets. return Commands() .Invoke<gf::cmd::host::DocumentOpen>( - {QStringLiteral("email"), title, QString(), + {u"email"_s, title, QString(), gf::cmd::MakeBlob(raw.constData(), static_cast<size_t>(raw.size())), false, false}) .Ok(); @@ -1721,7 +1723,7 @@ auto DoNewMessage(const gf::cmd::CommandContext& /*ctx*/, const gf::cmd::Unit& /*args*/) -> gf::cmd::Outcome<gf::cmd::Unit> { Commands().Invoke<gf::cmd::host::DocumentNew>( - {QStringLiteral("email"), QStringLiteral("untitled.eml")}); + {u"email"_s, u"untitled.eml"_s}); return gf::cmd::Outcome<gf::cmd::Unit>::Success({}); } diff --git a/src/m_email/EMailPageView.cpp b/src/m_email/EMailPageView.cpp index c26dad4..50cc605 100644 --- a/src/m_email/EMailPageView.cpp +++ b/src/m_email/EMailPageView.cpp @@ -90,6 +90,8 @@ #include "EMailViewStyle.h" #include "GFModule.h" +using namespace Qt::StringLiterals; + namespace { /// How far a locked surface moves from the page's own background towards its @@ -754,34 +756,32 @@ auto EMailPageView::build_message_surface() -> QWidget* { // Message-level actions. Each produces a NEW document in a new tab; none of // them writes to this one. - reply_act_ = make_command( - QStringLiteral("mail-reply-sender"), ":/icons/reply.png", tr("Reply"), - tr("Write a reply to the sender."), QKeySequence(Qt::CTRL | Qt::Key_R)); + reply_act_ = make_command(u"mail-reply-sender"_s, ":/icons/reply.png", + tr("Reply"), tr("Write a reply to the sender."), + QKeySequence(Qt::CTRL | Qt::Key_R)); reply_all_act_ = make_command( - QStringLiteral("mail-reply-all"), ":/icons/reply-all.png", - tr("Reply All"), + u"mail-reply-all"_s, ":/icons/reply-all.png", tr("Reply All"), tr("Write a reply to the sender and everyone else who was addressed. " "Blind recipients are not included."), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_R)); - forward_act_ = make_command( - QStringLiteral("mail-forward"), ":/icons/redo.png", tr("Forward"), - tr("Pass this message on, with its attachments."), - QKeySequence(Qt::CTRL | Qt::Key_L)); - send_act_ = make_command(QStringLiteral("mail-send"), - ":/icons/export-email.png", tr("Send..."), - tr("Send this message through a configured " - "mail account."), - QKeySequence(Qt::CTRL | Qt::Key_Return)); + forward_act_ = + make_command(u"mail-forward"_s, ":/icons/redo.png", tr("Forward"), + tr("Pass this message on, with its attachments."), + QKeySequence(Qt::CTRL | Qt::Key_L)); + send_act_ = + make_command(u"mail-send"_s, ":/icons/export-email.png", tr("Send..."), + tr("Send this message through a configured " + "mail account."), + QKeySequence(Qt::CTRL | Qt::Key_Return)); // The attachment menu's Attach is this same action, so the row and the // menu cannot disagree about it. attachment_attach_act_ = make_command( - QStringLiteral("mail-attachment"), ":/icons/attachment.png", - tr("Attach File..."), + u"mail-attachment"_s, ":/icons/attachment.png", tr("Attach File..."), tr("Add one or more files to this message. Files can also be dropped " "onto the message."), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_A)); details_act_ = make_command( - QStringLiteral("dialog-information"), ":/icons/detail.png", + u"dialog-information"_s, ":/icons/detail.png", // The ellipsis is doing its usual job: this opens a window rather than // changing anything here. tr("Details..."), @@ -789,7 +789,7 @@ auto EMailPageView::build_message_surface() -> QWidget* { "structure and its headers."), QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D)); forensic_act_ = make_command( - QStringLiteral("object-locked"), ":/icons/read-only.png", tr("Read-only"), + u"object-locked"_s, ":/icons/read-only.png", tr("Read-only"), tr("Lock this message so it cannot be edited or rewritten. Reply and " "Forward still work and produce new messages."), QKeySequence()); @@ -823,8 +823,8 @@ auto EMailPageView::build_message_surface() -> QWidget* { // attachments to operate on. Built here, filled in with the section below. attachment_menu_ = new QMenu(this); attachments_button_ = new QToolButton(this); - attachments_button_->setIcon(QIcon::fromTheme( - QStringLiteral("mail-attachment"), QIcon(":/icons/attachment.png"))); + attachments_button_->setIcon( + QIcon::fromTheme(u"mail-attachment"_s, QIcon(":/icons/attachment.png"))); attachments_button_->setText(tr("Attachments")); attachments_button_->setToolTip(tr("Open, save and manage attachments")); attachments_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -847,8 +847,8 @@ auto EMailPageView::build_message_surface() -> QWidget* { more_button_ = new QToolButton(this); more_button_->setText(tr("More")); more_button_->setToolTip(tr("More actions for this message")); - more_button_->setIcon(QIcon::fromTheme(QStringLiteral("view-more"), - QIcon(":/icons/detail.png"))); + more_button_->setIcon( + QIcon::fromTheme(u"view-more"_s, QIcon(":/icons/detail.png"))); more_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); more_button_->setAutoRaise(true); more_button_->setPopupMode(QToolButton::InstantPopup); @@ -858,7 +858,7 @@ auto EMailPageView::build_message_surface() -> QWidget* { // A state, not a control: the lock itself is toggled from More. read_only_label_ = new QLabel(this); - read_only_label_->setObjectName(QStringLiteral("emailReadOnlyStatus")); + read_only_label_->setObjectName(u"emailReadOnlyStatus"_s); read_only_label_->setText(tr("Read-only")); read_only_label_->setToolTip( tr("This message is open for inspection only. Turn it off in More.")); @@ -970,8 +970,7 @@ auto EMailPageView::build_message_surface() -> QWidget* { attachment_icon_ = new QLabel(this); attachment_icon_->setPixmap( - QIcon::fromTheme(QStringLiteral("mail-attachment"), - QIcon(":/icons/attachment.png")) + QIcon::fromTheme(u"mail-attachment"_s, QIcon(":/icons/attachment.png")) .pixmap(16, 16)); attachment_title_ = new QLabel(tr("Attachments"), this); @@ -1012,14 +1011,12 @@ auto EMailPageView::build_message_surface() -> QWidget* { // part, Save on the parts the user can see chosen, Save All on every one. attachment_open_act_ = attachment_menu_->addAction(tr("Open")); attachment_save_act_ = attachment_menu_->addAction( - QIcon::fromTheme(QStringLiteral("document-save"), - QIcon(":/icons/filesave.png")), + QIcon::fromTheme(u"document-save"_s, QIcon(":/icons/filesave.png")), tr("Save...")); attachment_save_act_->setToolTip( tr("Write the selected attachments to a folder.")); attachment_save_all_act_ = attachment_menu_->addAction( - QIcon::fromTheme(QStringLiteral("document-save-all"), - QIcon(":/icons/save-all.png")), + QIcon::fromTheme(u"document-save-all"_s, QIcon(":/icons/save-all.png")), tr("Save All...")); attachment_save_all_act_->setToolTip(tr("Write every attachment to a folder.")); attachment_edit_separator_ = attachment_menu_->addSeparator(); @@ -1028,8 +1025,7 @@ auto EMailPageView::build_message_surface() -> QWidget* { // nothing on disk, and the wording and icon both stay away from suggesting // it does. attachment_remove_act_ = attachment_menu_->addAction( - QIcon::fromTheme(QStringLiteral("list-remove"), - QIcon(":/icons/remove.png")), + QIcon::fromTheme(u"list-remove"_s, QIcon(":/icons/remove.png")), tr("Remove")); attachment_remove_act_->setToolTip( tr("Take the selected attachments out of this message.")); @@ -1868,7 +1864,7 @@ void EMailPageView::slot_derive_message(int mode) { // the tab says so. QPointer<EMailPageView> guard(this); Commands().Invoke<gf::cmd::host::DocumentOpen>( - {QStringLiteral("email"), title, QString(), + {u"email"_s, title, QString(), gf::cmd::MakeBlob(eml.constData(), static_cast<size_t>(eml.size())), false, true}, this, [guard, what, intact](const auto& r) { @@ -1931,8 +1927,8 @@ auto EMailPageView::build_locked_panel() -> QWidget* { // inside the ciphertext is the only kind worth anything here. emit SignalCryptoOperationRequested( security_state_ == EMailSecurityState::kSIGNED_ENCRYPTED - ? QStringLiteral("decrypt_verify") - : QStringLiteral("decrypt")); + ? u"decrypt_verify"_s + : u"decrypt"_s); }); return panel; diff --git a/src/m_email/EMailViewLayout.cpp b/src/m_email/EMailViewLayout.cpp index 7c6689e..a644faf 100644 --- a/src/m_email/EMailViewLayout.cpp +++ b/src/m_email/EMailViewLayout.cpp @@ -33,6 +33,8 @@ #include "EMailModel.h" +using namespace Qt::StringLiterals; + auto EMailClampDetailsSize(int width, int height) -> std::pair<int, int> { const auto wanted_width = width > 0 ? width : kEMailDetailsDefaultWidth; const auto wanted_height = height > 0 ? height : kEMailDetailsDefaultHeight; @@ -112,13 +114,13 @@ auto EMailSecurityStatus(EMailBadgeState badge, bool encrypted) // Translated under the view's own context, spelled out at every call so // lupdate sees each one: these are the view's strings, moved here only so // they can be checked. - const auto warning = QStringLiteral(":/icons/warning.png"); - const auto signature = QStringLiteral(":/icons/signature.png"); + const auto warning = u":/icons/warning.png"_s; + const auto signature = u":/icons/signature.png"_s; switch (badge) { case EMailBadgeState::kENCRYPTED_ONLY: return {QCoreApplication::translate("EMailPageView", "Encrypted"), - QStringLiteral(":/icons/lock.png")}; + u":/icons/lock.png"_s}; case EMailBadgeState::kSIGNED_UNVERIFIED: // What is actually known at this point: the message CARRIES a // signature. Whether it is any good is a separate question that has @@ -173,7 +175,7 @@ auto EMailSecurityStatus(EMailBadgeState badge, bool encrypted) } return { QCoreApplication::translate("EMailPageView", "Not signed or encrypted"), - QStringLiteral(":/icons/email.png")}; + u":/icons/email.png"_s}; } auto EMailAttachmentTargets(int count, const QList<int>& selected_rows, diff --git a/src/m_email/test/EMailSdkStubs.cpp b/src/m_email/test/EMailSdkStubs.cpp index c6e4ca0..3266713 100644 --- a/src/m_email/test/EMailSdkStubs.cpp +++ b/src/m_email/test/EMailSdkStubs.cpp @@ -24,6 +24,8 @@ #include <cstring> #include <set> +using namespace Qt::StringLiterals; + namespace { std::set<void*>& NormalArena() { @@ -207,7 +209,7 @@ auto SettingsRoot(GFHostContextRef) -> void* { /// Settings by key, kept in the same file the old settings root used, under /// the group the Host would give this module. auto SettingKey(const char* key) -> QString { - return QStringLiteral("email/") + QString::fromUtf8(key); + return u"email/"_s + QString::fromUtf8(key); } auto SettingGet(GFHostContextRef ctx, int, const char* key, GFBufferRef* out) diff --git a/src/m_email/test/EMailSecretTest.cpp b/src/m_email/test/EMailSecretTest.cpp index b36a99b..319615d 100644 --- a/src/m_email/test/EMailSecretTest.cpp +++ b/src/m_email/test/EMailSecretTest.cpp @@ -48,13 +48,15 @@ #include "EMailSecret.h" +using namespace Qt::StringLiterals; + /// Supplied by the harness (EMailSdkStubs.cpp). auto GFModuleSdkContext() -> GFSDKContext*; namespace { TEST(EMailSecretTest, AQStringWipeDoesNotReachASharedBuffer) { - QString original = QStringLiteral("correct-horse-battery"); + QString original = u"correct-horse-battery"_s; // Force a heap buffer of our own rather than a literal's shared data. original.detach(); @@ -64,13 +66,13 @@ TEST(EMailSecretTest, AQStringWipeDoesNotReachASharedBuffer) { original.fill(QChar('\0')); // The copy still reads the secret: original detached and zeroed elsewhere. - EXPECT_EQ(shared, QStringLiteral("correct-horse-battery")); + EXPECT_EQ(shared, u"correct-horse-battery"_s); EXPECT_EQ(buffer[0], QChar('c')) << "if this ever fails, QString has changed and the note above is stale"; } TEST(EMailSecretTest, WipingClearsTheOnlyCopy) { - auto secret = EMailSecret::CopyFrom(QStringLiteral("hunter2")); + auto secret = EMailSecret::CopyFrom(u"hunter2"_s); ASSERT_FALSE(secret->IsEmpty()); EXPECT_EQ(secret->Size(), 7U); @@ -82,7 +84,7 @@ TEST(EMailSecretTest, WipingClearsTheOnlyCopy) { } TEST(EMailSecretTest, WipingTwiceIsHarmless) { - auto secret = EMailSecret::CopyFrom(QStringLiteral("hunter2")); + auto secret = EMailSecret::CopyFrom(u"hunter2"_s); secret->Wipe(); secret->Wipe(); EXPECT_TRUE(secret->IsEmpty()); @@ -99,7 +101,7 @@ TEST(EMailSecretTest, AnEmptySecretIsUsable) { TEST(EMailSecretTest, MovingTransfersAndLeavesNothingBehind) { EMailSecret from; { - auto source = EMailSecret::CopyFrom(QStringLiteral("s3cret")); + auto source = EMailSecret::CopyFrom(u"s3cret"_s); from = std::move(*source); } EXPECT_EQ(from.StdStringCopy(), "s3cret"); @@ -110,8 +112,8 @@ TEST(EMailSecretTest, MovingTransfersAndLeavesNothingBehind) { } TEST(EMailSecretTest, MoveAssignmentWipesWhatItReplaces) { - auto first = EMailSecret::CopyFrom(QStringLiteral("first-secret")); - auto second = EMailSecret::CopyFrom(QStringLiteral("second")); + auto first = EMailSecret::CopyFrom(u"first-secret"_s); + auto second = EMailSecret::CopyFrom(u"second"_s); *first = std::move(*second); @@ -125,7 +127,7 @@ TEST(EMailSecretTest, TheLastHolderReleasingErasesTheBytes) { // the same bytes, not a duplicate. EMailSecretPtr shared; { - auto secret = EMailSecret::CopyFrom(QStringLiteral("shared-secret")); + auto secret = EMailSecret::CopyFrom(u"shared-secret"_s); shared = secret; EXPECT_EQ(shared.use_count(), 2); secret.reset(); @@ -175,7 +177,7 @@ TEST(EMailSecretTest, ASecureCStringCarriesTheSecretVerbatim) { // QSecStrDup(QString), which builds an unwiped QByteArray temporary on the // way -- one more copy of the password than there needs to be, and one // nothing can erase. - auto secret = EMailSecret::CopyFrom(QStringLiteral("correct-horse")); + auto secret = EMailSecret::CopyFrom(u"correct-horse"_s); auto* buffer = secret->ToSecureCString(); ASSERT_NE(buffer, nullptr); diff --git a/src/m_email/test/EMailViewLayoutTest.cpp b/src/m_email/test/EMailViewLayoutTest.cpp index 8e75dc1..e0cd488 100644 --- a/src/m_email/test/EMailViewLayoutTest.cpp +++ b/src/m_email/test/EMailViewLayoutTest.cpp @@ -31,6 +31,8 @@ #include "EMailModel.h" #include "EMailViewLayout.h" +using namespace Qt::StringLiterals; + // The details inspector's rules, checked without a widget. The view itself // cannot be built in a test here -- these bodies run off the GUI thread -- so // the decisions it makes are kept in a file that can be. @@ -265,29 +267,28 @@ TEST(EMailViewLayoutTest, EveryCommandIsReachableInEveryMode) { TEST(EMailViewLayoutTest, TheSecurityStatusSaysOnlyWhatIsKnown) { EXPECT_EQ(EMailSecurityStatus(EMailBadgeState::kENCRYPTED_ONLY, true).text, - QStringLiteral("Encrypted")); + u"Encrypted"_s); EXPECT_EQ( EMailSecurityStatus(EMailBadgeState::kSIGNED_UNVERIFIED, false).text, - QStringLiteral("Signature not checked")); + u"Signature not checked"_s); EXPECT_EQ(EMailSecurityStatus(EMailBadgeState::kSIGNED_UNVERIFIED, true).text, - QStringLiteral("Encrypted, signature not checked")); + u"Encrypted, signature not checked"_s); EXPECT_EQ(EMailSecurityStatus(EMailBadgeState::kSIGNED_GOOD, false).text, - QStringLiteral("Signature verified")); + u"Signature verified"_s); EXPECT_EQ(EMailSecurityStatus(EMailBadgeState::kSIGNED_BAD, false).text, - QStringLiteral("Bad signature")); + u"Bad signature"_s); EXPECT_EQ( EMailSecurityStatus(EMailBadgeState::kSIGNED_UNAUTHORIZED_KEY, false) .text, - QStringLiteral("Signing key not authorized")); + u"Signing key not authorized"_s); EXPECT_EQ(EMailSecurityStatus(EMailBadgeState::kNOT_PROTECTED, false).text, - QStringLiteral("Not signed or encrypted")); + u"Not signed or encrypted"_s); // A verdict against the signature never wears the signature's icon. for (const auto badge : {EMailBadgeState::kSIGNED_BAD, EMailBadgeState::kSIGNED_ERROR, EMailBadgeState::kSIGNED_UNAUTHORIZED_KEY, EMailBadgeState::kSIGNED_MISMATCH, EMailBadgeState::kMALFORMED}) { - EXPECT_EQ(EMailSecurityStatus(badge, false).icon, - QStringLiteral(":/icons/warning.png")); + EXPECT_EQ(EMailSecurityStatus(badge, false).icon, u":/icons/warning.png"_s); } } |
