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 "expireaccounttrashfolderconfigdialog.h" 0008 #include "expireaccounttrashfolderconfigwidget.h" 0009 #include <KConfigGroup> 0010 #include <KLocalizedString> 0011 #include <KSharedConfig> 0012 #include <KWindowConfig> 0013 #include <QDialogButtonBox> 0014 #include <QVBoxLayout> 0015 #include <QWindow> 0016 namespace 0017 { 0018 static const char myConfigGroupName[] = "ExpireAccountTrashFolderConfigDialog"; 0019 } 0020 0021 ExpireAccountTrashFolderConfigDialog::ExpireAccountTrashFolderConfigDialog(QWidget *parent) 0022 : QDialog(parent) 0023 , mExpireAccountTrashFolderConfig(new ExpireAccountTrashFolderConfigWidget(this)) 0024 { 0025 auto mainLayout = new QVBoxLayout(this); 0026 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0027 setWindowTitle(i18nc("@title:window", "Configure Expiry Account Trash Folder")); 0028 0029 mExpireAccountTrashFolderConfig->setObjectName(QLatin1StringView("mExpireAccountTrashFolderConfig")); 0030 mainLayout->addWidget(mExpireAccountTrashFolderConfig); 0031 0032 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, this); 0033 buttonBox->setObjectName(QLatin1StringView("buttonbox")); 0034 connect(buttonBox, &QDialogButtonBox::rejected, this, &ExpireAccountTrashFolderConfigDialog::reject); 0035 connect(buttonBox, &QDialogButtonBox::accepted, this, &ExpireAccountTrashFolderConfigDialog::accept); 0036 mainLayout->addWidget(buttonBox); 0037 readConfig(); 0038 } 0039 0040 ExpireAccountTrashFolderConfigDialog::~ExpireAccountTrashFolderConfigDialog() 0041 { 0042 mExpireAccountTrashFolderConfig->save(); 0043 writeConfig(); 0044 } 0045 0046 void ExpireAccountTrashFolderConfigDialog::readConfig() 0047 { 0048 create(); // ensure a window is created 0049 windowHandle()->resize(QSize(300, 200)); 0050 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGroupName)); 0051 KWindowConfig::restoreWindowSize(windowHandle(), group); 0052 resize(windowHandle()->size()); // workaround for QTBUG-40584 0053 } 0054 0055 void ExpireAccountTrashFolderConfigDialog::writeConfig() 0056 { 0057 KConfigGroup grp(KSharedConfig::openStateConfig(), QLatin1StringView(myConfigGroupName)); 0058 KWindowConfig::saveWindowSize(windowHandle(), grp); 0059 grp.sync(); 0060 } 0061 0062 #include "moc_expireaccounttrashfolderconfigdialog.cpp"