SVN_SILENT made messages (after extraction)
[kdepim.git] / kmail / kmail_part.cpp
blob6667e864636638f0f2194913de3f3d73d91ec639
1 /*
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 "foldertreeview.h"
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;
65 migrate.migrate();
67 // import i18n data and icons from libraries:
68 KMail::insertLibraryCataloguesAndIcons();
70 //local, do the init
71 KMKernel *mKMailKernel = new KMKernel();
72 mKMailKernel->init();
73 mKMailKernel->setXmlGuiInstanceName(QStringLiteral("kmail2"));
75 // and session management
76 mKMailKernel->doSessionManagement();
78 // any dead letters?
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"));
89 setWidget(canvas);
90 KIconLoader::global()->addAppDir(QStringLiteral("libkdepim"));
91 mainWidget = new KMMainWidget(canvas, this, actionCollection(),
92 KSharedConfig::openConfig());
93 mainWidget->setObjectName(QStringLiteral("partmainwidget"));
94 QVBoxLayout *topLayout = new QVBoxLayout(canvas);
95 topLayout->addWidget(mainWidget);
96 topLayout->setMargin(0);
97 mainWidget->setFocusPolicy(Qt::ClickFocus);
98 KParts::StatusBarExtension *statusBar = new KParts::StatusBarExtension(this);
99 statusBar->addStatusBarItem(mainWidget->vacationScriptIndicator(), 2, false);
101 setXMLFile(QStringLiteral("kmail_part.rc"), true);
102 KSettings::Dispatcher::registerComponent(QStringLiteral("kmail2"), mKMailKernel, "slotConfigChanged");
105 KMailPart::~KMailPart()
107 qCDebug(KMAIL_LOG) << "Closing last KMMainWin: stopping mail check";
108 // Running KIO jobs prevent kapp from exiting, so we need to kill them
109 // if they are only about checking mail (not important stuff like moving messages)
110 mainWidget->destruct();
111 kmkernel->cleanup();
112 delete kmkernel;
115 void KMailPart::updateQuickSearchText()
117 mainWidget->updateQuickSearchLineText();
120 bool KMailPart::openFile()
122 qCDebug(KMAIL_LOG);
124 mainWidget->show();
125 return true;
128 //-----------------------------------------------------------------------------
130 void KMailPart::guiActivateEvent(KParts::GUIActivateEvent *e)
132 qCDebug(KMAIL_LOG);
133 KParts::ReadOnlyPart::guiActivateEvent(e);
134 mainWidget->initializeFilterActions();
135 mainWidget->tagActionManager()->createActions();
136 mainWidget->folderShortcutActionManager()->createActions();
137 mainWidget->updateVacationScriptStatus();
138 mainWidget->populateMessageListStatusFilterCombo();
141 void KMailPart::exit()
143 delete this;
146 QWidget *KMailPart::parentWidget() const
148 return mParentWidget;
150 #include "kmail_part.moc"