File indexing completed on 2024-12-01 04:37:03
0001 /* 0002 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "usersinroomdialog.h" 0008 #include "usersinroomwidget.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 myUsersInRoomDialogGroupName[] = "UsersInRoomDialog"; 0021 } 0022 0023 UsersInRoomDialog::UsersInRoomDialog(RocketChatAccount *account, QWidget *parent) 0024 : QDialog(parent) 0025 , mUsersInRoomWidget(new UsersInRoomWidget(account, this)) 0026 { 0027 setWindowTitle(i18nc("@title:window", "Users")); 0028 auto mainLayout = new QVBoxLayout(this); 0029 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0030 0031 mUsersInRoomWidget->setObjectName(QStringLiteral("mUsersInRoomWidget")); 0032 mainLayout->addWidget(mUsersInRoomWidget); 0033 0034 auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this); 0035 buttonBox->setObjectName(QStringLiteral("button")); 0036 connect(buttonBox, &QDialogButtonBox::rejected, this, &UsersInRoomDialog::reject); 0037 mainLayout->addWidget(buttonBox); 0038 readConfig(); 0039 } 0040 0041 UsersInRoomDialog::~UsersInRoomDialog() 0042 { 0043 writeConfig(); 0044 } 0045 0046 void UsersInRoomDialog::setRoom(Room *room) 0047 { 0048 mUsersInRoomWidget->setRoom(room); 0049 } 0050 0051 void UsersInRoomDialog::writeConfig() 0052 { 0053 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myUsersInRoomDialogGroupName)); 0054 KWindowConfig::saveWindowSize(windowHandle(), group); 0055 } 0056 0057 void UsersInRoomDialog::readConfig() 0058 { 0059 create(); // ensure a window is created 0060 windowHandle()->resize(QSize(800, 600)); 0061 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myUsersInRoomDialogGroupName)); 0062 KWindowConfig::restoreWindowSize(windowHandle(), group); 0063 resize(windowHandle()->size()); // workaround for QTBUG-40584 0064 } 0065 0066 #include "moc_usersinroomdialog.cpp"