File indexing completed on 2024-12-22 04:45:36
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "moderationmessageinfodialog.h" 0008 #include "moderationmessageinfowidget.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 static const char myModerationMessageInfoDialogGroupName[] = "ModerationMessageInfoDialog"; 0021 } 0022 ModerationMessageInfoDialog::ModerationMessageInfoDialog(RocketChatAccount *account, QWidget *parent) 0023 : QDialog(parent) 0024 , mModerationMessageInfoWidget(new ModerationMessageInfoWidget(account, this)) 0025 { 0026 setWindowTitle(i18nc("@title:window", "Show Moderation Report")); 0027 auto mainLayout = new QVBoxLayout(this); 0028 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0029 0030 mModerationMessageInfoWidget->setObjectName(QStringLiteral("mModerationMessageInfoWidget")); 0031 mainLayout->addWidget(mModerationMessageInfoWidget); 0032 0033 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this); 0034 button->setObjectName(QStringLiteral("button")); 0035 mainLayout->addWidget(button); 0036 connect(button, &QDialogButtonBox::rejected, this, &ModerationMessageInfoDialog::reject); 0037 readConfig(); 0038 } 0039 0040 ModerationMessageInfoDialog::~ModerationMessageInfoDialog() 0041 { 0042 writeConfig(); 0043 } 0044 0045 void ModerationMessageInfoDialog::setReportInfos(const ModerationReportInfos &info) 0046 { 0047 mModerationMessageInfoWidget->setReportInfos(info); 0048 } 0049 0050 void ModerationMessageInfoDialog::readConfig() 0051 { 0052 create(); // ensure a window is created 0053 windowHandle()->resize(QSize(800, 600)); 0054 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myModerationMessageInfoDialogGroupName)); 0055 KWindowConfig::restoreWindowSize(windowHandle(), group); 0056 resize(windowHandle()->size()); // workaround for QTBUG-40584 0057 } 0058 0059 void ModerationMessageInfoDialog::writeConfig() 0060 { 0061 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myModerationMessageInfoDialogGroupName)); 0062 KWindowConfig::saveWindowSize(windowHandle(), group); 0063 } 0064 0065 #include "moc_moderationmessageinfodialog.cpp"