diff --git a/CMakeLists.txt b/CMakeLists.txt index 884022cd1..6ef23a81c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,6 @@ add_subdirectory(kcm_kpimidentities) if (NOT WINCE AND KDEPIM_BUILD_DESKTOP) set(kmailprivate_LIB_SRCS - kmcollectionpropertiesdialog.cpp collectionpane.cpp collectionannotationsattribute.cpp collectiontemplatespage.cpp diff --git a/collectionaclpage.cpp b/collectionaclpage.cpp index 03eb1e9e3..38dc99540 100644 --- a/collectionaclpage.cpp +++ b/collectionaclpage.cpp @@ -96,6 +96,8 @@ CollectionAclPage::CollectionAclPage( QWidget *parent ) mAclManager( new MailCommon::AclManager( this ) ), mChanged( false ) { + setObjectName( QLatin1String( "KMail::CollectionAclPage" ) ); + setPageTitle( i18n( "Access Control" ) ); init(); } diff --git a/collectionaclpage.h b/collectionaclpage.h index daf2456f7..b49f3a58c 100644 --- a/collectionaclpage.h +++ b/collectionaclpage.h @@ -72,4 +72,6 @@ class CollectionAclPage : public Akonadi::CollectionPropertiesPage bool mChanged; }; +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionAclPageFactory, CollectionAclPage ) + #endif diff --git a/collectiongeneralpage.cpp b/collectiongeneralpage.cpp index ca3557057..957b617db 100644 --- a/collectiongeneralpage.cpp +++ b/collectiongeneralpage.cpp @@ -50,6 +50,7 @@ using namespace MailCommon; CollectionGeneralPage::CollectionGeneralPage( QWidget *parent ) : CollectionPropertiesPage( parent ), mFolderCollection( 0 ) { + setObjectName( QLatin1String( "KMail::CollectionGeneralPage" ) ); setPageTitle( i18nc( "@title:tab General settings for a folder.", "General" ) ); } diff --git a/collectiongeneralpage.h b/collectiongeneralpage.h index 354040f09..4cf20e54d 100644 --- a/collectiongeneralpage.h +++ b/collectiongeneralpage.h @@ -87,6 +87,7 @@ private: }; +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionGeneralPageFactory, CollectionGeneralPage ) #endif /* COLLECTIONGENERALPAGE_H */ diff --git a/collectionmaintenancepage.cpp b/collectionmaintenancepage.cpp index da6f72397..b49ac28a1 100644 --- a/collectionmaintenancepage.cpp +++ b/collectionmaintenancepage.cpp @@ -40,6 +40,7 @@ using namespace Akonadi; CollectionMaintenancePage::CollectionMaintenancePage(QWidget * parent) : CollectionPropertiesPage( parent ), mIsNotAVirtualCollection( true ) { + setObjectName( QLatin1String( "KMail::CollectionMaintenancePage" ) ); setPageTitle( i18n("Maintenance") ); } diff --git a/collectionmaintenancepage.h b/collectionmaintenancepage.h index a8bad20ea..0c1b7321d 100644 --- a/collectionmaintenancepage.h +++ b/collectionmaintenancepage.h @@ -52,7 +52,7 @@ private: QLabel *mCollectionUnread; }; - +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionMaintenancePageFactory, CollectionMaintenancePage ) #endif /* COLLECTIONMAINTENANCEPAGE_H */ diff --git a/collectionquotapage.cpp b/collectionquotapage.cpp index e0e4ce8b0..cdb07e888 100644 --- a/collectionquotapage.cpp +++ b/collectionquotapage.cpp @@ -48,6 +48,7 @@ CollectionQuotaPage::CollectionQuotaPage( QWidget* parent ) : CollectionPropertiesPage( parent ) { + setObjectName( QLatin1String( "KMail::CollectionQuotaPage" ) ); setPageTitle( i18n("Quota") ); init(); } diff --git a/collectionquotapage.h b/collectionquotapage.h index 7e5dccbb6..9e6c1bd30 100644 --- a/collectionquotapage.h +++ b/collectionquotapage.h @@ -54,6 +54,7 @@ private: QuotaWidget* mQuotaWidget; }; +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionQuotaPageFactory, CollectionQuotaPage ) #endif /* COLLECTIONQUOTAPAGE_H */ diff --git a/collectiontemplatespage.cpp b/collectiontemplatespage.cpp index 34052480e..58aa36fec 100644 --- a/collectiontemplatespage.cpp +++ b/collectiontemplatespage.cpp @@ -36,6 +36,7 @@ using namespace MailCommon; CollectionTemplatesPage::CollectionTemplatesPage(QWidget * parent) : CollectionPropertiesPage( parent ), mFolderCollection( 0 ) { + setObjectName( QLatin1String( "KMail::CollectionTemplatesPage" ) ); setPageTitle( i18n( "Templates" ) ); init(); } diff --git a/collectiontemplatespage.h b/collectiontemplatespage.h index 7c7b72944..e886eb50d 100644 --- a/collectiontemplatespage.h +++ b/collectiontemplatespage.h @@ -55,5 +55,7 @@ private: bool mIsLocalSystemFolder; }; +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionTemplatesPageFactory, CollectionTemplatesPage ) + #endif /* COLLECTIONTEMPLATESPAGE_H */ diff --git a/collectionviewpage.cpp b/collectionviewpage.cpp index 9d0b42a18..96dce47d1 100644 --- a/collectionviewpage.cpp +++ b/collectionviewpage.cpp @@ -47,6 +47,7 @@ using namespace MailCommon; CollectionViewPage::CollectionViewPage(QWidget * parent) : CollectionPropertiesPage( parent ), mFolderCollection( 0 ) { + setObjectName( QLatin1String( "KMail::CollectionViewPage" ) ); setPageTitle( i18nc( "@title:tab View settings for a folder.", "View" ) ); } diff --git a/collectionviewpage.h b/collectionviewpage.h index 2c7e31fff..acd755192 100644 --- a/collectionviewpage.h +++ b/collectionviewpage.h @@ -74,6 +74,7 @@ private: int mShowSenderReceiverValue; }; +AKONADI_COLLECTION_PROPERTIES_PAGE_FACTORY( CollectionViewPageFactory, CollectionViewPage ) #endif /* COLLECTIONVIEWPAGE_H */ diff --git a/kmcollectionpropertiesdialog.cpp b/kmcollectionpropertiesdialog.cpp deleted file mode 100644 index 5fe37abe4..000000000 --- a/kmcollectionpropertiesdialog.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - This file is part of KMail, the KDE mail client. - Copyright (c) 2010 Montel Laurent - - KMail is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - KMail is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "kmcollectionpropertiesdialog.h" -#include "collectiontemplatespage.h" -#include "collectionmaintenancepage.h" -#include "collectiongeneralpage.h" -#include "collectionviewpage.h" -#include "collectionquotapage.h" -#include "collectionaclpage.h" - -#include -#include - -#include - -#include - - -KMCollectionPropertiesDialog::KMCollectionPropertiesDialog( const Akonadi::Collection &collection, QWidget *parent ) : - KDialog( parent ) -{ - mCollection = collection; - QBoxLayout *layout = new QHBoxLayout( mainWidget() ); - layout->setMargin( 0 ); - mTabWidget = new KTabWidget( mainWidget() ); - layout->addWidget( mTabWidget ); - - Akonadi::CollectionPropertiesPage *page = new CollectionGeneralPage( mTabWidget ); - insertPage( page ); - page = new CollectionViewPage( mTabWidget ); - insertPage( page ); - page = new Akonadi::CachePolicyPage( mTabWidget ); - insertPage( page ); - page = new CollectionTemplatesPage( mTabWidget ); - insertPage( page ); - page = new CollectionAclPage( mTabWidget ); - insertPage( page ); - page = new CollectionQuotaPage( mTabWidget ); - insertPage( page ); - page = new CollectionMaintenancePage( mTabWidget ); - insertPage( page ); - connect( this, SIGNAL( okClicked() ), SLOT( save() ) ); - connect( this, SIGNAL( cancelClicked() ), SLOT( deleteLater() ) ); - -} - -void KMCollectionPropertiesDialog::insertPage( Akonadi::CollectionPropertiesPage * page ) -{ - if ( page->canHandle( mCollection ) ) { - mTabWidget->addTab( page, page->pageTitle() ); - page->load( mCollection ); - } else { - delete page; - } -} - -void KMCollectionPropertiesDialog::save() -{ - for ( int i = 0; i < mTabWidget->count(); ++i ) { - Akonadi::CollectionPropertiesPage *page = static_cast( mTabWidget->widget( i ) ); - page->save( mCollection ); - } - - Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob( mCollection, this ); - connect( job, SIGNAL( result( KJob* ) ), this, SLOT( saveResult( KJob* ) ) ); -} - -void KMCollectionPropertiesDialog::saveResult( KJob *job ) -{ - if ( job->error() ) { - // TODO - kWarning() << job->errorString(); - } - deleteLater(); -} - -#include "kmcollectionpropertiesdialog.moc" diff --git a/kmcollectionpropertiesdialog.h b/kmcollectionpropertiesdialog.h deleted file mode 100644 index 27b0a298b..000000000 --- a/kmcollectionpropertiesdialog.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - This file is part of KMail, the KDE mail client. - Copyright (c) 2010 Montel Laurent - - KMail is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. - - KMail is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef KMCOLLECTIONPROPERTIESDIALOG_H -#define KMCOLLECTIONPROPERTIESDIALOG_H - -#include -#include -#include -#include - -class KTabWidget; - -class KMCollectionPropertiesDialog : public KDialog -{ - Q_OBJECT -public: - explicit KMCollectionPropertiesDialog( const Akonadi::Collection &collection, QWidget *parent = 0 ); - -protected: - void insertPage( Akonadi::CollectionPropertiesPage * page ); - -protected slots: - void save(); - void saveResult( KJob *job ); - -private: - Akonadi::Collection mCollection; - KTabWidget* mTabWidget; - -}; - - -#endif /* KMCOLLECTIONPROPERTIESDIALOG_H */ - diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index ca438b683..ea1aef81c 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -47,12 +47,19 @@ #include "tagactionmanager.h" #include "foldershortcutactionmanager.h" #include "collectionpane.h" -#include "kmcollectionpropertiesdialog.h" #if !defined(NDEBUG) #include using KSieveUi::SieveDebugDialog; #endif +#include "collectionaclpage.h" +#include "collectiongeneralpage.h" +#include "collectionmaintenancepage.h" +#include "collectionquotapage.h" +#include "collectiontemplatespage.h" +#include "collectionviewpage.h" + + #include "mailcommon/filtermanager.h" #include "mailcommon/mailfilter.h" @@ -271,6 +278,21 @@ K_GLOBAL_STATIC( KMMainWidget::PtrList, theMainWidgetList ) Akonadi::AttributeFactory::registerAttribute(); + { // make sure the pages are registered only once, since there can be multiple instances of KMMainWidget + static bool pagesRegistered = false; + + if ( !pagesRegistered ) { + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionAclPageFactory ); + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionGeneralPageFactory ); + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionMaintenancePageFactory ); + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionQuotaPageFactory ); + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionTemplatesPageFactory ); + Akonadi::CollectionPropertiesDialog::registerPage( new CollectionViewPageFactory ); + + pagesRegistered = true; + } + } + KMainWindow *mainWin = dynamic_cast(topLevelWidget()); KStatusBar *sb = mainWin ? mainWin->statusBar() : 0; mVacationScriptIndicator = new KMail::StatusBarLabel( sb ); @@ -4175,20 +4197,27 @@ KAction *KMMainWidget::akonadiStandardAction( Akonadi::StandardMailActionManager void KMMainWidget::slotCollectionProperties() { - if (!mCurrentFolder) return; + if ( !mCurrentFolder ) + return; Akonadi::CollectionAttributesSynchronizationJob sync( mCurrentFolder->collection() ); - // FIXME: this hangs kmail entirely when opening the folder properties dialog! -// sync.exec(); sync.start(); Akonadi::CollectionFetchJob fetch( mCurrentFolder->collection(), Akonadi::CollectionFetchJob::Base ); fetch.exec(); - Akonadi::Collection c = fetch.collections().first(); + const Akonadi::Collection collection = fetch.collections().first(); + + const QStringList pages = QStringList() << QLatin1String( "KMail::CollectionGeneralPage" ) + << QLatin1String( "KMail::CollectionViewPage" ) + << QLatin1String( "Akonadi::CachePolicyPage" ) + << QLatin1String( "KMail::CollectionTemplatesPage" ) + << QLatin1String( "KMail::CollectionAclPage" ) + << QLatin1String( "KMail::CollectionQuotaPage" ) + << QLatin1String( "KMail::CollectionMaintenancePage" ); - KMCollectionPropertiesDialog* dlg = new KMCollectionPropertiesDialog( c, this ); - dlg->setCaption( i18nc( "@title:window", "Properties of Folder %1", c.name() ) ); + Akonadi::CollectionPropertiesDialog *dlg = new Akonadi::CollectionPropertiesDialog( collection, pages, this ); + dlg->setCaption( i18nc( "@title:window", "Properties of Folder %1", collection.name() ) ); dlg->resize( 500, 400 ); dlg->show(); }