File indexing completed on 2024-12-01 04:36:35
0001 /* 0002 SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "bannerinfodialog.h" 0008 #include "bannerinfowidget.h" 0009 0010 #include <KConfigGroup> 0011 #include <KLocalizedString> 0012 #include <KSharedConfig> 0013 #include <KWindowConfig> 0014 #include <QDialogButtonBox> 0015 #include <QVBoxLayout> 0016 #include <QWindow> 0017 0018 namespace 0019 { 0020 const char myBannerInfoDialogConfigGroupName[] = "BannerInfoDialog"; 0021 } 0022 0023 BannerInfoDialog::BannerInfoDialog(RocketChatAccount *account, QWidget *parent) 0024 : QDialog(parent) 0025 , mBannerInfoWidget(new BannerInfoWidget(account, this)) 0026 { 0027 setWindowTitle(i18nc("@title:window", "Banner Information")); 0028 auto mainLayout = new QVBoxLayout(this); 0029 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0030 0031 mBannerInfoWidget->setObjectName(QStringLiteral("mBannerInfoWidget")); 0032 mainLayout->addWidget(mBannerInfoWidget); 0033 0034 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this); 0035 button->setObjectName(QStringLiteral("button")); 0036 mainLayout->addWidget(button); 0037 connect(button, &QDialogButtonBox::rejected, this, &BannerInfoDialog::reject); 0038 connect(button, &QDialogButtonBox::accepted, this, &BannerInfoDialog::accept); 0039 0040 readConfig(); 0041 } 0042 0043 BannerInfoDialog::~BannerInfoDialog() 0044 { 0045 writeConfig(); 0046 } 0047 0048 void BannerInfoDialog::readConfig() 0049 { 0050 create(); // ensure a window is created 0051 windowHandle()->resize(QSize(400, 300)); 0052 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myBannerInfoDialogConfigGroupName)); 0053 KWindowConfig::restoreWindowSize(windowHandle(), group); 0054 resize(windowHandle()->size()); // workaround for QTBUG-40584 0055 } 0056 0057 void BannerInfoDialog::writeConfig() 0058 { 0059 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myBannerInfoDialogConfigGroupName)); 0060 KWindowConfig::saveWindowSize(windowHandle(), group); 0061 } 0062 0063 #include "moc_bannerinfodialog.cpp"