Fixed charset support:

- no more "Unknown charset" dialog, when no charset for message is specified
  - you can switch between charsets editing one message, this way kmail can
    send multilingual messages. Of coure encoded in Unicode ( only UTF-8 now,
    but I'll add UTF-7 support before KDE 1.0)
  - and some more fixes I don't remember

svn path=/trunk/kdenetwork/kmail/; revision=5646
wilder-work
jacek 28 years ago
parent 53a40e1baa
commit 04546a736d
  1. 58
      kmcomposewin.cpp
  2. 7
      kmcomposewin.h
  3. 1
      kmreaderwin.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: "<<kcharset.name()<<"\n";
mEditor->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: "<<kcharset.name()<<"\n";
mEditor->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: "<<srcCharset<<"\n";
if (srcCharset==destCharset) return;
int flags=mQuoteUnknownCharacters?KCharsetConverter::AMP_SEQUENCES:0;
KCharsetConverter conv(srcCharset,destCharset,flags);
KCharsetConversionResult result=conv.convert(inputStr);
mComposeCharset=charset;
mEditor->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: "<<kcharset.name()<<"\n";
mEditor->setFont(kcharset.setQFont(fnt));
}
#endif //CHARSETS
//=============================================================================

@ -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:

@ -212,6 +212,7 @@ void KMReaderWin::parseMsg(void)
mViewer->begin(mPicsDir);
mViewer->write("<HTML><BODY>");
#ifdef CHARSETS
printf("Setting viewer charset to %s\n",(const char *)mMsg->charset());
mViewer->setCharset(mMsg->charset());
#endif

Loading…
Cancel
Save