fix(network): refresh loading icon not align center

https://github.com/linuxdeepin/internal-discussion/issues/1411
This commit is contained in:
justforlxz 2019-04-28 10:10:42 +08:00
parent 319d1eeeca
commit de0fac5409
No known key found for this signature in database
GPG Key ID: 593AFD577C1B1A60
3 changed files with 6 additions and 7 deletions

View File

@ -4,15 +4,14 @@
#include <QScreen>
namespace Utils {
static QPixmap renderSVG(const QString &path, const QSize &size) {
static QPixmap renderSVG(const QString &path, const QSize &size, const qreal devicePixelRatio) {
QImageReader reader;
QPixmap pixmap;
reader.setFileName(path);
if (reader.canRead()) {
const qreal ratio = qApp->devicePixelRatio();
reader.setScaledSize(size * ratio);
reader.setScaledSize(size * devicePixelRatio);
pixmap = QPixmap::fromImage(reader.read());
pixmap.setDevicePixelRatio(ratio);
pixmap.setDevicePixelRatio(devicePixelRatio);
}
else {
pixmap.load(path);

View File

@ -49,7 +49,7 @@ AccessPointWidget::AccessPointWidget()
m_disconnectBtn->setHoverPic(":/wireless/resources/wireless/disconnect_hover.svg");
m_disconnectBtn->setPressPic(":/wireless/resources/wireless/disconnect_press.svg");
m_securityPixmap = Utils::renderSVG(":/wireless/resources/wireless/security.svg", QSize(16, 16));
m_securityPixmap = Utils::renderSVG(":/wireless/resources/wireless/security.svg", QSize(16, 16), devicePixelRatioF());
m_securityIconSize = m_securityPixmap.size();
m_securityLabel->setPixmap(m_securityPixmap);
m_securityLabel->setFixedSize(m_securityIconSize / devicePixelRatioF());
@ -154,7 +154,7 @@ void AccessPointWidget::setStrengthIcon(const int strength)
else
type = QString::number(strength / 10 & ~0x1) + "0";
iconPix = Utils::renderSVG(QString(":/wireless/resources/wireless/wireless-%1-symbolic.svg").arg(type), s);
iconPix = Utils::renderSVG(QString(":/wireless/resources/wireless/wireless-%1-symbolic.svg").arg(type), s, devicePixelRatioF());
m_strengthLabel->setPixmap(iconPix);
}

View File

@ -161,7 +161,7 @@ void SoundApplet::onVolumeChanged()
volumeString = "low";
const QString &iconName = QString("://audio-volume-%1-symbolic.svg").arg(volumeString);
QPixmap pix = Utils::renderSVG(iconName, QSize(24, 24));
QPixmap pix = Utils::renderSVG(iconName, QSize(24, 24), devicePixelRatioF());
m_volumeBtn->setPixmap(pix);
}