22 #include "ui_settings.h"
29 #include "messagecore/settings/globalsettings.h"
31 #include <KConfigDialogManager>
34 using namespace MessageViewer;
39 mSettingsUi =
new Ui_Settings;
40 mSettingsUi->setupUi(
this );
41 layout()->setContentsMargins( 0, 0, 0, 0 );
44 mSettingsUi->fallbackCharacterEncoding->addItems( encodings );
45 encodings.prepend( i18n(
"Auto" ) );
46 mSettingsUi->overrideCharacterEncoding->addItems( encodings );
47 mSettingsUi->overrideCharacterEncoding->setCurrentIndex( 0 );
49 mSettingsUi->fallbackCharacterEncoding->setWhatsThis(
50 MessageCore::GlobalSettings::self()->fallbackCharacterEncodingItem()->whatsThis() );
51 mSettingsUi->overrideCharacterEncoding->setWhatsThis(
52 MessageCore::GlobalSettings::self()->overrideCharacterEncodingItem()->whatsThis() );
53 mSettingsUi->kcfg_ShowEmoticons->setWhatsThis(
55 mSettingsUi->kcfg_ShrinkQuotes->setWhatsThis(
57 mSettingsUi->kcfg_ShowExpandQuotesMark->setWhatsThis(
60 connect( mSettingsUi->fallbackCharacterEncoding, SIGNAL(currentIndexChanged(
int)),
62 connect( mSettingsUi->overrideCharacterEncoding, SIGNAL(currentIndexChanged(
int)),
65 connect( mSettingsUi->configureCustomHeadersButton, SIGNAL(clicked()),
66 this, SLOT(showCustomHeadersDialog()) );
77 readCurrentFallbackCodec();
78 readCurrentOverrideCodec();
79 mSettingsUi->kcfg_CollapseQuoteLevelSpin->setEnabled(
85 MessageCore::GlobalSettings::self()->setFallbackCharacterEncoding(
87 MessageCore::GlobalSettings::self()->setOverrideCharacterEncoding(
88 mSettingsUi->overrideCharacterEncoding->currentIndex() == 0 ?
96 void ConfigureWidget::readCurrentFallbackCodec()
99 QStringList::ConstIterator it( encodings.constBegin() );
100 const QStringList::ConstIterator end( encodings.constEnd() );
101 const QString currentEncoding = MessageCore::GlobalSettings::self()->fallbackCharacterEncoding();
103 int indexOfLatin9 = 0;
105 for( ; it != end; ++it ) {
107 if ( encoding == QLatin1String(
"ISO-8859-15") )
109 if( encoding == currentEncoding ) {
110 mSettingsUi->fallbackCharacterEncoding->setCurrentIndex( i );
117 mSettingsUi->fallbackCharacterEncoding->setCurrentIndex( indexOfLatin9 );
120 void ConfigureWidget::readCurrentOverrideCodec()
122 const QString ¤tOverrideEncoding = MessageCore::GlobalSettings::self()->overrideCharacterEncoding();
123 if ( currentOverrideEncoding.isEmpty() ) {
124 mSettingsUi->overrideCharacterEncoding->setCurrentIndex( 0 );
128 encodings.prepend( i18n(
"Auto" ) );
129 QStringList::ConstIterator it( encodings.constBegin() );
130 const QStringList::ConstIterator end( encodings.constEnd() );
132 for( ; it != end; ++it ) {
134 mSettingsUi->overrideCharacterEncoding->setCurrentIndex( i );
139 if ( i == encodings.size() ) {
141 kWarning() <<
"Unknown override character encoding" << currentOverrideEncoding
142 <<
". Resetting to Auto.";
143 mSettingsUi->overrideCharacterEncoding->setCurrentIndex( 0 );
144 MessageCore::GlobalSettings::self()->setOverrideCharacterEncoding( QString() );
148 void ConfigureWidget::showCustomHeadersDialog()
151 dialog.setButtons( KDialog::Default | KDialog::Ok | KDialog::Cancel );
152 dialog.resize(500,250);
154 connect( &dialog, SIGNAL(defaultClicked()), widget, SLOT(resetToDefault()) );
156 dialog.setMainWidget( widget );
157 if ( dialog.exec() == QDialog::Accepted ) {
163 #include "configurewidget.moc"
static QStringList supportedEncodings(bool usAscii)
Return a list of the supported encodings.
static GlobalSettings * self()
static QString encodingForName(const QString &descriptiveName)
Drop-in replacement for KCharsets::encodingForName().