File indexing completed on 2024-12-22 04:56:51
0001 /* 0002 * SPDX-FileCopyrightText: 2013 Christian Mollekopf <mollekopf@kolabsys.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 * 0006 */ 0007 #include "migrationagent.h" 0008 0009 #include "migrationstatuswidget.h" 0010 0011 #include "migration/gid/gidmigrator.h" 0012 #include "migration/googlegroupware/googleresourcemigrator.h" 0013 0014 #include <KContacts/Addressee> 0015 #include <KLocalizedString> 0016 #include <KUiServerJobTracker> 0017 #include <KWindowSystem> 0018 #include <QDialog> 0019 #include <QDialogButtonBox> 0020 #include <QVBoxLayout> 0021 0022 namespace Akonadi 0023 { 0024 MigrationAgent::MigrationAgent(const QString &id) 0025 : AgentBase(id) 0026 , mScheduler(new KUiServerJobTracker) 0027 { 0028 KLocalizedString::setApplicationDomain(QByteArrayLiteral("akonadi_migration_agent")); 0029 mScheduler.addMigrator(QSharedPointer<GidMigrator>::create(KContacts::Addressee::mimeType())); 0030 mScheduler.addMigrator(QSharedPointer<GoogleResourceMigrator>::create()); 0031 } 0032 0033 void MigrationAgent::configure(WId windowId) 0034 { 0035 auto dlg = new QDialog(); 0036 auto topLayout = new QVBoxLayout(dlg); 0037 0038 auto widget = new MigrationStatusWidget(mScheduler, dlg); 0039 topLayout->addWidget(widget); 0040 dlg->setAttribute(Qt::WA_DeleteOnClose); 0041 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, dlg); 0042 connect(buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept); 0043 connect(buttonBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject); 0044 topLayout->addWidget(buttonBox); 0045 0046 dlg->setWindowTitle(i18nc("Title of the window that shows the status of the migration agent and offers controls to start/stop individual migration jobs.", 0047 "Migration Status")); 0048 dlg->resize(600, 300); 0049 0050 if (windowId) { 0051 dlg->setAttribute(Qt::WA_NativeWindow, true); 0052 KWindowSystem::setMainWindow(dlg->windowHandle(), windowId); 0053 } 0054 dlg->show(); 0055 } 0056 } 0057 0058 AKONADI_AGENT_MAIN(Akonadi::MigrationAgent) 0059 0060 #include "moc_migrationagent.cpp"