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