folderconfiguresettingspagewidget.cpp 2.7 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 12
#include <MailCommon/CollectionExpiryWidget>
#include <KLocalizedString>
Laurent Montel's avatar
Laurent Montel committed
13
#include <KMessageBox>
Laurent Montel's avatar
Laurent Montel committed
14 15
#include <QTabWidget>
#include <QVBoxLayout>
16 17 18 19

FolderConfigureSettingsPageWidget::FolderConfigureSettingsPageWidget(QWidget *parent)
    : QWidget(parent)
{
Laurent Montel's avatar
Laurent Montel committed
20 21 22 23 24 25 26 27
    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);

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

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

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

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

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

Laurent Montel's avatar
Laurent Montel committed
54
void FolderConfigureSettingsPageWidget::save(const Akonadi::Collection::List &cols)
Laurent Montel's avatar
Laurent Montel committed
55
{
Laurent Montel's avatar
Laurent Montel committed
56
    if (KMessageBox::Continue ==
Yuri Chornoivan's avatar
Yuri Chornoivan committed
57
            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
58 59 60
        const MailCommon::CollectionExpirySettings settings = mCollectionExpiryWidget->settings();
        for (Akonadi::Collection col : cols) {
            mFolderConfigureSettingsGeneralWidget->save(col);
Laurent Montel's avatar
Laurent Montel committed
61
            mCollectionExpiryWidget->save(settings, col, true, false);
Laurent Montel's avatar
Laurent Montel committed
62 63 64 65
            mFolderConfigureSettingsViewWidget->save(col);
            mCollectionTemplateWidget->save(col);
            //TODO sync col
        }
Laurent Montel's avatar
Laurent Montel committed
66
    }
Laurent Montel's avatar
Laurent Montel committed
67
}