Astyle kdelibs
[kdepim.git] / kmail / configuredialog / configurestorageservicewidget.cpp
blob643d7299e67d4706f990a80f1344b961fb479ca5
1 /*
2 Copyright (c) 2014 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "configurestorageservicewidget.h"
19 #include "kmkernel.h"
20 #include "settings/globalsettings.h"
21 #include "pimcommon/storageservice/settings/storageservicesettingswidget.h"
22 #include "pimcommon/widgets/configureimmutablewidgetutils.h"
23 using namespace PimCommon::ConfigureImmutableWidgetUtils;
25 #include <KLocalizedString>
26 #include <KMessageBox>
28 #include <QVBoxLayout>
29 #include <QHBoxLayout>
30 #include <QCheckBox>
31 #include <QProcess>
32 #include <QPushButton>
33 #include <QStandardPaths>
35 ConfigureStorageServiceWidget::ConfigureStorageServiceWidget(QWidget *parent)
36 : QWidget(parent)
38 QVBoxLayout *lay = new QVBoxLayout;
39 mStorageServiceWidget = new PimCommon::StorageServiceSettingsWidget;
40 connect(mStorageServiceWidget, SIGNAL(changed()), this, SIGNAL(changed()));
41 lay->addWidget(mStorageServiceWidget);
43 QHBoxLayout *hbox = new QHBoxLayout;
44 mManageStorageService = new QPushButton(i18n("Manage Storage Service"));
45 hbox->addWidget(mManageStorageService);
46 hbox->addStretch();
47 lay->addLayout(hbox);
48 if (QStandardPaths::findExecutable(QLatin1String("storageservicemanager")).isEmpty()) {
49 mManageStorageService->setEnabled(false);
50 } else {
51 connect(mManageStorageService, &QPushButton::clicked, this, &ConfigureStorageServiceWidget::slotManageStorageService);
53 QList<PimCommon::StorageServiceAbstract::Capability> lstCapabilities;
54 lstCapabilities << PimCommon::StorageServiceAbstract::ShareLinkCapability;
55 if (KMKernel::self() && KMKernel::self()->storageServiceManager()) {
56 mStorageServiceWidget->setListService(KMKernel::self()->storageServiceManager()->listService(), lstCapabilities);
57 } else {
58 mStorageServiceWidget->setEnabled(false);
60 setLayout(lay);
63 ConfigureStorageServiceWidget::~ConfigureStorageServiceWidget()
67 void ConfigureStorageServiceWidget::slotManageStorageService()
69 if (!QProcess::startDetached(QLatin1String("storageservicemanager")))
70 KMessageBox::error(this, i18n("Could not start storage service manager; "
71 "please check your installation."),
72 i18n("KMail Error"));
75 void ConfigureStorageServiceWidget::save()
77 if (KMKernel::self() && KMKernel::self()->storageServiceManager()) {
78 KMKernel::self()->storageServiceManager()->setListService(mStorageServiceWidget->listService());
82 void ConfigureStorageServiceWidget::doLoadFromGlobalSettings()