From 5487a33a5c91a87ee14bbdcd8f7c9ef880c1cb54 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 3 Dec 2014 08:03:01 +0100 Subject: [PATCH 1/2] Clean up --- kmmainwidget.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 98e8cc97a..9fd602984 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -190,12 +190,7 @@ using KSieveUi::SieveDebugDialog; #include #include #include -#include -#include -#include -// System includes -#include // ugh #include #include #include @@ -211,9 +206,6 @@ using KMail::AntiSpamWizard; using KMime::Types::AddrSpecList; using MessageViewer::AttachmentStrategy; -Q_DECLARE_METATYPE(KPIM::ProgressItem*) -Q_DECLARE_METATYPE(Akonadi::Job*) -Q_DECLARE_METATYPE(QPointer) K_GLOBAL_STATIC( KMMainWidget::PtrList, theMainWidgetList ) //----------------------------------------------------------------------------- From 3b971093ad33d3a2846243fe0996761b13060c2d Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 3 Dec 2014 08:28:03 +0100 Subject: [PATCH 2/2] Move more function outside kmmainwidget --- CMakeLists.txt | 2 +- ...agent.cpp => kmlaunchexternalcomponent.cpp | 51 ++++++++++++++-- ...gureagent.h => kmlaunchexternalcomponent.h | 16 +++-- kmmainwidget.cpp | 58 +++---------------- kmmainwidget.h | 8 +-- 5 files changed, 67 insertions(+), 68 deletions(-) rename kmconfigureagent.cpp => kmlaunchexternalcomponent.cpp (52%) rename kmconfigureagent.h => kmlaunchexternalcomponent.h (70%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9be60ca1..3c73f8c2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,7 +189,7 @@ if (KDEPIM_BUILD_DESKTOP) util.cpp messageactions.cpp foldershortcutactionmanager.cpp - kmconfigureagent.cpp + kmlaunchexternalcomponent.cpp manageshowcollectionproperties.cpp ${kmailprivate_attributes_LIB_SRCS} ${kmailprivate_tag_LIB_SRCS} diff --git a/kmconfigureagent.cpp b/kmlaunchexternalcomponent.cpp similarity index 52% rename from kmconfigureagent.cpp rename to kmlaunchexternalcomponent.cpp index 2de2bfb87..173235526 100644 --- a/kmconfigureagent.cpp +++ b/kmlaunchexternalcomponent.cpp @@ -15,9 +15,10 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "kmconfigureagent.h" +#include "kmlaunchexternalcomponent.h" #include #include +#include #include "archivemailagentinterface.h" #include "sendlateragentinterface.h" @@ -25,20 +26,22 @@ #include #include +#include +#include -KMConfigureAgent::KMConfigureAgent(QWidget *parentWidget, QObject *parent) +KMLaunchExternalComponent::KMLaunchExternalComponent(QWidget *parentWidget, QObject *parent) : QObject(parent), mParentWidget(parentWidget) { } -KMConfigureAgent::~KMConfigureAgent() +KMLaunchExternalComponent::~KMLaunchExternalComponent() { } -void KMConfigureAgent::slotConfigureAutomaticArchiving() +void KMLaunchExternalComponent::slotConfigureAutomaticArchiving() { OrgFreedesktopAkonadiArchiveMailAgentInterface archiveMailInterface(QLatin1String("org.freedesktop.Akonadi.ArchiveMailAgent"), QLatin1String("/ArchiveMailAgent"),QDBusConnection::sessionBus(), this); if (archiveMailInterface.isValid()) { @@ -48,7 +51,7 @@ void KMConfigureAgent::slotConfigureAutomaticArchiving() } } -void KMConfigureAgent::slotConfigureSendLater() +void KMLaunchExternalComponent::slotConfigureSendLater() { OrgFreedesktopAkonadiSendLaterAgentInterface sendLaterInterface(QLatin1String("org.freedesktop.Akonadi.SendLaterAgent"), QLatin1String("/SendLaterAgent"),QDBusConnection::sessionBus(), this); if (sendLaterInterface.isValid()) { @@ -58,7 +61,7 @@ void KMConfigureAgent::slotConfigureSendLater() } } -void KMConfigureAgent::slotConfigureFollowupReminder() +void KMLaunchExternalComponent::slotConfigureFollowupReminder() { OrgFreedesktopAkonadiFollowUpReminderAgentInterface followUpInterface(QLatin1String("org.freedesktop.Akonadi.FollowUpReminder"), QLatin1String("/FollowUpReminder"),QDBusConnection::sessionBus(), this); if (followUpInterface.isValid()) { @@ -67,3 +70,39 @@ void KMConfigureAgent::slotConfigureFollowupReminder() KMessageBox::error(mParentWidget,i18n("Followup Reminder Agent was not registered.")); } } + +void KMLaunchExternalComponent::slotStartCertManager() +{ + if ( !QProcess::startDetached(QLatin1String("kleopatra") ) ) + KMessageBox::error( mParentWidget, i18n( "Could not start certificate manager; " + "please check your installation." ), + i18n( "KMail Error" ) ); + else + qDebug() << "slotStartCertManager(): certificate manager started."; +} + +void KMLaunchExternalComponent::slotStartWatchGnuPG() +{ + if ( !QProcess::startDetached(QLatin1String("kwatchgnupg")) ) + KMessageBox::error( mParentWidget, i18n( "Could not start GnuPG LogViewer (kwatchgnupg); " + "please check your installation." ), + i18n( "KMail Error" ) ); +} + +void KMLaunchExternalComponent::slotImportWizard() +{ + const QString path = KStandardDirs::findExe( QLatin1String("importwizard" ) ); + if ( !QProcess::startDetached( path ) ) + KMessageBox::error( mParentWidget, i18n( "Could not start the import wizard. " + "Please check your installation." ), + i18n( "Unable to start import wizard" ) ); +} + +void KMLaunchExternalComponent::slotExportData() +{ + const QString path = KStandardDirs::findExe( QLatin1String("pimsettingexporter" ) ); + if ( !QProcess::startDetached( path ) ) + KMessageBox::error( mParentWidget, i18n( "Could not start \"PIM Setting Exporter\" program. " + "Please check your installation." ), + i18n( "Unable to start \"PIM Setting Exporter\" program" ) ); +} diff --git a/kmconfigureagent.h b/kmlaunchexternalcomponent.h similarity index 70% rename from kmconfigureagent.h rename to kmlaunchexternalcomponent.h index 6ac7adf46..ffb266cd1 100644 --- a/kmconfigureagent.h +++ b/kmlaunchexternalcomponent.h @@ -15,24 +15,28 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef KMCONFIGUREAGENT_H -#define KMCONFIGUREAGENT_H +#ifndef KMLAUNCHEXTERNALCOMPONENT_H +#define KMLAUNCHEXTERNALCOMPONENT_H #include -class KMConfigureAgent : public QObject +class KMLaunchExternalComponent : public QObject { Q_OBJECT public: - explicit KMConfigureAgent(QWidget *parentWidget, QObject *parent=0); - ~KMConfigureAgent(); + explicit KMLaunchExternalComponent(QWidget *parentWidget, QObject *parent=0); + ~KMLaunchExternalComponent(); public Q_SLOTS: void slotConfigureSendLater(); void slotConfigureAutomaticArchiving(); void slotConfigureFollowupReminder(); + void slotStartCertManager(); + void slotStartWatchGnuPG(); + void slotImportWizard(); + void slotExportData(); private: QWidget *mParentWidget; }; -#endif // KMCONFIGUREAGENT_H +#endif // KMLAUNCHEXTERNALCOMPONENT_H diff --git a/kmmainwidget.cpp b/kmmainwidget.cpp index 9fd602984..46b41d931 100644 --- a/kmmainwidget.cpp +++ b/kmmainwidget.cpp @@ -96,7 +96,7 @@ using KSieveUi::SieveDebugDialog; #include "widgets/displaymessageformatactionmenu.h" #include "ksieveui/vacation/vacationmanager.h" -#include "kmconfigureagent.h" +#include "kmlaunchexternalcomponent.h" // LIBKDEPIM includes #include "progresswidget/progressmanager.h" @@ -230,7 +230,7 @@ KMMainWidget::KMMainWidget( QWidget *parent, KXMLGUIClient *aGUIClient, mSearchMessages( 0 ), mManageShowCollectionProperties(new ManageShowCollectionProperties(this, this)) { - mConfigAgent = new KMConfigureAgent(this, this); + mLaunchExternalComponent = new KMLaunchExternalComponent(this, this); // must be the first line of the constructor: mStartupDone = false; mWasEverShown = false; @@ -1477,7 +1477,6 @@ void KMMainWidget::slotExpireFolder() return; bool mustDeleteExpirationAttribute = false; MailCommon::ExpireCollectionAttribute *attr = MailCommon::ExpireCollectionAttribute::expirationCollectionAttribute( mCurrentFolder->collection(), mustDeleteExpirationAttribute ); - ; bool canBeExpired = true; if ( !attr->isAutoExpire() ) { canBeExpired = false; @@ -2314,26 +2313,6 @@ void KMMainWidget::slotDebugSieve() #endif } -//----------------------------------------------------------------------------- -void KMMainWidget::slotStartCertManager() -{ - if ( !QProcess::startDetached(QLatin1String("kleopatra") ) ) - KMessageBox::error( this, i18n( "Could not start certificate manager; " - "please check your installation." ), - i18n( "KMail Error" ) ); - else - kDebug() << "\nslotStartCertManager(): certificate manager started."; -} - -//----------------------------------------------------------------------------- -void KMMainWidget::slotStartWatchGnuPG() -{ - if ( !QProcess::startDetached(QLatin1String("kwatchgnupg")) ) - KMessageBox::error( this, i18n( "Could not start GnuPG LogViewer (kwatchgnupg); " - "please check your installation." ), - i18n( "KMail Error" ) ); -} - //----------------------------------------------------------------------------- void KMMainWidget::slotConfigChanged() { @@ -3006,7 +2985,7 @@ void KMMainWidget::setupActions() { KAction *action = new KAction(KIcon(QLatin1String("pgp-keys")), i18n("Certificate Manager"), this); actionCollection()->addAction(QLatin1String("tools_start_certman"), action ); - connect(action, SIGNAL(triggered(bool)), SLOT(slotStartCertManager())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotStartCertManager())); // disable action if no certman binary is around if (KStandardDirs::findExe(QLatin1String("kleopatra")).isEmpty()) action->setEnabled(false); @@ -3014,7 +2993,7 @@ void KMMainWidget::setupActions() { KAction *action = new KAction(KIcon(QLatin1String("pgp-keys")), i18n("GnuPG Log Viewer"), this); actionCollection()->addAction(QLatin1String("tools_start_kwatchgnupg"), action ); - connect(action, SIGNAL(triggered(bool)), SLOT(slotStartWatchGnuPG())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotStartWatchGnuPG())); #ifdef Q_OS_WIN32 // not ported yet, underlying infrastructure missing on Windows const bool usableKWatchGnupg = false; @@ -3062,7 +3041,7 @@ void KMMainWidget::setupActions() { KAction *action = new KAction( i18n("&Import Wizard..."), this ); actionCollection()->addAction( QLatin1String("importWizard"), action ); - connect( action, SIGNAL(triggered(bool)), SLOT(slotImportWizard()) ); + connect( action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotImportWizard()) ); } if ( KSieveUi::Util::allowOutOfOfficeSettings() ) { @@ -3074,19 +3053,19 @@ void KMMainWidget::setupActions() { KAction *action = new KAction(i18n("&Configure Automatic Archiving..."), this); actionCollection()->addAction(QLatin1String("tools_automatic_archiving"), action ); - connect(action, SIGNAL(triggered(bool)), mConfigAgent, SLOT(slotConfigureAutomaticArchiving())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotConfigureAutomaticArchiving())); } { KAction *action = new KAction(i18n("Delayed Messages..."), this); actionCollection()->addAction(QLatin1String("message_delayed"), action ); - connect(action, SIGNAL(triggered(bool)), mConfigAgent, SLOT(slotConfigureSendLater())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotConfigureSendLater())); } { KAction *action = new KAction(i18n("Followup Reminder Messages..."), this); actionCollection()->addAction(QLatin1String("followup_reminder_messages"), action ); - connect(action, SIGNAL(triggered(bool)), mConfigAgent, SLOT(slotConfigureFollowupReminder())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotConfigureFollowupReminder())); } @@ -3504,7 +3483,7 @@ void KMMainWidget::setupActions() { KAction *action = new KAction(KIcon(QLatin1String("kmail")), i18n("&Export KMail Data..."), this); actionCollection()->addAction(QLatin1String("kmail_export_data"), action ); - connect(action, SIGNAL(triggered(bool)), this, SLOT(slotExportData())); + connect(action, SIGNAL(triggered(bool)), mLaunchExternalComponent, SLOT(slotExportData())); } { @@ -4318,15 +4297,6 @@ void KMMainWidget::slotAccountWizard() KMail::Util::launchAccountWizard( this ); } -void KMMainWidget::slotImportWizard() -{ - const QString path = KStandardDirs::findExe( QLatin1String("importwizard" ) ); - if ( !QProcess::startDetached( path ) ) - KMessageBox::error( this, i18n( "Could not start the import wizard. " - "Please check your installation." ), - i18n( "Unable to start import wizard" ) ); -} - //----------------------------------------------------------------------------- void KMMainWidget::slotFilterLogViewer() { @@ -4561,16 +4531,6 @@ void KMMainWidget::updatePaneTagComboBox() } } - -void KMMainWidget::slotExportData() -{ - const QString path = KStandardDirs::findExe( QLatin1String("pimsettingexporter" ) ); - if ( !QProcess::startDetached( path ) ) - KMessageBox::error( this, i18n( "Could not start \"PIM Setting Exporter\" program. " - "Please check your installation." ), - i18n( "Unable to start \"PIM Setting Exporter\" program" ) ); -} - void KMMainWidget::slotCreateAddressBookContact() { CreateNewContactJob *job = new CreateNewContactJob( this, this ); diff --git a/kmmainwidget.h b/kmmainwidget.h index 2ba62b511..d46283582 100644 --- a/kmmainwidget.h +++ b/kmmainwidget.h @@ -48,7 +48,7 @@ class Message; class KUrl; class QVBoxLayout; class QSplitter; -class KMConfigureAgent; +class KMLaunchExternalComponent; class DisplayMessageFormatActionMenu; class QMenu; class KAction; @@ -321,8 +321,6 @@ protected slots: void slotResendMsg(); void slotCheckVacation(); void slotDebugSieve(); - void slotStartCertManager(); - void slotStartWatchGnuPG(); void slotApplyFilters(); void slotApplyFiltersOnFolder(); void slotExpandThread(); @@ -352,7 +350,6 @@ protected slots: void slotAntiVirusWizard(); void slotFilterLogViewer(); void slotAccountWizard(); - void slotImportWizard(); /** Message navigation */ void slotSelectNextMessage(); @@ -422,7 +419,6 @@ protected slots: void slotCollectionChanged( const Akonadi::Collection&, const QSet& ); void slotCreateNewTab( bool ); void slotUpdateActionsAfterMailChecking(); - void slotExportData(); void slotCreateAddressBookContact(); void slotOpenRecentMsg(const KUrl& url); @@ -618,7 +614,7 @@ private: DisplayMessageFormatActionMenu *mDisplayMessageFormatMenu; MessageViewer::Viewer::DisplayFormatMessage mFolderDisplayFormatPreference; KAction *mSearchMessages; - KMConfigureAgent *mConfigAgent; + KMLaunchExternalComponent *mLaunchExternalComponent; ManageShowCollectionProperties *mManageShowCollectionProperties; };