File indexing completed on 2025-01-19 04:46:52
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "folderconfiguresettingspagewidget.h" 0008 #include "folderconfiguremodifycollectionjob.h" 0009 #include "folderconfiguresettingsexperywidget.h" 0010 #include "folderconfiguresettingsgeneralwidget.h" 0011 #include "folderconfiguresettingstemplatewidget.h" 0012 #include "folderconfiguresettingsviewwidget.h" 0013 #include <KLocalizedString> 0014 #include <KMessageBox> 0015 #include <MailCommon/CollectionExpiryWidget> 0016 #include <QTabWidget> 0017 #include <QVBoxLayout> 0018 0019 FolderConfigureSettingsPageWidget::FolderConfigureSettingsPageWidget(QWidget *parent) 0020 : QWidget(parent) 0021 , mCollectionExpiryWidget(new FolderConfigureSettingsExperyWidget(this)) 0022 , mFolderConfigureSettingsGeneralWidget(new FolderConfigureSettingsGeneralWidget(this)) 0023 , mCollectionTemplateWidget(new FolderConfigureSettingsTemplateWidget(this)) 0024 , mFolderConfigureSettingsViewWidget(new FolderConfigureSettingsViewWidget(this)) 0025 { 0026 auto mainLayout = new QVBoxLayout(this); 0027 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0028 mainLayout->setContentsMargins({}); 0029 0030 auto tab = new QTabWidget(this); 0031 tab->setObjectName(QLatin1StringView("tab")); 0032 mainLayout->addWidget(tab); 0033 0034 // General 0035 mFolderConfigureSettingsGeneralWidget->setObjectName(QLatin1StringView("mFolderConfigureSettingsGeneralWidget")); 0036 tab->addTab(mFolderConfigureSettingsGeneralWidget, i18n("General")); 0037 0038 // View 0039 mFolderConfigureSettingsViewWidget->setObjectName(QLatin1StringView("mFolderConfigureSettingsViewWidget")); 0040 tab->addTab(mFolderConfigureSettingsViewWidget, i18n("View")); 0041 0042 // Expiry => add Tab 0043 mCollectionExpiryWidget->setObjectName(QLatin1StringView("mCollectionExpiryWidget")); 0044 tab->addTab(mCollectionExpiryWidget, i18n("Expiry")); 0045 0046 // Template 0047 mCollectionTemplateWidget->setObjectName(QLatin1StringView("mCollectionTemplateWidget")); 0048 tab->addTab(mCollectionTemplateWidget, i18n("Template")); 0049 } 0050 0051 FolderConfigureSettingsPageWidget::~FolderConfigureSettingsPageWidget() = default; 0052 0053 void FolderConfigureSettingsPageWidget::save(const Akonadi::Collection::List &cols) 0054 { 0055 if (KMessageBox::Continue 0056 == KMessageBox::warningContinueCancel(this, 0057 i18n("It will override all settings for each selected folder. Do you want to continue?"), 0058 i18nc("@title:window", "Save Folder Settings"), 0059 KStandardGuiItem::save())) { 0060 for (Akonadi::Collection col : cols) { 0061 mFolderConfigureSettingsGeneralWidget->save(col); 0062 mCollectionExpiryWidget->save(col); 0063 mFolderConfigureSettingsViewWidget->save(col); 0064 mCollectionTemplateWidget->save(col); 0065 auto job = new FolderConfigureModifyCollectionJob(); 0066 job->setCollection(col); 0067 job->start(); 0068 } 0069 } 0070 } 0071 0072 #include "moc_folderconfiguresettingspagewidget.cpp"