Replace raster qbt logo with vector version

Add helper function for svg icons.
This commit is contained in:
Chocobo1 2018-05-08 21:30:12 +08:00
parent f934042a98
commit 4d04af4043
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
4 changed files with 23 additions and 5 deletions

View file

@ -30,6 +30,7 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QPixmapCache>
#include <QScreen>
#include <QStyle>
#include <QWidget>
@ -69,6 +70,20 @@ QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, con
return pixmap.scaledToHeight(scaledHeight, Qt::SmoothTransformation);
}
QPixmap Utils::Gui::scaledPixmapSvg(const QString &path, const QWidget *widget, const int baseHeight)
{
const int scaledHeight = baseHeight * Utils::Gui::screenScalingFactor(widget);
const QString normalizedKey = path + "@" + QString::number(scaledHeight);
QPixmap pm;
QPixmapCache cache;
if (!cache.find(normalizedKey, &pm)) {
pm = QIcon(path).pixmap(scaledHeight);
cache.insert(normalizedKey, pm);
}
return pm;
}
QSize Utils::Gui::smallIconSize(const QWidget *widget)
{
// Get DPI scaled icon size (device-dependent), see QT source