Commit 467e8cd9 authored by Laurent Montel's avatar Laurent Montel 😁

Move more function outside kmmainwidget

parent e22cd16c
......@@ -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}
......
......@@ -15,9 +15,10 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "kmconfigureagent.h"
#include "kmlaunchexternalcomponent.h"
#include <KMessageBox>
#include <KLocalizedString>
#include <KStandardDirs>
#include "archivemailagentinterface.h"
#include "sendlateragentinterface.h"
......@@ -25,20 +26,22 @@
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
#include <QProcess>
#include <QDebug>
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" ) );
}
......@@ -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 <QObject>
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
......@@ -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 );
......
......@@ -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<QByteArray>& );
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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment