22 #include "kernel/mailkernel.h"
24 #include <akonadi/collection.h>
25 #include <akonadi/entitydisplayattribute.h>
26 #include <akonadi/kmime/messagefolderattribute.h>
29 #include <QHBoxLayout>
30 #include <kicondialog.h>
33 #include <QVBoxLayout>
34 #include <KLocalizedString>
38 #include "messagelist/utils/aggregationcombobox.h"
39 #include "messagelist/utils/aggregationconfigbutton.h"
40 #include "messagelist/utils/themecombobox.h"
41 #include "messagelist/utils/themeconfigbutton.h"
43 #include "foldercollection.h"
45 using namespace MailCommon;
48 CollectionPropertiesPage( parent ), mIsLocalSystemFolder(false)
50 setObjectName(
QLatin1String(
"KMail::CollectionViewPage" ) );
51 setPageTitle( i18nc(
"@title:tab View settings for a folder.",
"View" ) );
58 void CollectionViewPage::init(
const Akonadi::Collection & col)
60 mCurrentCollection = col;
62 mIsLocalSystemFolder = CommonKernel->isSystemFolderCollection( col ) || fd->isStructural() || Kernel::folderIsInbox( col,
true );
65 topLayout->
setSpacing( KDialog::spacingHint() );
66 topLayout->
setMargin( KDialog::marginHint() );
68 if ( !mIsLocalSystemFolder ) {
70 mIconsCheckBox =
new QCheckBox( i18n(
"Use custom &icons"),
this );
73 mNormalIconLabel =
new QLabel( i18nc(
"Icon used for folders with no unread messages.",
"&Normal:" ),
this );
76 mNormalIconButton =
new KIconButton(
this );
77 mNormalIconLabel->
setBuddy( mNormalIconButton );
78 mNormalIconButton->setIconType( KIconLoader::NoGroup, KIconLoader::Place,
false );
79 mNormalIconButton->setIconSize( 16 );
80 mNormalIconButton->setStrictIconSize(
true );
81 mNormalIconButton->setFixedSize( 28, 28 );
84 mNormalIconButton->setEnabled(
false );
86 mUnreadIconLabel =
new QLabel( i18nc(
"Icon used for folders which do have unread messages.",
"&Unread:" ),
this );
89 mUnreadIconButton =
new KIconButton(
this );
90 mUnreadIconLabel->
setBuddy( mUnreadIconButton );
91 mUnreadIconButton->setIconType( KIconLoader::NoGroup, KIconLoader::Place,
false );
92 mUnreadIconButton->setIconSize( 16 );
93 mUnreadIconButton->setStrictIconSize(
true );
94 mUnreadIconButton->setFixedSize( 28, 28 );
97 mUnreadIconButton->setEnabled(
false );
100 iconHLayout->
addWidget( mIconsCheckBox );
102 iconHLayout->
addWidget( mNormalIconLabel );
103 iconHLayout->
addWidget( mNormalIconButton );
104 iconHLayout->
addWidget( mUnreadIconLabel );
105 iconHLayout->
addWidget( mUnreadIconButton );
109 connect( mIconsCheckBox, SIGNAL(toggled(
bool)),
110 mNormalIconLabel, SLOT(setEnabled(
bool)) );
111 connect( mIconsCheckBox, SIGNAL(toggled(
bool)),
112 mNormalIconButton, SLOT(setEnabled(
bool)) );
113 connect( mIconsCheckBox, SIGNAL(toggled(
bool)),
114 mUnreadIconButton, SLOT(setEnabled(
bool)) );
115 connect( mIconsCheckBox, SIGNAL(toggled(
bool)),
116 mUnreadIconLabel, SLOT(setEnabled(
bool)) );
118 connect( mNormalIconButton, SIGNAL(iconChanged(
QString)),
123 const QString senderReceiverColumnTip = i18n(
"Show Sender/Receiver Column in List of Messages" );
125 QLabel * senderReceiverColumnLabel =
new QLabel( i18n(
"Sho&w column:" ),
this );
126 mShowSenderReceiverComboBox =
new KComboBox(
this );
127 mShowSenderReceiverComboBox->setToolTip( senderReceiverColumnTip );
128 senderReceiverColumnLabel->
setBuddy( mShowSenderReceiverComboBox );
129 mShowSenderReceiverComboBox->insertItem( 0, i18nc(
"@item:inlistbox Show default value.",
"Default" ) );
130 mShowSenderReceiverComboBox->insertItem( 1, i18nc(
"@item:inlistbox Show sender.",
"Sender" ) );
131 mShowSenderReceiverComboBox->insertItem( 2, i18nc(
"@item:inlistbox Show receiver.",
"Receiver" ) );
134 senderReceiverColumnHLayout->
addWidget( senderReceiverColumnLabel );
135 senderReceiverColumnHLayout->
addWidget( mShowSenderReceiverComboBox );
136 topLayout->
addLayout( senderReceiverColumnHLayout );
141 messageListGroupLayout->
setSpacing( KDialog::spacingHint() );
142 messageListGroupLayout->
setMargin( KDialog::marginHint() );
143 topLayout->
addWidget( messageListGroup );
146 mUseDefaultAggregationCheckBox =
new QCheckBox( i18n(
"Use default aggregation" ), messageListGroup );
147 messageListGroupLayout->
addWidget( mUseDefaultAggregationCheckBox );
148 connect( mUseDefaultAggregationCheckBox, SIGNAL(stateChanged(
int)),
151 mAggregationComboBox =
new MessageList::Utils::AggregationComboBox( messageListGroup );
153 QLabel * aggregationLabel =
new QLabel( i18n(
"Aggregation" ), messageListGroup );
154 aggregationLabel->
setBuddy( mAggregationComboBox );
156 using MessageList::Utils::AggregationConfigButton;
157 AggregationConfigButton * aggregationConfigButton =
new AggregationConfigButton( messageListGroup, mAggregationComboBox );
159 connect( aggregationConfigButton, SIGNAL(configureDialogCompleted()),
163 aggregationLayout->
addWidget( aggregationLabel, 1 );
164 aggregationLayout->
addWidget( mAggregationComboBox, 1 );
165 aggregationLayout->
addWidget( aggregationConfigButton, 0 );
166 messageListGroupLayout->
addLayout( aggregationLayout );
169 mUseDefaultThemeCheckBox =
new QCheckBox( i18n(
"Use default theme" ), messageListGroup );
170 messageListGroupLayout->
addWidget( mUseDefaultThemeCheckBox );
171 connect( mUseDefaultThemeCheckBox, SIGNAL(stateChanged(
int)),
174 mThemeComboBox =
new MessageList::Utils::ThemeComboBox( messageListGroup );
176 QLabel * themeLabel =
new QLabel( i18n(
"Theme" ), messageListGroup );
177 themeLabel->
setBuddy( mThemeComboBox );
179 using MessageList::Utils::ThemeConfigButton;
180 ThemeConfigButton * themeConfigButton =
new ThemeConfigButton( messageListGroup, mThemeComboBox );
182 connect( themeConfigButton, SIGNAL(configureDialogCompleted()),
187 themeLayout->
addWidget( mThemeComboBox, 1 );
188 themeLayout->
addWidget( themeConfigButton, 0 );
189 messageListGroupLayout->
addLayout( themeLayout );
197 mUnreadIconButton->setIcon( icon );
202 mAggregationComboBox->setEnabled( !mUseDefaultAggregationCheckBox->
isChecked() );
207 mThemeComboBox->setEnabled( !mUseDefaultThemeCheckBox->
isChecked() );
212 bool usesPrivateAggregation =
false;
213 mAggregationComboBox->readStorageModelConfig(mCurrentCollection, usesPrivateAggregation );
214 mUseDefaultAggregationCheckBox->
setChecked( !usesPrivateAggregation );
219 bool usesPrivateTheme =
false;
220 mThemeComboBox->readStorageModelConfig( mCurrentCollection, usesPrivateTheme );
221 mUseDefaultThemeCheckBox->
setChecked( !usesPrivateTheme );
227 if ( !mIsLocalSystemFolder ) {
230 bool iconWasEmpty =
false;
231 if ( col.hasAttribute<Akonadi::EntityDisplayAttribute>() ) {
232 iconName = col.attribute<Akonadi::EntityDisplayAttribute>()->iconName();
233 unreadIconName = col.attribute<Akonadi::EntityDisplayAttribute>()->activeIconName();
240 mNormalIconButton->setIcon( iconName );
242 if ( unreadIconName.
isEmpty() ) {
243 mUnreadIconButton->setIcon( iconName );
246 mUnreadIconButton->setIcon( unreadIconName );
252 if ( col.hasAttribute<Akonadi::MessageFolderAttribute>() ) {
253 const bool outboundFolder = col.attribute<Akonadi::MessageFolderAttribute>()->isOutboundFolder();
254 if ( outboundFolder )
255 mShowSenderReceiverComboBox->setCurrentIndex( 2 );
257 mShowSenderReceiverComboBox->setCurrentIndex( 1 );
259 mShowSenderReceiverComboBox->setCurrentIndex( 0 );
261 mShowSenderReceiverValue = mShowSenderReceiverComboBox->currentIndex();
272 if ( !mIsLocalSystemFolder ) {
274 col.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Collection::AddIfMissing )->setIconName( mNormalIconButton->icon() );
275 col.attribute<Akonadi::EntityDisplayAttribute>( Akonadi::Collection::AddIfMissing )->setActiveIconName( mUnreadIconButton->icon() );
277 else if ( col.hasAttribute<Akonadi::EntityDisplayAttribute>() ) {
278 col.attribute<Akonadi::EntityDisplayAttribute>()->setIconName(
QString() );
279 col.attribute<Akonadi::EntityDisplayAttribute>()->setActiveIconName(
QString() );
283 const int currentIndex = mShowSenderReceiverComboBox->currentIndex();
284 if ( mShowSenderReceiverValue != currentIndex ) {
285 if ( currentIndex == 1 ) {
286 Akonadi::MessageFolderAttribute *messageFolder = col.attribute<Akonadi::MessageFolderAttribute>( Akonadi::Entity::AddIfMissing );
287 messageFolder->setOutboundFolder(
false );
288 }
else if ( currentIndex == 2 ) {
289 Akonadi::MessageFolderAttribute *messageFolder = col.attribute<Akonadi::MessageFolderAttribute>( Akonadi::Entity::AddIfMissing );
290 messageFolder->setOutboundFolder(
true );
292 col.removeAttribute<Akonadi::MessageFolderAttribute>();
296 const bool usePrivateTheme = !mUseDefaultThemeCheckBox->
isChecked();
297 mThemeComboBox->writeStorageModelConfig( mCurrentCollection, usePrivateTheme );
299 const bool usePrivateAggregation = !mUseDefaultAggregationCheckBox->
isChecked();
300 mAggregationComboBox->writeStorageModelConfig( mCurrentCollection, usePrivateAggregation );
void slotSelectFolderAggregation()
void load(const Akonadi::Collection &col)
void save(Akonadi::Collection &col)
void setBuddy(QWidget *buddy)
void slotThemeCheckboxChanged()
CollectionViewPage(QWidget *parent=0)
void slotChangeIcon(const QString &icon)
void setMargin(int margin)
void addStretch(int stretch)
void slotSelectFolderTheme()
void slotAggregationCheckboxChanged()
void setSpacing(int spacing)
void addLayout(QLayout *layout, int stretch)