19 #include "pimcommon/widgets/configureimmutablewidgetutils.h"
20 using namespace PimCommon::ConfigureImmutableWidgetUtils;
22 #include "messagelist/utils/aggregationcombobox.h"
23 #include "messagelist/utils/aggregationconfigbutton.h"
24 #include "messagelist/utils/themecombobox.h"
25 #include "messagelist/utils/themeconfigbutton.h"
26 #include "mailcommon/tag/tagwidget.h"
27 #include "mailcommon/tag/tag.h"
30 #include "foldertreewidget.h"
34 #include "foldertreewidget.h"
36 #include "mailcommon/mailcommonsettings_base.h"
38 #include "messageviewer/widgets/configurewidget.h"
39 #include "messageviewer/settings/globalsettings.h"
41 #include "messagelist/core/settings.h"
42 #include "messagelist/messagelistutil.h"
43 #include "messagecore/settings/globalsettings.h"
46 #include "mailcommon/util/mailutil.h"
48 #include <Akonadi/Tag>
49 #include <Akonadi/TagFetchJob>
50 #include <Akonadi/TagFetchScope>
51 #include <Akonadi/TagDeleteJob>
52 #include <Akonadi/TagCreateJob>
53 #include <Akonadi/TagAttribute>
54 #include <Akonadi/TagModifyJob>
56 #include <KIconButton>
57 #include <KButtonGroup>
58 #include <KLocalizedString>
59 #include <KColorScheme>
61 #include <KFontChooser>
63 #include <KMessageBox>
64 #include <KKeySequenceWidget>
68 #include <kmime/kmime_dateformatter.h>
69 using KMime::DateFormatter;
72 #include <QButtonGroup>
76 #include <widgets/gravatarconfigwidget.h>
77 using namespace MailCommon;
91 addTab( mFontsTab, i18n(
"Fonts") );
97 addTab( mColorsTab, i18n(
"Colors") );
103 addTab( mLayoutTab, i18n(
"Layout") );
109 addTab( mHeadersTab, i18n(
"Message List") );
115 addTab( mReaderTab, i18n(
"Message Window") );
116 addConfig( MessageViewer::GlobalSettings::self(), mReaderTab );
122 addTab( mSystemTrayTab, i18n(
"System Tray") );
128 addTab( mMessageTagTab, i18n(
"Message Tags") );
137 static const struct {
143 {
"body-font", I18N_NOOP(
"Message Body"),
true,
false },
144 {
"MessageListFont", I18N_NOOP(
"Message List"),
true,
false },
145 {
"UnreadMessageFont", I18N_NOOP(
"Message List - Unread Messages"),
true,
false },
146 {
"ImportantMessageFont", I18N_NOOP(
"Message List - Important Messages"),
true,
false },
147 {
"TodoMessageFont", I18N_NOOP(
"Message List - Action Item Messages"),
true,
false },
148 {
"folder-font", I18N_NOOP(
"Folder List"),
true,
false },
149 {
"quote1-font", I18N_NOOP(
"Quoted Text - First Level"),
false,
false },
150 {
"quote2-font", I18N_NOOP(
"Quoted Text - Second Level"),
false,
false },
151 {
"quote3-font", I18N_NOOP(
"Quoted Text - Third Level"),
false,
false },
152 {
"fixed-font", I18N_NOOP(
"Fixed Width Font"),
true,
true },
153 {
"composer-font", I18N_NOOP(
"Composer"),
true,
false },
154 {
"print-font", I18N_NOOP(
"Printing Output"),
true,
false },
166 vlay->
setMargin( KDialog::marginHint() );
167 mCustomFontCheck =
new QCheckBox( i18n(
"&Use custom fonts"),
this );
169 vlay->
addWidget(
new KSeparator( Qt::Horizontal,
this ) );
170 connect ( mCustomFontCheck, SIGNAL(stateChanged(
int)),
176 mFontLocationCombo =
new KComboBox(
this );
177 mFontLocationCombo->setEditable(
false );
178 mFontLocationCombo->setEnabled(
false );
183 mFontLocationCombo->addItems( fontDescriptions );
186 label->
setBuddy( mFontLocationCombo );
193 mFontChooser =
new KFontChooser(
this, KFontChooser::DisplayFrame,
195 mFontChooser->setEnabled(
false );
202 connect( mCustomFontCheck, SIGNAL(toggled(
bool)),
204 connect( mCustomFontCheck, SIGNAL(toggled(
bool)),
206 connect( mCustomFontCheck, SIGNAL(toggled(
bool)),
209 connect( mFontLocationCombo, SIGNAL(activated(
int)),
210 this, SLOT(slotFontSelectorChanged(
int)) );
214 void AppearancePage::FontsTab::slotFontSelectorChanged(
int index )
216 kDebug() <<
"slotFontSelectorChanged() called";
217 if( index < 0 || index >= mFontLocationCombo->count() )
221 if( mActiveFontIndex == 0 ) {
222 mFont[0] = mFontChooser->font();
232 }
else if ( mActiveFontIndex > 0 )
233 mFont[ mActiveFontIndex ] = mFontChooser->font();
234 mActiveFontIndex = index;
247 mFontChooser->enableColumn( KFontChooser::FamilyList|KFontChooser::SizeList,
248 fontNames[ index ].enableFamilyAndSize );
251 void AppearancePage::FontsTab::doLoadOther()
255 KConfigGroup messagelistFont(
KMKernel::self()->config(),
"MessageListView::Fonts" );
257 mFont[0] = KGlobalSettings::generalFont();
258 QFont fixedFont = KGlobalSettings::fixedFont();
266 mFont[i] = messagelistFont.readEntry( configName,
267 (
fontNames[i].onlyFixed) ? fixedFont : mFont[0] );
269 mFont[i] = fonts.readEntry( configName,
270 (
fontNames[i].onlyFixed) ? fixedFont : mFont[0] );
273 mCustomFontCheck->
setChecked( !MessageCore::GlobalSettings::self()->useDefaultFonts() );
274 mFontLocationCombo->setCurrentIndex( 0 );
275 slotFontSelectorChanged( 0 );
285 KConfigGroup messagelistFont(
KMKernel::self()->config(),
"MessageListView::Fonts" );
288 if ( mActiveFontIndex >= 0 )
289 mFont[ mActiveFontIndex ] = mFontChooser->font();
291 const bool customFonts = mCustomFontCheck->
isChecked();
292 MessageCore::GlobalSettings::self()->setUseDefaultFonts( !customFonts );
300 if ( customFonts || messagelistFont.hasKey( configName ) ) {
303 messagelistFont.writeEntry( configName, mFont[i] );
306 if ( customFonts || fonts.hasKey( configName ) )
309 fonts.writeEntry( configName, mFont[i] );
315 void AppearancePage::FontsTab::doResetToDefaultsOther()
326 static const struct {
330 {
"QuotedText1", I18N_NOOP(
"Quoted Text - First Level") },
331 {
"QuotedText2", I18N_NOOP(
"Quoted Text - Second Level") },
332 {
"QuotedText3", I18N_NOOP(
"Quoted Text - Third Level") },
333 {
"LinkColor", I18N_NOOP(
"Link") },
334 {
"FollowedColor", I18N_NOOP(
"Followed Link") },
335 {
"MisspelledColor", I18N_NOOP(
"Misspelled Words") },
336 {
"UnreadMessageColor", I18N_NOOP(
"Unread Message") },
337 {
"ImportantMessageColor", I18N_NOOP(
"Important Message") },
338 {
"TodoMessageColor", I18N_NOOP(
"Action Item Message") },
339 {
"PGPMessageEncr", I18N_NOOP(
"OpenPGP Message - Encrypted") },
340 {
"PGPMessageOkKeyOk", I18N_NOOP(
"OpenPGP Message - Valid Signature with Trusted Key") },
341 {
"PGPMessageOkKeyBad", I18N_NOOP(
"OpenPGP Message - Valid Signature with Untrusted Key") },
342 {
"PGPMessageWarn", I18N_NOOP(
"OpenPGP Message - Unchecked Signature") },
343 {
"PGPMessageErr", I18N_NOOP(
"OpenPGP Message - Bad Signature") },
344 {
"HTMLWarningColor", I18N_NOOP(
"Border Around Warning Prepending HTML Messages") },
345 {
"CloseToQuotaColor", I18N_NOOP(
"Folder Name and Size When Close to Quota") },
346 {
"ColorbarBackgroundPlain", I18N_NOOP(
"HTML Status Bar Background - No HTML Message") },
347 {
"ColorbarForegroundPlain", I18N_NOOP(
"HTML Status Bar Foreground - No HTML Message") },
348 {
"ColorbarBackgroundHTML", I18N_NOOP(
"HTML Status Bar Background - HTML Message") },
349 {
"ColorbarForegroundHTML", I18N_NOOP(
"HTML Status Bar Foreground - HTML Message") },
350 {
"BrokenAccountColor", I18N_NOOP(
"Broken Account - Folder Text Color") },
351 {
"BackgroundColor", I18N_NOOP(
"Background Color") },
361 vlay->
setMargin( KDialog::marginHint() );
362 mCustomColorCheck =
new QCheckBox( i18n(
"&Use custom colors"),
this );
364 connect( mCustomColorCheck, SIGNAL(stateChanged(
int)),
376 new QCheckBox( i18n(
"Recycle colors on deep "ing"),
this );
379 connect( mRecycleColorCheck, SIGNAL(stateChanged(
int)),
385 QLabel *l =
new QLabel( i18n(
"Close to quota threshold:"),
this );
387 mCloseToQuotaThreshold =
new QSpinBox(
this );
388 mCloseToQuotaThreshold->
setRange( 0, 100 );
390 connect( mCloseToQuotaThreshold, SIGNAL(valueChanged(
int)),
392 mCloseToQuotaThreshold->
setSuffix( i18n(
"%"));
394 hbox->
addWidget( mCloseToQuotaThreshold );
398 connect( mCustomColorCheck, SIGNAL(toggled(
bool)),
400 connect( mCustomColorCheck, SIGNAL(toggled(
bool)),
402 connect( mCustomColorCheck, SIGNAL(stateChanged(
int)),
408 void AppearancePage::ColorsTab::doLoadOther()
410 mCustomColorCheck->
setChecked( !MessageCore::GlobalSettings::self()->useDefaultColors() );
411 mRecycleColorCheck->
setChecked( MessageViewer::GlobalSettings::self()->recycleQuoteColors() );
416 void AppearancePage::ColorsTab::loadColor(
bool loadFromConfig )
419 KColorScheme scheme( QPalette::Active, KColorScheme::View );
423 KConfigGroup messageListView(
KMKernel::self()->config(),
"MessageListView::Colors" );
425 KConfigGroup collectionFolderView(
KMKernel::self()->config(),
"CollectionFolderView" );
431 scheme.foreground( KColorScheme::LinkText ).color(),
432 scheme.foreground( KColorScheme::VisitedText ).color(),
433 scheme.foreground( KColorScheme::NegativeText ).color(),
434 MessageList::Util::unreadDefaultMessageColor(),
435 MessageList::Util::importantDefaultMessageColor(),
436 MessageList::Util::todoDefaultMessageColor(),
437 QColor( 0x00, 0x80, 0xFF ),
438 scheme.background( KColorScheme::PositiveBackground ).color(),
439 QColor( 0xFF, 0xFF, 0x40 ),
440 QColor( 0xFF, 0xFF, 0x40 ),
442 QColor( 0xFF, 0x40, 0x40 ),
443 MailCommon::Util::defaultQuotaColor(),
448 scheme.foreground(KColorScheme::NegativeText).color(),
449 scheme.background().color()
453 if ( loadFromConfig ) {
458 mColorList->
setColorSilently( i, messageListView.readEntry( configName, defaultColor[i] ) );
459 }
else if( configName ==
QLatin1String(
"BrokenAccountColor")) {
460 mColorList->
setColorSilently( i, collectionFolderView.readEntry(configName,defaultColor[i]));
462 mColorList->
setColorSilently( i, reader.readEntry( configName, defaultColor[i] ) );
473 void AppearancePage::ColorsTab::doResetToDefaultsOther()
477 mCloseToQuotaThreshold->
setValue( 80 );
486 KConfigGroup messageListView(
KMKernel::self()->config(),
"MessageListView::Colors" );
487 KConfigGroup collectionFolderView(
KMKernel::self()->config(),
"CollectionFolderView" );
488 bool customColors = mCustomColorCheck->
isChecked();
489 MessageCore::GlobalSettings::self()->setUseDefaultColors( !customColors );
491 KColorScheme scheme( QPalette::Active, KColorScheme::View );
500 if ( customColors || messageListView.hasKey( configName ) )
501 messageListView.writeEntry( configName, mColorList->
color(i) );
503 }
else if( configName ==
QLatin1String(
"BrokenAccountColor")) {
504 if ( customColors || collectionFolderView.hasKey( configName ) )
505 collectionFolderView.writeEntry(configName,mColorList->
color(i));
507 if (customColors && (mColorList->
color(i) != scheme.background().color() ))
508 reader.writeEntry(configName, mColorList->
color(i));
510 if ( customColors || reader.hasKey( configName ) )
511 reader.writeEntry( configName, mColorList->
color(i) );
514 MessageViewer::GlobalSettings::self()->setRecycleQuoteColors( mRecycleColorCheck->
isChecked() );
528 vlay->
setMargin( KDialog::marginHint() );
531 populateButtonGroup( mFolderListGroupBox =
new QGroupBox(
this ),
535 connect( mFolderListGroup, SIGNAL (buttonClicked(
int)),
539 mFolderQuickSearchCB =
new QCheckBox( i18n(
"Show folder quick search field"),
this );
541 folderCBHLayout->
addWidget( mFolderQuickSearchCB );
546 mFavoriteFoldersViewGroupBox =
new QGroupBox(
this );
547 mFavoriteFoldersViewGroupBox->
setTitle( i18n(
"Show Favorite Folders View" ) );
549 mFavoriteFoldersViewGroupBox->
layout()->
setSpacing( KDialog::spacingHint() );
551 connect( mFavoriteFoldersViewGroup, SIGNAL(buttonClicked(
int)),
555 mFavoriteFoldersViewGroup->
addButton( favoriteFoldersViewHiddenRadio, static_cast<int>( MailCommon::MailCommonSettings::EnumFavoriteCollectionViewMode::HiddenMode ) );
556 mFavoriteFoldersViewGroupBox->
layout()->
addWidget( favoriteFoldersViewHiddenRadio );
559 mFavoriteFoldersViewGroup->
addButton( favoriteFoldersViewIconsRadio, static_cast<int>( MailCommon::MailCommonSettings::EnumFavoriteCollectionViewMode::IconMode ) );
560 mFavoriteFoldersViewGroupBox->
layout()->
addWidget( favoriteFoldersViewIconsRadio );
563 mFavoriteFoldersViewGroup->
addButton( favoriteFoldersViewListRadio, static_cast<int>( MailCommon::MailCommonSettings::EnumFavoriteCollectionViewMode::ListMode ) );
564 mFavoriteFoldersViewGroupBox->
layout()->
addWidget( favoriteFoldersViewListRadio );
566 vlay->
addWidget( mFavoriteFoldersViewGroupBox );
570 mFolderToolTipsGroupBox =
new QGroupBox(
this );
571 mFolderToolTipsGroupBox->
setTitle( i18n(
"Folder Tooltips" ) );
575 connect( mFolderToolTipsGroup, SIGNAL(buttonClicked(
int)),
579 mFolderToolTipsGroup->
addButton( folderToolTipsAlwaysRadio, static_cast< int >( FolderTreeWidget::DisplayAlways ) );
580 mFolderToolTipsGroupBox->
layout()->
addWidget( folderToolTipsAlwaysRadio );
583 mFolderToolTipsGroup->
addButton( folderToolTipsNeverRadio, static_cast< int >( FolderTreeWidget::DisplayNever ) );
584 mFolderToolTipsGroupBox->
layout()->
addWidget( folderToolTipsNeverRadio );
586 vlay->
addWidget( mFolderToolTipsGroupBox );
589 populateButtonGroup( mReaderWindowModeGroupBox =
new QGroupBox(
this ),
592 vlay->
addWidget( mReaderWindowModeGroupBox );
593 connect( mReaderWindowModeGroup, SIGNAL (buttonClicked(
int)),
599 void AppearancePage::LayoutTab::doLoadOther()
602 loadWidget( mReaderWindowModeGroupBox, mReaderWindowModeGroup,
GlobalSettings::self()->readerWindowModeItem() );
603 loadWidget( mFavoriteFoldersViewGroupBox, mFavoriteFoldersViewGroup, MailCommon::MailCommonSettings::self()->favoriteCollectionViewModeItem() );
606 if ( checkedFolderToolTipsPolicy >= 0 )
607 mFolderToolTipsGroup->
button(checkedFolderToolTipsPolicy)->
setChecked(
true );
614 saveButtonGroup( mFavoriteFoldersViewGroup, MailCommon::MailCommonSettings::self()->favoriteCollectionViewModeItem() );
628 static const struct {
632 { I18N_NOOP(
"Sta&ndard format (%1)"), KMime::DateFormatter::CTime },
633 { I18N_NOOP(
"Locali&zed format (%1)"), KMime::DateFormatter::Localized },
634 { I18N_NOOP(
"Smart for&mat (%1)"), KMime::DateFormatter::Fancy },
635 { I18N_NOOP(
"C&ustom format:"), KMime::DateFormatter::Custom }
642 mCustomDateFormatEdit( 0 )
646 vlay->
setMargin( KDialog::marginHint() );
649 QGroupBox *group =
new QGroupBox( i18nc(
"General options for the message list.",
"General" ),
this );
655 MessageList::Core::Settings::self()->messageToolTipEnabledItem()->label(), group );
656 gvlay->
addWidget( mDisplayMessageToolTips );
658 connect( mDisplayMessageToolTips, SIGNAL(stateChanged(
int)),
661 mHideTabBarWithSingleTab =
new QCheckBox(
662 MessageList::Core::Settings::self()->autoHideTabBarWithSingleTabItem()->label(), group );
663 gvlay->
addWidget( mHideTabBarWithSingleTab );
665 connect( mHideTabBarWithSingleTab, SIGNAL(stateChanged(
int)),
669 MessageList::Core::Settings::self()->tabsHaveCloseButtonItem()->label(), group );
670 gvlay->
addWidget( mTabsHaveCloseButton );
672 connect( mTabsHaveCloseButton, SIGNAL(stateChanged(
int)),
676 using MessageList::Utils::AggregationComboBox;
677 mAggregationComboBox =
new AggregationComboBox( group );
679 QLabel* aggregationLabel =
new QLabel( i18n(
"Default aggregation:" ), group );
680 aggregationLabel->
setBuddy( mAggregationComboBox );
682 using MessageList::Utils::AggregationConfigButton;
683 AggregationConfigButton * aggregationConfigButton =
new AggregationConfigButton( group, mAggregationComboBox );
686 aggregationLayout->
addWidget( aggregationLabel, 1 );
687 aggregationLayout->
addWidget( mAggregationComboBox, 1 );
688 aggregationLayout->
addWidget( aggregationConfigButton, 0 );
691 connect( aggregationConfigButton, SIGNAL(configureDialogCompleted()),
692 this, SLOT(slotSelectDefaultAggregation()) );
693 connect( mAggregationComboBox, SIGNAL(activated(
int)),
697 using MessageList::Utils::ThemeComboBox;
698 mThemeComboBox =
new ThemeComboBox( group );
700 QLabel *themeLabel =
new QLabel( i18n(
"Default theme:" ), group );
701 themeLabel->
setBuddy( mThemeComboBox );
703 using MessageList::Utils::ThemeConfigButton;
704 ThemeConfigButton * themeConfigButton =
new ThemeConfigButton( group, mThemeComboBox );
708 themeLayout->
addWidget( mThemeComboBox, 1 );
709 themeLayout->
addWidget( themeConfigButton, 0 );
712 connect( themeConfigButton, SIGNAL(configureDialogCompleted()),
713 this, SLOT(slotSelectDefaultTheme()) );
714 connect( mThemeComboBox, SIGNAL(activated(
int)),
720 mDateDisplay =
new KButtonGroup(
this );
721 mDateDisplay->setTitle( i18n(
"Date Display") );
731 buttonLabel = i18n( label );
737 hbox->setSpacing( KDialog::spacingHint() );
739 mCustomDateFormatEdit =
new KLineEdit( hbox );
740 mCustomDateFormatEdit->setEnabled(
false );
741 hbox->setStretchFactor( mCustomDateFormatEdit, 1 );
743 connect( radio, SIGNAL(toggled(
bool)),
744 mCustomDateFormatEdit, SLOT(
setEnabled(
bool)) );
749 i18n(
"<qt><a href=\"whatsthis1\">Custom format information...</a></qt>"), hbox );
752 SLOT(slotLinkClicked(
QString)) );
754 mCustomDateWhatsThis =
755 i18n(
"<qt><p><strong>These expressions may be used for the date:"
758 "<li>d - the day as a number without a leading zero (1-31)</li>"
759 "<li>dd - the day as a number with a leading zero (01-31)</li>"
760 "<li>ddd - the abbreviated day name (Mon - Sun)</li>"
761 "<li>dddd - the long day name (Monday - Sunday)</li>"
762 "<li>M - the month as a number without a leading zero (1-12)</li>"
763 "<li>MM - the month as a number with a leading zero (01-12)</li>"
764 "<li>MMM - the abbreviated month name (Jan - Dec)</li>"
765 "<li>MMMM - the long month name (January - December)</li>"
766 "<li>yy - the year as a two digit number (00-99)</li>"
767 "<li>yyyy - the year as a four digit number (0000-9999)</li>"
769 "<p><strong>These expressions may be used for the time:"
772 "<li>h - the hour without a leading zero (0-23 or 1-12 if AM/PM display)</li>"
773 "<li>hh - the hour with a leading zero (00-23 or 01-12 if AM/PM display)</li>"
774 "<li>m - the minutes without a leading zero (0-59)</li>"
775 "<li>mm - the minutes with a leading zero (00-59)</li>"
776 "<li>s - the seconds without a leading zero (0-59)</li>"
777 "<li>ss - the seconds with a leading zero (00-59)</li>"
778 "<li>z - the milliseconds without leading zeroes (0-999)</li>"
779 "<li>zzz - the milliseconds with leading zeroes (000-999)</li>"
780 "<li>AP - switch to AM/PM display. AP will be replaced by either \"AM\" or \"PM\".</li>"
781 "<li>ap - switch to AM/PM display. ap will be replaced by either \"am\" or \"pm\".</li>"
782 "<li>Z - time zone in numeric form (-0500)</li>"
784 "<p><strong>All other input characters will be ignored."
785 "</strong></p></qt>");
786 mCustomDateFormatEdit->setWhatsThis( mCustomDateWhatsThis );
792 connect( mDateDisplay, SIGNAL(clicked(
int)),
799 void AppearancePageHeadersTab::slotLinkClicked(
const QString & link )
805 void AppearancePage::HeadersTab::slotSelectDefaultAggregation()
808 mAggregationComboBox->selectDefault();
811 void AppearancePage::HeadersTab::slotSelectDefaultTheme()
814 mThemeComboBox->selectDefault();
817 void AppearancePage::HeadersTab::doLoadOther()
820 loadWidget(mDisplayMessageToolTips, MessageList::Core::Settings::self()->messageToolTipEnabledItem());
821 loadWidget(mHideTabBarWithSingleTab, MessageList::Core::Settings::self()->autoHideTabBarWithSingleTabItem() );
822 loadWidget(mTabsHaveCloseButton, MessageList::Core::Settings::self()->tabsHaveCloseButtonItem() );
825 slotSelectDefaultAggregation();
828 slotSelectDefaultTheme();
831 setDateDisplay( MessageCore::GlobalSettings::self()->dateFormat(),
832 MessageCore::GlobalSettings::self()->customDateFormat() );
835 void AppearancePage::HeadersTab::doLoadFromGlobalSettings()
837 loadWidget(mDisplayMessageToolTips, MessageList::Core::Settings::self()->messageToolTipEnabledItem());
838 loadWidget(mHideTabBarWithSingleTab, MessageList::Core::Settings::self()->autoHideTabBarWithSingleTabItem() );
839 loadWidget(mTabsHaveCloseButton, MessageList::Core::Settings::self()->tabsHaveCloseButtonItem() );
841 slotSelectDefaultAggregation();
844 slotSelectDefaultTheme();
846 setDateDisplay( MessageCore::GlobalSettings::self()->dateFormat(),
847 MessageCore::GlobalSettings::self()->customDateFormat() );
851 void AppearancePage::HeadersTab::setDateDisplay(
int num,
const QString & format )
854 static_cast<DateFormatter::FormatType
>( num );
857 if ( dateDisplay == DateFormatter::Custom )
858 mCustomDateFormatEdit->setText( format );
862 mDateDisplay->setSelected( i );
866 mDateDisplay->setSelected( numDateDisplayConfig - 2 );
871 saveCheckBox(mDisplayMessageToolTips, MessageList::Core::Settings::self()->messageToolTipEnabledItem());
872 saveCheckBox(mHideTabBarWithSingleTab, MessageList::Core::Settings::self()->autoHideTabBarWithSingleTabItem() );
873 saveCheckBox(mTabsHaveCloseButton, MessageList::Core::Settings::self()->tabsHaveCloseButtonItem() );
877 mAggregationComboBox->writeDefaultConfig();
880 mThemeComboBox->writeDefaultConfig();
882 const int dateDisplayID = mDateDisplay->selected();
884 if ( ( dateDisplayID >= 0 ) && ( dateDisplayID < numDateDisplayConfig ) ) {
885 MessageCore::GlobalSettings::self()->setDateFormat(
888 MessageCore::GlobalSettings::self()->setCustomDateFormat( mCustomDateFormatEdit->text() );
905 topLayout->
setSpacing( KDialog::spacingHint() );
906 topLayout->
setMargin( KDialog::marginHint() );
909 populateCheckBox( mCloseAfterReplyOrForwardCheck =
new QCheckBox(
this ),
912 i18n(
"Close the standalone message window after replying or forwarding the message" ) );
913 topLayout->
addWidget( mCloseAfterReplyOrForwardCheck );
914 connect( mCloseAfterReplyOrForwardCheck, SIGNAL (stateChanged(
int)),
917 mViewerSettings =
new MessageViewer::ConfigureWidget;
918 connect( mViewerSettings, SIGNAL(settingsChanged()),
922 mGravatarConfigWidget =
new MessageViewer::GravatarConfigWidget;
924 topLayout->
addWidget( mGravatarConfigWidget );
928 void AppearancePage::ReaderTab::doResetToDefaultsOther()
930 mGravatarConfigWidget->doResetToDefaultsOther();
933 void AppearancePage::ReaderTab::doLoadOther()
935 loadWidget( mCloseAfterReplyOrForwardCheck,
GlobalSettings::self()->closeAfterReplyOrForwardItem() );
936 mViewerSettings->readConfig();
937 mGravatarConfigWidget->doLoadFromGlobalSettings();
943 saveCheckBox( mCloseAfterReplyOrForwardCheck,
GlobalSettings::self()->closeAfterReplyOrForwardItem() );
944 mViewerSettings->writeConfig();
945 mGravatarConfigWidget->save();
958 vlay->
setMargin( KDialog::marginHint() );
961 mSystemTrayCheck =
new QCheckBox( i18n(
"Enable system tray icon"),
this );
963 connect( mSystemTrayCheck, SIGNAL(stateChanged(
int)),
966 mSystemTrayShowUnreadMail =
new QCheckBox( i18n(
"Show unread mail in tray icon"),
this );
967 vlay->
addWidget( mSystemTrayShowUnreadMail );
969 connect( mSystemTrayShowUnreadMail, SIGNAL(stateChanged(
int)),
971 connect( mSystemTrayCheck, SIGNAL(toggled(
bool)),
972 mSystemTrayShowUnreadMail, SLOT(
setEnabled(
bool)) );
976 mSystemTrayGroup =
new KButtonGroup(
this );
977 mSystemTrayGroup->setTitle( i18n(
"System Tray Mode" ) );
981 connect( mSystemTrayGroup, SIGNAL(clicked(
int)),
983 connect( mSystemTrayCheck, SIGNAL(toggled(
bool)),
987 gvlay->
addWidget(
new QRadioButton( i18n(
"Only show KMail in system tray if there are unread messages"), mSystemTrayGroup ) );
993 void AppearancePage::SystemTrayTab::doLoadFromGlobalSettings()
998 mSystemTrayGroup->setEnabled( mSystemTrayCheck->
isChecked() );
1045 maingrid->
setMargin( KDialog::marginHint() );
1046 maingrid->
setSpacing( KDialog::spacingHint() );
1052 mTagsGroupBox =
new QGroupBox( i18n(
"A&vailable Tags"),
this );
1055 tageditgrid->
setMargin( KDialog::marginHint() );
1056 tageditgrid->
setSpacing( KDialog::spacingHint() );
1057 tageditgrid->
addSpacing( 2 * KDialog::spacingHint() );
1061 tageditgrid->
addLayout( addremovegrid );
1063 mTagAddLineEdit =
new KLineEdit( mTagsGroupBox );
1064 mTagAddLineEdit->setTrapReturnKey(
true );
1065 addremovegrid->
addWidget( mTagAddLineEdit );
1067 mTagAddButton =
new KPushButton( mTagsGroupBox );
1068 mTagAddButton->
setToolTip( i18n(
"Add new tag") );
1070 addremovegrid->
addWidget( mTagAddButton );
1072 mTagRemoveButton =
new KPushButton( mTagsGroupBox );
1073 mTagRemoveButton->
setToolTip( i18n(
"Remove selected tag") );
1075 addremovegrid->
addWidget( mTagRemoveButton );
1081 mTagUpButton =
new KPushButton( mTagsGroupBox );
1082 mTagUpButton->
setToolTip( i18n(
"Increase tag priority") );
1087 mTagDownButton =
new KPushButton( mTagsGroupBox );
1088 mTagDownButton->
setToolTip( i18n(
"Decrease tag priority") );
1091 updowngrid->
addWidget( mTagDownButton );
1098 connect( mTagListBox->
model(),SIGNAL(rowsMoved(
QModelIndex,
int,
int,
QModelIndex,
int)),SLOT(slotRowsMoved(
QModelIndex,
int,
int,
QModelIndex,
int)) );
1111 mTagSettingGroupBox =
new QGroupBox( i18n(
"Ta&g Settings"),
1113 tagsettinggrid->
addWidget( mTagSettingGroupBox );
1116 actionCollections =
kmkernel->getKMMainWidget()->actionCollections();
1119 mTagWidget =
new MailCommon::TagWidget(actionCollections,
this);
1122 connect(mTagWidget,SIGNAL(
changed()),
this, SLOT(slotEmitChangeCheck()));
1129 connect( mTagWidget->tagNameLineEdit(), SIGNAL(textChanged(
QString)),
1130 this, SLOT(slotNameLineTextChanged(
QString)) );
1134 connect( mTagAddLineEdit, SIGNAL(returnPressed()),
1138 connect( mTagAddButton, SIGNAL(clicked()),
1141 connect( mTagRemoveButton, SIGNAL(clicked()),
1144 connect( mTagUpButton, SIGNAL(clicked()),
1147 connect( mTagDownButton, SIGNAL(clicked()),
1151 this, SLOT(slotSelectionChanged()) );
1162 void AppearancePage::MessageTagTab::slotEmitChangeCheck()
1167 void AppearancePage::MessageTagTab::slotRowsMoved(
const QModelIndex &,
1168 int sourcestart,
int sourceEnd,
1171 Q_UNUSED( sourceEnd );
1172 Q_UNUSED( sourcestart );
1173 Q_UNUSED( destinationRow );
1175 slotEmitChangeCheck();
1179 void AppearancePage::MessageTagTab::updateButtons()
1181 const int currentIndex = mTagListBox->
currentRow();
1183 const bool theFirst = ( currentIndex == 0 );
1184 const bool theLast = ( currentIndex >= (int)mTagListBox->
count() - 1 );
1185 const bool aFilterIsSelected = ( currentIndex >= 0 );
1187 mTagUpButton->
setEnabled( aFilterIsSelected && !theFirst );
1188 mTagDownButton->
setEnabled( aFilterIsSelected && !theLast );
1193 const int tmp_index = mTagListBox->
currentRow();
1194 if ( tmp_index <= 0 )
1196 swapTagsInListBox( tmp_index, tmp_index - 1 );
1202 const int tmp_index = mTagListBox->
currentRow();
1203 if ( ( tmp_index < 0 )
1204 || ( tmp_index >=
int( mTagListBox->
count() ) - 1 ) )
1206 swapTagsInListBox( tmp_index, tmp_index + 1 );
1210 void AppearancePage::MessageTagTab::swapTagsInListBox(
const int first,
1214 this, SLOT(slotSelectionChanged()) );
1218 mPreviousTag = second;
1222 this, SLOT(slotSelectionChanged()) );
1223 slotEmitChangeCheck();
1226 void AppearancePage::MessageTagTab::slotRecordTagSettings(
int aIndex )
1228 if ( ( aIndex < 0 ) || ( aIndex >=
int( mTagListBox->
count() ) ) )
1233 MailCommon::Tag::Ptr tmp_desc = tagItem->
kmailTag();
1235 tmp_desc->tagName = tagItem->
text();
1236 mTagWidget->recordTagSettings(tmp_desc);
1239 void AppearancePage::MessageTagTab::slotUpdateTagSettingWidgets(
int aIndex )
1242 if ( ( aIndex < 0 ) || ( mTagListBox->
currentRow() < 0 ) ) {
1247 mTagWidget->setEnabled(
false);
1250 mTagWidget->setEnabled(
true);
1254 mTagDownButton->
setEnabled(( (
int( mTagListBox->
count() ) - 1 ) != aIndex ) );
1257 MailCommon::Tag::Ptr tmp_desc = tagItem->
kmailTag();
1260 this, SLOT(slotNameLineTextChanged(
QString)) );
1262 mTagWidget->tagNameLineEdit()->setEnabled( !tmp_desc->isImmutable );
1263 mTagWidget->tagNameLineEdit()->setText( tmp_desc->tagName );
1264 connect( mTagWidget->tagNameLineEdit(), SIGNAL(textChanged(
QString)),
1265 this, SLOT(slotNameLineTextChanged(
QString)) );
1268 mTagWidget->setTagTextColor(tmp_desc->textColor);
1270 mTagWidget->setTagBackgroundColor(tmp_desc->backgroundColor);
1272 mTagWidget->setTagTextFont(tmp_desc->textFont);
1274 mTagWidget->iconButton()->setEnabled( !tmp_desc->isImmutable );
1275 mTagWidget->iconButton()->setIcon( tmp_desc->iconName );
1277 mTagWidget->keySequenceWidget()->setEnabled(
true );
1278 mTagWidget->keySequenceWidget()->setKeySequence( tmp_desc->shortcut.primary(),
1279 KKeySequenceWidget::NoValidate );
1281 mTagWidget->inToolBarCheck()->setEnabled(
true );
1282 mTagWidget->inToolBarCheck()->setChecked( tmp_desc->inToolbar );
1285 void AppearancePage::MessageTagTab::slotSelectionChanged()
1288 slotRecordTagSettings( mPreviousTag );
1289 slotUpdateTagSettingWidgets( mTagListBox->
currentRow() );
1296 const int tmp_index = mTagListBox->
currentRow();
1297 if ( tmp_index >= 0 ) {
1298 if (KMessageBox::Yes == KMessageBox::questionYesNo(
this,i18n(
"Do you want to remove tag \'%1\'?", mTagListBox->
item(mTagListBox->
currentRow())->
text()))) {
1301 MailCommon::Tag::Ptr tmp_desc = tagItem->
kmailTag();
1302 if ( tmp_desc->tag().isValid() ) {
1303 new Akonadi::TagDeleteJob(tmp_desc->tag());
1305 kWarning() <<
"Can't remove tag with invalid akonadi tag";
1313 this, SLOT(slotSelectionChanged()) );
1317 this, SLOT(slotSelectionChanged()) );
1319 slotSelectionChanged();
1320 slotEmitChangeCheck();
1325 void AppearancePage::MessageTagTab::slotDeleteTagJob(
KJob* job)
1328 kWarning() <<
"Failed to delete tag " << job->errorString();
1332 void AppearancePage::MessageTagTab::slotNameLineTextChanged(
const QString
1340 const int count = mTagListBox->
count();
1341 for (
int i=0; i < count; ++i ) {
1342 if(mTagListBox->
item(i)->
text() == aText) {
1343 KMessageBox::error(
this,i18n(
"We cannot create tag. A tag with same name already exists."));
1345 this, SLOT(slotNameLineTextChanged(
QString)) );
1346 mTagWidget->tagNameLineEdit()->setText(mTagListBox->
currentItem()->
text());
1347 connect( mTagWidget->tagNameLineEdit(), SIGNAL(textChanged(
QString)),
1348 this, SLOT(slotNameLineTextChanged(
QString)) );
1357 this, SLOT(slotSelectionChanged()) );
1361 this, SLOT(slotSelectionChanged()) );
1364 void AppearancePage::MessageTagTab::slotIconNameChanged(
const QString &iconName )
1376 const QString newTagName = mTagAddLineEdit->text();
1377 const int count = mTagListBox->
count();
1378 for (
int i=0; i < count; ++i ) {
1379 if(mTagListBox->
item(i)->
text() == newTagName) {
1380 KMessageBox::error(
this,i18n(
"We cannot create tag. A tag with same name already exists."));
1385 const int tmp_priority = mTagListBox->
count();
1387 MailCommon::Tag::Ptr tag( Tag::createDefaultTag( newTagName ) );
1388 tag->priority = tmp_priority;
1390 slotEmitChangeCheck();
1393 mTagListBox->
addItem( newItem );
1395 mTagAddLineEdit->setText(
QString() );
1398 void AppearancePage::MessageTagTab::doLoadFromGlobalSettings()
1400 mTagListBox->
clear();
1402 Akonadi::TagFetchJob *fetchJob =
new Akonadi::TagFetchJob(
this);
1403 fetchJob->fetchScope().fetchAttribute<Akonadi::TagAttribute>();
1404 connect(fetchJob, SIGNAL(result(
KJob*)),
this, SLOT(slotTagsFetched(
KJob*)));
1407 void AppearancePage::MessageTagTab::slotTagsFetched(
KJob *job)
1410 kWarning() <<
"Failed to load tags " << job->errorString();
1413 Akonadi::TagFetchJob *fetchJob =
static_cast<Akonadi::TagFetchJob*
>(job);
1416 foreach(
const Akonadi::Tag &akonadiTag, fetchJob->tags() ) {
1417 MailCommon::Tag::Ptr tag = MailCommon::Tag::fromAkonadi( akonadiTag );
1418 msgTagList.
append( tag );
1421 qSort( msgTagList.
begin(), msgTagList.
end(), MailCommon::Tag::compare );
1423 foreach(
const MailCommon::Tag::Ptr& tag, msgTagList ) {
1426 if ( tag->priority == -1 )
1427 tag->priority = mTagListBox->
count() - 1;
1432 this, SLOT(slotSelectionChanged()) );
1435 this, SLOT(slotSelectionChanged()) );
1437 slotUpdateTagSettingWidgets( -1 );
1442 mOriginalMsgTagList.
clear();
1451 const int currentRow = mTagListBox->
currentRow();
1452 if ( currentRow < 0 ) {
1456 const int count = mTagListBox->
count();
1465 slotRecordTagSettings( currentRow );
1466 const int numberOfMsgTagList = count;
1467 for (
int i=0; i < numberOfMsgTagList; ++i ) {
1469 if ( ( i>=mOriginalMsgTagList.
count() ) || *(tagItem->
kmailTag()) != *(mOriginalMsgTagList[i]) ) {
1470 MailCommon::Tag::Ptr tag = tagItem->
kmailTag();
1473 MailCommon::Tag::SaveFlags saveFlags = mTagWidget->saveFlags();
1474 Akonadi::Tag akonadiTag = tag->saveToAkonadi( saveFlags );
1475 if ((*tag).id()> 0) {
1476 akonadiTag.setId((*tag).id());
1478 if (akonadiTag.isValid()) {
1479 new Akonadi::TagModifyJob(akonadiTag);
1481 new Akonadi::TagCreateJob(akonadiTag);
void slotRemoveTag()
Removes the currently selected text in the list box.
void showText(const QPoint &pos, const QString &text, QWidget *w)
DateFormatter::FormatType dateDisplay
QString helpAnchor() const
Should return the help anchor for this page or tab.
static const int numFontNames
QString helpAnchor() const
AppearancePageLayoutTab LayoutTab
void setPointSize(int pointSize)
~AppearancePageMessageTagTab()
AppearancePageColorsTab ColorsTab
static const struct @1 colorNames[]
void setSuffix(const QString &suffix)
static const int numDateDisplayConfig
virtual QByteArray text(quint32 serialNumber) const =0
AppearancePageReaderTab ReaderTab
void slotAddLineTextChanged(const QString &aText)
Enables/disables Add button according to whether aText is empty.
AppearancePageFontsTab FontsTab
void setDragDropMode(DragDropMode behavior)
void addSpacing(int size)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
static const int numColorNames
static KMKernel * self()
normal control stuff
void setRange(int minimum, int maximum)
void setBuddy(QWidget *buddy)
int count(const T &value) const
void append(const T &value)
void slotMoveTagUp()
Increases the currently selected tag's priority and handles related visual changes.
QString helpAnchor() const
AppearancePageLayoutTab(QWidget *parent=0)
void addTab(ConfigModuleTab *tab, const QString &title)
AppearancePageColorsTab(QWidget *parent=0)
AppearancePageHeadersTab HeadersTab
void setMargin(int margin)
void slotAddNewTag()
Creates a generic tag with the visible name from the line edit widget for adding tags.
AppearancePageMessageTagTab MessageTagTab
void setSingleStep(int val)
static const struct @0 fontNames[]
QColor color(int index) const
QString helpAnchor() const
void setColorSilently(int index, const QColor &color)
AppearancePage(const KComponentData &instance, QWidget *parent=0)
static GlobalSettings * self()
AppearancePageMessageTagTab(QWidget *parent=0)
void addStretch(int stretch)
void setTitle(const QString &title)
void setFamily(const QString &family)
static const struct @2 dateDisplayConfig[]
QString fromLatin1(const char *str, int size)
AppearancePageFontsTab(QWidget *parent=0)
void slotMoveTagDown()
Decreases the currently selected tag's priority and handles related visual changes.
AppearancePageSystemTrayTab(QWidget *parent=0)
QAbstractItemModel * model() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
AppearancePageSystemTrayTab SystemTrayTab
void addColor(const QString &text, const QColor &color=Qt::black)
QString helpAnchor() const
QString helpAnchor() const
bool setStretchFactor(QWidget *widget, int stretch)
void setSpacing(int spacing)
void setText(const QString &text)
void addLayout(QLayout *layout, int stretch)