fixes for gmail, fixed crash when editing email

This commit is contained in:
Martin Rotter 2023-11-16 10:21:30 +01:00
parent 4aa59e7915
commit 76c7dd1703
5 changed files with 23 additions and 12 deletions

View File

@ -30,11 +30,13 @@ QColor ColorToolButton::color() const {
return m_color;
}
void ColorToolButton::setColor(const QColor& color) {
void ColorToolButton::setColor(const QColor& color, bool inform_about_changes) {
m_color = color;
repaint();
emit colorChanged(m_color);
if (inform_about_changes) {
emit colorChanged(m_color);
}
}
void ColorToolButton::setRandomColor() {

View File

@ -12,7 +12,7 @@ class ColorToolButton : public QToolButton {
explicit ColorToolButton(QWidget* parent = nullptr);
QColor color() const;
void setColor(const QColor& color);
void setColor(const QColor& color, bool inform_about_changes = true);
QColor alternateColor() const;
void setAlternateColor(const QColor& alt_color);

View File

@ -555,9 +555,11 @@ void MRichTextEdit::fontChanged(const QFont& f) {
void MRichTextEdit::onCurrentCharFormatChanged(const QTextCharFormat& format) {
fontChanged(format.font());
m_ui.f_bgcolor->setColor(format.background().isOpaque() ? format.background().color()
: m_ui.f_bgcolor->alternateColor());
: m_ui.f_bgcolor->alternateColor(),
false);
m_ui.f_fgcolor->setColor(format.foreground().isOpaque() ? format.foreground().color()
: m_ui.f_fgcolor->alternateColor());
: m_ui.f_fgcolor->alternateColor(),
false);
m_ui.f_link->setChecked(format.isAnchor());
}

View File

@ -688,7 +688,7 @@ QMap<QString, QString> GmailNetworkFactory::getMessageMetadata(const QString& ms
return result;
}
else {
throw ApplicationException(tr("failed to get metadata"));
throw NetworkException(res.m_networkError);
}
}

View File

@ -59,11 +59,6 @@ void FormAddEditEmail::execForReply(Message* original_message) {
m_ui.m_txtSubject->setEnabled(false);
m_ui.m_txtMessage->setFocus();
auto from_header =
m_root->network()->getMessageMetadata(original_message->m_customId, {QSL("FROM")}, m_root->networkProxy());
// TODO: konverze html > plain
// QTextDocumentFragment::fromHtml(m_originalMessage->m_contents).toPlainText()
m_ui.m_txtMessage->setText(m_originalMessage->m_contents);
m_ui.m_txtMessage->editor()->moveCursor(QTextCursor::MoveOperation::Start);
m_ui.m_txtMessage->editor()->insertHtml(QSL("<p>"
@ -71,7 +66,15 @@ void FormAddEditEmail::execForReply(Message* original_message) {
"</p><br/>"));
m_ui.m_txtMessage->editor()->moveCursor(QTextCursor::MoveOperation::Start);
addRecipientRow(from_header[QSL("From")]);
try {
auto from_header =
m_root->network()->getMessageMetadata(original_message->m_customId, {QSL("FROM")}, m_root->networkProxy());
addRecipientRow(from_header.value(QSL("From")));
}
catch (const ApplicationException& ex) {
qWarningNN << LOGSEC_GMAIL << "Failed to get message metadata:" << QUOTE_W_SPACE_DOT(ex.message());
}
exec();
}
@ -187,6 +190,10 @@ void FormAddEditEmail::onOkClicked() {
}
EmailRecipientControl* FormAddEditEmail::addRecipientRow(const QString& recipient) {
if (recipient.isEmpty()) {
return nullptr;
}
auto* mail_rec = new EmailRecipientControl(recipient, this);
connect(mail_rec, &EmailRecipientControl::removalRequested, this, &FormAddEditEmail::removeRecipientRow);