File indexing completed on 2024-12-08 04:34:21
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "explorepermissionsdialog.h" 0008 #include "explorepermissionswidget.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 const char myExplorePermissionDialogConfigGroupName[] = "ExplorePermissionDialog"; 0019 } 0020 ExplorePermissionsDialog::ExplorePermissionsDialog(QWidget *parent) 0021 : QDialog(parent) 0022 , mExporePermissionWidget(new ExplorePermissionsWidget(this)) 0023 { 0024 setWindowTitle(i18nc("@title:window", "Permissions")); 0025 auto mainLayout = new QVBoxLayout(this); 0026 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0027 0028 mExporePermissionWidget->setObjectName(QStringLiteral("mExporePermissionWidget")); 0029 mainLayout->addWidget(mExporePermissionWidget); 0030 0031 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this); 0032 button->setObjectName(QStringLiteral("button")); 0033 mainLayout->addWidget(button); 0034 connect(button, &QDialogButtonBox::rejected, this, &ExplorePermissionsDialog::reject); 0035 connect(button, &QDialogButtonBox::accepted, this, &ExplorePermissionsDialog::accept); 0036 0037 readConfig(); 0038 } 0039 0040 ExplorePermissionsDialog::~ExplorePermissionsDialog() 0041 { 0042 writeConfig(); 0043 } 0044 0045 void ExplorePermissionsDialog::readConfig() 0046 { 0047 create(); // ensure a window is created 0048 windowHandle()->resize(QSize(400, 300)); 0049 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myExplorePermissionDialogConfigGroupName)); 0050 KWindowConfig::restoreWindowSize(windowHandle(), group); 0051 resize(windowHandle()->size()); // workaround for QTBUG-40584 0052 } 0053 0054 void ExplorePermissionsDialog::writeConfig() 0055 { 0056 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myExplorePermissionDialogConfigGroupName)); 0057 KWindowConfig::saveWindowSize(windowHandle(), group); 0058 } 0059 0060 void ExplorePermissionsDialog::setPermissions(const QVector<Permission> &permissions) 0061 { 0062 mExporePermissionWidget->setPermissions(permissions); 0063 } 0064 0065 void ExplorePermissionsDialog::setOWnRoles(const QStringList &roleStr) 0066 { 0067 mExporePermissionWidget->setOWnRoles(roleStr); 0068 } 0069 0070 #include "moc_explorepermissionsdialog.cpp"