mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat():add sound and wired icon
This commit is contained in:
parent
e840ff73d9
commit
0b86ba1c52
@ -58,6 +58,8 @@ WiredItem::WiredItem(WiredDevice *device)
|
||||
|
||||
QTimer::singleShot(0, this, &WiredItem::refreshTips);
|
||||
QTimer::singleShot(0, this, &WiredItem::refreshIcon);
|
||||
|
||||
m_defaultIcon = QIcon::fromTheme(":/wired/resources/wired/network-wired-symbolic-connecting1.svg");
|
||||
}
|
||||
|
||||
QWidget *WiredItem::itemTips()
|
||||
@ -147,7 +149,8 @@ void WiredItem::reloadIcon()
|
||||
m_delayTimer->start();
|
||||
const quint64 index = QDateTime::currentMSecsSinceEpoch() / 200;
|
||||
const int num = (index % 5) + 1;
|
||||
m_icon = QIcon(QString(":/wired/resources/wired/network-wired-symbolic-connecting%1.svg").arg(num))
|
||||
|
||||
m_icon = QIcon::fromTheme(QString(":/wired/resources/wired/network-wired-symbolic-connecting%1.svg").arg(num), m_defaultIcon)
|
||||
.pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_icon.setDevicePixelRatio(ratio);
|
||||
update();
|
||||
@ -185,7 +188,7 @@ void WiredItem::reloadIcon()
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
|
||||
iconName.append(PLUGIN_MIN_ICON_NAME);
|
||||
|
||||
m_icon = QIcon::fromTheme(iconName).pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_icon = QIcon::fromTheme(iconName, m_defaultIcon).pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_icon.setDevicePixelRatio(ratio);
|
||||
update();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include <WiredDevice>
|
||||
#include <QIcon>
|
||||
|
||||
class TipsWidget;
|
||||
class WiredItem : public DeviceItem
|
||||
@ -56,6 +57,7 @@ private:
|
||||
|
||||
TipsWidget *m_itemTips;
|
||||
QTimer *m_delayTimer;
|
||||
QIcon m_defaultIcon;
|
||||
};
|
||||
|
||||
#endif // WIREDITEM_H
|
||||
|
@ -50,12 +50,13 @@ 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, static_cast<void (SoundApplet::*)(DBusSink *) const>(&SoundApplet::defaultSinkChanged), this, &SoundItem::sinkChanged);
|
||||
connect(m_applet, &SoundApplet::volumeChanged, this, &SoundItem::refreshTips, Qt::QueuedConnection);
|
||||
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ] {
|
||||
refreshIcon();
|
||||
});
|
||||
m_icon = QIcon::fromTheme(":/audio-volume-muted-symbolic.svg");
|
||||
}
|
||||
|
||||
QWidget *SoundItem::tipsWidget()
|
||||
@ -109,12 +110,12 @@ void SoundItem::invokeMenuItem(const QString menuId, const bool checked)
|
||||
m_sinkInter->SetMuteQueued(!m_sinkInter->mute());
|
||||
else if (menuId == SETTINGS)
|
||||
DDBusSender()
|
||||
.service("com.deepin.dde.ControlCenter")
|
||||
.interface("com.deepin.dde.ControlCenter")
|
||||
.path("/com/deepin/dde/ControlCenter")
|
||||
.method(QString("ShowModule"))
|
||||
.arg(QString("sound"))
|
||||
.call();
|
||||
.service("com.deepin.dde.ControlCenter")
|
||||
.interface("com.deepin.dde.ControlCenter")
|
||||
.path("/com/deepin/dde/ControlCenter")
|
||||
.method(QString("ShowModule"))
|
||||
.arg(QString("sound"))
|
||||
.call();
|
||||
}
|
||||
|
||||
QSize SoundItem::sizeHint() const
|
||||
@ -158,8 +159,7 @@ void SoundItem::refreshIcon()
|
||||
const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient;
|
||||
|
||||
QString iconString;
|
||||
if (displayMode == Dock::Fashion)
|
||||
{
|
||||
if (displayMode == Dock::Fashion) {
|
||||
QString volumeString;
|
||||
if (volmue >= 1000)
|
||||
volumeString = "100";
|
||||
@ -174,9 +174,9 @@ void SoundItem::refreshIcon()
|
||||
QString volumeString;
|
||||
if (mute)
|
||||
volumeString = "muted";
|
||||
else if (volmue / 1000.0f >= double(2)/3)
|
||||
else if (volmue / 1000.0f >= double(2) / 3)
|
||||
volumeString = "high";
|
||||
else if (volmue / 1000.0f >= double(1)/3)
|
||||
else if (volmue / 1000.0f >= double(1) / 3)
|
||||
volumeString = "medium";
|
||||
else
|
||||
volumeString = "low";
|
||||
@ -189,7 +189,7 @@ void SoundItem::refreshIcon()
|
||||
if (height() <= PLUGIN_BACKGROUND_MIN_SIZE && DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType)
|
||||
iconString.append(PLUGIN_MIN_ICON_NAME);
|
||||
|
||||
const QIcon icon = QIcon::fromTheme(iconString);
|
||||
const QIcon icon = QIcon::fromTheme(iconString, m_icon);
|
||||
m_iconPixmap = icon.pixmap(iconSize * ratio, iconSize * ratio);
|
||||
m_iconPixmap.setDevicePixelRatio(ratio);
|
||||
|
||||
@ -201,7 +201,7 @@ void SoundItem::refreshTips(const bool force)
|
||||
if (!force && !m_tipsLabel->isVisible())
|
||||
return;
|
||||
|
||||
if(!m_sinkInter)
|
||||
if (!m_sinkInter)
|
||||
return;
|
||||
|
||||
QString value;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "dbus/dbussink.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
#define SOUND_KEY "sound-item-key"
|
||||
|
||||
@ -62,6 +63,7 @@ private:
|
||||
TipsWidget *m_tipsLabel;
|
||||
SoundApplet *m_applet;
|
||||
DBusSink *m_sinkInter;
|
||||
QIcon m_icon;
|
||||
QPixmap m_iconPixmap;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user