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

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QMediaPlayer>
0010 #include <QWidget>
0011 
0012 #include "libruqolawidgets_private_export.h"
0013 class QPushButton;
0014 class QToolButton;
0015 class QSlider;
0016 class QLabel;
0017 class QComboBox;
0018 class KMessageWidget;
0019 class RocketChatAccount;
0020 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0021 class QAudioOutput;
0022 #endif
0023 class LIBRUQOLAWIDGETS_TESTS_EXPORT PlaySoundWidget : public QWidget
0024 {
0025     Q_OBJECT
0026 public:
0027     explicit PlaySoundWidget(RocketChatAccount *account, QWidget *parent = nullptr);
0028     ~PlaySoundWidget() override;
0029 
0030     void setAudioPath(const QString &url);
0031     [[nodiscard]] QUrl audioUrl() const;
0032 
0033 Q_SIGNALS:
0034     void updateTitle(const QUrl &url);
0035 
0036 private:
0037     LIBRUQOLAWIDGETS_NO_EXPORT void play();
0038     LIBRUQOLAWIDGETS_NO_EXPORT void muteChanged(bool state);
0039     LIBRUQOLAWIDGETS_NO_EXPORT void setPosition(int position);
0040     LIBRUQOLAWIDGETS_NO_EXPORT void slotPositionChanged(qint64 progress);
0041     LIBRUQOLAWIDGETS_NO_EXPORT void slotDurationChanged(qint64 duration);
0042     LIBRUQOLAWIDGETS_NO_EXPORT void updateDurationInfo(qint64 currentInfo);
0043     LIBRUQOLAWIDGETS_NO_EXPORT void slotVolumeChanged(int position);
0044     LIBRUQOLAWIDGETS_NO_EXPORT void handleError();
0045     LIBRUQOLAWIDGETS_NO_EXPORT void initializeAudioOutput();
0046     LIBRUQOLAWIDGETS_NO_EXPORT void audioOutputChanged(int index);
0047 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0048     LIBRUQOLAWIDGETS_NO_EXPORT void mediaStateChanged(QMediaPlayer::State state);
0049 #else
0050     LIBRUQOLAWIDGETS_NO_EXPORT void mediaStateChanged(QMediaPlayer::PlaybackState state);
0051 #endif
0052     void slotAttachmentFileDownloadDone(const QString &url);
0053     qint64 mDuration;
0054     QMediaPlayer *const mMediaPlayer;
0055     QPushButton *const mPlayButton;
0056     QToolButton *const mSoundButton;
0057     QSlider *const mSoundSlider;
0058     QSlider *const mPositionSlider;
0059     QLabel *const mLabelDuration;
0060     KMessageWidget *const mMessageWidget;
0061     QLabel *const mLabelPercentSound;
0062 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0063     QAudioOutput *const mAudioOutput;
0064     QComboBox *const mDeviceComboBox;
0065 #endif
0066     RocketChatAccount *const mRocketChatAccount;
0067 };