diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index b6675c26c..fd057b25d 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -157,6 +157,11 @@ KMComposeWin::KMComposeWin(KMMessage *aMsg) : KMComposeWinInherited(), windowList->append(this); +#ifdef CHARSETS + // As family may change with charset, we must save original settings + mSavedEditorFont=mEditor->font(); +#endif + mMsg = NULL; if (aMsg) setMsg(aMsg); @@ -735,15 +740,9 @@ void KMComposeWin::setMsg(KMMessage* newMsg, bool mayAutoSign) if (mAutoSign && mayAutoSign) slotAppendSignature(); mEditor->toggleModified(FALSE); - + #ifdef CHARSETS - // Jacek: We must set proper font for displaing message in known charset - QFont fnt=mEditor->font(); - KCharset kcharset; - if (mComposeCharset=="default") kcharset=klocale->charset(); - else kcharset=mComposeCharset; - cout<<"Setting font to: "<setFont(kcharset.setQFont(fnt)); + setEditCharset(); #endif } @@ -1634,22 +1633,17 @@ void KMComposeWin::slotSetCharsets(const char *message,const char *composer, { #ifdef CHARSETS mCharset=message; - mComposeCharset=composer; m7BitAscii=ascii; + if (composer!=mComposeCharset && quote) + transcodeMessageTo(composer); + mComposeCharset=composer; mQuoteUnknownCharacters=quote; if (def) { mDefaultCharset=message; mDefComposeCharset=composer; } - - // Jacek: We must set proper font for displaing message in known charset - QFont fnt=mEditor->font(); - KCharset kcharset; - if (mComposeCharset=="default") kcharset=klocale->charset(); - else kcharset=mComposeCharset; - cout<<"Setting font to: "<setFont(kcharset.setQFont(fnt)); + setEditCharset(); #endif } @@ -1719,9 +1713,37 @@ QString KMComposeWin::convertToSend(const QString str) KCharsetConversionResult result=conv.convert(str); return result.copy(); } -#endif //CHARSETS +//----------------------------------------------------------------------------- +void KMComposeWin::transcodeMessageTo(const QString charset) +{ + + cout<<"Transcoding message...\n"; + QString inputStr=mEditor->text(); + KCharset srcCharset; + KCharset destCharset(charset); + if (mComposeCharset=="default") srcCharset=klocale->charset(); + else srcCharset=mComposeCharset; + cout<<"srcCharset: "<setText(result.copy()); +} +void KMComposeWin::setEditCharset(){ + + QFont fnt=mSavedEditorFont; + KCharset kcharset; + if (mComposeCharset=="default") kcharset=klocale->charset(); + else if (mComposeCharset!="") kcharset=mComposeCharset; + cout<<"Setting font to: "<setFont(kcharset.setQFont(fnt)); +} + +#endif //CHARSETS //============================================================================= diff --git a/kmcomposewin.h b/kmcomposewin.h index 6f5846232..07295e0b0 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -229,8 +229,14 @@ private: /** Converts message text for sending. */ QString convertToSend(const QString str); + /** Converts message text for sending. */ + void transcodeMessageTo(const QString newCharset); + /** Test if string has any 8-bit characters */ bool is8Bit(const QString str); + + /** Set edit widget charset */ + void setEditCharset(); #endif protected: @@ -274,6 +280,7 @@ protected: QString mDefComposeCharset; QString mComposeCharset; int mQuoteUnknownCharacters; + QFont mSavedEditorFont; #endif private: diff --git a/kmreaderwin.cpp b/kmreaderwin.cpp index 44f1bb7bf..45c2fdfbb 100644 --- a/kmreaderwin.cpp +++ b/kmreaderwin.cpp @@ -212,6 +212,7 @@ void KMReaderWin::parseMsg(void) mViewer->begin(mPicsDir); mViewer->write(""); #ifdef CHARSETS + printf("Setting viewer charset to %s\n",(const char *)mMsg->charset()); mViewer->setCharset(mMsg->charset()); #endif