2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2022-11-01 08:13:27 +00:00
|
|
|
#ifndef SOUNDDEVICESWIDGET_H
|
|
|
|
#define SOUNDDEVICESWIDGET_H
|
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
#include "org_deepin_dde_audio1.h"
|
|
|
|
#include "org_deepin_dde_audio1_sink.h"
|
2022-11-01 08:13:27 +00:00
|
|
|
|
|
|
|
#include <DStyledItemDelegate>
|
|
|
|
|
|
|
|
#include <QWidget>
|
2023-05-05 11:32:14 +08:00
|
|
|
#include <DGuiApplicationHelper>
|
2023-08-23 14:11:20 +08:00
|
|
|
#include <QTimer>
|
2022-11-01 08:13:27 +00:00
|
|
|
|
|
|
|
namespace Dtk { namespace Widget { class DListView; } }
|
|
|
|
|
|
|
|
using namespace Dtk::Widget;
|
2023-06-19 18:07:19 +08:00
|
|
|
using namespace Dtk::Gui;
|
2023-05-05 11:32:14 +08:00
|
|
|
namespace Dock {
|
|
|
|
class TipsWidget;
|
|
|
|
}
|
2022-11-01 08:13:27 +00:00
|
|
|
|
|
|
|
class SliderContainer;
|
|
|
|
class QStandardItemModel;
|
|
|
|
class QLabel;
|
|
|
|
class VolumeModel;
|
|
|
|
class AudioSink;
|
2022-11-24 08:14:19 +00:00
|
|
|
class SoundDevicePort;
|
2022-11-01 08:13:27 +00:00
|
|
|
|
2022-11-18 17:08:32 +08:00
|
|
|
using DBusAudio = org::deepin::dde::Audio1;
|
|
|
|
using DBusSink = org::deepin::dde::audio1::Sink;
|
2022-11-01 08:13:27 +00:00
|
|
|
|
|
|
|
class SoundDevicesWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit SoundDevicesWidget(QWidget *parent = nullptr);
|
|
|
|
~SoundDevicesWidget() override;
|
|
|
|
|
2023-05-05 11:32:14 +08:00
|
|
|
QWidget* tipsWidget();
|
|
|
|
QPixmap pixmap() const;
|
|
|
|
QPixmap pixmap(DGuiApplicationHelper::ColorType colorType, int iconWidth, int iconHeight) const;
|
|
|
|
|
2022-11-28 14:01:16 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void enableChanged(bool);
|
2023-01-14 19:45:12 +08:00
|
|
|
void requestHide();
|
2023-05-05 11:32:14 +08:00
|
|
|
void iconChanged();
|
2022-11-28 14:01:16 +08:00
|
|
|
|
2022-11-01 08:13:27 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *watcher, QEvent *event) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initUi();
|
|
|
|
void initConnection();
|
|
|
|
|
|
|
|
void resizeHeight();
|
|
|
|
|
|
|
|
void resetVolumeInfo();
|
|
|
|
uint audioPortCardId(const AudioPort &audioport) const;
|
|
|
|
|
2022-11-24 08:14:19 +00:00
|
|
|
SoundDevicePort *findPort(const QString &portId, const uint &cardId) const;
|
|
|
|
void startAddPort(SoundDevicePort *port);
|
|
|
|
void startRemovePort(const QString &portId, const uint &cardId);
|
|
|
|
|
|
|
|
void addPort(const SoundDevicePort *port);
|
|
|
|
void removePort(const QString &portId, const uint &cardId);
|
|
|
|
|
|
|
|
void activePort(const QString &portId, const uint &cardId);
|
|
|
|
|
|
|
|
void removeDisabledDevice(QString portId, unsigned int cardId);
|
|
|
|
|
2022-11-28 14:01:16 +08:00
|
|
|
void deviceEnabled(bool enable);
|
|
|
|
|
2023-05-05 11:32:14 +08:00
|
|
|
|
|
|
|
void refreshTips(const int volume, const bool force);
|
|
|
|
|
2022-11-01 08:13:27 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void onSelectIndexChanged(const QModelIndex &index);
|
|
|
|
void onDefaultSinkChanged(const QDBusObjectPath & value);
|
|
|
|
void onAudioDevicesChanged();
|
|
|
|
|
|
|
|
private:
|
2023-05-05 11:32:14 +08:00
|
|
|
Dock::TipsWidget *m_tipsLabel;
|
2022-11-01 08:13:27 +00:00
|
|
|
SliderContainer *m_sliderContainer;
|
|
|
|
QLabel *m_descriptionLabel;
|
|
|
|
DListView *m_deviceList;
|
2022-11-24 08:14:19 +00:00
|
|
|
DBusAudio *m_soundInter;
|
|
|
|
DBusSink *m_sinkInter;
|
2022-11-01 08:13:27 +00:00
|
|
|
QStandardItemModel *m_model;
|
2022-11-24 08:14:19 +00:00
|
|
|
QList<SoundDevicePort *> m_ports;
|
2023-08-23 14:11:20 +08:00
|
|
|
QTimer *m_setVolumeTimer;
|
2022-11-01 08:13:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOLUMEDEVICESWIDGET_H
|