Commit 435cae67 authored by Laurent Montel's avatar Laurent Montel 😁

Split code to configure agent

parent dca48009
......@@ -186,6 +186,7 @@ if (KDEPIM_BUILD_DESKTOP)
util.cpp
messageactions.cpp
foldershortcutactionmanager.cpp
kmconfigureagent.cpp
${kmailprivate_attributes_LIB_SRCS}
${kmailprivate_tag_LIB_SRCS}
${kmailprivate_job_LIB_SRCS}
......
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program 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.
This program 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 "kmconfigureagent.h"
#include <KMessageBox>
#include <KLocalizedString>
#include "archivemailagentinterface.h"
#include "sendlateragentinterface.h"
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
KMConfigureAgent::KMConfigureAgent(QWidget *parentWidget, QObject *parent)
: QObject(parent),
mParentWidget(parentWidget)
{
}
KMConfigureAgent::~KMConfigureAgent()
{
}
void KMConfigureAgent::slotConfigureAutomaticArchiving()
{
OrgFreedesktopAkonadiArchiveMailAgentInterface archiveMailInterface(QLatin1String("org.freedesktop.Akonadi.ArchiveMailAgent"), QLatin1String("/ArchiveMailAgent"),QDBusConnection::sessionBus(), this);
if (archiveMailInterface.isValid()) {
archiveMailInterface.showConfigureDialog( (qlonglong)mParentWidget->winId() );
} else {
KMessageBox::error(mParentWidget,i18n("Archive Mail Agent was not registered."));
}
}
void KMConfigureAgent::slotConfigureSendLater()
{
OrgFreedesktopAkonadiSendLaterAgentInterface sendLaterInterface(QLatin1String("org.freedesktop.Akonadi.SendLaterAgent"), QLatin1String("/SendLaterAgent"),QDBusConnection::sessionBus(), this);
if (sendLaterInterface.isValid()) {
sendLaterInterface.showConfigureDialog( (qlonglong)mParentWidget->winId() );
} else {
KMessageBox::error(mParentWidget,i18n("Send Later Agent was not registered."));
}
}
/*
Copyright (c) 2014 Montel Laurent <montel@kde.org>
This program 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.
This program 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 KMCONFIGUREAGENT_H
#define KMCONFIGUREAGENT_H
#include <QObject>
class KMConfigureAgent : public QObject
{
Q_OBJECT
public:
explicit KMConfigureAgent(QWidget *parentWidget, QObject *parent=0);
~KMConfigureAgent();
public Q_SLOTS:
void slotConfigureSendLater();
void slotConfigureAutomaticArchiving();
private:
QWidget *mParentWidget;
};
#endif // KMCONFIGUREAGENT_H
......@@ -53,9 +53,7 @@ using KSieveUi::SieveDebugDialog;
#include "collectionpage/collectionviewpage.h"
#include "collectionpage/collectionmailinglistpage.h"
#include "tag/tagselectdialog.h"
#include "archivemailagentinterface.h"
#include "job/createnewcontactjob.h"
#include "sendlateragentinterface.h"
#include "folderarchive/folderarchiveutil.h"
#include "folderarchive/folderarchivemanager.h"
......@@ -97,7 +95,7 @@ using KSieveUi::SieveDebugDialog;
#include "widgets/displaymessageformatactionmenu.h"
#include "ksieveui/vacation/vacationmanager.h"
#include "kmconfigureagent.h"
// LIBKDEPIM includes
#include "progresswidget/progressmanager.h"
......@@ -238,6 +236,7 @@ KMMainWidget::KMMainWidget( QWidget *parent, KXMLGUIClient *aGUIClient,
mFolderDisplayFormatPreference(MessageViewer::Viewer::UseGlobalSetting),
mSearchMessages( 0 )
{
mConfigAgent = new KMConfigureAgent(this, this);
// must be the first line of the constructor:
mStartupDone = false;
mWasEverShown = false;
......@@ -3093,13 +3092,13 @@ void KMMainWidget::setupActions()
{
KAction *action = new KAction(i18n("&Configure Automatic Archiving..."), this);
actionCollection()->addAction(QLatin1String("tools_automatic_archiving"), action );
connect(action, SIGNAL(triggered(bool)), SLOT(slotConfigureAutomaticArchiving()));
connect(action, SIGNAL(triggered(bool)), mConfigAgent, SLOT(slotConfigureAutomaticArchiving()));
}
{
KAction *action = new KAction(i18n("Delayed Messages..."), this);
actionCollection()->addAction(QLatin1String("message_delayed"), action );
connect(action, SIGNAL(triggered(bool)), SLOT(slotConfigureSendLater()));
connect(action, SIGNAL(triggered(bool)), mConfigAgent, SLOT(slotConfigureSendLater()));
}
......@@ -4729,26 +4728,6 @@ void KMMainWidget::savePaneSelection()
}
}
void KMMainWidget::slotConfigureAutomaticArchiving()
{
OrgFreedesktopAkonadiArchiveMailAgentInterface archiveMailInterface(QLatin1String("org.freedesktop.Akonadi.ArchiveMailAgent"), QLatin1String("/ArchiveMailAgent"),QDBusConnection::sessionBus(), this);
if (archiveMailInterface.isValid()) {
archiveMailInterface.showConfigureDialog( (qlonglong)winId() );
} else {
KMessageBox::error(this,i18n("Archive Mail Agent was not registered."));
}
}
void KMMainWidget::slotConfigureSendLater()
{
OrgFreedesktopAkonadiSendLaterAgentInterface sendLaterInterface(QLatin1String("org.freedesktop.Akonadi.SendLaterAgent"), QLatin1String("/SendLaterAgent"),QDBusConnection::sessionBus(), this);
if (sendLaterInterface.isValid()) {
sendLaterInterface.showConfigureDialog( (qlonglong)winId() );
} else {
KMessageBox::error(this,i18n("Send Later Agent was not registered."));
}
}
void KMMainWidget::updatePaneTagComboBox()
{
if (mMessagePane) {
......
......@@ -48,7 +48,7 @@ class Message;
class KUrl;
class QVBoxLayout;
class QSplitter;
class KMConfigureAgent;
class DisplayMessageFormatActionMenu;
class QMenu;
class KAction;
......@@ -426,11 +426,9 @@ protected slots:
void slotCollectionChanged( const Akonadi::Collection&, const QSet<QByteArray>& );
void slotCreateNewTab( bool );
void slotUpdateActionsAfterMailChecking();
void slotConfigureAutomaticArchiving();
void slotExportData();
void slotCreateAddressBookContact();
void slotOpenRecentMsg(const KUrl& url);
void slotConfigureSendLater();
private:
void checkAkonadiServerManagerState();
......@@ -629,6 +627,7 @@ private:
DisplayMessageFormatActionMenu *mDisplayMessageFormatMenu;
MessageViewer::Viewer::DisplayFormatMessage mFolderDisplayFormatPreference;
KAction *mSearchMessages;
KMConfigureAgent *mConfigAgent;
};
#endif
......
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