diff --git a/CMakeLists.txt b/CMakeLists.txt index c86b737ad1..57c6a08aa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(DISABLE_AUTHENTICATION "disable build authentication plugins" OFF) option(DISABLE_UPDATE "disable build update plugins" OFF) option(DISABLE_LANGUAGE "disable lanugage settings in control center" OFF) option(USE_DEEPIN_ZONE "enable special timezone file on deepin" OFF) +option(DISABLE_SOUND_ADVANCED "disable sound advanced settings" OFF) set(DEEPIN_TIME_ZONE_PATH "/usr/share/dde/zoneinfo/zone1970.tab" CACHE STRING "deepin timezone path") # asan 自己有内存泄露,暂不使用 @@ -808,6 +809,10 @@ if (BUILD_PLUGIN) ${Sound_SRCS} ) + if (DISABLE_SOUND_ADVANCED) + target_compile_definitions(${Sound_Name} PUBLIC -DDCC_DISABLE_SOUND_ADVANCED) + endif() + set(Sound_Includes src/plugin-sound/operation src/plugin-sound/window diff --git a/src/plugin-sound/operation/sounddbusproxy.cpp b/src/plugin-sound/operation/sounddbusproxy.cpp index 285c1149f8..58bea95be9 100644 --- a/src/plugin-sound/operation/sounddbusproxy.cpp +++ b/src/plugin-sound/operation/sounddbusproxy.cpp @@ -104,6 +104,23 @@ void SoundDBusProxy::setPausePlayer(bool value) m_audioInter->setProperty("PausePlayer", QVariant::fromValue(value)); } +QString SoundDBusProxy::audioServer() +{ + return qvariant_cast(m_audioInter->property("CurrentAudioServer")); +} + +void SoundDBusProxy::SetAudioServer(const QString &in0) +{ + QList argumentList; + argumentList << QVariant::fromValue(in0); + m_audioInter->asyncCallWithArgumentList(QStringLiteral("SetCurrentAudioServer"), argumentList); +} + +bool SoundDBusProxy::audioServerState() +{ + return qvariant_cast(m_audioInter->property("AudioServerState")); +} + void SoundDBusProxy::SetPortEnabled(uint in0, const QString &in1, bool in2) { QList argumentList; diff --git a/src/plugin-sound/operation/sounddbusproxy.h b/src/plugin-sound/operation/sounddbusproxy.h index 711d7adba0..a415365f6c 100644 --- a/src/plugin-sound/operation/sounddbusproxy.h +++ b/src/plugin-sound/operation/sounddbusproxy.h @@ -31,7 +31,6 @@ class SoundDBusProxy : public QObject void SetPort(uint in0, const QString &in1, int in2); void SetBluetoothAudioMode(const QString &in0); - // SoundEffect void GetSoundEnabledMap(); void EnableSound(const QString &name, bool enabled, QObject *receiver, const char *member, const char *errorSlot); @@ -76,6 +75,14 @@ class SoundDBusProxy : public QObject bool pausePlayer(); void setPausePlayer(bool value); + Q_PROPERTY(QString CurrentAudioServer READ audioServer WRITE SetAudioServer NOTIFY CurrentAudioServerChanged) + QString audioServer(); + void SetAudioServer(const QString &in0); + + // 音频切换的状态 + Q_PROPERTY(bool AudioServerState READ audioServerState NOTIFY AudioServerStateChanged) + bool audioServerState(); + Q_PROPERTY(QString BluetoothAudioMode READ bluetoothAudioMode NOTIFY BluetoothAudioModeChanged) QString bluetoothAudioMode(); Q_PROPERTY(QStringList BluetoothAudioModeOpts READ bluetoothAudioModeOpts NOTIFY BluetoothAudioModeOptsChanged) @@ -141,6 +148,8 @@ class SoundDBusProxy : public QObject void SinkInputsChanged(const QList &value) const; void SinksChanged(const QList &value) const; void SourcesChanged(const QList &value) const; + void CurrentAudioServerChanged(const QString &value) const; + void AudioServerStateChanged(const bool state) const; // SoundEffect SIGNALS void EnabledChanged(bool value) const; diff --git a/src/plugin-sound/operation/soundmodel.cpp b/src/plugin-sound/operation/soundmodel.cpp index e6a619fbf7..8d2936983b 100644 --- a/src/plugin-sound/operation/soundmodel.cpp +++ b/src/plugin-sound/operation/soundmodel.cpp @@ -1,18 +1,18 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. // -//SPDX-License-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: GPL-3.0-or-later #include "soundmodel.h" #include #include +#include -#include #include #include -#include +#include #include -#include #include +#include Q_LOGGING_CATEGORY(DdcSoundModel, "dcc-sound-model") @@ -44,7 +44,7 @@ SoundLabel::SoundLabel(QWidget *parent) , m_mute(false) , m_btn(new DTK_WIDGET_NAMESPACE::DToolButton(this)) { - QHBoxLayout* layout = new QHBoxLayout(this); + QHBoxLayout *layout = new QHBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_btn); @@ -120,7 +120,7 @@ SoundModel::SoundModel(QObject *parent) { tr("Error"), DDesktopServices::SSE_Error }, }; - if(IsServerSystem) { + if (IsServerSystem) { m_soundEffectMapBattery.removeOne({ tr("Wake up"), DDesktopServices::SSE_WakeUp }); m_soundEffectMapPower.removeOne({ tr("Wake up"), DDesktopServices::SSE_WakeUp }); } @@ -166,7 +166,6 @@ void SoundModel::setPausePlayer(bool pausePlayer) } } - void SoundModel::setMicrophoneOn(bool microphoneOn) { if (microphoneOn != m_microphoneOn) { @@ -215,8 +214,7 @@ void SoundModel::addPort(Port *port) if (port->direction() == Port::Out) { m_outputPorts.append(port); - } - else { + } else { m_inputPorts.append(port); } @@ -234,8 +232,7 @@ void SoundModel::removePort(const QString &portId, const uint &cardId) if (port->direction() == Port::Out) { m_outputPorts.removeOne(port); - } - else { + } else { m_inputPorts.removeOne(port); } port->deleteLater(); @@ -249,7 +246,7 @@ bool SoundModel::containsPort(const Port *port) Port *SoundModel::findPort(const QString &portId, const uint &cardId) const { - auto res = std::find_if(m_ports.cbegin(), m_ports.end(), [=] (const Port *data)->bool { + auto res = std::find_if(m_ports.cbegin(), m_ports.end(), [=](const Port *data) -> bool { return ((data->id() == portId) && (data->cardId() == cardId)); }); @@ -275,8 +272,8 @@ void SoundModel::setSpeakerVolume(double speakerVolume) void SoundModel::setMaxUIVolume(double value) { - double val = qRound(value * 10) / 10.0; - if (!qFuzzyCompare(val, m_maxUIVolume)) { + double val = qRound(value * 10) / 10.0; + if (!qFuzzyCompare(val, m_maxUIVolume)) { m_maxUIVolume = val; Q_EMIT maxUIVolumeChanged(val); } @@ -329,7 +326,7 @@ SoundEffectList SoundModel::soundEffectMap() const void SoundModel::setEffectData(DDesktopServices::SystemSoundEffect effect, const bool enable) { - if(m_soundEffectData[effect] == enable) + if (m_soundEffectData[effect] == enable) return; m_soundEffectData[effect] = enable; @@ -344,14 +341,16 @@ bool SoundModel::queryEffectData(DDesktopServices::SystemSoundEffect effect) void SoundModel::setEnableSoundEffect(bool enableSoundEffect) { - if (m_enableSoundEffect == enableSoundEffect) return; + if (m_enableSoundEffect == enableSoundEffect) + return; m_enableSoundEffect = enableSoundEffect; Q_EMIT enableSoundEffectChanged(enableSoundEffect); } -void SoundModel::updateSoundEffectPath(DDesktopServices::SystemSoundEffect effect, const QString &path) +void SoundModel::updateSoundEffectPath(DDesktopServices::SystemSoundEffect effect, + const QString &path) { m_soundEffectPaths[effect] = path; } @@ -366,7 +365,8 @@ const QString SoundModel::getNameByEffectType(DDesktopServices::SystemSoundEffec return SOUND_EFFECT_MAP.value(effect); } -DDesktopServices::SystemSoundEffect SoundModel::getEffectTypeByGsettingName(const QString &name) { +DDesktopServices::SystemSoundEffect SoundModel::getEffectTypeByGsettingName(const QString &name) +{ return SOUND_EFFECT_MAP.key(name); } @@ -380,8 +380,10 @@ bool SoundModel::isLaptop() const return m_isLaptop; } -void SoundModel::setIsLaptop(bool isLaptop) { - if (isLaptop == m_isLaptop) return; +void SoundModel::setIsLaptop(bool isLaptop) +{ + if (isLaptop == m_isLaptop) + return; m_isLaptop = isLaptop; @@ -395,7 +397,7 @@ bool SoundModel::isIncreaseVolume() const void SoundModel::setIncreaseVolume(bool value) { - if(m_increaseVolume != value) { + if (m_increaseVolume != value) { m_increaseVolume = value; Q_EMIT increaseVolumeChanged(value); } @@ -426,6 +428,22 @@ void SoundModel::setWaitSoundReceiptTime(const int receiptTime) } } +void SoundModel::setAudioServerChangedState(const bool state) +{ + if (m_audioServerStatus != state) { + m_audioServerStatus = state; + Q_EMIT onSetAudioServerFinish(state); + } +} + +void SoundModel::setAudioServer(const QString &audioServer) +{ + if (m_audioServer != audioServer) { + m_audioServer = audioServer; + Q_EMIT curAudioServerChanged(audioServer); + } +} + void Port::setId(const QString &id) { if (id != m_id) { diff --git a/src/plugin-sound/operation/soundmodel.h b/src/plugin-sound/operation/soundmodel.h index 1110e8dfab..1903df5faa 100644 --- a/src/plugin-sound/operation/soundmodel.h +++ b/src/plugin-sound/operation/soundmodel.h @@ -190,6 +190,14 @@ class SoundModel : public QObject inline int currentWaitSoundReceiptTime() { return m_waitSoundReceiptTime; } void setWaitSoundReceiptTime(const int receiptTime); + // 设置音频框架 + inline QString audioServer() const { return m_audioServer; } + void setAudioServer(const QString &serverName); + + // 音频框架切换的状态 + inline bool audioServerChangedState() const { return m_audioServerStatus; } + void setAudioServerChangedState(const bool state); + Q_SIGNALS: void speakerOnChanged(bool speakerOn) const; void microphoneOnChanged(bool microphoneOn) const; @@ -217,6 +225,11 @@ class SoundModel : public QObject //声音输出设备是否可见 void outputDevicesVisibleChanged(QString name, bool flag); + // 音频框架设置完成 + void onSetAudioServerFinish(bool value); + // 当前音频框架切换的信号 + void curAudioServerChanged(const QString &audioFrame); + #ifndef DCC_DISABLE_FEEDBACK void microphoneFeedbackChanged(double microphoneFeedback) const; #endif @@ -228,6 +241,8 @@ class SoundModel : public QObject void isLaptopChanged(bool isLaptop); private: + QString m_audioServer; // 当前使用音频框架 + bool m_audioServerStatus{true}; // 设置音频时的状态 bool m_speakerOn; bool m_microphoneOn; bool m_enableSoundEffect; diff --git a/src/plugin-sound/operation/soundworker.cpp b/src/plugin-sound/operation/soundworker.cpp index 9ba4e3e777..8d6e37ec88 100644 --- a/src/plugin-sound/operation/soundworker.cpp +++ b/src/plugin-sound/operation/soundworker.cpp @@ -50,6 +50,9 @@ void SoundWorker::initConnect() connect(m_pingTimer, &QTimer::timeout, [this] { if (m_soundDBusInter) m_soundDBusInter->Tick(); }); connect(m_soundDBusInter, &SoundDBusProxy::HasBatteryChanged, m_model, &SoundModel::setIsLaptop); + + connect(m_soundDBusInter, &SoundDBusProxy::CurrentAudioServerChanged, m_model, &SoundModel::setAudioServer); + connect(m_soundDBusInter, &SoundDBusProxy::AudioServerStateChanged, m_model, &SoundModel::setAudioServerChangedState); } void SoundWorker::activate() @@ -66,6 +69,8 @@ void SoundWorker::activate() m_model->setCurrentBluetoothAudioMode(m_soundDBusInter->bluetoothAudioMode()); m_model->setEnableSoundEffect(m_soundDBusInter->enabled()); m_model->setWaitSoundReceiptTime(m_waitSoundPortReceipt); + m_model->setAudioServer(m_soundDBusInter->audioServer()); + m_model->setAudioServerChangedState(m_soundDBusInter->audioServerState()); m_pingTimer->start(); m_soundDBusInter->blockSignals(false); @@ -88,6 +93,12 @@ void SoundWorker::refreshSoundEffect() m_soundDBusInter->GetSoundEnabledMap(); } +void SoundWorker::setAudioServer(const QString &value) +{ + m_soundDBusInter->SetAudioServer(value); + m_model->setAudioServer(value); +} + void SoundWorker::switchSpeaker(bool on) { m_soundDBusInter->SetMuteSink(!on); diff --git a/src/plugin-sound/operation/soundworker.h b/src/plugin-sound/operation/soundworker.h index 99558014bf..d4e4f1a763 100644 --- a/src/plugin-sound/operation/soundworker.h +++ b/src/plugin-sound/operation/soundworker.h @@ -45,6 +45,8 @@ public Q_SLOTS: void setBluetoothMode(const QString &mode); void refreshSoundEffect(); + void setAudioServer(const QString &value); + private Q_SLOTS: void defaultSinkChanged(const QDBusObjectPath &path); void defaultSourceChanged(const QDBusObjectPath &path); diff --git a/src/plugin-sound/window/advancedsettingmodule.cpp b/src/plugin-sound/window/advancedsettingmodule.cpp new file mode 100644 index 0000000000..34c84f428c --- /dev/null +++ b/src/plugin-sound/window/advancedsettingmodule.cpp @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later +#include "advancedsettingmodule.h" + +#include "widgets/dcclistview.h" +#include "widgets/widgetmodule.h" + +#include + +#include + +using namespace DCC_NAMESPACE; +DWIDGET_USE_NAMESPACE + +AdvancedSettingModule::AdvancedSettingModule(SoundModel *model, SoundWorker *work, QObject *parent) + : PageModule("advancedSetting", tr("Advanced Setting"), parent) + , m_model(model) + , m_work(work) +{ + initUI(); +} + +AdvancedSettingModule::~AdvancedSettingModule() { } + +void AdvancedSettingModule::deactive() { } + +void AdvancedSettingModule::initUI() +{ + // 音频选项标题 + appendChild(new ItemModule("audioFrameworkTitle", tr("Audio Framework"))); + + // 音频框架列表 + m_audioItemModel = new QStandardItemModel(this); + DStandardItem *m_pulseAudio = new DStandardItem("PulseAudio"); + m_pulseAudio->setData("PulseAudio", Dtk::UserRole); + m_audioItemModel->appendRow(m_pulseAudio); + + DStandardItem *m_pipeWire = new DStandardItem("PipeWire"); + m_pipeWire->setData("PipeWire", Dtk::UserRole); + m_audioItemModel->appendRow(m_pipeWire); + + m_audioListModule = new ItemModule( + "selectFramework", + QString(), + [this](ModuleObject *) -> QWidget * { + DCCListView *audiorListView = new DCCListView(); + audiorListView->setModel(m_audioItemModel); + setAudioServerByName(m_model->audioServer()); + + connect(audiorListView, + &DListView::clicked, + this, + &AdvancedSettingModule::onAudioServerChecked); + // 被点击时设置为不可选中状态,直到切换结束 + connect(audiorListView, &DListView::clicked, this, [this](const QModelIndex &) { + m_audioListModule->setDisabled(true); + }); + + return audiorListView; + }, + false); + m_audioListModule->setEnabled(m_model->audioServerChangedState()); + // 等待切换结束的信号,才允许操作 + connect(m_model, + &SoundModel::onSetAudioServerFinish, + m_audioListModule, + &ItemModule::setEnabled); + appendChild(m_audioListModule); + + // 音频框架提示 + appendChild(new WidgetModule("framework", QString(), [](DTipLabel *dTipLabel) { + dTipLabel->setWordWrap(true); + dTipLabel->setAlignment(Qt::AlignLeft); + dTipLabel->setContentsMargins(10, 0, 10, 0); + dTipLabel->setText( + tr("Different audio frameworks have their own advantages and disadvantages, and " + "you can choose the one that best matches you to use")); + })); +} + +void AdvancedSettingModule::setAudioServerByName(const QString &curAudioServer) +{ + qDebug() << "current AudioFrame is " << curAudioServer; + int row_count = m_audioItemModel->rowCount(); + for (int i = 0; i < row_count; i++) { + QStandardItem *item = m_audioItemModel->item(i, 0); + if (item && (item->text().toLower() == curAudioServer)) { + item->setCheckState(Qt::Checked); + } else if (item) { // 如果不加此判断,item会出现空指针 + item->setCheckState(Qt::Unchecked); + } + } +} + +void AdvancedSettingModule::onAudioServerChecked(const QModelIndex &index) +{ + int row_count = m_audioItemModel->rowCount(); + for (int i = 0; i < row_count; i++) { + QStandardItem *item = m_audioItemModel->item(i, 0); + if (item && (index.row() == i)) { + qDebug() << "switch AudioFrame " << item->text(); + item->setCheckState(Qt::Checked); + Q_EMIT setCurAudioServer(item->text().toLower()); + } else if (item) { // 如果不加此判断,item会出现空指针 + item->setCheckState(Qt::Unchecked); + } + } +} diff --git a/src/plugin-sound/window/advancedsettingmodule.h b/src/plugin-sound/window/advancedsettingmodule.h new file mode 100644 index 0000000000..6800c1e12f --- /dev/null +++ b/src/plugin-sound/window/advancedsettingmodule.h @@ -0,0 +1,63 @@ +//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +// +//SPDX-License-Identifier: GPL-3.0-or-later +#ifndef ADVANCEDSETTINGMODULE_H +#define ADVANCEDSETTINGMODULE_H + +#include "interface/pagemodule.h" + +#include "interface/namespace.h" +#include "soundmodel.h" +#include "itemmodule.h" + +#include + +#include + + +QT_BEGIN_NAMESPACE +class QVBoxLayout; +QT_END_NAMESPACE + +namespace DCC_NAMESPACE { +class ItemModule; +class PageModule; +} + +class SoundModel; +class SoundWorker; +/** + * 该界面类对应 控制中心-声音模块-高级设置 界面 + */ + +class AdvancedSettingModule : public DCC_NAMESPACE::PageModule +{ + Q_OBJECT + +public: + explicit AdvancedSettingModule(SoundModel *model, SoundWorker *work, QObject *parent); + ~AdvancedSettingModule(); + void deactive() override; + +Q_SIGNALS: + void setCurAudioServer(const QString &curAudioServer); // 设置音频框架时触发信号 + +public Q_SLOTS: + void setAudioServerByName(const QString &curAudioServer); // 通过框架名设置选中状态 + void onAudioServerChecked(const QModelIndex &index); // 当音频框架被选中时触发 + +private: + void initUI(); + +private: + // model类, 为后端数据来源及数据变化信号来源 + SoundModel *m_model{nullptr}; + SoundWorker *m_work{nullptr}; + + // 音频服务选项 + QStandardItemModel *m_audioItemModel{nullptr}; + DCC_NAMESPACE::ItemModule *m_audioListModule{nullptr}; + +}; + +#endif // ADVANCEDSETTINGMODULE_H diff --git a/src/plugin-sound/window/soundplugin.cpp b/src/plugin-sound/window/soundplugin.cpp index e7440bf644..f33ed050df 100644 --- a/src/plugin-sound/window/soundplugin.cpp +++ b/src/plugin-sound/window/soundplugin.cpp @@ -1,24 +1,28 @@ -//SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd. // -//SPDX-License-Identifier: GPL-3.0-or-later -#include -#include -#include -#include -#include +// SPDX-License-Identifier: GPL-3.0-or-later +#include "soundplugin.h" -#include "widgets/titlelabel.h" -#include "widgets/itemmodule.h" -#include "widgets/widgetmodule.h" +#ifndef DCC_DISABLE_SOUND_ADVANCED +# include "advancedsettingmodule.h" +#endif +#include "devicemanagespage.h" #include "interface/pagemodule.h" - -#include "soundplugin.h" +#include "microphonepage.h" +#include "soundeffectspage.h" #include "soundmodel.h" #include "soundworker.h" #include "speakerpage.h" -#include "microphonepage.h" -#include "soundeffectspage.h" -#include "devicemanagespage.h" +#include "widgets/itemmodule.h" +#include "widgets/titlelabel.h" +#include "widgets/widgetmodule.h" + +#include +#include +#include +#include + +#include DGUI_USE_NAMESPACE DWIDGET_USE_NAMESPACE @@ -27,7 +31,6 @@ using namespace DCC_NAMESPACE; QString SoundPlugin::name() const { return QStringLiteral("Sound"); - } ModuleObject *SoundPlugin::module() @@ -37,67 +40,86 @@ ModuleObject *SoundPlugin::module() // 二级 -- 输出 ModuleObject *moduleOutput = new PageModule("output", tr("Output")); - OutputModule *outputPage = new OutputModule(soundInterface->model(), soundInterface->work(), moduleOutput); + OutputModule *outputPage = + new OutputModule(soundInterface->model(), soundInterface->work(), moduleOutput); moduleOutput->appendChild(outputPage); - ItemModule* pauseAudio = new ItemModule("PauseAudio", - tr("Auto pause"), - [soundInterface](ModuleObject *module) -> QWidget * { - Q_UNUSED(module) - DSwitchButton *pluginControl = new DSwitchButton; - auto model = soundInterface->model(); - auto work = soundInterface->work(); - pluginControl->setChecked(model->pausePlayer()); - connect(model, - &SoundModel::pausePlayerChanged, - pluginControl, - &DSwitchButton::setChecked); - connect(pluginControl, - &DSwitchButton::checkedChanged, - work, - &SoundWorker::setPausePlayer); - return pluginControl; - }); + ItemModule *pauseAudio = new ItemModule("PauseAudio", + tr("Auto pause"), + [soundInterface](ModuleObject *module) -> QWidget * { + Q_UNUSED(module) + DSwitchButton *pluginControl = new DSwitchButton; + auto model = soundInterface->model(); + auto work = soundInterface->work(); + pluginControl->setChecked(model->pausePlayer()); + connect(model, + &SoundModel::pausePlayerChanged, + pluginControl, + &DSwitchButton::setChecked); + connect(pluginControl, + &DSwitchButton::checkedChanged, + work, + &SoundWorker::setPausePlayer); + return pluginControl; + }); pauseAudio->setBackground(true); moduleOutput->appendChild(pauseAudio); - auto autoLoginTip = new WidgetModule( - "plugcontroltip", - tr(""), - [](DTipLabel *plugcontrollabel) { - plugcontrollabel->setWordWrap(true); - plugcontrollabel->setAlignment(Qt::AlignLeft); - plugcontrollabel->setContentsMargins(10, 0, 10, 0); - plugcontrollabel->setText(tr("Whether the audio will be automatically paused when the current audio device is unplugged")); - }); + auto autoLoginTip = + new WidgetModule("plugcontroltip", tr(""), [](DTipLabel *plugcontrollabel) { + plugcontrollabel->setWordWrap(true); + plugcontrollabel->setAlignment(Qt::AlignLeft); + plugcontrollabel->setContentsMargins(10, 0, 10, 0); + plugcontrollabel->setText(tr("Whether the audio will be automatically paused when " + "the current audio device is unplugged")); + }); moduleOutput->appendChild(autoLoginTip); soundInterface->appendChild(moduleOutput); // 二级 -- 输入 ModuleObject *moduleInput = new PageModule("input", tr("Input")); - InputModule *inputPage = new InputModule(soundInterface->model(), soundInterface->work(), moduleInput); + InputModule *inputPage = + new InputModule(soundInterface->model(), soundInterface->work(), moduleInput); moduleInput->appendChild(inputPage); soundInterface->appendChild(moduleInput); // 二级 -- 系统音效 ModuleObject *moduleSoundEffects = new PageModule("soundEffects", tr("Sound Effects")); - SoundEffectsModule *effectsPage = new SoundEffectsModule(soundInterface->model(), soundInterface->work(), moduleSoundEffects); + SoundEffectsModule *effectsPage = new SoundEffectsModule(soundInterface->model(), + soundInterface->work(), + moduleSoundEffects); moduleSoundEffects->appendChild(effectsPage); soundInterface->appendChild(moduleSoundEffects); // 二级 -- 设备管理 ModuleObject *moduleDevices = new PageModule("devices", tr("Devices")); - DeviceTitleModule *inputTitle = new DeviceTitleModule("inputDevices", tr("Input Devices"), moduleDevices); + DeviceTitleModule *inputTitle = + new DeviceTitleModule("inputDevices", tr("Input Devices"), moduleDevices); moduleDevices->appendChild(inputTitle); - InputDeviceModule *inputDevWidget = new InputDeviceModule(soundInterface->model(), soundInterface->work(), moduleDevices); + InputDeviceModule *inputDevWidget = + new InputDeviceModule(soundInterface->model(), soundInterface->work(), moduleDevices); moduleDevices->appendChild(inputDevWidget); - DeviceTitleModule *outputTitle = new DeviceTitleModule("outputDevices", tr("Output Devices"), moduleDevices); + DeviceTitleModule *outputTitle = + new DeviceTitleModule("outputDevices", tr("Output Devices"), moduleDevices); moduleDevices->appendChild(outputTitle); - OutputDeviceModule *outputDevWidget = new OutputDeviceModule(soundInterface->model(), soundInterface->work(), moduleDevices); + OutputDeviceModule *outputDevWidget = + new OutputDeviceModule(soundInterface->model(), soundInterface->work(), moduleDevices); moduleDevices->appendChild(outputDevWidget); soundInterface->appendChild(moduleDevices); + + // 二级 -- 高级设置 +#ifndef DCC_DISABLE_SOUND_ADVANCED + AdvancedSettingModule *advancedSettingModule = + new AdvancedSettingModule(soundInterface->model(), soundInterface->work(), this); + connect(advancedSettingModule, + &AdvancedSettingModule::setCurAudioServer, + soundInterface->work(), + &SoundWorker::setAudioServer); + // connect(advancedSettingModule, &AdvancedSettingModule::se) + soundInterface->appendChild(advancedSettingModule); +#endif return soundInterface; } @@ -111,7 +133,6 @@ SoundModule::SoundModule(QObject *parent) , m_model(new SoundModel(this)) , m_work(new SoundWorker(m_model, this)) { - } SoundModule::~SoundModule() @@ -140,8 +161,11 @@ QWidget *OutputModule::page() QWidget *InputModule::page() { - MicrophonePage * w = new MicrophonePage; - connect(w, &MicrophonePage::requestSetMicrophoneVolume, m_worker, &SoundWorker::setSourceVolume); + MicrophonePage *w = new MicrophonePage; + connect(w, + &MicrophonePage::requestSetMicrophoneVolume, + m_worker, + &SoundWorker::setSourceVolume); connect(w, &MicrophonePage::requestSetPort, m_worker, &SoundWorker::setPort); connect(w, &MicrophonePage::requestReduceNoise, m_worker, &SoundWorker::setReduceNoise); connect(w, &MicrophonePage::requestMute, m_worker, &SoundWorker::setSourceMute); @@ -153,7 +177,10 @@ QWidget *InputModule::page() QWidget *SoundEffectsModule::page() { SoundEffectsPage *w = new SoundEffectsPage; - connect(w, &SoundEffectsPage::requestSwitchSoundEffects, m_worker, &SoundWorker::enableAllSoundEffect); + connect(w, + &SoundEffectsPage::requestSwitchSoundEffects, + m_worker, + &SoundWorker::enableAllSoundEffect); connect(w, &SoundEffectsPage::requestRefreshList, m_worker, &SoundWorker::refreshSoundEffect); connect(w, &SoundEffectsPage::requestSetEffectAble, m_worker, &SoundWorker::setEffectEnable); w->setModel(m_model); @@ -192,6 +219,8 @@ DeviceTitleModule::DeviceTitleModule(const QString &name, const QString &title, QWidget *DeviceTitleModule::page() { TitleLabel *titleLabel = new TitleLabel(description()); - DFontSizeManager::instance()->bind(titleLabel, DFontSizeManager::T5, QFont::DemiBold); // 设置字体 + DFontSizeManager::instance()->bind(titleLabel, + DFontSizeManager::T5, + QFont::DemiBold); // 设置字体 return titleLabel; }