File indexing completed on 2024-05-12 16:27:16

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 "showmentionsmessagesdialog.h"
0008 #include "rocketchataccount.h"
0009 #include <KConfigGroup>
0010 #include <KLocalizedString>
0011 #include <KSharedConfig>
0012 #include <KWindowConfig>
0013 #include <QWindow>
0014 namespace
0015 {
0016 static const char myShowMentionsMessagesDialogGroupName[] = "ShowMentionsMessagesDialog";
0017 }
0018 
0019 ShowMentionsMessagesDialog::ShowMentionsMessagesDialog(RocketChatAccount *account, QWidget *parent)
0020     : ShowListMessageBaseDialog(account, parent)
0021 {
0022     setWindowTitle(i18nc("@title:window", "Show Mentions Messages - %1", account ? account->accountName() : QStringLiteral("AccountName")));
0023     readConfig();
0024 }
0025 
0026 ShowMentionsMessagesDialog::~ShowMentionsMessagesDialog()
0027 {
0028     writeConfig();
0029 }
0030 
0031 void ShowMentionsMessagesDialog::readConfig()
0032 {
0033     create(); // ensure a window is created
0034     windowHandle()->resize(QSize(800, 600));
0035     KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myShowMentionsMessagesDialogGroupName));
0036     KWindowConfig::restoreWindowSize(windowHandle(), group);
0037     resize(windowHandle()->size()); // workaround for QTBUG-40584
0038 }
0039 
0040 void ShowMentionsMessagesDialog::writeConfig()
0041 {
0042     KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myShowMentionsMessagesDialogGroupName));
0043     KWindowConfig::saveWindowSize(windowHandle(), group);
0044 }
0045 
0046 #include "moc_showmentionsmessagesdialog.cpp"