Commit 5f1e5547 authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Claudio Cambra
Browse files

Improve display of error message



and various other small improvements

Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent cbed64cf
......@@ -37,6 +37,10 @@ struct Error {
{
return gpgme_err_code(error);
}
const char *errorMessage() const
{
return gpgme_strerror(error);
}
operator bool() const
{
return error != GPG_ERR_NO_ERROR;
......
......@@ -12,6 +12,7 @@
#include <QRegularExpression>
#include <QTextDocument>
// We return a pair containing the trimmed string, as well as a boolean indicating whether the string was trimmed or not
std::pair<QString, bool> PartModel::trim(const QString &text)
{
// The delimiters have <p>.? prefixed including the .? because sometimes we get a byte order mark <feff> (seen with user-agent:
......@@ -117,7 +118,8 @@ public:
}
auto preprocessPlaintext = [&](const QString &text) {
// We alwas do richtext (so we get highlighted links and stuff). NOTE: this inserts non-breaking spaces instead of regular spaces.
// We always do rich text (so we get highlighted links and stuff).
// NOTE: this inserts non-breaking spaces instead of regular spaces.
const auto html = Qt::convertFromPlainText(text);
if (trimMail) {
const auto result = PartModel::trim(html);
......@@ -155,17 +157,17 @@ public:
isTrimmed = false;
const auto parts = mParser->collectContentParts();
for (auto p : parts) {
checkPart(p);
if (auto e = p.dynamicCast<MimeTreeParser::EncapsulatedRfc822MessagePart>()) {
findEncapsulated(e);
for (auto part : parts) {
checkPart(part);
if (auto encapsulatedPart = part.dynamicCast<MimeTreeParser::EncapsulatedRfc822MessagePart>()) {
findEncapsulated(encapsulatedPart);
}
}
for (auto p : parts) {
if (mMimeTypeCache[p.data()] == "text/calendar") {
mParts.prepend(p);
for (auto part : parts) {
if (mMimeTypeCache[part.data()] == "text/calendar") {
mParts.prepend(part);
} else {
mParts.append(p);
mParts.append(part);
}
}
}
......@@ -261,8 +263,11 @@ QModelIndex PartModel::index(int row, int column, const QModelIndex &parent) con
return QModelIndex();
}
if (parent.isValid()) {
if (auto e = dynamic_cast<MimeTreeParser::EncapsulatedRfc822MessagePart *>(static_cast<MimeTreeParser::MessagePart *>(parent.internalPointer()))) {
const auto parts = d->mEncapsulatedParts[e];
const auto part = static_cast<MimeTreeParser::MessagePart *>(parent.internalPointer());
auto encapsulatedPart = dynamic_cast<MimeTreeParser::EncapsulatedRfc822MessagePart *>(part);
if (encapsulatedPart) {
const auto parts = d->mEncapsulatedParts[encapsulatedPart];
if (row < parts.size()) {
return createIndex(row, column, parts.at(row).data());
}
......@@ -282,8 +287,8 @@ SignatureInfo *encryptionInfo(MimeTreeParser::MessagePart *messagePart)
if (encryptions.size() > 1) {
qWarning() << "Can't deal with more than one encryption";
}
for (const auto &p : encryptions) {
signatureInfo->keyId = p->partMetaData()->keyId;
for (const auto &encryptionPart : encryptions) {
signatureInfo->keyId = encryptionPart->partMetaData()->keyId;
}
return signatureInfo;
};
......@@ -291,22 +296,22 @@ SignatureInfo *encryptionInfo(MimeTreeParser::MessagePart *messagePart)
SignatureInfo *signatureInfo(MimeTreeParser::MessagePart *messagePart)
{
auto signatureInfo = new SignatureInfo;
const auto signatureParts = messagePart->signatures();
if (signatureParts.size() > 1) {
const auto signatures = messagePart->signatures();
if (signatures.size() > 1) {
qWarning() << "Can't deal with more than one signature";
}
for (const auto &p : signatureParts) {
signatureInfo->keyId = p->partMetaData()->keyId;
signatureInfo->keyMissing = p->partMetaData()->keyMissing;
signatureInfo->keyExpired = p->partMetaData()->keyExpired;
signatureInfo->keyRevoked = p->partMetaData()->keyRevoked;
signatureInfo->sigExpired = p->partMetaData()->sigExpired;
signatureInfo->crlMissing = p->partMetaData()->crlMissing;
signatureInfo->crlTooOld = p->partMetaData()->crlTooOld;
signatureInfo->signer = p->partMetaData()->signer;
signatureInfo->signerMailAddresses = p->partMetaData()->signerMailAddresses;
signatureInfo->signatureIsGood = p->partMetaData()->isGoodSignature;
signatureInfo->keyIsTrusted = p->partMetaData()->keyIsTrusted;
for (const auto &signaturePart : signatures) {
signatureInfo->keyId = signaturePart->partMetaData()->keyId;
signatureInfo->keyMissing = signaturePart->partMetaData()->keyMissing;
signatureInfo->keyExpired = signaturePart->partMetaData()->keyExpired;
signatureInfo->keyRevoked = signaturePart->partMetaData()->keyRevoked;
signatureInfo->sigExpired = signaturePart->partMetaData()->sigExpired;
signatureInfo->crlMissing = signaturePart->partMetaData()->crlMissing;
signatureInfo->crlTooOld = signaturePart->partMetaData()->crlTooOld;
signatureInfo->signer = signaturePart->partMetaData()->signer;
signatureInfo->signerMailAddresses = signaturePart->partMetaData()->signerMailAddresses;
signatureInfo->signatureIsGood = signaturePart->partMetaData()->isGoodSignature;
signatureInfo->keyIsTrusted = signaturePart->partMetaData()->keyIsTrusted;
}
return signatureInfo;
}
......@@ -482,18 +487,18 @@ QVariant PartModel::data(const QModelIndex &index, int role) const
QModelIndex PartModel::parent(const QModelIndex &index) const
{
if (index.isValid()) {
if (auto e = static_cast<MimeTreeParser::MessagePart *>(index.internalPointer())) {
for (const auto &p : d->mParts) {
if (p.data() == e) {
if (auto indexPart = static_cast<MimeTreeParser::MessagePart *>(index.internalPointer())) {
for (const auto &part : d->mParts) {
if (part.data() == indexPart) {
return QModelIndex();
}
}
const auto parentPart = d->mParents[e];
const auto parentPart = d->mParents[indexPart];
Q_ASSERT(parentPart);
int row = 0;
const auto parts = d->mEncapsulatedParts[parentPart];
for (const auto &p : parts) {
if (p.data() == e) {
for (const auto &part : parts) {
if (part.data() == indexPart) {
break;
}
row++;
......@@ -508,8 +513,11 @@ QModelIndex PartModel::parent(const QModelIndex &index) const
int PartModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) {
if (auto e = dynamic_cast<MimeTreeParser::EncapsulatedRfc822MessagePart *>(static_cast<MimeTreeParser::MessagePart *>(parent.internalPointer()))) {
const auto parts = d->mEncapsulatedParts[e];
const auto part = static_cast<MimeTreeParser::MessagePart *>(parent.internalPointer());
auto encapsulatedPart = dynamic_cast<MimeTreeParser::EncapsulatedRfc822MessagePart *>(part);
if (encapsulatedPart) {
const auto parts = d->mEncapsulatedParts[encapsulatedPart];
return parts.size();
}
return 0;
......
......@@ -9,6 +9,7 @@
#include "utils.h"
#include <KLocalizedString>
#include <KMime/Content>
#include <QTextCodec>
......@@ -614,7 +615,7 @@ SignedMessagePart::SignedMessagePart(ObjectTreeParser *otp,
{
mMetaData.isSigned = true;
mMetaData.isGoodSignature = false;
mMetaData.status = tr("Wrong Crypto Plug-In.");
mMetaData.status = i18n("Wrong Crypto Plug-In.");
}
SignedMessagePart::~SignedMessagePart()
......@@ -714,7 +715,7 @@ void SignedMessagePart::startVerification()
}
mMetaData.isSigned = false;
mMetaData.status = tr("Wrong Crypto Plug-In.");
mMetaData.status = i18n("Wrong Crypto Plug-In.");
mMetaData.isEncrypted = false;
mMetaData.isDecryptable = false;
......@@ -788,7 +789,7 @@ EncryptedMessagePart::EncryptedMessagePart(ObjectTreeParser *otp,
mMetaData.isGoodSignature = false;
mMetaData.isEncrypted = false;
mMetaData.isDecryptable = false;
mMetaData.status = tr("Wrong Crypto Plug-In.");
mMetaData.status = i18n("Wrong Crypto Plug-In.");
}
void EncryptedMessagePart::setIsEncrypted(bool encrypted)
......@@ -870,14 +871,13 @@ bool EncryptedMessagePart::decrypt(KMime::Content &data)
if (noSecretKeyAvilable) {
mError = NoKeyError;
mMetaData.errorText = tr("Could not decrypt the data: no key found for recipients.");
mMetaData.errorText = i18n("Could not decrypt the data: no key found for recipients.");
} else if (passphraseError) {
mError = PassphraseError;
// mMetaData.errorText = QString::fromLocal8Bit(decryptResult.error().asString());
mMetaData.errorText = QString::fromLocal8Bit(decryptResult.error.errorMessage());
} else {
mError = UnknownError;
mMetaData.errorText = tr("Could not decrypt the data.");
// + tr("Error: %1").arg(QString::fromLocal8Bit(decryptResult.error().asString()));
mMetaData.errorText = i18n("Could not decrypt the data. Error: %1", QString::fromLocal8Bit(decryptResult.error.errorMessage()));
}
setText(QString::fromUtf8(mDecryptedData.constData()));
return false;
......
......@@ -484,8 +484,8 @@ const QTextCodec *ObjectTreeParser::codecFor(KMime::Content *node) const
QByteArray charset = node->contentType()->charset().toLower();
// utf-8 is a superset of us-ascii, so we don't loose anything, if we it insead
// utf-8 is nowadays that widely, that it is a good guess to use it to fix issus with broken clients.
// utf-8 is a superset of us-ascii, so we don't lose anything if we use it instead
// utf-8 is used so widely nowadays that it is a good idea to use it to fix issues with broken clients.
if (charset == "us-ascii") {
charset = "utf-8";
}
......
......@@ -21,6 +21,8 @@ Kirigami.ScrollablePage {
ColumnLayout {
// TODO use repeater to see the full conversation
MailViewer {
Layout.fillWidth: true
item: root.item
subject: props.title
from: props.from
......
......@@ -21,10 +21,10 @@ import org.kde.kitemmodels 1.0 as KItemModels
QQC2.Menu {
title: i18nc('@action:menu', 'Mark Message')
QQC2.MenuItem {
text: i18n('Mark message as Read')
text: i18n('Mark Message as Read')
}
QQC2.MenuItem {
text: i18n('Mark message as Unread')
text: i18n('Mark Message as Unread')
}
QQC2.MenuSeparator {}
......@@ -36,7 +36,7 @@ import org.kde.kitemmodels 1.0 as KItemModels
QQC2.MenuItem {
icon.name: 'delete'
text: i18n('Move to trash')
text: i18n('Move to Trash')
}
QQC2.MenuItem {
......@@ -51,7 +51,7 @@ import org.kde.kitemmodels 1.0 as KItemModels
QQC2.MenuItem {
icon.name: 'edit-copy'
text: i18n('Add followup reminder')
text: i18n('Add Followup Reminder')
}
}
}
......
......@@ -20,7 +20,7 @@ QQC2.ScrollView {
clip: true
contentItem: ListView {
id: calendarList
id: mailList
model: KDescendantsProxyModel {
id: foldersModel
......@@ -53,7 +53,7 @@ QQC2.ScrollView {
source: model.kDescendantExpanded ? 'arrow-up' : 'arrow-down'
}
onClicked: calendarList.model.toggleChildren(index)
onClicked: mailList.model.toggleChildren(index)
}
}
......
......@@ -20,16 +20,12 @@ QQC2.Page {
property string to
property date dateTime
Layout.fillWidth: true
header: QQC2.ToolBar {
topInset: 1
leftInset: 1
rightInset: 1
bottomInset: 1
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
topPadding: Kirigami.Units.largeSpacing
bottomPadding: Kirigami.Units.largeSpacing
padding: Kirigami.Units.largeSpacing
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
background: Item {
implicitHeight: 40
Kirigami.Separator {
......@@ -41,7 +37,9 @@ QQC2.Page {
}
}
}
contentItem: GridLayout {
GridLayout {
anchors.fill: parent
columns: 3
QQC2.Label {
text: i18n('From:')
......@@ -80,20 +78,19 @@ QQC2.Page {
}
}
}
contentItem: MailPartView {
MailPartView {
id: mailPartView
anchors.fill: parent
item: root.item
}
footer: QQC2.ToolBar {
topInset: 1
leftInset: 1
rightInset: 1
bottomInset: 1
leftPadding: Kirigami.Units.largeSpacing
rightPadding: Kirigami.Units.largeSpacing
topPadding: Kirigami.Units.largeSpacing
bottomPadding: Kirigami.Units.largeSpacing
padding: Kirigami.Units.largeSpacing
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.View
background: Item {
implicitHeight: 40
Kirigami.Separator {
......@@ -106,7 +103,8 @@ QQC2.Page {
}
}
contentItem: Flow {
Flow {
anchors.fill: parent
spacing: Kirigami.Units.smallSpacing
Repeater {
model: mailPartView.attachmentModel
......
......@@ -16,6 +16,7 @@ SPDX-License-Identifier: CC0-1.0
<file alias="IncidenceDelegateBackground.qml">contents/ui/Delegates/IncidenceDelegateBackground.qml</file>
<file alias="DayGridViewIncidenceDelegate.qml">contents/ui/Delegates/DayGridViewIncidenceDelegate.qml</file>
<file alias="ViewTitleDelegate.qml">contents/ui/Delegates/ViewTitleDelegate.qml</file>
<file alias="RelatedIncidenceDelegate.qml">contents/ui/Delegates/RelatedIncidenceDelegate.qml</file>
<file alias="DayGridView.qml">contents/ui/MainViews/DayGridView.qml</file>
<file alias="MonthView.qml">contents/ui/MainViews/MonthView.qml</file>
......@@ -24,6 +25,7 @@ SPDX-License-Identifier: CC0-1.0
<file alias="TodoView.qml">contents/ui/MainViews/TodoView.qml</file>
<file alias="HourlyView.qml">contents/ui/MainViews/HourlyView.qml</file>
<file alias="LazyContactView.qml">contents/ui/MainViews/LazyContactView.qml</file>
<file alias="LazyMailView.qml">contents/ui/MainViews/LazyMailView.qml</file>
<file alias="dateutils.js">contents/ui/KalendarUtils/dateutils.js</file>
<file alias="labelutils.js">contents/ui/KalendarUtils/labelutils.js</file>
......@@ -51,6 +53,7 @@ SPDX-License-Identifier: CC0-1.0
<file alias="Tag.qml">contents/ui/Controls/Tag.qml</file>
<file alias="ResizerSeparator.qml">contents/ui/Controls/ResizerSeparator.qml</file>
<file alias="CalendarItemTapHandler.qml">contents/ui/Controls/CalendarItemTapHandler.qml</file>
<file alias="TodoCheckBox.qml">contents/ui/Controls/TodoCheckBox.qml</file>
<file alias="LocationMap.qml">contents/ui/Location/LocationMap.qml</file>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment