mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
refactor: delete deprecated function calls
Change-Id: I749455a6bc5b387142789e989368e743f6e52a5e
This commit is contained in:
parent
31bac3caf7
commit
69a9ccc487
Notes:
gerrit
2018-08-24 14:59:07 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: 张丁元 <lxz@ilxz.me> Submitted-by: 张丁元 <lxz@ilxz.me> Submitted-at: Fri, 24 Aug 2018 14:59:07 +0800 Reviewed-on: https://cr.deepin.io/37939 Project: dde/dde-dock Branch: refs/heads/master
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,3 +20,4 @@ CMakeLists.txt.user*
|
|||||||
|
|
||||||
# binary file
|
# binary file
|
||||||
dde-dock
|
dde-dock
|
||||||
|
.vscode
|
||||||
|
22
frame/util/utils.h
Normal file
22
frame/util/utils.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <QPixmap>
|
||||||
|
#include <QImageReader>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
static QPixmap renderSVG(const QString &path, const QSize &size) {
|
||||||
|
QImageReader reader;
|
||||||
|
QPixmap pixmap;
|
||||||
|
reader.setFileName(path);
|
||||||
|
if (reader.canRead()) {
|
||||||
|
const qreal ratio = qApp->devicePixelRatio();
|
||||||
|
reader.setScaledSize(size * ratio);
|
||||||
|
pixmap = QPixmap::fromImage(reader.read());
|
||||||
|
pixmap.setDevicePixelRatio(ratio);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pixmap.load(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ set(PLUGIN_NAME "network")
|
|||||||
project(${PLUGIN_NAME})
|
project(${PLUGIN_NAME})
|
||||||
|
|
||||||
# Sources files
|
# Sources files
|
||||||
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp")
|
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp" "../../frame/util/utils.h")
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
|
|
||||||
#include "accesspointwidget.h"
|
#include "accesspointwidget.h"
|
||||||
#include "horizontalseperator.h"
|
#include "horizontalseperator.h"
|
||||||
|
#include "../../frame/util/utils.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <dimagebutton.h>
|
||||||
#include <DSvgRenderer>
|
|
||||||
|
|
||||||
using namespace dde::network;
|
using namespace dde::network;
|
||||||
|
|
||||||
@ -40,7 +40,6 @@ AccessPointWidget::AccessPointWidget()
|
|||||||
m_securityIcon(new QLabel),
|
m_securityIcon(new QLabel),
|
||||||
m_strengthIcon(new QLabel)
|
m_strengthIcon(new QLabel)
|
||||||
{
|
{
|
||||||
const auto ratio = devicePixelRatioF();
|
|
||||||
m_ssidBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
m_ssidBtn->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
m_ssidBtn->setObjectName("Ssid");
|
m_ssidBtn->setObjectName("Ssid");
|
||||||
@ -50,8 +49,7 @@ AccessPointWidget::AccessPointWidget()
|
|||||||
m_disconnectBtn->setHoverPic(":/wireless/resources/wireless/disconnect_hover.svg");
|
m_disconnectBtn->setHoverPic(":/wireless/resources/wireless/disconnect_hover.svg");
|
||||||
m_disconnectBtn->setPressPic(":/wireless/resources/wireless/disconnect_press.svg");
|
m_disconnectBtn->setPressPic(":/wireless/resources/wireless/disconnect_press.svg");
|
||||||
|
|
||||||
QPixmap iconPix = DSvgRenderer::render(":/wireless/resources/wireless/security.svg", QSize(16, 16) * ratio);
|
QPixmap iconPix = Utils::renderSVG(":/wireless/resources/wireless/security.svg", QSize(16, 16));
|
||||||
iconPix.setDevicePixelRatio(ratio);
|
|
||||||
m_securityIconSize = iconPix.size();
|
m_securityIconSize = iconPix.size();
|
||||||
m_securityIcon->setPixmap(iconPix);
|
m_securityIcon->setPixmap(iconPix);
|
||||||
|
|
||||||
@ -146,8 +144,7 @@ void AccessPointWidget::leaveEvent(QEvent *e)
|
|||||||
void AccessPointWidget::setStrengthIcon(const int strength)
|
void AccessPointWidget::setStrengthIcon(const int strength)
|
||||||
{
|
{
|
||||||
QPixmap iconPix;
|
QPixmap iconPix;
|
||||||
const auto ratio = devicePixelRatioF();
|
const QSize s = QSize(16, 16);
|
||||||
const QSize s = QSize(16, 16) * ratio;
|
|
||||||
|
|
||||||
QString type;
|
QString type;
|
||||||
if (strength == 100)
|
if (strength == 100)
|
||||||
@ -157,8 +154,7 @@ void AccessPointWidget::setStrengthIcon(const int strength)
|
|||||||
else
|
else
|
||||||
type = QString::number(strength / 10 & ~0x1) + "0";
|
type = QString::number(strength / 10 & ~0x1) + "0";
|
||||||
|
|
||||||
iconPix = DSvgRenderer::render(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);
|
||||||
iconPix.setDevicePixelRatio(ratio);
|
|
||||||
|
|
||||||
m_strengthIcon->setPixmap(iconPix);
|
m_strengthIcon->setPixmap(iconPix);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ set(PLUGIN_NAME "sound")
|
|||||||
project(${PLUGIN_NAME})
|
project(${PLUGIN_NAME})
|
||||||
|
|
||||||
# Sources files
|
# Sources files
|
||||||
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp")
|
file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp" "../../frame/util/utils.h")
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
@ -23,12 +23,11 @@
|
|||||||
#include "sinkinputwidget.h"
|
#include "sinkinputwidget.h"
|
||||||
#include "componments/horizontalseparator.h"
|
#include "componments/horizontalseparator.h"
|
||||||
#include "../widgets/tipswidget.h"
|
#include "../widgets/tipswidget.h"
|
||||||
|
#include "../../frame/util/utils.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
#include <DSvgRenderer>
|
|
||||||
|
|
||||||
#define WIDTH 200
|
#define WIDTH 200
|
||||||
#define MAX_HEIGHT 200
|
#define MAX_HEIGHT 200
|
||||||
#define ICON_SIZE 24
|
#define ICON_SIZE 24
|
||||||
@ -162,9 +161,7 @@ void SoundApplet::onVolumeChanged()
|
|||||||
volumeString = "low";
|
volumeString = "low";
|
||||||
|
|
||||||
const QString &iconName = QString(":/audio-volume-%1-symbolic.svg").arg(volumeString);
|
const QString &iconName = QString(":/audio-volume-%1-symbolic.svg").arg(volumeString);
|
||||||
const auto ratio = devicePixelRatioF();
|
QPixmap pix = Utils::renderSVG(iconName, QSize(24, 24));
|
||||||
QPixmap pix = DSvgRenderer::render(iconName, QSize(24, 24) * ratio);
|
|
||||||
pix.setDevicePixelRatio(ratio);
|
|
||||||
|
|
||||||
m_volumeBtn->setPixmap(pix);
|
m_volumeBtn->setPixmap(pix);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user