File indexing completed on 2024-12-01 04:37:05
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 "teamchannelsdialog.h" 0008 #include "teamchannelswidget.h" 0009 #include <KConfigGroup> 0010 #include <KLocalizedString> 0011 #include <KSharedConfig> 0012 #include <KWindowConfig> 0013 #include <QDialogButtonBox> 0014 #include <QVBoxLayout> 0015 #include <QWindow> 0016 namespace 0017 { 0018 const char myTeamChannelsDialogConfigGroupName[] = "TeamChannelsDialog"; 0019 } 0020 TeamChannelsDialog::TeamChannelsDialog(RocketChatAccount *account, QWidget *parent) 0021 : QDialog(parent) 0022 , mTeamChannelsWidget(new TeamChannelsWidget(account, this)) 0023 { 0024 setWindowTitle(i18nc("@title:window", "Team Channels")); 0025 auto mainLayout = new QVBoxLayout(this); 0026 mainLayout->setObjectName(QStringLiteral("mainLayout")); 0027 0028 mTeamChannelsWidget->setObjectName(QStringLiteral("mTeamChannelsWidget")); 0029 mainLayout->addWidget(mTeamChannelsWidget); 0030 0031 auto button = new QDialogButtonBox(QDialogButtonBox::Close, this); 0032 button->setObjectName(QStringLiteral("button")); 0033 mainLayout->addWidget(button); 0034 connect(button, &QDialogButtonBox::rejected, this, &TeamChannelsDialog::reject); 0035 connect(button, &QDialogButtonBox::accepted, this, &TeamChannelsDialog::accept); 0036 readConfig(); 0037 } 0038 0039 TeamChannelsDialog::~TeamChannelsDialog() 0040 { 0041 writeConfig(); 0042 } 0043 0044 void TeamChannelsDialog::setRoom(Room *room) 0045 { 0046 mTeamChannelsWidget->setRoom(room); 0047 } 0048 0049 void TeamChannelsDialog::readConfig() 0050 { 0051 create(); // ensure a window is created 0052 windowHandle()->resize(QSize(400, 300)); 0053 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myTeamChannelsDialogConfigGroupName)); 0054 KWindowConfig::restoreWindowSize(windowHandle(), group); 0055 resize(windowHandle()->size()); // workaround for QTBUG-40584 0056 } 0057 0058 void TeamChannelsDialog::writeConfig() 0059 { 0060 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1String(myTeamChannelsDialogConfigGroupName)); 0061 KWindowConfig::saveWindowSize(windowHandle(), group); 0062 } 0063 0064 #include "moc_teamchannelsdialog.cpp"