File indexing completed on 2024-12-08 04:34:11

0001 /*
0002    SPDX-FileCopyrightText: 2022-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "conferencecallwidget.h"
0008 #include "rocketchataccount.h"
0009 #include <KLocalizedString>
0010 #include <QFormLayout>
0011 #include <QToolButton>
0012 
0013 ConferenceCallWidget::ConferenceCallWidget(RocketChatAccount *account, QWidget *parent)
0014     : QWidget{parent}
0015     , mMicroButton(new QToolButton(this))
0016     , mCameraButton(new QToolButton(this))
0017 {
0018     Q_UNUSED(account);
0019     auto mainLayout = new QFormLayout(this);
0020     mainLayout->setContentsMargins({});
0021     mainLayout->setObjectName(QStringLiteral("mainLayout"));
0022 
0023     mMicroButton->setObjectName(QStringLiteral("mMicroButton"));
0024     mMicroButton->setCheckable(true);
0025     mMicroButton->setAutoRaise(true);
0026     mMicroButton->setIcon(QIcon::fromTheme(QStringLiteral("mic-off")));
0027     mCameraButton->setObjectName(QStringLiteral("mCameraButton"));
0028     mCameraButton->setCheckable(true);
0029     mCameraButton->setAutoRaise(true);
0030     mCameraButton->setIcon(QIcon::fromTheme(QStringLiteral("camera-on")));
0031     connect(mCameraButton, &QToolButton::toggled, this, [this](bool clicked) {
0032         mCameraButton->setIcon(clicked ? QIcon::fromTheme(QStringLiteral("camera-on")) : QIcon::fromTheme(QStringLiteral("camera-off")));
0033         mCameraButton->setToolTip(clicked ? i18n("Camera On") : i18n("Camera Off"));
0034     });
0035     connect(mMicroButton, &QToolButton::toggled, this, [this](bool clicked) {
0036         mMicroButton->setIcon(clicked ? QIcon::fromTheme(QStringLiteral("mic-on")) : QIcon::fromTheme(QStringLiteral("mic-off")));
0037         mMicroButton->setToolTip(clicked ? i18n("Micro On") : i18n("Micro Off"));
0038     });
0039 
0040     mainLayout->addRow(i18n("Micro"), mMicroButton);
0041     mainLayout->addRow(i18n("Camera"), mCameraButton);
0042 }
0043 
0044 ConferenceCallWidget::~ConferenceCallWidget() = default;
0045 
0046 ConferenceCallWidget::ConferenceCallStart ConferenceCallWidget::conferenceCallInfo() const
0047 {
0048     ConferenceCallStart info;
0049     info.useCamera = mCameraButton->isChecked();
0050     info.useMic = mMicroButton->isChecked();
0051     return info;
0052 }
0053 
0054 void ConferenceCallWidget::setConferenceCallInfo(const ConferenceCallStart &infoCallStart)
0055 {
0056     mCameraButton->setChecked(infoCallStart.useCamera);
0057     mMicroButton->setChecked(infoCallStart.useMic);
0058 }
0059 
0060 #include "moc_conferencecallwidget.cpp"