3 This file is part of KMail.
4 Copyright (c) 2002-2003 Don Sanders <sanders@kde.org>,
5 Copyright (c) 2003 Zack Rusin <zack@kde.org>,
6 Based on the work of Cornelius Schumacher <schumacher@kde.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
27 #include "kmail_part.h"
29 #include "kmmainwin.h"
30 #include "kmmainwidget.h"
31 #include "kmstartup.h"
32 #include "aboutdata.h"
34 #include <QVBoxLayout>
36 #include <kparts/statusbarextension.h>
37 #include <kparts/mainwindow.h>
38 #include <kpluginfactory.h>
39 #include <kpluginloader.h>
40 #include <kiconloader.h>
41 #include "kmail_debug.h"
42 #include <ksettings/dispatcher.h>
43 #include <kmailpartadaptor.h>
44 #include <AkonadiCore/collection.h>
45 #include <AkonadiCore/entitydisplayattribute.h>
46 #include <AkonadiCore/changerecorder.h>
47 #include "MailCommon/FolderTreeView"
48 #include "tag/tagactionmanager.h"
49 #include "foldershortcutactionmanager.h"
50 #include "kmmigrateapplication.h"
52 #include <KSharedConfig>
54 K_PLUGIN_FACTORY(KMailFactory
, registerPlugin
<KMailPart
>();)
56 using namespace KMail
;
58 KMailPart::KMailPart(QWidget
*parentWidget
, QObject
*parent
, const QVariantList
&) :
59 KParts::ReadOnlyPart(parent
),
60 mParentWidget(parentWidget
)
62 setComponentName(QStringLiteral("kmail2"), QStringLiteral("kmail2"));
64 KMMigrateApplication migrate
;
67 // import i18n data and icons from libraries:
68 KMail::insertLibraryCataloguesAndIcons();
71 KMKernel
*mKMailKernel
= new KMKernel();
73 mKMailKernel
->setXmlGuiInstanceName(QStringLiteral("kmail2"));
75 // and session management
76 mKMailKernel
->doSessionManagement();
79 mKMailKernel
->recoverDeadLetters();
81 kmkernel
->setupDBus(); // Ok. We are ready for D-Bus requests.
82 (void) new KmailpartAdaptor(this);
83 QDBusConnection::sessionBus().registerObject(QStringLiteral("/KMailPart"), this);
85 // create a canvas to insert our widget
86 QWidget
*canvas
= new QWidget(parentWidget
);
87 canvas
->setFocusPolicy(Qt::ClickFocus
);
88 canvas
->setObjectName(QStringLiteral("canvas"));
90 mainWidget
= new KMMainWidget(canvas
, this, actionCollection(),
91 KSharedConfig::openConfig());
92 mainWidget
->setObjectName(QStringLiteral("partmainwidget"));
93 QVBoxLayout
*topLayout
= new QVBoxLayout(canvas
);
94 topLayout
->addWidget(mainWidget
);
95 topLayout
->setMargin(0);
96 mainWidget
->setFocusPolicy(Qt::ClickFocus
);
97 KParts::StatusBarExtension
*statusBar
= new KParts::StatusBarExtension(this);
98 statusBar
->addStatusBarItem(mainWidget
->vacationScriptIndicator(), 2, false);
100 setXMLFile(QStringLiteral("kmail_part.rc"), true);
101 KSettings::Dispatcher::registerComponent(QStringLiteral("kmail2"), mKMailKernel
, "slotConfigChanged");
104 KMailPart::~KMailPart()
106 qCDebug(KMAIL_LOG
) << "Closing last KMMainWin: stopping mail check";
107 // Running KIO jobs prevent kapp from exiting, so we need to kill them
108 // if they are only about checking mail (not important stuff like moving messages)
109 mainWidget
->destruct();
114 void KMailPart::updateQuickSearchText()
116 mainWidget
->updateQuickSearchLineText();
119 bool KMailPart::openFile()
127 //-----------------------------------------------------------------------------
129 void KMailPart::guiActivateEvent(KParts::GUIActivateEvent
*e
)
132 KParts::ReadOnlyPart::guiActivateEvent(e
);
133 mainWidget
->initializeFilterActions();
134 mainWidget
->tagActionManager()->createActions();
135 mainWidget
->folderShortcutActionManager()->createActions();
136 mainWidget
->updateVacationScriptStatus();
137 mainWidget
->populateMessageListStatusFilterCombo();
140 void KMailPart::exit()
145 QWidget
*KMailPart::parentWidget() const
147 return mParentWidget
;
150 void KMailPart::save()
154 #include "kmail_part.moc"