Skip to content

Commit

Permalink
fixes for gmail, fixed crash when editing email
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Nov 16, 2023
1 parent 4aa59e7 commit 76c7dd1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/librssguard/gui/reusable/colortoolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/gui/reusable/colortoolbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/librssguard/gui/richtexteditor/mrichtextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
2 changes: 1 addition & 1 deletion src/librssguard/services/gmail/gmailnetworkfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
19 changes: 13 additions & 6 deletions src/librssguard/services/gmail/gui/formaddeditemail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,22 @@ 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>"
"---------- 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();
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 76c7dd1

Please sign in to comment.