mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: sound checked item highlight do not follow theme
1. update sound icon when theme changed 2. add built-in dci resources to prevent it become a white icon when changed into theme without dci resources log: update sound icon when theme changed
This commit is contained in:
parent
31958dfe1b
commit
579cf0afe9
@ -24,7 +24,7 @@ Copyright: UnionTech Software Technology Co., Ltd.
|
|||||||
License: LGPL-3.0-or-later
|
License: LGPL-3.0-or-later
|
||||||
|
|
||||||
# png svg
|
# png svg
|
||||||
Files: plugins/*.png plugins/*.svg frame/*.svg tests/*.png tests/*.svg
|
Files: plugins/*.png plugins/*.svg frame/*.svg tests/*.png tests/*.svg plugins/*.dci
|
||||||
Copyright: UnionTech Software Technology Co., Ltd.
|
Copyright: UnionTech Software Technology Co., Ltd.
|
||||||
License: LGPL-3.0-or-later
|
License: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
|
@ -25,7 +25,7 @@ pkg_check_modules(XCB_LIBS REQUIRED IMPORTED_TARGET xcursor)
|
|||||||
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
|
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
|
||||||
|
|
||||||
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
|
||||||
add_library(${PLUGIN_NAME} SHARED ${SRCS})
|
add_library(${PLUGIN_NAME} SHARED ${SRCS} resources/sound.qrc)
|
||||||
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../quick-trays)
|
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../quick-trays)
|
||||||
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
|
||||||
./dbusinterface
|
./dbusinterface
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
plugins/sound/resources/sound.qrc
Normal file
9
plugins/sound/resources/sound.qrc
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/dsg">
|
||||||
|
<file>built-in-icons/audio-volume-high-symbolic.dci</file>
|
||||||
|
<file>built-in-icons/audio-volume-low-symbolic.dci</file>
|
||||||
|
<file>built-in-icons/audio-volume-medium-symbolic.dci</file>
|
||||||
|
<file>built-in-icons/audio-volume-muted-symbolic.dci</file>
|
||||||
|
<file>built-in-icons/audio-volume-off-symbolic.dci</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
#define HEADERHEIGHT 30
|
#define HEADERHEIGHT 10
|
||||||
#define ITEMSPACE 16
|
#define ITEMSPACE 16
|
||||||
#define ROWSPACE 5
|
#define ROWSPACE 5
|
||||||
#define DESCRIPTIONHEIGHT 20
|
#define DESCRIPTIONHEIGHT 20
|
||||||
@ -49,7 +49,6 @@ using namespace Dock;
|
|||||||
SoundDevicesWidget::SoundDevicesWidget(QWidget *parent)
|
SoundDevicesWidget::SoundDevicesWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_tipsLabel(new TipsWidget(this))
|
, m_tipsLabel(new TipsWidget(this))
|
||||||
, m_titleLabel(new QLabel(tr("Sound"), this))
|
|
||||||
, m_sliderContainer(new SliderContainer(this))
|
, m_sliderContainer(new SliderContainer(this))
|
||||||
, m_descriptionLabel(new QLabel(tr("Output Device"), this))
|
, m_descriptionLabel(new QLabel(tr("Output Device"), this))
|
||||||
, m_deviceList(new DListView(this))
|
, m_deviceList(new DListView(this))
|
||||||
@ -94,9 +93,6 @@ void SoundDevicesWidget::initUi()
|
|||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
layout->setContentsMargins(10, 0, 10, 0);
|
layout->setContentsMargins(10, 0, 10, 0);
|
||||||
|
|
||||||
m_titleLabel->setFixedHeight(HEADERHEIGHT);
|
|
||||||
m_titleLabel->setAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
QPixmap leftPixmap = QIcon::fromTheme(QString("audio-volume-%1-symbolic").arg(m_sinkInter->mute() ? "muted" : "off")).pixmap(18, 18);
|
QPixmap leftPixmap = QIcon::fromTheme(QString("audio-volume-%1-symbolic").arg(m_sinkInter->mute() ? "muted" : "off")).pixmap(18, 18);
|
||||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 5);
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 5);
|
||||||
QPixmap rightPixmap = QIcon::fromTheme("audio-volume-high-symbolic").pixmap(18, 18);
|
QPixmap rightPixmap = QIcon::fromTheme("audio-volume-high-symbolic").pixmap(18, 18);
|
||||||
@ -112,7 +108,6 @@ void SoundDevicesWidget::initUi()
|
|||||||
topLayout->setContentsMargins(7, 0, 7, 0);
|
topLayout->setContentsMargins(7, 0, 7, 0);
|
||||||
topLayout->setSpacing(0);
|
topLayout->setSpacing(0);
|
||||||
|
|
||||||
topLayout->addWidget(m_titleLabel);
|
|
||||||
topLayout->addWidget(m_sliderContainer);
|
topLayout->addWidget(m_sliderContainer);
|
||||||
m_descriptionLabel->setMargin(5);
|
m_descriptionLabel->setMargin(5);
|
||||||
|
|
||||||
@ -220,6 +215,25 @@ void SoundDevicesWidget::initConnection()
|
|||||||
}
|
}
|
||||||
emit iconChanged();
|
emit iconChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] {
|
||||||
|
// 更新右icon,左icon放在pixmap跟随refreshIcon一起更新
|
||||||
|
QPixmap rightPixmap = QIcon::fromTheme("audio-volume-high-symbolic").pixmap(18, 18);
|
||||||
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(), 7);
|
||||||
|
// 主题变更时更新checked的背景色
|
||||||
|
for (int i =0; i < m_model->rowCount() -1; i++) {
|
||||||
|
auto item = m_model->item(i);
|
||||||
|
if (item->checkState() == Qt::Checked) {
|
||||||
|
item->setBackground(DPaletteHelper::instance()->palette(this).highlight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(m_sliderContainer, &SliderContainer::iconClicked, this, [ this ](const SliderContainer::IconPosition icon) {
|
||||||
|
if (SliderContainer::IconPosition::LeftIcon == icon) {
|
||||||
|
m_sinkInter->SetMute(!m_sinkInter->mute());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,7 +83,6 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Dock::TipsWidget *m_tipsLabel;
|
Dock::TipsWidget *m_tipsLabel;
|
||||||
QLabel *m_titleLabel;
|
|
||||||
SliderContainer *m_sliderContainer;
|
SliderContainer *m_sliderContainer;
|
||||||
QLabel *m_descriptionLabel;
|
QLabel *m_descriptionLabel;
|
||||||
DListView *m_deviceList;
|
DListView *m_deviceList;
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
DGUI_USE_NAMESPACE
|
DGUI_USE_NAMESPACE
|
||||||
|
|
||||||
@ -73,7 +75,11 @@ void SoundWidget::initConnection()
|
|||||||
|
|
||||||
m_defaultSink = new DBusSink("org.deepin.dde.Audio1", value.path(), QDBusConnection::sessionBus(), this);
|
m_defaultSink = new DBusSink("org.deepin.dde.Audio1", value.path(), QDBusConnection::sessionBus(), this);
|
||||||
connect(m_defaultSink, &DBusSink::VolumeChanged, this, [ this ](double value) { m_sliderContainer->updateSliderValue(std::round(value * 100.00)); });
|
connect(m_defaultSink, &DBusSink::VolumeChanged, this, [ this ](double value) { m_sliderContainer->updateSliderValue(std::round(value * 100.00)); });
|
||||||
connect(m_defaultSink, &DBusSink::MuteChanged, this, [ = ] { m_sliderContainer->updateSliderValue(m_defaultSink->volume() * 100); });
|
connect(m_defaultSink, &DBusSink::MuteChanged, this, [ = ] {
|
||||||
|
m_sliderContainer->updateSliderValue(m_defaultSink->volume() * 100);
|
||||||
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon,
|
||||||
|
QIcon::fromTheme(leftIcon()).pixmap(ICON_SIZE, ICON_SIZE), QSize(), 10);
|
||||||
|
});
|
||||||
|
|
||||||
m_sliderContainer->updateSliderValue(std::round(m_defaultSink->volume() * 100.00));
|
m_sliderContainer->updateSliderValue(std::round(m_defaultSink->volume() * 100.00));
|
||||||
});
|
});
|
||||||
@ -90,7 +96,8 @@ void SoundWidget::initConnection()
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(m_defaultSink, &DBusSink::MuteChanged, this, [ this ] {
|
connect(m_defaultSink, &DBusSink::MuteChanged, this, [ this ] {
|
||||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, QIcon(leftIcon()));
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon,
|
||||||
|
QIcon::fromTheme(leftIcon()).pixmap(ICON_SIZE, ICON_SIZE), QSize(), 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SoundWidget::onThemeTypeChanged);
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &SoundWidget::onThemeTypeChanged);
|
||||||
@ -114,21 +121,13 @@ void SoundWidget::initConnection()
|
|||||||
const QString SoundWidget::leftIcon()
|
const QString SoundWidget::leftIcon()
|
||||||
{
|
{
|
||||||
const bool mute = existActiveOutputDevice() ? m_defaultSink->mute() : true;
|
const bool mute = existActiveOutputDevice() ? m_defaultSink->mute() : true;
|
||||||
if (mute) {
|
return QString("audio-volume-%1-symbolic").arg(mute? "muted": "medium");
|
||||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
|
||||||
return QString(":/audio-volume-muted-symbolic-dark.svg");
|
|
||||||
|
|
||||||
return QString(":/audio-volume-muted-symbolic.svg");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
|
|
||||||
return QString(":/audio-volume-medium-symbolic-dark.svg");
|
|
||||||
|
|
||||||
return QString(":/audio-volume-medium-symbolic.svg");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString SoundWidget::rightIcon()
|
const QString SoundWidget::rightIcon()
|
||||||
{
|
{
|
||||||
|
// TODO: broadcast ???
|
||||||
|
// svg from display plugins
|
||||||
return QString(":/icons/resources/broadcast.svg");
|
return QString(":/icons/resources/broadcast.svg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,8 +170,8 @@ bool SoundWidget::existActiveOutputDevice() const
|
|||||||
|
|
||||||
void SoundWidget::onThemeTypeChanged()
|
void SoundWidget::onThemeTypeChanged()
|
||||||
{
|
{
|
||||||
QPixmap leftPixmap = ImageUtil::loadSvg(leftIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
QPixmap leftPixmap = QIcon::fromTheme(leftIcon()).pixmap(ICON_SIZE, ICON_SIZE);
|
||||||
QPixmap rightPixmap = ImageUtil::loadSvg(rightIcon(), QSize(ICON_SIZE, ICON_SIZE));
|
QPixmap rightPixmap = QIcon::fromTheme(rightIcon()).pixmap(ICON_SIZE, ICON_SIZE);
|
||||||
convertThemePixmap(rightPixmap);
|
convertThemePixmap(rightPixmap);
|
||||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::LeftIcon, leftPixmap, QSize(), 10);
|
||||||
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
m_sliderContainer->setIcon(SliderContainer::IconPosition::RightIcon, rightPixmap, QSize(BACKSIZE, BACKSIZE), 12);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user