File indexing completed on 2025-03-09 04:54:37
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "remotecontentconfiguredialog.h" 0008 #include "remotecontentconfigurewidget.h" 0009 #include <KConfigGroup> 0010 #include <KLocalizedString> 0011 #include <KSharedConfig> 0012 #include <KWindowConfig> 0013 #include <QDialogButtonBox> 0014 #include <QVBoxLayout> 0015 #include <QWindow> 0016 0017 namespace 0018 { 0019 static const char myRemoteContentConfigureConfigGroupName[] = "RemoteContentConfigureDialog"; 0020 } 0021 0022 using namespace MessageViewer; 0023 RemoteContentConfigureDialog::RemoteContentConfigureDialog(QWidget *parent) 0024 : QDialog(parent) 0025 , mRemoteContentConfigureWidget(new RemoteContentConfigureWidget(this)) 0026 { 0027 setWindowTitle(i18nc("@title:window", "Configure Remote Content")); 0028 auto mainLayout = new QVBoxLayout(this); 0029 mainLayout->setObjectName(QLatin1StringView("mainLayout")); 0030 0031 mRemoteContentConfigureWidget->setObjectName(QLatin1StringView("mRemoteContentConfigureWidget")); 0032 mainLayout->addWidget(mRemoteContentConfigureWidget); 0033 0034 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this); 0035 buttonBox->setObjectName(QLatin1StringView("buttonBox")); 0036 connect(buttonBox, &QDialogButtonBox::accepted, this, &RemoteContentConfigureDialog::slotAccept); 0037 connect(buttonBox, &QDialogButtonBox::rejected, this, &RemoteContentConfigureDialog::reject); 0038 mainLayout->addWidget(buttonBox); 0039 readConfig(); 0040 } 0041 0042 RemoteContentConfigureDialog::~RemoteContentConfigureDialog() 0043 { 0044 writeConfig(); 0045 } 0046 0047 void RemoteContentConfigureDialog::slotAccept() 0048 { 0049 mRemoteContentConfigureWidget->saveSettings(); 0050 accept(); 0051 } 0052 0053 void RemoteContentConfigureDialog::readConfig() 0054 { 0055 create(); // ensure a window is created 0056 windowHandle()->resize(QSize(600, 200)); 0057 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myRemoteContentConfigureConfigGroupName)); 0058 KWindowConfig::restoreWindowSize(windowHandle(), group); 0059 resize(windowHandle()->size()); // workaround for QTBUG-40584 0060 } 0061 0062 void RemoteContentConfigureDialog::writeConfig() 0063 { 0064 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(myRemoteContentConfigureConfigGroupName)); 0065 KWindowConfig::saveWindowSize(windowHandle(), group); 0066 } 0067 0068 #include "moc_remotecontentconfiguredialog.cpp"