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>
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 );
64 QVBoxLayout * topLayout =
new QVBoxLayout(
this );
65 topLayout->setSpacing( KDialog::spacingHint() );
66 topLayout->setMargin( KDialog::marginHint() );
68 if ( !mIsLocalSystemFolder ) {
70 mIconsCheckBox =
new QCheckBox( i18n(
"Use custom &icons"),
this );
71 mIconsCheckBox->setChecked(
false );
73 mNormalIconLabel =
new QLabel( i18nc(
"Icon used for folders with no unread messages.",
"&Normal:" ),
this );
74 mNormalIconLabel->setEnabled(
false );
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 );
83 mNormalIconButton->setIcon( QLatin1String(
"folder") );
84 mNormalIconButton->setEnabled(
false );
86 mUnreadIconLabel =
new QLabel( i18nc(
"Icon used for folders which do have unread messages.",
"&Unread:" ),
this );
87 mUnreadIconLabel->setEnabled(
false );
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 );
96 mUnreadIconButton->setIcon( QLatin1String(
"folder-open") );
97 mUnreadIconButton->setEnabled(
false );
99 QHBoxLayout * iconHLayout =
new QHBoxLayout();
100 iconHLayout->addWidget( mIconsCheckBox );
101 iconHLayout->addStretch( 2 );
102 iconHLayout->addWidget( mNormalIconLabel );
103 iconHLayout->addWidget( mNormalIconButton );
104 iconHLayout->addWidget( mUnreadIconLabel );
105 iconHLayout->addWidget( mUnreadIconButton );
106 iconHLayout->addStretch( 1 );
107 topLayout->addLayout( iconHLayout );
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" ) );
133 QHBoxLayout * senderReceiverColumnHLayout =
new QHBoxLayout();
134 senderReceiverColumnHLayout->addWidget( senderReceiverColumnLabel );
135 senderReceiverColumnHLayout->addWidget( mShowSenderReceiverComboBox );
136 topLayout->addLayout( senderReceiverColumnHLayout );
139 QGroupBox * messageListGroup =
new QGroupBox( i18n(
"Message List" ),
this );
140 QVBoxLayout * messageListGroupLayout =
new QVBoxLayout( messageListGroup );
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()),
162 QHBoxLayout * aggregationLayout =
new QHBoxLayout();
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()),
185 QHBoxLayout * themeLayout =
new QHBoxLayout();
186 themeLayout->addWidget( themeLabel, 1 );
187 themeLayout->addWidget( mThemeComboBox, 1 );
188 themeLayout->addWidget( themeConfigButton, 0 );
189 messageListGroupLayout->addLayout( themeLayout );
191 topLayout->addStretch( 100 );
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 ) {
229 QString unreadIconName;
230 bool iconWasEmpty =
false;
231 if ( col.hasAttribute<Akonadi::EntityDisplayAttribute>() ) {
232 iconName = col.attribute<Akonadi::EntityDisplayAttribute>()->iconName();
233 unreadIconName = col.attribute<Akonadi::EntityDisplayAttribute>()->activeIconName();
236 if ( iconName.isEmpty() ) {
237 iconName = QLatin1String(
"folder" );
240 mNormalIconButton->setIcon( iconName );
242 if ( unreadIconName.isEmpty() ) {
243 mUnreadIconButton->setIcon( iconName );
246 mUnreadIconButton->setIcon( unreadIconName );
249 mIconsCheckBox->setChecked( !iconWasEmpty );
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 ) {
273 if ( mIconsCheckBox->isChecked() ) {
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 );
304 #include "collectionviewpage.moc"
void slotSelectFolderAggregation()
void load(const Akonadi::Collection &col)
void save(Akonadi::Collection &col)
void slotThemeCheckboxChanged()
CollectionViewPage(QWidget *parent=0)
void slotChangeIcon(const QString &icon)
void slotSelectFolderTheme()
void slotAggregationCheckboxChanged()