From 6077bf9c82149b9f08c4fbfe5bb72b468da6b7b4 Mon Sep 17 00:00:00 2001 From: fpc_diesel Date: Mon, 25 May 2020 17:51:02 +0800 Subject: [PATCH 1/5] feat(sound):sound icon display error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG6382 【任务栏】托盘区域音量显示问题 --- plugins/sound/sinkinputwidget.cpp | 55 +++++++++++++++---------------- plugins/sound/soundapplet.cpp | 5 +++ plugins/sound/soundapplet.h | 1 + plugins/sound/sounditem.cpp | 7 ++-- 4 files changed, 37 insertions(+), 31 deletions(-) diff --git a/plugins/sound/sinkinputwidget.cpp b/plugins/sound/sinkinputwidget.cpp index f4ad692bb..e16802946 100644 --- a/plugins/sound/sinkinputwidget.cpp +++ b/plugins/sound/sinkinputwidget.cpp @@ -104,7 +104,6 @@ SinkInputWidget::SinkInputWidget(const QString &inputPath, QWidget *parent) connect(m_volumeSlider, &VolumeSlider::valueChanged, this, &SinkInputWidget::setVolume); connect(m_volumeSlider, &VolumeSlider::valueChanged, this, &SinkInputWidget::onVolumeChanged); // connect(m_volumeSlider, &VolumeSlider::requestPlaySoundEffect, this, &SinkInputWidget::onPlaySoundEffect); - connect(m_appBtn, &DImageButton::clicked, this, &SinkInputWidget::setMute); connect(m_volumeBtnMin, &DImageButton::clicked, this, &SinkInputWidget::setMute); connect(m_inputInter, &DBusSinkInput::MuteChanged, this, &SinkInputWidget::setMuteIcon); connect(m_inputInter, &DBusSinkInput::VolumeChanged, this, [ = ] { @@ -140,35 +139,34 @@ void SinkInputWidget::setMute() void SinkInputWidget::setMuteIcon() { - //app应用为静音时,只需要将音量图标设置成静音,无需将应用图标设置为静音图标 -// if (m_inputInter->mute()) { -// const auto ratio = devicePixelRatioF(); -// QString iconString = "audio-volume-muted-symbolic"; -// if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { -// iconString.append("-dark"); -// } -// QPixmap muteIcon = QIcon::fromTheme(iconString).pixmap(ICON_SIZE * ratio, ICON_SIZE * ratio); -// muteIcon.setDevicePixelRatio(ratio); -// QPixmap appIconSource(getIconFromTheme(m_inputInter->icon(), QSize(ICON_SIZE, ICON_SIZE), devicePixelRatioF())); + if (m_inputInter->mute()) { + const auto ratio = devicePixelRatioF(); + QString iconString = "audio-volume-muted-symbolic"; + if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { + iconString.append("-dark"); + } + QPixmap muteIcon = QIcon::fromTheme(iconString).pixmap(ICON_SIZE * ratio, ICON_SIZE * ratio); + muteIcon.setDevicePixelRatio(ratio); + QPixmap appIconSource(getIconFromTheme(m_inputInter->icon(), QSize(ICON_SIZE, ICON_SIZE), devicePixelRatioF())); -// QPixmap temp(appIconSource.size()); -// temp.fill(Qt::transparent); -// temp.setDevicePixelRatio(ratio); -// QPainter p1(&temp); -// p1.drawPixmap(0, 0, appIconSource); -// p1.setCompositionMode(QPainter::CompositionMode_DestinationIn); -// p1.fillRect(temp.rect(), QColor(0, 0, 0, 40)); -// p1.end(); -// appIconSource = temp; + QPixmap temp(appIconSource.size()); + temp.fill(Qt::transparent); + temp.setDevicePixelRatio(ratio); + QPainter p1(&temp); + p1.drawPixmap(0, 0, appIconSource); + p1.setCompositionMode(QPainter::CompositionMode_DestinationIn); + p1.fillRect(temp.rect(), QColor(0, 0, 0, 40)); + p1.end(); + appIconSource = temp; -// QPainter p(&appIconSource); -// p.drawPixmap(0, 0, muteIcon); + QPainter p(&appIconSource); + p.drawPixmap(0, 0, muteIcon); -// appIconSource.setDevicePixelRatio(ratio); -// m_appBtn->setPixmap(appIconSource); -// } else { -// m_appBtn->setPixmap(getIconFromTheme(m_inputInter->icon(), QSize(ICON_SIZE, ICON_SIZE), devicePixelRatioF())); -// } + appIconSource.setDevicePixelRatio(ratio); + m_volumeBtnMin->setPixmap(appIconSource); + } else { + m_volumeBtnMin->setPixmap(getIconFromTheme(m_inputInter->icon(), QSize(ICON_SIZE, ICON_SIZE), devicePixelRatioF())); + } refreshIcon(); } @@ -199,7 +197,7 @@ void SinkInputWidget::refreshIcon() volumeString = "low"; } - QString iconLeft = QString("audio-volume-%1-symbolic").arg(volumeString); + QString iconLeft = QString(m_inputInter->mute() ? "audio-volume-muted-symbolic" : "audio-volume-low-symbolic"); QString iconRight = QString("audio-volume-high-symbolic"); if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) { @@ -213,7 +211,6 @@ void SinkInputWidget::refreshIcon() ret = ImageUtil::loadSvg(iconLeft, ":/", ICON_SIZE, ratio); m_volumeBtnMin->setPixmap(ret); - } void SinkInputWidget:: onVolumeChanged() diff --git a/plugins/sound/soundapplet.cpp b/plugins/sound/soundapplet.cpp index 55f788670..157bafebb 100644 --- a/plugins/sound/soundapplet.cpp +++ b/plugins/sound/soundapplet.cpp @@ -152,6 +152,11 @@ int SoundApplet::volumeValue() const return m_volumeSlider->value(); } +int SoundApplet::maxVolumeValue() const +{ + return m_volumeSlider->maximum(); +} + VolumeSlider *SoundApplet::mainSlider() { return m_volumeSlider; diff --git a/plugins/sound/soundapplet.h b/plugins/sound/soundapplet.h index 1158be969..9aca0fba7 100644 --- a/plugins/sound/soundapplet.h +++ b/plugins/sound/soundapplet.h @@ -41,6 +41,7 @@ public: explicit SoundApplet(QWidget *parent = 0); int volumeValue() const; + int maxVolumeValue() const; VolumeSlider *mainSlider(); signals: void volumeChanged(const int value) const; diff --git a/plugins/sound/sounditem.cpp b/plugins/sound/sounditem.cpp index cd498cf45..b636164df 100644 --- a/plugins/sound/sounditem.cpp +++ b/plugins/sound/sounditem.cpp @@ -160,6 +160,7 @@ void SoundItem::refreshIcon() return; const double volmue = m_applet->volumeValue(); + const double maxVolmue = m_applet->maxVolumeValue(); const bool mute = m_sinkInter->mute(); const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient; @@ -179,9 +180,11 @@ void SoundItem::refreshIcon() QString volumeString; if (mute) volumeString = "muted"; - else if (volmue / 100.0f >= double(2) / 3) + else if (int(volmue) == 0) + volumeString = "off"; + else if (volmue / maxVolmue >= double(2) / 3) volumeString = "high"; - else if (volmue / 100.0f >= double(1) / 3) + else if (volmue / maxVolmue >= double(1) / 3) volumeString = "medium"; else volumeString = "low"; From df62981c14c68a9d148bfebc61fa297167730320 Mon Sep 17 00:00:00 2001 From: wangxuwen Date: Mon, 25 May 2020 13:58:34 +0800 Subject: [PATCH 2/5] fixed : change the dock position will display error for bug 25873 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 切换任务栏位置有时候布局错乱bug 25873 --- frame/panel/mainpanelcontrol.cpp | 24 ++++++++++++++++-------- frame/panel/mainpanelcontrol.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 18990eb64..33c26ae8f 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -217,6 +217,9 @@ void MainPanelControl::updateMainPanelLayout() m_pluginLayout->setContentsMargins(0, 10, 0, 10); break; } + + resizeDesktopWidget(); + resizeDockIcon(); } void MainPanelControl::addFixedAreaItem(int index, QWidget *wdg) @@ -277,14 +280,7 @@ void MainPanelControl::removePluginAreaItem(QWidget *wdg) void MainPanelControl::resizeEvent(QResizeEvent *event) { - if (m_position == Position::Right || m_position == Position::Left) - m_desktopWidget->setFixedSize(width(), DESKTOP_SIZE); - else - m_desktopWidget->setFixedSize(DESKTOP_SIZE, height()); - - if (DisplayMode::Fashion == m_dislayMode) - m_desktopWidget->setFixedSize(0, 0); - + resizeDesktopWidget(); resizeDockIcon(); return QWidget::resizeEvent(event); } @@ -1065,3 +1061,15 @@ void MainPanelControl::getTrayVisableItemCount() // 模式切换时,托盘区域宽度错误,对应任务11933 m_trayAreaWidget->adjustSize(); } + +void MainPanelControl::resizeDesktopWidget() +{ + if (m_position == Position::Right || m_position == Position::Left) + m_desktopWidget->setFixedSize(width(), DESKTOP_SIZE); + else + m_desktopWidget->setFixedSize(DESKTOP_SIZE, height()); + + if (DisplayMode::Fashion == m_dislayMode) + m_desktopWidget->setFixedSize(0, 0); +} + diff --git a/frame/panel/mainpanelcontrol.h b/frame/panel/mainpanelcontrol.h index bbaff3730..912582331 100755 --- a/frame/panel/mainpanelcontrol.h +++ b/frame/panel/mainpanelcontrol.h @@ -91,6 +91,7 @@ private: void paintEvent(QPaintEvent *event) override; void resizeDockIcon(); void calcuDockIconSize(const int w, const int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin); + void resizeDesktopWidget(); public slots: void insertItem(const int index, DockItem *item); From 7a731315abd32cfd6116931c28afae373286d4ad Mon Sep 17 00:00:00 2001 From: fpc_diesel Date: Tue, 26 May 2020 14:39:31 +0800 Subject: [PATCH 3/5] feat:gsettings control power display --- .../com.deepin.dde.dock.module.gschema.xml | 23 ++++++++ plugins/power/CMakeLists.txt | 2 + plugins/power/powerplugin.cpp | 58 ++++++++++++++++--- plugins/power/powerplugin.h | 2 + plugins/power/powerstatuswidget.cpp | 26 ++++++--- translations/dde-dock.ts | 18 ++++-- 6 files changed, 108 insertions(+), 21 deletions(-) diff --git a/gschema/com.deepin.dde.dock.module.gschema.xml b/gschema/com.deepin.dde.dock.module.gschema.xml index 3d4c92f14..2af4a9313 100644 --- a/gschema/com.deepin.dde.dock.module.gschema.xml +++ b/gschema/com.deepin.dde.dock.module.gschema.xml @@ -112,6 +112,22 @@ + + + false + Blocking event + + Blocking mouse events + + + + true + Module Enable + + Control Module Enable + + + false @@ -127,6 +143,13 @@ Control Module Enable + + true + Show TimeToFull + + Show TimeToFull + + diff --git a/plugins/power/CMakeLists.txt b/plugins/power/CMakeLists.txt index 39b7ec67c..a7819a9d3 100644 --- a/plugins/power/CMakeLists.txt +++ b/plugins/power/CMakeLists.txt @@ -20,6 +20,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../syst target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${DFrameworkDBus_INCLUDE_DIRS} + ${QGSettings_INCLUDE_DIRS} ../../interfaces) target_link_libraries(${PLUGIN_NAME} PRIVATE ${DtkWidget_LIBRARIES} @@ -27,6 +28,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE ${Qt5Svg_LIBRARIES} ${Qt5DBus_LIBRARIES} ${DFrameworkDBus_LIBRARIES} + ${QGSettings_LIBRARIES} ) install(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION lib/dde-dock/plugins/system-trays) diff --git a/plugins/power/powerplugin.cpp b/plugins/power/powerplugin.cpp index cbefd5fbc..72db7db2b 100644 --- a/plugins/power/powerplugin.cpp +++ b/plugins/power/powerplugin.cpp @@ -23,14 +23,21 @@ #include "dbus/dbusaccount.h" #include +#include #define PLUGIN_STATE_KEY "enable" -PowerPlugin::PowerPlugin(QObject *parent) - : QObject(parent), +static QGSettings *GSettingsByApp() +{ + static QGSettings settings("com.deepin.dde.dock.module.power"); + return &settings; +} - m_pluginLoaded(false), - m_tipsLabel(new TipsWidget) +PowerPlugin::PowerPlugin(QObject *parent) + : QObject(parent) + , m_pluginLoaded(false) + , m_showTimeToFull(true) + , m_tipsLabel(new TipsWidget) { m_tipsLabel->setVisible(false); m_tipsLabel->setObjectName("power"); @@ -181,6 +188,7 @@ void PowerPlugin::loadPlugin() m_systemPowerInter = new SystemPowerInter("com.deepin.system.Power", "/com/deepin/system/Power", QDBusConnection::systemBus(), this); m_systemPowerInter->setSync(true); + connect(GSettingsByApp(), &QGSettings::changed, this, &PowerPlugin::onGSettingsChanged); connect(m_systemPowerInter, &SystemPowerInter::BatteryStatusChanged, this, &PowerPlugin::refreshTipsData); connect(m_systemPowerInter, &SystemPowerInter::BatteryTimeToEmptyChanged, this, &PowerPlugin::refreshTipsData); connect(m_systemPowerInter, &SystemPowerInter::BatteryTimeToFullChanged, this, &PowerPlugin::refreshTipsData); @@ -188,6 +196,8 @@ void PowerPlugin::loadPlugin() connect(m_powerInter, &DBusPower::BatteryPercentageChanged, this, &PowerPlugin::updateBatteryVisible); updateBatteryVisible(); + + onGSettingsChanged("showtimetofull"); } void PowerPlugin::refreshPluginItemsVisible() @@ -203,6 +213,20 @@ void PowerPlugin::refreshPluginItemsVisible() } } +void PowerPlugin::onGSettingsChanged(const QString &key) +{ + if (key != "showtimetofull") { + return; + } + + if (GSettingsByApp()->keys().contains("showtimetofull")) { + const bool isEnable = GSettingsByApp()->keys().contains("showtimetofull") && GSettingsByApp()->get("showtimetofull").toBool(); + m_showTimeToFull = isEnable && GSettingsByApp()->get("showtimetofull").toBool(); + } + + refreshTipsData(); +} + void PowerPlugin::refreshTipsData() { const BatteryPercentageMap data = m_powerInter->batteryPercentage(); @@ -220,9 +244,19 @@ void PowerPlugin::refreshTipsData() if (min == 0) tips = tr("Charged"); else - tips = tr("Capacity %1, %2 min remaining").arg(value).arg(min); + { + if(m_showTimeToFull) + tips = tr("Capacity %1, %2 min remaining").arg(value).arg(min); + else { + tips = tr("Capacity %1"); + } + } } else { - tips = tr("Capacity %1, %2 hr %3 min remaining").arg(value).arg(hour).arg(min); + if(m_showTimeToFull) + tips = tr("Capacity %1, %2 hr %3 min remaining").arg(value).arg(hour).arg(min); + else { + tips = tr("Capacity %1").arg(value).arg(hour); + } } m_tipsLabel->setText(tips); @@ -237,9 +271,17 @@ void PowerPlugin::refreshTipsData() if(timeToFull == 0) { // 电量已充満或电量计算中,剩余充满时间会返回0 tips = tr("Capacity %1 ....").arg(value); } else if (hour == 0) { - tips = tr("Charging %1, %2 min until full").arg(value).arg(min); + if(m_showTimeToFull) + tips = tr("Charging %1, %2 min until full").arg(value).arg(min); + else { + tips = tr("Charging %1").arg(value); + } } else { - tips = tr("Charging %1, %2 hr %3 min until full").arg(value).arg(hour).arg(min); + if(m_showTimeToFull) + tips = tr("Charging %1, %2 hr %3 min until full").arg(value).arg(hour).arg(min); + else { + tips = tr("Charging %1").arg(value); + } } m_tipsLabel->setText(tips); diff --git a/plugins/power/powerplugin.h b/plugins/power/powerplugin.h index f1ce34dac..f8515612d 100644 --- a/plugins/power/powerplugin.h +++ b/plugins/power/powerplugin.h @@ -72,10 +72,12 @@ private: void updateBatteryVisible(); void loadPlugin(); void refreshPluginItemsVisible(); + void onGSettingsChanged(const QString &key); void refreshTipsData(); private: bool m_pluginLoaded; + bool m_showTimeToFull; PowerStatusWidget *m_powerStatusWidget; TipsWidget *m_tipsLabel; diff --git a/plugins/power/powerstatuswidget.cpp b/plugins/power/powerstatuswidget.cpp index 862543689..1d869be1f 100644 --- a/plugins/power/powerstatuswidget.cpp +++ b/plugins/power/powerstatuswidget.cpp @@ -71,22 +71,34 @@ QPixmap PowerStatusWidget::getBatteryIcon() const bool plugged = !m_powerInter->onBattery(); /*根据新需求,电池电量显示分别是*/ - /* 0-5%; 6-20% 21-40% 41-60% 61-80% 81-100% */ + /* 0-5%、6-10%、11%-20%、21-30%、31-40%、41-50%、51-60%、61%-70%、71-80%、81-90%、91-100% */ QString percentageStr; - if (percentage <= 5 && percentage >= 0) { + if (percentage < 0) { percentageStr = "000"; + } else if (percentage <= 5 && percentage >= 0) { + percentageStr = "000"; + } else if (percentage <= 10) { + percentageStr = "010"; } else if (percentage <= 20) { percentageStr = "020"; - } else if (percentage <= 40) { + } else if (percentage <= 30) { + percentageStr = "030"; + }else if (percentage <= 40) { percentageStr = "040"; - } else if (percentage <= 60) { + } else if (percentage <= 50) { + percentageStr = "050"; + }else if (percentage <= 60) { percentageStr = "060"; - } else if (percentage < 80) { + } else if (percentage <= 70) { + percentageStr = "070"; + }else if (percentage < 80) { percentageStr = "080"; - } else if (percentage <= 100){ + } else if (percentage <= 90) { + percentageStr = "090"; + }else if (percentage <= 100){ percentageStr = "100"; } else { - percentageStr = "000"; + percentageStr = "100"; } QString iconStr = QString("battery-%1-%2") diff --git a/translations/dde-dock.ts b/translations/dde-dock.ts index 465a2153b..c2c1fb86f 100644 --- a/translations/dde-dock.ts +++ b/translations/dde-dock.ts @@ -1,4 +1,6 @@ - + + + AbstractPluginsController @@ -213,10 +215,6 @@ Charging %1, %2 hr %3 min until full Charging %1, %2 hr %3 min until full - - Charging %1 .... - Charging %1 .... - Charged Charged @@ -225,6 +223,14 @@ Capacity %1 .... + + Capacity %1 + + + + Charging %1 + + ShowDesktopPlugin @@ -383,4 +389,4 @@ Wireless Network %1 - \ No newline at end of file + From 9530b870ca75add174e191e888ad144e40e019eb Mon Sep 17 00:00:00 2001 From: fpc_diesel Date: Tue, 26 May 2020 15:16:13 +0800 Subject: [PATCH 4/5] feat(sound):sound icon display error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG6382 【任务栏】托盘区域音量显示问题 --- plugins/sound/sinkinputwidget.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/sound/sinkinputwidget.cpp b/plugins/sound/sinkinputwidget.cpp index e16802946..3848c3715 100644 --- a/plugins/sound/sinkinputwidget.cpp +++ b/plugins/sound/sinkinputwidget.cpp @@ -179,23 +179,26 @@ void SinkInputWidget::onPlaySoundEffect() void SinkInputWidget::refreshIcon() { +// qDebug() << __PRETTY_FUNCTION__ << __LINE__ << __FILE__; if (!m_inputInter) return; - const float volume = m_inputInter->volume(); - const bool mute = m_inputInter->mute(); +// const float volume = m_inputInter->volume(); +// const bool mute = m_inputInter->mute(); - QString volumeString; +// QString volumeString; - if (mute) { - volumeString = "muted"; - } else if (volume >= double(2) / 3) { - volumeString = "high"; - } else if (volume >= double(1) / 3) { - volumeString = "medium"; - } else { - volumeString = "low"; - } +// if (mute) { +// volumeString = "muted"; +// } else if (int(volume) == 0) { +// volumeString = "off"; +// } else if (volume >= double(2) / 3) { +// volumeString = "high"; +// } else if (volume >= double(1) / 3) { +// volumeString = "medium"; +// } else { +// volumeString = "low"; +// } QString iconLeft = QString(m_inputInter->mute() ? "audio-volume-muted-symbolic" : "audio-volume-low-symbolic"); QString iconRight = QString("audio-volume-high-symbolic"); From e85732882321d29232823c1ce0f0e5f73b3b6a8f Mon Sep 17 00:00:00 2001 From: fpc_diesel Date: Tue, 26 May 2020 15:27:29 +0800 Subject: [PATCH 5/5] feat:remove note --- plugins/sound/sinkinputwidget.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/plugins/sound/sinkinputwidget.cpp b/plugins/sound/sinkinputwidget.cpp index 3848c3715..d5611a79a 100644 --- a/plugins/sound/sinkinputwidget.cpp +++ b/plugins/sound/sinkinputwidget.cpp @@ -179,27 +179,9 @@ void SinkInputWidget::onPlaySoundEffect() void SinkInputWidget::refreshIcon() { -// qDebug() << __PRETTY_FUNCTION__ << __LINE__ << __FILE__; if (!m_inputInter) return; -// const float volume = m_inputInter->volume(); -// const bool mute = m_inputInter->mute(); - -// QString volumeString; - -// if (mute) { -// volumeString = "muted"; -// } else if (int(volume) == 0) { -// volumeString = "off"; -// } else if (volume >= double(2) / 3) { -// volumeString = "high"; -// } else if (volume >= double(1) / 3) { -// volumeString = "medium"; -// } else { -// volumeString = "low"; -// } - QString iconLeft = QString(m_inputInter->mute() ? "audio-volume-muted-symbolic" : "audio-volume-low-symbolic"); QString iconRight = QString("audio-volume-high-symbolic");