22 #include "kernel/mailkernel.h"
23 #include "foldercollection.h"
24 #include "templateparser/templatesconfiguration.h"
25 #include "templateparser/templatesconfiguration_kfg.h"
26 #include <akonadi/collection.h>
29 #include <KPushButton>
32 using namespace Akonadi;
33 using namespace MailCommon;
36 CollectionPropertiesPage( parent ), mChanged(false)
38 setObjectName( QLatin1String(
"KMail::CollectionTemplatesPage" ) );
39 setPageTitle( i18n(
"Templates" ) );
49 return ( !CommonKernel->isSystemFolderCollection( collection ) ||
50 CommonKernel->isMainFolderCollection( collection ) );
53 void CollectionTemplatesPage::init()
55 QVBoxLayout *topLayout =
new QVBoxLayout(
this );
56 topLayout->setMargin( KDialog::marginHint() );
57 topLayout->setSpacing( KDialog::spacingHint() );
59 QHBoxLayout *topItems =
new QHBoxLayout;
60 topLayout->addLayout( topItems );
62 mCustom =
new QCheckBox( i18n(
"&Use custom message templates in this folder"),
this );
63 connect(mCustom, SIGNAL(clicked(
bool)),
this, SLOT(slotChanged()));
64 topItems->addWidget( mCustom, Qt::AlignLeft );
66 mWidget =
new TemplateParser::TemplatesConfiguration(
this, QLatin1String(
"folder-templates") );
67 connect(mWidget, SIGNAL(changed()),
this, SLOT(slotChanged()));
68 mWidget->setEnabled(
false );
72 topItems->addStretch( 9 );
73 topItems->addWidget( mWidget->helpLabel(), Qt::AlignRight );
75 topLayout->addWidget( mWidget );
77 QHBoxLayout *btns =
new QHBoxLayout();
78 btns->setSpacing( KDialog::spacingHint() );
79 KPushButton *copyGlobal =
new KPushButton( i18n(
"&Copy Global Templates"),
this );
80 copyGlobal->setEnabled(
false );
81 btns->addWidget( copyGlobal );
82 topLayout->addLayout( btns );
84 connect( mCustom, SIGNAL(toggled(
bool)),
85 mWidget, SLOT(setEnabled(
bool)) );
86 connect( mCustom, SIGNAL(toggled(
bool)),
87 copyGlobal, SLOT(setEnabled(
bool)) );
89 connect( copyGlobal, SIGNAL(clicked()),
100 mCollectionId = QString::number( col.id() );
102 TemplateParser::Templates t( mCollectionId );
104 mCustom->setChecked(t.useCustomTemplates());
106 mIdentity = fd->identity();
108 mWidget->loadFromFolder( mCollectionId, mIdentity );
114 if ( mChanged && !mCollectionId.isEmpty() ) {
115 TemplateParser::Templates t(mCollectionId);
117 t.setUseCustomTemplates(mCustom->isChecked());
120 mWidget->saveToFolder(mCollectionId);
126 mWidget->loadFromIdentity( mIdentity );
128 mWidget->loadFromGlobal();
132 void CollectionTemplatesPage::slotChanged()
137 #include "collectiontemplatespage.moc"
bool canHandle(const Akonadi::Collection &collection) const
CollectionTemplatesPage(QWidget *parent=0)
~CollectionTemplatesPage()
void save(Akonadi::Collection &col)
void load(const Akonadi::Collection &col)