mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: tray icon do not change after system icon theme has changed
https://tower.im/projects/e4ae1ad0b5d5497fb4b7c14fe2d2efbf/todos/d9725c7eddce0c87e5ef5f1939d1964a/ Change-Id: Id094f51c7426f321a1628fdd5e3128d6356c9353
This commit is contained in:
parent
3ee25e36b1
commit
16f10b665c
Notes:
gerrit
2018-12-07 16:59:08 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: listenerri <listenerri@gmail.com> Submitted-by: listenerri <listenerri@gmail.com> Submitted-at: Fri, 07 Dec 2018 16:59:06 +0800 Reviewed-on: https://cr.deepin.io/40342 Project: dde/dde-dock Branch: refs/heads/master
@ -37,22 +37,22 @@ class NetworkPlugin : public QObject, PluginsItemInterface
|
||||
public:
|
||||
explicit NetworkPlugin(QObject *parent = 0);
|
||||
|
||||
const QString pluginName() const;
|
||||
const QString pluginDisplayName() const;
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
|
||||
void refreshIcon(const QString &itemKey);
|
||||
void pluginStateSwitched();
|
||||
bool pluginIsAllowDisable() { return true; }
|
||||
bool pluginIsDisable();
|
||||
const QString itemCommand(const QString &itemKey);
|
||||
const QString itemContextMenu(const QString &itemKey);
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
const QString pluginName() const Q_DECL_OVERRIDE;
|
||||
const QString pluginDisplayName() const Q_DECL_OVERRIDE;
|
||||
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void pluginStateSwitched() Q_DECL_OVERRIDE;
|
||||
bool pluginIsAllowDisable() Q_DECL_OVERRIDE { return true; }
|
||||
bool pluginIsDisable() Q_DECL_OVERRIDE;
|
||||
const QString itemCommand(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
const QString itemContextMenu(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
|
||||
int itemSortKey(const QString &itemKey);
|
||||
void setSortKey(const QString &itemKey, const int order);
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
static bool isConnectivity();
|
||||
|
||||
|
@ -150,6 +150,13 @@ void PowerPlugin::invokedMenuItem(const QString &itemKey, const QString &menuId,
|
||||
QProcess::startDetached("dbus-send --print-reply --dest=com.deepin.dde.ControlCenter /com/deepin/dde/ControlCenter com.deepin.dde.ControlCenter.ShowModule \"string:power\"");
|
||||
}
|
||||
|
||||
void PowerPlugin::refreshIcon(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == POWER_KEY) {
|
||||
m_powerStatusWidget->refreshIcon();
|
||||
}
|
||||
}
|
||||
|
||||
int PowerPlugin::itemSortKey(const QString &itemKey)
|
||||
{
|
||||
const QString key = QString("pos_%1_%2").arg(itemKey).arg(displayMode());
|
||||
|
@ -44,17 +44,15 @@ public:
|
||||
const QString pluginName() const override;
|
||||
const QString pluginDisplayName() const override;
|
||||
void init(PluginProxyInterface *proxyInter) override;
|
||||
|
||||
void pluginStateSwitched() override;
|
||||
bool pluginIsAllowDisable() override { return true; }
|
||||
bool pluginIsDisable() override;
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey) override;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) override;
|
||||
const QString itemCommand(const QString &itemKey) override;
|
||||
const QString itemContextMenu(const QString &itemKey) override;
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) override;
|
||||
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
|
||||
|
@ -37,6 +37,11 @@ PowerStatusWidget::PowerStatusWidget(QWidget *parent)
|
||||
connect(m_powerInter, &DBusPower::OnBatteryChanged, this, static_cast<void (PowerStatusWidget::*)()>(&PowerStatusWidget::update));
|
||||
}
|
||||
|
||||
void PowerStatusWidget::refreshIcon()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
QSize PowerStatusWidget::sizeHint() const
|
||||
{
|
||||
return QSize(26, 26);
|
||||
|
@ -35,6 +35,8 @@ class PowerStatusWidget : public QWidget
|
||||
public:
|
||||
explicit PowerStatusWidget(QWidget *parent = 0);
|
||||
|
||||
void refreshIcon();
|
||||
|
||||
signals:
|
||||
void requestContextMenu(const QString &itemKey) const;
|
||||
|
||||
|
@ -46,9 +46,6 @@ protected:
|
||||
private:
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
|
||||
|
||||
private:
|
||||
void refershIconPixmap();
|
||||
|
||||
private:
|
||||
bool m_hover;
|
||||
Dock::DisplayMode m_displayMode;
|
||||
|
@ -49,13 +49,12 @@ SoundItem::SoundItem(QWidget *parent)
|
||||
m_applet->setVisible(false);
|
||||
|
||||
connect(m_applet, static_cast<void (SoundApplet::*)(DBusSink*) const>(&SoundApplet::defaultSinkChanged), this, &SoundItem::sinkChanged);
|
||||
connect(m_applet, &SoundApplet::volumeChanged, this, &SoundItem::refershTips, Qt::QueuedConnection);
|
||||
connect(static_cast<DApplication*>(qApp), &DApplication::iconThemeChanged, this, &SoundItem::refershIcon);
|
||||
connect(m_applet, &SoundApplet::volumeChanged, this, &SoundItem::refreshTips, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QWidget *SoundItem::tipsWidget()
|
||||
{
|
||||
refershTips(true);
|
||||
refreshTips(true);
|
||||
|
||||
m_tipsLabel->resize(m_tipsLabel->sizeHint().width() + 10,
|
||||
m_tipsLabel->sizeHint().height());
|
||||
@ -121,7 +120,7 @@ void SoundItem::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
|
||||
refershIcon();
|
||||
refreshIcon();
|
||||
}
|
||||
|
||||
void SoundItem::mousePressEvent(QMouseEvent *e)
|
||||
@ -158,7 +157,7 @@ void SoundItem::paintEvent(QPaintEvent *e)
|
||||
painter.drawPixmap(rf.center() - rfp.center() / m_iconPixmap.devicePixelRatioF(), m_iconPixmap);
|
||||
}
|
||||
|
||||
void SoundItem::refershIcon()
|
||||
void SoundItem::refreshIcon()
|
||||
{
|
||||
if (!m_sinkInter)
|
||||
return;
|
||||
@ -204,7 +203,7 @@ void SoundItem::refershIcon()
|
||||
update();
|
||||
}
|
||||
|
||||
void SoundItem::refershTips(const bool force)
|
||||
void SoundItem::refreshTips(const bool force)
|
||||
{
|
||||
if (!force && !m_tipsLabel->isVisible())
|
||||
return;
|
||||
@ -228,7 +227,7 @@ void SoundItem::sinkChanged(DBusSink *sink)
|
||||
{
|
||||
m_sinkInter = sink;
|
||||
|
||||
connect(m_sinkInter, &DBusSink::MuteChanged, this, &SoundItem::refershIcon);
|
||||
connect(m_sinkInter, &DBusSink::VolumeChanged, this, &SoundItem::refershIcon);
|
||||
refershIcon();
|
||||
connect(m_sinkInter, &DBusSink::MuteChanged, this, &SoundItem::refreshIcon);
|
||||
connect(m_sinkInter, &DBusSink::VolumeChanged, this, &SoundItem::refreshIcon);
|
||||
refreshIcon();
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
const QString contextMenu() const;
|
||||
void invokeMenuItem(const QString menuId, const bool checked);
|
||||
|
||||
void refreshIcon();
|
||||
|
||||
signals:
|
||||
void requestContextMenu() const;
|
||||
|
||||
@ -54,8 +56,7 @@ protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private slots:
|
||||
void refershIcon();
|
||||
void refershTips(const bool force = false);
|
||||
void refreshTips(const bool force = false);
|
||||
void sinkChanged(DBusSink *sink);
|
||||
|
||||
private:
|
||||
|
@ -68,37 +68,45 @@ bool SoundPlugin::pluginIsDisable()
|
||||
|
||||
QWidget *SoundPlugin::itemWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
if (itemKey == SOUND_KEY) {
|
||||
return m_soundItem;
|
||||
}
|
||||
|
||||
return m_soundItem;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *SoundPlugin::itemTipsWidget(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
if (itemKey == SOUND_KEY) {
|
||||
return m_soundItem->tipsWidget();
|
||||
}
|
||||
|
||||
return m_soundItem->tipsWidget();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *SoundPlugin::itemPopupApplet(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
if (itemKey == SOUND_KEY) {
|
||||
return m_soundItem->popupApplet();
|
||||
}
|
||||
|
||||
return m_soundItem->popupApplet();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QString SoundPlugin::itemContextMenu(const QString &itemKey)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
if (itemKey == SOUND_KEY) {
|
||||
return m_soundItem->contextMenu();
|
||||
}
|
||||
|
||||
return m_soundItem->contextMenu();
|
||||
return QString();
|
||||
}
|
||||
|
||||
void SoundPlugin::invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked)
|
||||
{
|
||||
Q_UNUSED(itemKey);
|
||||
|
||||
m_soundItem->invokeMenuItem(menuId, checked);
|
||||
if (itemKey == SOUND_KEY) {
|
||||
m_soundItem->invokeMenuItem(menuId, checked);
|
||||
}
|
||||
}
|
||||
|
||||
int SoundPlugin::itemSortKey(const QString &itemKey)
|
||||
@ -114,3 +122,10 @@ void SoundPlugin::setSortKey(const QString &itemKey, const int order)
|
||||
|
||||
m_proxyInter->saveValue(this, key, order);
|
||||
}
|
||||
|
||||
void SoundPlugin::refreshIcon(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == SOUND_KEY) {
|
||||
m_soundItem->refreshIcon();
|
||||
}
|
||||
}
|
||||
|
@ -34,22 +34,20 @@ class SoundPlugin : public QObject, PluginsItemInterface
|
||||
public:
|
||||
explicit SoundPlugin(QObject *parent = 0);
|
||||
|
||||
const QString pluginName() const;
|
||||
const QString pluginDisplayName() const;
|
||||
void init(PluginProxyInterface *proxyInter);
|
||||
void pluginStateSwitched();
|
||||
bool pluginIsAllowDisable() { return true; }
|
||||
bool pluginIsDisable();
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey);
|
||||
QWidget *itemTipsWidget(const QString &itemKey);
|
||||
QWidget *itemPopupApplet(const QString &itemKey);
|
||||
|
||||
const QString itemContextMenu(const QString &itemKey);
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked);
|
||||
|
||||
int itemSortKey(const QString &itemKey);
|
||||
void setSortKey(const QString &itemKey, const int order);
|
||||
const QString pluginName() const Q_DECL_OVERRIDE;
|
||||
const QString pluginDisplayName() const Q_DECL_OVERRIDE;
|
||||
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
|
||||
void pluginStateSwitched() Q_DECL_OVERRIDE;
|
||||
bool pluginIsAllowDisable() Q_DECL_OVERRIDE { return true; }
|
||||
bool pluginIsDisable() Q_DECL_OVERRIDE;
|
||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
const QString itemContextMenu(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) Q_DECL_OVERRIDE;
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
SoundItem *m_soundItem;
|
||||
|
@ -211,6 +211,23 @@ void TrayPlugin::setItemIsInContainer(const QString &itemKey, const bool contain
|
||||
m_proxyInter->saveValue(this, widKey.isEmpty() ? itemKey : widKey, container);
|
||||
}
|
||||
|
||||
void TrayPlugin::refreshIcon(const QString &itemKey)
|
||||
{
|
||||
if (itemKey == FASHION_MODE_ITEM) {
|
||||
for (auto trayWidget : m_trayMap.values()) {
|
||||
if (trayWidget) {
|
||||
trayWidget->updateIcon();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractTrayWidget * const trayWidget = m_trayMap.value(itemKey);
|
||||
if (trayWidget) {
|
||||
trayWidget->updateIcon();
|
||||
}
|
||||
}
|
||||
|
||||
Dock::Position TrayPlugin::dockPosition() const
|
||||
{
|
||||
return position();
|
||||
|
@ -49,16 +49,15 @@ public:
|
||||
void init(PluginProxyInterface *proxyInter) Q_DECL_OVERRIDE;
|
||||
void displayModeChanged(const Dock::DisplayMode mode) Q_DECL_OVERRIDE;
|
||||
void positionChanged(const Dock::Position position) Q_DECL_OVERRIDE;
|
||||
|
||||
QWidget *itemWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemTipsWidget(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
QWidget *itemPopupApplet(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
|
||||
bool itemAllowContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
bool itemIsInContainer(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
int itemSortKey(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
void setSortKey(const QString &itemKey, const int order) Q_DECL_OVERRIDE;
|
||||
void setItemIsInContainer(const QString &itemKey, const bool container) Q_DECL_OVERRIDE;
|
||||
void refreshIcon(const QString &itemKey) Q_DECL_OVERRIDE;
|
||||
|
||||
Dock::Position dockPosition() const;
|
||||
bool traysSortedInFashionMode();
|
||||
|
Loading…
x
Reference in New Issue
Block a user