Skip to content

Commit

Permalink
fix: wired tray icon in hihdpi
Browse files Browse the repository at this point in the history
linuxdeepin/internal-discussion#594

Change-Id: I107b111614b2a79f57aa2059e660f220d2b185b7
  • Loading branch information
listenerri committed Dec 10, 2018
1 parent 5b5d55d commit a9998b6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/network/item/wireditem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ void WiredItem::reloadIcon()

// const Dock::DisplayMode displayMode = qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
const Dock::DisplayMode displayMode = Dock::DisplayMode::Efficient;
const auto ratio = qApp->devicePixelRatio();
const int iconSize = displayMode == Dock::Efficient ? 16 : std::min(width(), height()) * 0.8;

QString iconName = "network-";
NetworkDevice::DeviceStatus devState = m_device->status();
Expand All @@ -138,7 +140,9 @@ void WiredItem::reloadIcon()
m_delayTimer->start();
const quint64 index = QDateTime::currentMSecsSinceEpoch() / 200;
const int num = (index % 5) + 1;
m_icon = QPixmap(QString(":/wired/resources/wired/network-wired-symbolic-connecting%1.svg").arg(num));
m_icon = QIcon(QString(":/wired/resources/wired/network-wired-symbolic-connecting%1.svg").arg(num))
.pixmap(iconSize * ratio, iconSize * ratio);
m_icon.setDevicePixelRatio(ratio);
update();
return;
}
Expand Down Expand Up @@ -170,9 +174,7 @@ void WiredItem::reloadIcon()
if (displayMode == Dock::Efficient)
iconName.append("-symbolic");

const auto ratio = qApp->devicePixelRatio();
const int size = displayMode == Dock::Efficient ? 16 : std::min(width(), height()) * 0.8;
m_icon = QIcon::fromTheme(iconName).pixmap(size * ratio, size * ratio);
m_icon = QIcon::fromTheme(iconName).pixmap(iconSize * ratio, iconSize * ratio);
m_icon.setDevicePixelRatio(ratio);
update();
}
Expand Down

0 comments on commit a9998b6

Please sign in to comment.