diff --git a/0001-fix-audio-Improve-the-disabling-of-volume-plugin-and.patch b/0001-fix-audio-Improve-the-disabling-of-volume-plugin-and.patch deleted file mode 100644 index 23b5220..0000000 --- a/0001-fix-audio-Improve-the-disabling-of-volume-plugin-and.patch +++ /dev/null @@ -1,758 +0,0 @@ -From d627f399c25625fa3a0483b2bdcb25f2bf25fe6a Mon Sep 17 00:00:00 2001 -From: luoqing -Date: Thu, 29 Dec 2022 11:33:18 +0800 -Subject: [PATCH] fix(audio):Improve the disabling of volume plugin and tray -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -- 完善音量插件和托盘显示禁用的情况 ---- - plugins/audio/src/plugin/input-page.cpp | 33 ++-- - plugins/audio/src/plugin/input-page.h | 4 + - plugins/audio/src/plugin/output-page.cpp | 153 ++++++++++++------ - plugins/audio/src/plugin/output-page.h | 22 ++- - .../src/system-tray/audio-system-tray.cpp | 14 ++ - .../audio/src/system-tray/audio-system-tray.h | 8 +- - .../src/system-tray/volume-setting-page.cpp | 139 ++++++++++++---- - .../src/system-tray/volume-setting-page.h | 18 ++- - 8 files changed, 292 insertions(+), 99 deletions(-) - -diff --git a/plugins/audio/src/plugin/input-page.cpp b/plugins/audio/src/plugin/input-page.cpp -index 9dcd9bd..e9f5018 100644 ---- a/plugins/audio/src/plugin/input-page.cpp -+++ b/plugins/audio/src/plugin/input-page.cpp -@@ -167,6 +167,16 @@ qint64 AudioInfo::writeData(const char *data, qint64 len) - InputPage::InputPage(QWidget *parent) : QWidget(parent), ui(new Ui::InputPage) - { - ui->setupUi(this); -+ init(); -+} -+ -+InputPage::~InputPage() -+{ -+ delete ui; -+} -+ -+void InputPage::init() -+{ - m_audioInterface = AudioInterface::instance(); - ui->inputVolume->setStyleSheet("color:#2eb3ff;"); - initInputDevice(); -@@ -176,16 +186,8 @@ InputPage::InputPage(QWidget *parent) : QWidget(parent), ui(new Ui::InputPage) - initConnet(); - } - --InputPage::~InputPage() --{ -- delete ui; --} -- - void InputPage::initInputDevice() - { -- QDBusPendingReply getSources = m_audioInterface->GetSources(); -- QStringList sourcesList = getSources.value(); -- - QDBusPendingReply defaultSourcePath = m_audioInterface->GetDefaultSource(); - KLOG_DEBUG() << "defaultSourcePath" << defaultSourcePath; - -@@ -236,11 +238,7 @@ void InputPage::initActivedPort() - else - { - KLOG_DEBUG() << "ports is null"; -- m_isValidPort = false; -- ui->inputDevices->insertItem(0, tr("No input device detected")); -- ui->inputDevices->setEnabled(false); -- ui->volumeSetting->setValue(0); -- ui->volumeSetting->setEnabled(false); -+ disableSettings(); - } - } - -@@ -294,6 +292,15 @@ void InputPage::initConnet() - connect(m_audioInterface, &AudioInterface::DefaultSourceChange, this, &InputPage::handleDefaultSourceChanged, Qt::QueuedConnection); - } - -+void InputPage::disableSettings() -+{ -+ m_isValidPort = false; -+ ui->inputDevices->insertItem(0, tr("No input device detected")); -+ ui->inputDevices->setEnabled(false); -+ ui->volumeSetting->setValue(0); -+ ui->volumeSetting->setEnabled(false); -+} -+ - void InputPage::handleActivePortChanged(const QString &value) - { - KLOG_DEBUG() << "handleActivePortChanged :" << value; -diff --git a/plugins/audio/src/plugin/input-page.h b/plugins/audio/src/plugin/input-page.h -index 95b8aa4..3b57daf 100644 ---- a/plugins/audio/src/plugin/input-page.h -+++ b/plugins/audio/src/plugin/input-page.h -@@ -62,10 +62,14 @@ public: - explicit InputPage(QWidget *parent = nullptr); - ~InputPage() override; - QSize sizeHint() const override; -+ -+private: -+ void init(); - void initInputDevice(); - void initInputSettins(); - void initActivedPort(); - void initConnet(); -+ void disableSettings(); - - void initVoulumeFeedBack(); - void initAudioFormat(); -diff --git a/plugins/audio/src/plugin/output-page.cpp b/plugins/audio/src/plugin/output-page.cpp -index cc19e07..b28ba53 100644 ---- a/plugins/audio/src/plugin/output-page.cpp -+++ b/plugins/audio/src/plugin/output-page.cpp -@@ -21,32 +21,74 @@ - #include - #include - --OutputPage::OutputPage(QWidget *parent) : QWidget(parent), ui(new Ui::OutputPage) -+OutputPage::OutputPage(QWidget *parent) : QWidget(parent), -+ ui(new Ui::OutputPage), -+ m_audioInterface(nullptr), -+ m_defaultSink(nullptr) - { - ui->setupUi(this); -- ui->outputVolume->setStyleSheet("color:#2eb3ff;"); -- m_audioInterface = AudioInterface::instance(); -- initOutputDevice(); -- initOutputSettins(); -- initConnect(); -+ init(); -+ -+ m_dbusServiceWatcher = new QDBusServiceWatcher(); -+ m_dbusServiceWatcher->setConnection(QDBusConnection::sessionBus()); -+ m_dbusServiceWatcher->addWatchedService(AUDIO_DBUS_NAME); -+ -+ m_dbusServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); -+ connect(m_dbusServiceWatcher, &QDBusServiceWatcher::serviceUnregistered,[this](const QString &service){ -+ KLOG_DEBUG() << "serviceUnregistered:" << service; -+ disableSettings(); -+ }); - } - - OutputPage::~OutputPage() - { -+ delete m_dbusServiceWatcher; - delete ui; - } - --void OutputPage::initOutputDevice() -+void OutputPage::init() - { -- QDBusPendingReply getSinks = m_audioInterface->GetSinks(); -- QStringList sinksList = getSinks.value(); -+ ui->outputVolume->setStyleSheet("color:#2eb3ff;"); -+ ui->volumeSetting->setRange(0, 100); -+ ui->volumeSetting->setSingleStep(1); -+ ui->volumeSetting->setPageStep(1); -+ -+ ui->volumeBalance->setRange(-100, 100); -+ ui->volumeBalance->setSingleStep(1); -+ ui->volumeBalance->setPageStep(1); -+ -+ m_audioInterface = AudioInterface::instance(); -+ initOutputDevice(); -+ initConnect(); -+} - -+void OutputPage::initOutputDevice() -+{ - QDBusPendingReply defaultSinkPath = m_audioInterface->GetDefaultSink(); - KLOG_DEBUG() << "defaultSink" << defaultSinkPath; -- -- m_defaultSink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this); -- m_defaultSinkIndex = m_defaultSink->index(); -- initActivedPort(); -+ KLOG_DEBUG() << "defaultSinkPath.isValid():" << defaultSinkPath.isValid(); -+ -+ if(defaultSinkPath.isValid()) -+ { -+ QString defaultSinkPathString = defaultSinkPath.value(); -+ if(!defaultSinkPathString.isEmpty()) -+ { -+ m_defaultSink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this); -+ initActivedPort(); -+ -+ connect(m_defaultSink, &AudioDeviceInterface::volumeChanged, this, &OutputPage::handleVolumeChanged); -+ connect(m_defaultSink, &AudioDeviceInterface::balanceChanged, this, &OutputPage::handleBalanceChanged); -+ connect(m_defaultSink, &AudioDeviceInterface::active_portChanged, this, &OutputPage::handleActivePortChanged); -+ } -+ else -+ { -+ disableSettings(); -+ } -+ } -+ else -+ { -+ KLOG_DEBUG() << "defaultSinkPath error:" <active_port() == name) - { - m_defaultDeviceIndex = i; -- KLOG_DEBUG() << "m_defaultDeviceIndex" << m_defaultDeviceIndex; - } - } - } - //默认选中已激活的端口 - ui->outputDevices->setCurrentIndex(m_defaultDeviceIndex); -- ui->outputDevices->setEnabled(true); -- ui->volumeSetting->setEnabled(true); -- ui->volumeBalance->setEnabled(true); -+ initOutputSettins(); - } - else - { - //无激活端口则禁用音量设置和平衡 - KLOG_DEBUG() << "default sink ports is null"; -- ui->outputDevices->insertItem(0, tr("No output device detected")); -- ui->outputDevices->setEnabled(false); -- ui->volumeSetting->setValue(0); -- ui->volumeSetting->setEnabled(false); -- ui->volumeBalance->setValue(0); -- ui->volumeBalance->setEnabled(false); -+ disableSettings(); - } - } - - void OutputPage::initOutputSettins() - { -- initVolumeSetting(); -- initBalanceSetting(); -+ ui->outputDevices->setEnabled(true); -+ ui->volumeSetting->setEnabled(true); -+ ui->volumeBalance->setEnabled(true); -+ initVolumeValue(); -+ initBalanceValue(); - } - --void OutputPage::initVolumeSetting() -+void OutputPage::initVolumeValue() - { -- ui->volumeSetting->setRange(0, 100); -- ui->volumeSetting->setSingleStep(1); -- ui->volumeSetting->setPageStep(1); -- - double currentVolumeDouble = m_defaultSink->volume() * 100; - int currentVolume = round(currentVolumeDouble); - ui->volumeSetting->setValue(currentVolume); - ui->outputVolume->setText(QString::number(currentVolume) + "%"); - } - --void OutputPage::initBalanceSetting() -+void OutputPage::initBalanceValue() - { -- ui->volumeBalance->setRange(-100, 100); -- ui->volumeBalance->setSingleStep(1); -- ui->volumeBalance->setPageStep(1); -- - KLOG_DEBUG() << "current balance:" << m_defaultSink->balance(); - double currentBalanceDouble = m_defaultSink->balance() * 100; - int currentBalance = round(currentBalanceDouble); -@@ -134,9 +163,6 @@ void OutputPage::initBalanceSetting() - - void OutputPage::initConnect() - { -- connect(m_defaultSink, &AudioDeviceInterface::volumeChanged, this, &OutputPage::handleVolumeChanged); -- connect(m_defaultSink, &AudioDeviceInterface::balanceChanged, this, &OutputPage::handleBalanceChanged); -- connect(m_defaultSink, &AudioDeviceInterface::active_portChanged, this, &OutputPage::handleActivePortChanged); - connect(m_audioInterface, &AudioInterface::SinkAdded, this, &OutputPage::handleSinkAdded); - connect(m_audioInterface, &AudioInterface::SinkDelete, this, &OutputPage::handleSinkDelete); - connect(m_audioInterface, &AudioInterface::DefaultSinkChange, this, &OutputPage::handleDefaultSinkChanged, Qt::QueuedConnection); -@@ -204,31 +230,68 @@ void OutputPage::handleBalanceChanged(double value) - ui->volumeBalance->blockSignals(false); - } - --void OutputPage::handleSinkAdded(int index) -+void OutputPage::disableSettings() - { -- KLOG_DEBUG() << "SinkAdded"; -+ ui->outputDevices->insertItem(0, tr("No output device detected")); -+ ui->outputDevices->setEnabled(false); -+ -+ ui->volumeSetting->setValue(0); -+ ui->outputVolume->setText(QString::number(0) + "%"); -+ ui->volumeSetting->setEnabled(false); -+ -+ ui->volumeBalance->setValue(0); -+ ui->volumeBalance->setEnabled(false); - } - - void OutputPage::handleDefaultSinkChanged(int index) - { - // delete and restart init defaultSource -- m_defaultSink->deleteLater(); -- m_defaultSink = nullptr; -+ if(m_defaultSink != nullptr) -+ { -+ m_defaultSink->deleteLater(); -+ m_defaultSink = nullptr; -+ } - ui->outputDevices->blockSignals(true); - ui->outputDevices->clear(); - ui->outputDevices->blockSignals(false); - - initOutputDevice(); - initOutputSettins(); -+} -+ - -- connect(m_defaultSink, &AudioDeviceInterface::volumeChanged, this, &OutputPage::handleVolumeChanged); -- connect(m_defaultSink, &AudioDeviceInterface::balanceChanged, this, &OutputPage::handleBalanceChanged); -- connect(m_defaultSink, &AudioDeviceInterface::active_portChanged, this, &OutputPage::handleActivePortChanged); -+void OutputPage::handleSinkAdded(int index) -+{ -+ KLOG_DEBUG() << "SinkAdded"; -+ //当已经存在defaultSink时,暂时不处理其他sink的添加 -+ if(m_defaultSink != nullptr) -+ { -+ //刷新界面 -+ initOutputSettins(); -+ } -+ else -+ { -+ //defaultSink不存在,则重新初始化设备 -+ initOutputDevice(); -+ } - } - -+//当pulseAudio被kill时,会发出SinkDelete和SourceDelete信号 - void OutputPage::handleSinkDelete(int index) - { - KLOG_DEBUG() << "SinkDelete"; -+ QDBusPendingReply getSinks = m_audioInterface->GetSinks(); -+ QStringList sinksList = getSinks.value(); -+ -+ //当前存在defaultSink -+ if(m_defaultSink != nullptr) -+ { -+ //删除的是defaultSink则进行处理,删除其他sink暂时不处理 -+ if(m_defaultSink->index() == index) -+ { -+ disableSettings(); -+ } -+ } - } - - QSize OutputPage::sizeHint() const -diff --git a/plugins/audio/src/plugin/output-page.h b/plugins/audio/src/plugin/output-page.h -index 76ac458..abaf9a1 100644 ---- a/plugins/audio/src/plugin/output-page.h -+++ b/plugins/audio/src/plugin/output-page.h -@@ -16,6 +16,7 @@ - - #include - #include -+#include - - QT_BEGIN_NAMESPACE - namespace Ui -@@ -35,12 +36,7 @@ public: - explicit OutputPage(QWidget *parent = nullptr); - ~OutputPage() override; - QSize sizeHint() const override; -- void initOutputDevice(); -- void initOutputSettins(); -- void initConnect(); -- void initActivedPort(); -- void initVolumeSetting(); -- void initBalanceSetting(); -+ - public slots: - void handleDefaultSinkChanged(int index); - void handleSinkAdded(int index); -@@ -49,13 +45,25 @@ public slots: - void handleVolumeChanged(double value); - void handleBalanceChanged(double value); - -+private: -+ void init(); -+ void initOutputDevice(); -+ void initOutputSettins(); -+ void initConnect(); -+ void initActivedPort(); -+ void initVolumeValue(); -+ void initBalanceValue(); -+ -+ void disableSettings(); -+ - private: - Ui::OutputPage *ui; - AudioInterface *m_audioInterface; - QMap m_outputDevicesMap; - AudioDeviceInterface *m_defaultSink; -- int m_defaultSinkIndex; - int m_defaultDeviceIndex; -+ QDBusServiceWatcher *m_dbusServiceWatcher; - }; - -+ - #endif //KIRAN_CPANEL_AUDIO_OUTPUT_PAGE_H -diff --git a/plugins/audio/src/system-tray/audio-system-tray.cpp b/plugins/audio/src/system-tray/audio-system-tray.cpp -index 7fcb9c3..00e90f7 100644 ---- a/plugins/audio/src/system-tray/audio-system-tray.cpp -+++ b/plugins/audio/src/system-tray/audio-system-tray.cpp -@@ -47,8 +47,10 @@ AudioSystemTray::AudioSystemTray(QWidget *parent) : QWidget(parent) - - initTrayIcon(); - initMenu(); -+ initDbusServiceWatcher(); - initConnect(); - } -+ - AudioSystemTray::~AudioSystemTray() - { - } -@@ -99,6 +101,18 @@ void AudioSystemTray::initMenu() - connect(m_mixedSetting, &QAction::triggered, this, &AudioSystemTray::handleMixedSettingClicked); - } - -+void AudioSystemTray::initDbusServiceWatcher() -+{ -+ m_dbusServiceWatcher = new QDBusServiceWatcher(); -+ m_dbusServiceWatcher->setConnection(QDBusConnection::sessionBus()); -+ m_dbusServiceWatcher->addWatchedService(AUDIO_DBUS_NAME); -+ m_dbusServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); -+ connect(m_dbusServiceWatcher, &QDBusServiceWatcher::serviceUnregistered, [this](const QString &service) -+ { -+ setTrayIcon(0); -+ }); -+} -+ - void AudioSystemTray::initConnect() - { - connect(m_systemTray, &QSystemTrayIcon::activated, this, &AudioSystemTray::handleAudioTrayClicked); -diff --git a/plugins/audio/src/system-tray/audio-system-tray.h b/plugins/audio/src/system-tray/audio-system-tray.h -index 623c602..16846e6 100644 ---- a/plugins/audio/src/system-tray/audio-system-tray.h -+++ b/plugins/audio/src/system-tray/audio-system-tray.h -@@ -17,8 +17,7 @@ - - #include - #include --// #include --// #include -+#include - - class VolumeSettingPage; - class MixedSettingPage; -@@ -38,12 +37,13 @@ public: - void initTrayIcon(); - void initMenu(); - void initConnect(); -+ void initDbusServiceWatcher(); - void setVolumeSettingPos(); - void setMixedSettingPos(); - QPixmap trayIconColorSwitch(const QString& iconPath, const int iconSize = 16); - void getTrayGeometry(); --public slots: - -+public slots: - void handleAudioTrayClicked(QSystemTrayIcon::ActivationReason reason); - void handleMixedSettingClicked(); - void handleVolumeSettingClicked(); -@@ -72,6 +72,8 @@ private: - - QString m_colorTheme; - int xTray, yTray, heightTray, widthTray; -+ -+ QDBusServiceWatcher *m_dbusServiceWatcher; - }; - - #endif // KIRAN_CPANEL_AUDIO_AUDIOSYSTEMTRAY_H -diff --git a/plugins/audio/src/system-tray/volume-setting-page.cpp b/plugins/audio/src/system-tray/volume-setting-page.cpp -index dc43283..fac69a6 100644 ---- a/plugins/audio/src/system-tray/volume-setting-page.cpp -+++ b/plugins/audio/src/system-tray/volume-setting-page.cpp -@@ -26,26 +26,38 @@ - #include - #include - --VolumeSettingPage::VolumeSettingPage(enum AudioNode audio, QString objectPath, QWidget *parent) : QWidget(parent), ui(new Ui::VolumeSettingPage) -+VolumeSettingPage::VolumeSettingPage(enum AudioNode audio, const QString objectPath, QWidget *parent) : QWidget(parent), ui(new Ui::VolumeSettingPage) - { - ui->setupUi(this); - ui->volume->setStyleSheet("color:#2eb3ff;"); - QDBusConnection session = QDBusConnection::sessionBus(); - m_audioInterface = AudioInterface::instance(); -- audioNode = audio; -- if (audioNode == AUDIO_DEVICE) -+ m_audioNode = audio; -+ -+ if (m_audioNode == AUDIO_DEVICE) - { -- KLOG_DEBUG() << "AUDIO_DEVICE"; -- m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, objectPath, session, this); -+ QDBusPendingReply defaultSinkPath = m_audioInterface->GetDefaultSink(); -+ m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this); - initAudioDevice(); -+ -+ connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged); -+ connect(ui->volumeSetting, &QSlider::valueChanged, [this](int value) -+ { -+ double volumeValue = static_cast(value) / static_cast(100); -+ m_sink->SetVolume(volumeValue); }); -+ -+ connect(m_audioInterface, &AudioInterface::SinkAdded, this, &VolumeSettingPage::handleSinkAdded); -+ connect(m_audioInterface, &AudioInterface::SinkDelete, this, &VolumeSettingPage::handleSinkDelete); -+ connect(m_audioInterface, &AudioInterface::DefaultSinkChange, this, &VolumeSettingPage::handleDefaultSinkChanged, Qt::QueuedConnection); - } -- else if (audioNode == AUDIO_STREAM) -+ else if (m_audioNode == AUDIO_STREAM) - { -- KLOG_DEBUG() << "AUDIO_STREAM"; - m_sinkInput = new AudioStreamInterface(AUDIO_DBUS_NAME, objectPath, session, this); - initAudioStream(); - } - connect(ui->muteButton, &QPushButton::clicked, this, &VolumeSettingPage::handleMuteButtonClicked); -+ -+ initDbusServiceWatcher(); - } - - VolumeSettingPage::~VolumeSettingPage() -@@ -53,22 +65,47 @@ VolumeSettingPage::~VolumeSettingPage() - delete ui; - } - -+void VolumeSettingPage::initDbusServiceWatcher() -+{ -+ m_dbusServiceWatcher = new QDBusServiceWatcher(); -+ m_dbusServiceWatcher->setConnection(QDBusConnection::sessionBus()); -+ m_dbusServiceWatcher->addWatchedService(AUDIO_DBUS_NAME); -+ m_dbusServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); -+ connect(m_dbusServiceWatcher, &QDBusServiceWatcher::serviceUnregistered, [this](const QString &service) -+ { -+ KLOG_DEBUG() << "serviceUnregistered:" << service; -+ disableSettings(); }); -+} -+ - void VolumeSettingPage::initAudioDevice() - { -- initSettings(m_sink); -+ KLOG_DEBUG() << "AUDIO_DEVICE"; -+ QDBusPendingReply getPorts = m_sink->GetPorts(); -+ // 解析默认sink的端口信息 -+ QJsonParseError jsonParseError; -+ QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toLatin1(), &jsonParseError); -+ if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError) -+ { -+ initSettings(m_sink); -+ } -+ else -+ { -+ // 无激活端口则禁用音量设置 -+ disableSettings(); -+ } - ui->volumeName->setText(tr("Volume")); -- connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged); -- connect(m_sink, &AudioDeviceInterface::muteChanged, [=](bool value) -- { KLOG_DEBUG() << "m_sink muteChanged:" << value; }); - } - - void VolumeSettingPage::initAudioStream() - { -+ KLOG_DEBUG() << "AUDIO_STREAM"; - initSettings(m_sinkInput); - ui->volumeName->setText(m_sinkInput->GetProperty("application.name")); - connect(m_sinkInput, &AudioStreamInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged); -- connect(m_sinkInput, &AudioStreamInterface::muteChanged, [=](bool value) -- { KLOG_DEBUG() << "m_sinkInput muteChanged:" << value; }); -+ connect(ui->volumeSetting, &QSlider::valueChanged, [=](int value) -+ { -+ double volumeValue = static_cast(value) / static_cast(100); -+ m_sinkInput->SetVolume(volumeValue); }); - } - - template -@@ -77,6 +114,7 @@ void VolumeSettingPage::initSettings(Audio *audio) - ui->volumeSetting->setRange(0, 100); - ui->volumeSetting->setSingleStep(1); - ui->volumeSetting->setPageStep(1); -+ ui->volumeSetting->setEnabled(true); - - KLOG_DEBUG() << "current volume:" << audio->volume(); - double currentVolumeDouble = audio->volume() * 100; -@@ -84,17 +122,12 @@ void VolumeSettingPage::initSettings(Audio *audio) - setVolumeIcon(currentVolume); - ui->volumeSetting->setValue(currentVolume); - ui->volume->setText(QString::number(currentVolume) + "%"); -- -- connect(ui->volumeSetting, &QSlider::valueChanged, [=](int value) -- { -- double volumeValue = static_cast(value) / static_cast(100); -- audio->SetVolume(volumeValue); }); - } - - void VolumeSettingPage::handleVolumeChanged(double value) - { -- ui->volumeSetting->blockSignals(true); //为了避免拖动的同时设置位置会出现问题 -- int currentVolume = round(value * 100); //表示数值的时候向上取整 -+ ui->volumeSetting->blockSignals(true); // 为了避免拖动的同时设置位置会出现问题 -+ int currentVolume = round(value * 100); // 表示数值的时候向上取整 - ui->volume->setText(QString::number(currentVolume) + "%"); - setVolumeIcon(currentVolume); - ui->volumeSetting->setValue(currentVolume); -@@ -103,12 +136,56 @@ void VolumeSettingPage::handleVolumeChanged(double value) - - void VolumeSettingPage::handleMuteButtonClicked() - { -- if (audioNode == AUDIO_DEVICE) -+ if (m_audioNode == AUDIO_DEVICE) - clickMuteButton(m_sink); - else - clickMuteButton(m_sinkInput); - } - -+void VolumeSettingPage::handleDefaultSinkChanged(int index) -+{ -+ // delete and restart init defaultSink -+ if (m_sink != nullptr) -+ { -+ m_sink->deleteLater(); -+ m_sink = nullptr; -+ } -+ -+ QDBusPendingReply defaultSinkPath = m_audioInterface->GetDefaultSink(); -+ m_sink = new AudioDeviceInterface(AUDIO_DBUS_NAME, defaultSinkPath, QDBusConnection::sessionBus(), this); -+ initAudioDevice(); -+ connect(m_sink, &AudioDeviceInterface::volumeChanged, this, &VolumeSettingPage::handleVolumeChanged); -+} -+ -+void VolumeSettingPage::handleSinkAdded(int index) -+{ -+ KLOG_DEBUG() << "SinkAdded"; -+ // 当已经存在defaultSink时,暂时不处理其他sink的添加 -+ if (m_sink != nullptr) -+ { -+ // 刷新界面 -+ initSettings(m_sink); -+ } -+ else -+ { -+ // defaultSink不存在,则重新初始化设备 -+ initAudioDevice(); -+ } -+} -+ -+void VolumeSettingPage::handleSinkDelete(int index) -+{ -+ // 当前存在Sink -+ if (m_sink != nullptr) -+ { -+ // 删除的是defaultSink则进行处理,删除其他sink暂时不处理 -+ if (m_sink->index() == index) -+ { -+ disableSettings(); -+ } -+ } -+} -+ - template - void VolumeSettingPage::clickMuteButton(Audio *audio) - { -@@ -120,19 +197,17 @@ void VolumeSettingPage::clickMuteButton(Audio *audio) - KLOG_DEBUG() << "m_sink->mute() :" << audio->mute(); - if (!audio->mute()) - { -- volumeBeforeMute = currentVolume; -- KLOG_DEBUG() << "volumeBeforeMute:" << volumeBeforeMute; -+ m_volumeBeforeMute = currentVolume; - audio->SetMute(true); - } - } - else - { -- if (volumeBeforeMute != 0) -+ if (m_volumeBeforeMute != 0) - { -- KLOG_DEBUG() << "SetVolume volumeBeforeMute:" << volumeBeforeMute; -- audio->SetVolume(static_cast(volumeBeforeMute) / static_cast(100)); -- volumeBeforeMute = 0; -- KLOG_DEBUG() << "volumeBeforeMute = 0"; -+ KLOG_DEBUG() << "SetVolume m_volumeBeforeMute:" << m_volumeBeforeMute; -+ audio->SetVolume(static_cast(m_volumeBeforeMute) / static_cast(100)); -+ m_volumeBeforeMute = 0; - } - } - } -@@ -172,6 +247,14 @@ QPixmap VolumeSettingPage::trayIconColorSwitch(const QString &iconPath) - return pixmap; - } - -+void VolumeSettingPage::disableSettings() -+{ -+ ui->volumeSetting->setValue(0); -+ ui->volume->setText(QString::number(0) + "%"); -+ ui->volumeSetting->setEnabled(false); -+ setVolumeIcon(0); -+} -+ - void VolumeSettingPage::hideLine() - { - ui->line->hide(); -diff --git a/plugins/audio/src/system-tray/volume-setting-page.h b/plugins/audio/src/system-tray/volume-setting-page.h -index d78bd13..4719021 100644 ---- a/plugins/audio/src/system-tray/volume-setting-page.h -+++ b/plugins/audio/src/system-tray/volume-setting-page.h -@@ -17,6 +17,7 @@ - - #include - #include "common/audio-node.h" -+#include - - QT_BEGIN_NAMESPACE - namespace Ui -@@ -36,17 +37,26 @@ public: - explicit VolumeSettingPage(enum AudioNode audio, const QString objectPath, QWidget *parent = nullptr); - ~VolumeSettingPage() override; - -+ QPixmap trayIconColorSwitch(const QString &iconPath); -+ void disableSettings(); -+ -+private: -+ void initDbusServiceWatcher(); - void initAudioDevice(); - void initAudioStream(); - template - void initSettings(Audio *audio); - template - void clickMuteButton(Audio *audio); -- QPixmap trayIconColorSwitch(const QString &iconPath); -+ - - public slots: - void handleVolumeChanged(double value); - void handleMuteButtonClicked(); -+ void handleDefaultSinkChanged(int index); -+ void handleSinkAdded(int index); -+ void handleSinkDelete(int index); -+ - void setVolumeIcon(int value); - void hideLine(); - -@@ -56,8 +66,10 @@ private: - AudioDeviceInterface *m_sink; - AudioStreamInterface *m_sinkInput; - -- int volumeBeforeMute; -- AudioNode audioNode; -+ int m_volumeBeforeMute; -+ AudioNode m_audioNode; -+ -+ QDBusServiceWatcher *m_dbusServiceWatcher; - }; - - #endif // KIRAN_CPANEL_AUDIO_VOLUME_SETTING_PAGE_H --- -2.33.0 - diff --git a/0001-fix-network-Change-the-width-of-the-secondary-option.patch b/0001-fix-network-Change-the-width-of-the-secondary-option.patch deleted file mode 100644 index bab2681..0000000 --- a/0001-fix-network-Change-the-width-of-the-secondary-option.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 4d70ccd259e54a48507f722085101ff76a414962 Mon Sep 17 00:00:00 2001 -From: luoqing -Date: Thu, 29 Dec 2022 11:22:42 +0800 -Subject: [PATCH] fix(network):Change the width of the secondary options - sidebar -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -- 修改二级选项侧边栏的宽度 ---- - plugins/network/src/plugin/cpanel-network-widget.ui | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/plugins/network/src/plugin/cpanel-network-widget.ui b/plugins/network/src/plugin/cpanel-network-widget.ui -index add60a4..de70410 100644 ---- a/plugins/network/src/plugin/cpanel-network-widget.ui -+++ b/plugins/network/src/plugin/cpanel-network-widget.ui -@@ -63,13 +63,13 @@ - - - -- 283 -+ 272 - 0 - - - - -- 283 -+ 272 - 16777215 - - --- -2.33.0 - diff --git a/0001-fix-network-Fix-the-problem-that-the-network-setting.patch b/0001-fix-network-Fix-the-problem-that-the-network-setting.patch deleted file mode 100644 index 78daeab..0000000 --- a/0001-fix-network-Fix-the-problem-that-the-network-setting.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0d0b3c2403abd618b6f664f9e21b0ed8672b852b Mon Sep 17 00:00:00 2001 -From: luoqing -Date: Thu, 5 Jan 2023 13:48:58 +0800 -Subject: [PATCH] fix(network):Fix the problem that the network settings of the - control center, clone MAC address settings, can't be saved after being - modified and cleared -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -- 修复控制中心网络设置克隆MAC地址设置保存之后,再修改清空,保存无法保存的问题 ---- - .../plugin/setting-widget/ethernet-widget.cpp | 22 ++++++++++++++++++- - 1 file changed, 21 insertions(+), 1 deletion(-) - -diff --git a/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp b/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp -index af438bf..9d5dfe7 100644 ---- a/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp -+++ b/plugins/network/src/plugin/setting-widget/ethernet-widget.cpp -@@ -89,8 +89,28 @@ void EthernetWidget::saveSettings() - QString cloneMac = ui->cloneDeviceMac->text(); - KLOG_DEBUG() << "macAddress:" << macAddress; - KLOG_DEBUG() << "cloneMac:" << cloneMac; -+ - m_wiredSetting->setMacAddress(QByteArray::fromHex(macAddress.toUtf8())); -- m_wiredSetting->setClonedMacAddress(QByteArray::fromHex(cloneMac.toUtf8())); -+ -+ if(cloneMac.isEmpty()) -+ { -+ /** -+ * assigned-mac-address: -+ * The new field for the cloned MAC address. -+ * It can be either a hardware address in ASCII representation, -+ * or one of the special values "preserve", "permanent", "random" or "stable". -+ * This field replaces the deprecated "cloned-mac-address" on D-Bus, -+ * which can only contain explicit hardware addresses. -+ * Note that this property only exists in D-Bus API. -+ * libnm and nmcli continue to call this property "cloned-mac-address". -+ */ -+ m_wiredSetting->setAssignedMacAddress(QString()); -+ m_wiredSetting->setClonedMacAddress(QByteArray()); -+ } -+ else -+ { -+ m_wiredSetting->setClonedMacAddress(QByteArray::fromHex(cloneMac.toUtf8())); -+ } - m_wiredSetting->setMtu(ui->customMTU->value()); - } - } --- -2.33.0 - diff --git a/0001-fix-translation-Translation-activation-state.patch b/0001-fix-translation-Translation-activation-state.patch deleted file mode 100644 index 455d1e4..0000000 --- a/0001-fix-translation-Translation-activation-state.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 341ba1fb31bc94ce0c7a3821c88831a465f15bc1 Mon Sep 17 00:00:00 2001 -From: liuxinhao -Date: Tue, 13 Dec 2022 14:18:53 +0800 -Subject: [PATCH] fix(translation): Translation activation state -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -- 翻译激活状态 ---- - .../translations/kiran-cpanel-system.zh_CN.ts | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/plugins/system/translations/kiran-cpanel-system.zh_CN.ts b/plugins/system/translations/kiran-cpanel-system.zh_CN.ts -index c40820f..143de36 100644 ---- a/plugins/system/translations/kiran-cpanel-system.zh_CN.ts -+++ b/plugins/system/translations/kiran-cpanel-system.zh_CN.ts -@@ -587,7 +587,7 @@ p, li { white-space: pre-wrap; } - - - Activation status: -- 激活状态: -+ 激活状态: - - - -@@ -632,32 +632,32 @@ p, li { white-space: pre-wrap; } - - - UnActivated -- -+ 未激活 - - - - Activation code has expired -- -+ 激活码已过期 - - - - Permanently activated -- -+ 永久激活 - - - - Activated -- 已激活 -+ 已激活 - - - - Error -- -+ 错误 - - - - Failed to open the license activator -- -+ 启动激活许可证弹窗失败 - - - Copyright © --- -2.33.0 - diff --git a/kiran-control-panel-2.4.1.tar.gz b/kiran-control-panel-2.5.0.tar.gz similarity index 64% rename from kiran-control-panel-2.4.1.tar.gz rename to kiran-control-panel-2.5.0.tar.gz index e638eae..ce7c2c1 100644 Binary files a/kiran-control-panel-2.4.1.tar.gz and b/kiran-control-panel-2.5.0.tar.gz differ diff --git a/kiran-control-panel.spec b/kiran-control-panel.spec index a405a4c..9c1b1d3 100644 --- a/kiran-control-panel.spec +++ b/kiran-control-panel.spec @@ -1,15 +1,11 @@ Name: kiran-control-panel -Version: 2.4.1 -Release: 3 +Version: 2.5.0 +Release: 1 Summary: Kiran Control Panel Summary(zh_CN): Kiran桌面控制面板 License: MulanPSL-2.0 Source0: %{name}-%{version}.tar.gz -Patch01: 0001-fix-translation-Translation-activation-state.patch -Patch02: 0001-fix-network-Change-the-width-of-the-secondary-option.patch -Patch03: 0001-fix-audio-Improve-the-disabling-of-volume-plugin-and.patch -Patch04: 0001-fix-network-Fix-the-problem-that-the-network-setting.patch BuildRequires: gcc-c++ BuildRequires: cmake >= 3.2 @@ -32,6 +28,7 @@ BuildRequires: kiran-widgets-qt5-devel BuildRequires: kiran-qt5-integration-devel BuildRequires: kiran-qdbusxml2cpp BuildRequires: kiran-cc-daemon-devel +BuildRequires: kiran-authentication-service-devel >= 2.5 Requires: qt5-qtbase Requires: qt5-qtbase-gui @@ -45,6 +42,7 @@ Requires: kiran-widgets-qt5 >= 2.4 Requires: kiran-qt5-integration >= 2.4 Requires: kiran-system-daemon >= 2.4 Requires: kiran-session-daemon >= 2.4 +Requires: kiran-authentication-service >= 2.5 Requires: glib2 Requires: upower @@ -145,6 +143,9 @@ make %{?_smp_mflags} rm -rf %{buildroot} %changelog +* Wed Apr 05 2023 liuxinhao - 2.5.0-1 +- KYOS-F: add authentication manager and user group plugin + * Thu Jan 05 2023 luoqing - 2.4.1-3 - KYOS-F: Modify the width of the secondary options sidebar of the network plugin - KYOS-F: Improve the disabling of volume plugin and tray