folderconfiguresettingspagewidget.cpp 2.88 KB
Newer Older
1
/*
2
   SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
3

4
   SPDX-License-Identifier: GPL-2.0-or-later
5 6
*/

Laurent Montel's avatar
Laurent Montel committed
7
#include "folderconfiguresettingsgeneralwidget.h"
8
#include "folderconfiguresettingspagewidget.h"
9
#include "folderconfiguresettingstemplatewidget.h"
Laurent Montel's avatar
Laurent Montel committed
10
#include "folderconfiguresettingsviewwidget.h"
Laurent Montel's avatar
Laurent Montel committed
11
#include "folderconfiguremodifycollectionjob.h"
Laurent Montel's avatar
Laurent Montel committed
12 13
#include <MailCommon/CollectionExpiryWidget>
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
14
#include <KMessageBox>
Laurent Montel's avatar
Laurent Montel committed
15 16
#include <QTabWidget>
#include <QVBoxLayout>
17 18 19 20

FolderConfigureSettingsPageWidget::FolderConfigureSettingsPageWidget(QWidget *parent)
    : QWidget(parent)
{
Laurent Montel's avatar
Laurent Montel committed
21 22 23 24 25 26 27 28
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    mainLayout->setObjectName(QStringLiteral("mainLayout"));
    mainLayout->setContentsMargins(0, 0, 0, 0);

    QTabWidget *tab = new QTabWidget(this);
    tab->setObjectName(QStringLiteral("tab"));
    mainLayout->addWidget(tab);

29
    //General
Laurent Montel's avatar
Laurent Montel committed
30 31 32 33
    mFolderConfigureSettingsGeneralWidget = new FolderConfigureSettingsGeneralWidget(this);
    mFolderConfigureSettingsGeneralWidget->setObjectName(QStringLiteral("mFolderConfigureSettingsGeneralWidget"));
    tab->addTab(mFolderConfigureSettingsGeneralWidget, i18n("General"));

Laurent Montel's avatar
Laurent Montel committed
34 35 36 37 38
    //View
    mFolderConfigureSettingsViewWidget = new FolderConfigureSettingsViewWidget(this);
    mFolderConfigureSettingsViewWidget->setObjectName(QStringLiteral("mFolderConfigureSettingsViewWidget"));
    tab->addTab(mFolderConfigureSettingsViewWidget, i18n("View"));

Laurent Montel's avatar
Laurent Montel committed
39
    //Expiry => add Tab
Laurent Montel's avatar
Laurent Montel committed
40 41
    mCollectionExpiryWidget = new MailCommon::CollectionExpiryWidget(this);
    mCollectionExpiryWidget->setObjectName(QStringLiteral("mCollectionExpiryWidget"));
Laurent Montel's avatar
Laurent Montel committed
42
    mCollectionExpiryWidget->hideExpireNowButton();
Laurent Montel's avatar
Laurent Montel committed
43
    tab->addTab(mCollectionExpiryWidget, i18n("Expiry"));
44 45 46 47 48

    //Template
    mCollectionTemplateWidget = new FolderConfigureSettingsTemplateWidget(this);
    mCollectionTemplateWidget->setObjectName(QStringLiteral("mCollectionTemplateWidget"));
    tab->addTab(mCollectionTemplateWidget, i18n("Template"));
49 50 51 52 53
}

FolderConfigureSettingsPageWidget::~FolderConfigureSettingsPageWidget()
{
}
Laurent Montel's avatar
Laurent Montel committed
54

Laurent Montel's avatar
Laurent Montel committed
55
void FolderConfigureSettingsPageWidget::save(const Akonadi::Collection::List &cols)
Laurent Montel's avatar
Laurent Montel committed
56
{
Laurent Montel's avatar
Laurent Montel committed
57
    if (KMessageBox::Continue ==
Yuri Chornoivan's avatar
Yuri Chornoivan committed
58
            KMessageBox::warningContinueCancel(this, i18n("It will override all settings for each selected folder. Do you want to continue?"),i18n("Save Folder Settings"))) {
Laurent Montel's avatar
Laurent Montel committed
59 60 61
        const MailCommon::CollectionExpirySettings settings = mCollectionExpiryWidget->settings();
        for (Akonadi::Collection col : cols) {
            mFolderConfigureSettingsGeneralWidget->save(col);
Laurent Montel's avatar
Laurent Montel committed
62
            mCollectionExpiryWidget->save(settings, col, true, false);
Laurent Montel's avatar
Laurent Montel committed
63 64
            mFolderConfigureSettingsViewWidget->save(col);
            mCollectionTemplateWidget->save(col);
Laurent Montel's avatar
Laurent Montel committed
65 66 67
            FolderConfigureModifyCollectionJob *job = new FolderConfigureModifyCollectionJob();
            job->setCollection(col);
            job->start();
Laurent Montel's avatar
Laurent Montel committed
68
        }
Laurent Montel's avatar
Laurent Montel committed
69
    }
Laurent Montel's avatar
Laurent Montel committed
70
}