From 2128c14fb2cfce9512f957fe2475c1ef196156a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sun, 9 Oct 2022 20:33:10 +0200 Subject: [PATCH] Distinguish between settings and explicit override for external content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This will allow KMail to properly communicate the difference also when using per-folder settings for loading external references. This in turn makes 746e02af07f7dc223940ad80a0a234c0aff85850 also work in that case. Taken from KDE patches and adapted to TDE. See https://phabricator.kde.org/D12393 and https://phabricator.kde.org/D12394 Signed-off-by: Slávek Banko (cherry picked from commit c8e1b254e243af4368f5430d8478f7a3a66d1fc6) --- kmail/kmmainwidget.cpp | 7 ++++--- kmail/kmreadermainwin.cpp | 4 ++-- kmail/kmreadermainwin.h | 2 +- kmail/kmreaderwin.cpp | 17 ++++++++++------- kmail/kmreaderwin.h | 19 ++++++++++++++++--- 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/kmail/kmmainwidget.cpp b/kmail/kmmainwidget.cpp index 8f883c58..c868c582 100644 --- a/kmail/kmmainwidget.cpp +++ b/kmail/kmmainwidget.cpp @@ -1386,7 +1386,7 @@ void KMMainWidget::slotOverrideHtmlLoadExt() } mFolderHtmlLoadExtPref = !mFolderHtmlLoadExtPref; if (mMsgView) { - mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref); + mMsgView->setHtmlLoadExtDefault(mFolderHtmlLoadExtPref); mMsgView->update( true ); } } @@ -2084,7 +2084,7 @@ void KMMainWidget::folderSelected( KMFolder* aFolder, bool forceJumpToUnread ) if (mMsgView) { mMsgView->setHtmlOverride(mFolderHtmlPref); - mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref); + mMsgView->setHtmlLoadExtDefault(mFolderHtmlLoadExtPref); } mHeaders->setFolder( mFolder, forceJumpToUnread ); updateMessageActions(); @@ -2140,7 +2140,8 @@ void KMMainWidget::slotMsgSelected(KMMessage *msg) } // reset HTML override to the folder setting mMsgView->setHtmlOverride(mFolderHtmlPref); - mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref); + mMsgView->setHtmlLoadExtDefault(mFolderHtmlLoadExtPref); + mMsgView->setHtmlLoadExtOverride(false); mMsgView->setDecryptMessageOverwrite( false ); mMsgView->setShowSignatureDetails( false ); } diff --git a/kmail/kmreadermainwin.cpp b/kmail/kmreadermainwin.cpp index 6694ba3f..06f6c771 100644 --- a/kmail/kmreadermainwin.cpp +++ b/kmail/kmreadermainwin.cpp @@ -50,7 +50,7 @@ #include "kmreadermainwin.h" -KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool htmlLoadExtOverride, +KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool htmlLoadExtDefault, char *name ) : KMail::SecondaryWindow( name ? name : "readerwindow#" ), mMsg( 0 ) @@ -59,7 +59,7 @@ KMReaderMainWin::KMReaderMainWin( bool htmlOverride, bool htmlLoadExtOverride, //mReaderWin->setShowCompleteMessage( true ); mReaderWin->setAutoDelete( true ); mReaderWin->setHtmlOverride( htmlOverride ); - mReaderWin->setHtmlLoadExtOverride( htmlLoadExtOverride ); + mReaderWin->setHtmlLoadExtDefault( htmlLoadExtDefault ); mReaderWin->setDecryptMessageOverwrite( true ); mReaderWin->setShowSignatureDetails( false ); initKMReaderMainWin(); diff --git a/kmail/kmreadermainwin.h b/kmail/kmreadermainwin.h index 2101fcb5..976f1066 100644 --- a/kmail/kmreadermainwin.h +++ b/kmail/kmreadermainwin.h @@ -26,7 +26,7 @@ class KMReaderMainWin : public KMail::SecondaryWindow public: - KMReaderMainWin( bool htmlOverride, bool htmlLoadExtOverride, char *name = 0 ); + KMReaderMainWin( bool htmlOverride, bool htmlLoadExtDefault, char *name = 0 ); KMReaderMainWin( char *name = 0 ); KMReaderMainWin(KMMessagePart* aMsgPart, bool aHTML, const TQString& aFileName, const TQString& pname, diff --git a/kmail/kmreaderwin.cpp b/kmail/kmreaderwin.cpp index a8153393..512f7ca8 100644 --- a/kmail/kmreaderwin.cpp +++ b/kmail/kmreaderwin.cpp @@ -462,6 +462,7 @@ KMReaderWin::KMReaderWin(TQWidget *aParent, readConfig(); mHtmlOverride = false; + mHtmlLoadExtDefault = false; mHtmlLoadExtOverride = false; mLevelQuote = GlobalSettings::self()->collapseQuoteLevelSpin() - 1; @@ -895,7 +896,6 @@ void KMReaderWin::readConfig(void) mToggleFixFontAction->setChecked( mUseFixedFont ); mHtmlMail = reader.readBoolEntry( "htmlMail", false ); - mHtmlLoadExternal = reader.readBoolEntry( "htmlLoadExternal", false ); setHeaderStyleAndStrategy( HeaderStyle::create( reader.readEntry( "header-style", "fancy" ) ), HeaderStrategy::create( reader.readEntry( "header-set-displayed", "rich" ) ) ); @@ -2471,11 +2471,14 @@ void KMReaderWin::setHtmlOverride(bool override) //----------------------------------------------------------------------------- -void KMReaderWin::setHtmlLoadExtOverride(bool override) +void KMReaderWin::setHtmlLoadExtDefault(bool loadExtDefault) { - mHtmlLoadExtOverride = override; - //if (message()) - // message()->setDecodeHTML(htmlMail()); + mHtmlLoadExtDefault = loadExtDefault; +} + +void KMReaderWin::setHtmlLoadExtOverride(bool loadExtOverride) +{ + mHtmlLoadExtOverride = loadExtOverride; } @@ -2500,8 +2503,8 @@ bool KMReaderWin::htmlLoadExternal() return mHtmlLoadExtOverride; } - return ((mHtmlLoadExternal && !mHtmlLoadExtOverride) || - (!mHtmlLoadExternal && mHtmlLoadExtOverride)); + return ((mHtmlLoadExtDefault && !mHtmlLoadExtOverride) || + (!mHtmlLoadExtDefault && mHtmlLoadExtOverride)); } diff --git a/kmail/kmreaderwin.h b/kmail/kmreaderwin.h index 239c0fc0..a3da9762 100644 --- a/kmail/kmreaderwin.h +++ b/kmail/kmreaderwin.h @@ -199,9 +199,22 @@ public: bool htmlOverride() const { return mHtmlOverride; } void setHtmlOverride( bool override ); - /** Override default load external references setting */ + /** Get the load external references override setting */ bool htmlLoadExtOverride() const { return mHtmlLoadExtOverride; } - void setHtmlLoadExtOverride( bool override ); + + /** Default behavior for loading external references. + * Use this for specifying the external reference loading behavior as + * specified in the user settings. + * @see setHtmlLoadExtOverride + */ + void setHtmlLoadExtDefault(bool loadExtDefault); + + /** Override default load external references setting + * @warning This must only be called when the user has explicitly + * been asked to retrieve external references! + * @see setHtmlLoadExtDefault + */ + void setHtmlLoadExtOverride(bool loadExtOverride); /** Is html mail to be supported? Takes into account override */ bool htmlMail(); @@ -540,7 +553,7 @@ private: TQString renderAttachments( partNode *node, const TQColor &bgColor ); private: - bool mHtmlMail, mHtmlLoadExternal, mHtmlOverride, mHtmlLoadExtOverride; + bool mHtmlMail, mHtmlLoadExtDefault, mHtmlOverride, mHtmlLoadExtOverride; int mAtmCurrent; TQString mAtmCurrentName; KMMessage *mMessage;