From 2e15c4050878f148359cffc2ad2fee76893ee5ab Mon Sep 17 00:00:00 2001 From: sonichy Date: Wed, 9 Jan 2019 11:32:01 +0800 Subject: [PATCH] fix icon oblate, shrink icon to have spacing --- weatherplugin.cpp | 2 +- weatherwidget.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/weatherplugin.cpp b/weatherplugin.cpp index a118a83..cd52e06 100644 --- a/weatherplugin.cpp +++ b/weatherplugin.cpp @@ -166,7 +166,7 @@ void WeatherPlugin::invokedMenuItem(const QString &itemKey, const QString &menuI void WeatherPlugin::MBAbout() { - QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.3", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: sonichy@163.com\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5"); + QMessageBox aboutMB(QMessageBox::NoIcon, "HTYWeather 5.3.1", "About\n\nDeepin Linux Dock Weather Plugin.\nAuthor: 黄颖\nE-mail: sonichy@163.com\nSource: https://github.com/sonichy/WEATHER_DDE_DOCK\nAPI: https://openweathermap.org/forecast5"); aboutMB.setIconPixmap(QPixmap(":/icon/Default/01d.png")); aboutMB.exec(); } diff --git a/weatherwidget.cpp b/weatherwidget.cpp index 3047ca8..fc3ec22 100644 --- a/weatherwidget.cpp +++ b/weatherwidget.cpp @@ -2,8 +2,6 @@ #include "weatherwidget.h" #include #include -#include -//#include #include #define PLUGIN_STATE_KEY "enable" @@ -56,11 +54,13 @@ void WeatherWidget::paintEvent(QPaintEvent *e) QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::SmoothPixmapTransform, true); - painter.setPen(Qt::white); if (displayMode == Dock::Efficient) { + painter.setPen(Qt::white); painter.drawText(rect(), Qt::AlignCenter, sw + "\n" + temp); } else { - painter.drawPixmap(rect(), pixmap); + int w = qMin(width(), height()); + pixmap = pixmap.scaled(w*0.8, w*0.8, Qt::KeepAspectRatio, Qt::SmoothTransformation); + painter.drawPixmap(rect().center() - pixmap.rect().center(), pixmap); } } @@ -77,4 +77,4 @@ void WeatherWidget::mousePressEvent(QMouseEvent *e) } QWidget::mousePressEvent(e); -} +} \ No newline at end of file