diff --git a/configuredialog/configureappearancepage.cpp b/configuredialog/configureappearancepage.cpp index e5ac1c282..0d6c1af45 100644 --- a/configuredialog/configureappearancepage.cpp +++ b/configuredialog/configureappearancepage.cpp @@ -248,58 +248,64 @@ void AppearancePage::FontsTab::slotFontSelectorChanged( int index ) void AppearancePage::FontsTab::doLoadOther() { - KConfigGroup fonts( KMKernel::self()->config(), "Fonts" ); - KConfigGroup messagelistFont( KMKernel::self()->config(), "MessageListView::Fonts" ); - - mFont[0] = KGlobalSettings::generalFont(); - QFont fixedFont = KGlobalSettings::fixedFont(); - - for ( int i = 0 ; i < numFontNames ; ++i ) { - const QString configName = QLatin1String(fontNames[i].configName); - if ( configName == QLatin1String( "MessageListFont" ) || - configName == QLatin1String( "UnreadMessageFont" ) || - configName == QLatin1String( "ImportantMessageFont" ) || - configName == QLatin1String( "TodoMessageFont" ) ) { - mFont[i] = messagelistFont.readEntry( configName, - (fontNames[i].onlyFixed) ? fixedFont : mFont[0] ); - } else { - mFont[i] = fonts.readEntry( configName, - (fontNames[i].onlyFixed) ? fixedFont : mFont[0] ); + if (KMKernel::self()) { + KConfigGroup fonts( KMKernel::self()->config(), "Fonts" ); + KConfigGroup messagelistFont( KMKernel::self()->config(), "MessageListView::Fonts" ); + + mFont[0] = KGlobalSettings::generalFont(); + QFont fixedFont = KGlobalSettings::fixedFont(); + + for ( int i = 0 ; i < numFontNames ; ++i ) { + const QString configName = QLatin1String(fontNames[i].configName); + if ( configName == QLatin1String( "MessageListFont" ) || + configName == QLatin1String( "UnreadMessageFont" ) || + configName == QLatin1String( "ImportantMessageFont" ) || + configName == QLatin1String( "TodoMessageFont" ) ) { + mFont[i] = messagelistFont.readEntry( configName, + (fontNames[i].onlyFixed) ? fixedFont : mFont[0] ); + } else { + mFont[i] = fonts.readEntry( configName, + (fontNames[i].onlyFixed) ? fixedFont : mFont[0] ); + } } + mCustomFontCheck->setChecked( !MessageCore::GlobalSettings::self()->useDefaultFonts() ); + mFontLocationCombo->setCurrentIndex( 0 ); + slotFontSelectorChanged( 0 ); + } else { + setEnabled(false); } - mCustomFontCheck->setChecked( !MessageCore::GlobalSettings::self()->useDefaultFonts() ); - mFontLocationCombo->setCurrentIndex( 0 ); - slotFontSelectorChanged( 0 ); } void AppearancePage::FontsTab::save() { - KConfigGroup fonts( KMKernel::self()->config(), "Fonts" ); - KConfigGroup messagelistFont( KMKernel::self()->config(), "MessageListView::Fonts" ); - - // read the current font (might have been modified) - if ( mActiveFontIndex >= 0 ) - mFont[ mActiveFontIndex ] = mFontChooser->font(); - - const bool customFonts = mCustomFontCheck->isChecked(); - MessageCore::GlobalSettings::self()->setUseDefaultFonts( !customFonts ); - - for ( int i = 0 ; i < numFontNames ; ++i ) { - const QString configName = QLatin1String(fontNames[i].configName); - if ( configName == QLatin1String( "MessageListFont" ) || - configName == QLatin1String( "UnreadMessageFont" ) || - configName == QLatin1String( "ImportantMessageFont" ) || - configName == QLatin1String( "TodoMessageFont" ) ) { - if ( customFonts || messagelistFont.hasKey( configName ) ) { - // Don't write font info when we use default fonts, but write - // if it's already there: - messagelistFont.writeEntry( configName, mFont[i] ); + if (KMKernel::self()) { + KConfigGroup fonts( KMKernel::self()->config(), "Fonts" ); + KConfigGroup messagelistFont( KMKernel::self()->config(), "MessageListView::Fonts" ); + + // read the current font (might have been modified) + if ( mActiveFontIndex >= 0 ) + mFont[ mActiveFontIndex ] = mFontChooser->font(); + + const bool customFonts = mCustomFontCheck->isChecked(); + MessageCore::GlobalSettings::self()->setUseDefaultFonts( !customFonts ); + + for ( int i = 0 ; i < numFontNames ; ++i ) { + const QString configName = QLatin1String(fontNames[i].configName); + if ( configName == QLatin1String( "MessageListFont" ) || + configName == QLatin1String( "UnreadMessageFont" ) || + configName == QLatin1String( "ImportantMessageFont" ) || + configName == QLatin1String( "TodoMessageFont" ) ) { + if ( customFonts || messagelistFont.hasKey( configName ) ) { + // Don't write font info when we use default fonts, but write + // if it's already there: + messagelistFont.writeEntry( configName, mFont[i] ); + } + } else { + if ( customFonts || fonts.hasKey( configName ) ) + // Don't write font info when we use default fonts, but write + // if it's already there: + fonts.writeEntry( configName, mFont[i] ); } - } else { - if ( customFonts || fonts.hasKey( configName ) ) - // Don't write font info when we use default fonts, but write - // if it's already there: - fonts.writeEntry( configName, mFont[i] ); } } } @@ -407,54 +413,58 @@ void AppearancePage::ColorsTab::doLoadOther() void AppearancePage::ColorsTab::loadColor( bool loadFromConfig ) { - KColorScheme scheme( QPalette::Active, KColorScheme::View ); - - KConfigGroup reader( KMKernel::self()->config(), "Reader" ); - - KConfigGroup messageListView( KMKernel::self()->config(), "MessageListView::Colors" ); - - KConfigGroup collectionFolderView( KMKernel::self()->config(), "CollectionFolderView" ); - - static const QColor defaultColor[ numColorNames ] = { - KMail::Util::quoteL1Color(), - KMail::Util::quoteL2Color(), - KMail::Util::quoteL3Color(), - scheme.foreground( KColorScheme::LinkText ).color(), // link - scheme.foreground( KColorScheme::VisitedText ).color(),// visited link - scheme.foreground( KColorScheme::NegativeText ).color(), // misspelled words - MessageList::Util::unreadDefaultMessageColor(), // unread mgs - MessageList::Util::importantDefaultMessageColor(), // important msg - MessageList::Util::todoDefaultMessageColor(), // action item mgs - QColor( 0x00, 0x80, 0xFF ), // pgp encrypted - scheme.background( KColorScheme::PositiveBackground ).color(), // pgp ok, trusted key - QColor( 0xFF, 0xFF, 0x40 ), // pgp ok, untrusted key - QColor( 0xFF, 0xFF, 0x40 ), // pgp unchk - Qt::red, // pgp bad - QColor( 0xFF, 0x40, 0x40 ), // warning text color - MailCommon::Util::defaultQuotaColor(), // close to quota - Qt::lightGray, // colorbar plain bg - Qt::black, // colorbar plain fg - Qt::black, // colorbar html bg - Qt::white, // colorbar html fg - scheme.foreground(KColorScheme::NegativeText).color(), //Broken Account Color - scheme.background().color() // reader background color - }; - - for ( int i = 0 ; i < numColorNames ; ++i ) { - if ( loadFromConfig ) { - const QString configName = QLatin1String(colorNames[i].configName); - if ( configName == QLatin1String( "UnreadMessageColor" ) || - configName == QLatin1String( "ImportantMessageColor" ) || - configName == QLatin1String( "TodoMessageColor" ) ) { - mColorList->setColorSilently( i, messageListView.readEntry( configName, defaultColor[i] ) ); - } else if( configName == QLatin1String("BrokenAccountColor")) { - mColorList->setColorSilently( i, collectionFolderView.readEntry(configName,defaultColor[i])); + if (KMKernel::self()) { + KColorScheme scheme( QPalette::Active, KColorScheme::View ); + + KConfigGroup reader( KMKernel::self()->config(), "Reader" ); + + KConfigGroup messageListView( KMKernel::self()->config(), "MessageListView::Colors" ); + + KConfigGroup collectionFolderView( KMKernel::self()->config(), "CollectionFolderView" ); + + static const QColor defaultColor[ numColorNames ] = { + KMail::Util::quoteL1Color(), + KMail::Util::quoteL2Color(), + KMail::Util::quoteL3Color(), + scheme.foreground( KColorScheme::LinkText ).color(), // link + scheme.foreground( KColorScheme::VisitedText ).color(),// visited link + scheme.foreground( KColorScheme::NegativeText ).color(), // misspelled words + MessageList::Util::unreadDefaultMessageColor(), // unread mgs + MessageList::Util::importantDefaultMessageColor(), // important msg + MessageList::Util::todoDefaultMessageColor(), // action item mgs + QColor( 0x00, 0x80, 0xFF ), // pgp encrypted + scheme.background( KColorScheme::PositiveBackground ).color(), // pgp ok, trusted key + QColor( 0xFF, 0xFF, 0x40 ), // pgp ok, untrusted key + QColor( 0xFF, 0xFF, 0x40 ), // pgp unchk + Qt::red, // pgp bad + QColor( 0xFF, 0x40, 0x40 ), // warning text color + MailCommon::Util::defaultQuotaColor(), // close to quota + Qt::lightGray, // colorbar plain bg + Qt::black, // colorbar plain fg + Qt::black, // colorbar html bg + Qt::white, // colorbar html fg + scheme.foreground(KColorScheme::NegativeText).color(), //Broken Account Color + scheme.background().color() // reader background color + }; + + for ( int i = 0 ; i < numColorNames ; ++i ) { + if ( loadFromConfig ) { + const QString configName = QLatin1String(colorNames[i].configName); + if ( configName == QLatin1String( "UnreadMessageColor" ) || + configName == QLatin1String( "ImportantMessageColor" ) || + configName == QLatin1String( "TodoMessageColor" ) ) { + mColorList->setColorSilently( i, messageListView.readEntry( configName, defaultColor[i] ) ); + } else if( configName == QLatin1String("BrokenAccountColor")) { + mColorList->setColorSilently( i, collectionFolderView.readEntry(configName,defaultColor[i])); + } else { + mColorList->setColorSilently( i, reader.readEntry( configName, defaultColor[i] ) ); + } } else { - mColorList->setColorSilently( i, reader.readEntry( configName, defaultColor[i] ) ); + mColorList->setColorSilently( i, defaultColor[i] ); } - } else { - mColorList->setColorSilently( i, defaultColor[i] ); } + } else { + setEnabled(false); } } @@ -468,6 +478,8 @@ void AppearancePage::ColorsTab::doResetToDefaultsOther() void AppearancePage::ColorsTab::save() { + if (!KMKernel::self()) + return; KConfigGroup reader( KMKernel::self()->config(), "Reader" ); KConfigGroup messageListView( KMKernel::self()->config(), "MessageListView::Colors" ); KConfigGroup collectionFolderView( KMKernel::self()->config(), "CollectionFolderView" ); diff --git a/configuredialog/configurecomposerpage.cpp b/configuredialog/configurecomposerpage.cpp index 1bb680a3e..ef7f15318 100644 --- a/configuredialog/configurecomposerpage.cpp +++ b/configuredialog/configurecomposerpage.cpp @@ -895,6 +895,7 @@ ComposerPageCharsetTab::ComposerPageCharsetTab( QWidget * parent ) connect( mCharsetListEditor, SIGNAL(aboutToAdd(QString&)), this, SLOT(slotVerifyCharset(QString&)) ); + setEnabled(kmkernel); } void ComposerPage::CharsetTab::slotVerifyCharset( QString & charset ) @@ -927,6 +928,8 @@ void ComposerPage::CharsetTab::slotVerifyCharset( QString & charset ) void ComposerPage::CharsetTab::doLoadOther() { + if (!kmkernel) + return; QStringList charsets = MessageComposer::MessageComposerSettings::preferredCharsets(); QStringList::Iterator end( charsets.end() ); for ( QStringList::Iterator it = charsets.begin() ; @@ -955,6 +958,8 @@ void ComposerPage::CharsetTab::doResetToDefaultsOther() void ComposerPage::CharsetTab::save() { + if (!kmkernel) + return; QStringList charsetList = mCharsetListEditor->stringList(); QStringList::Iterator it = charsetList.begin(); QStringList::Iterator end = charsetList.end(); diff --git a/configuredialog/configurestorageservicewidget.cpp b/configuredialog/configurestorageservicewidget.cpp index b5003e7d0..4cd514227 100644 --- a/configuredialog/configurestorageservicewidget.cpp +++ b/configuredialog/configurestorageservicewidget.cpp @@ -53,7 +53,11 @@ ConfigureStorageServiceWidget::ConfigureStorageServiceWidget(QWidget *parent) } QList lstCapabilities; lstCapabilities << PimCommon::StorageServiceAbstract::ShareLinkCapability; - mStorageServiceWidget->setListService(KMKernel::self()->storageServiceManager()->listService(), lstCapabilities); + if (KMKernel::self() && KMKernel::self()->storageServiceManager()) { + mStorageServiceWidget->setListService(KMKernel::self()->storageServiceManager()->listService(), lstCapabilities); + } else { + mStorageServiceWidget->setEnabled(false); + } setLayout(lay); } @@ -71,7 +75,8 @@ void ConfigureStorageServiceWidget::slotManageStorageService() void ConfigureStorageServiceWidget::save() { - KMKernel::self()->storageServiceManager()->setListService(mStorageServiceWidget->listService()); + if (KMKernel::self() && KMKernel::self()->storageServiceManager()) + KMKernel::self()->storageServiceManager()->setListService(mStorageServiceWidget->listService()); } void ConfigureStorageServiceWidget::doLoadFromGlobalSettings()