mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 14:57:52 +00:00
Merge pull request #8868 from Chocobo1/macos
Fix GUI scaling factor on macOS
This commit is contained in:
commit
a1a6a7ef56
@ -55,7 +55,7 @@ public:
|
||||
lb_name->setText("<b><h2>qBittorrent " QBT_VERSION " (32-bit)</h2></b>");
|
||||
#endif
|
||||
|
||||
logo->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/qbittorrent32.png", this));
|
||||
logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));
|
||||
|
||||
// About
|
||||
QString aboutText = QString(
|
||||
|
@ -160,11 +160,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
// Setting icons
|
||||
#ifndef Q_OS_MAC
|
||||
#ifdef Q_OS_UNIX
|
||||
if (Preferences::instance()->useSystemIconTheme())
|
||||
setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(":/icons/skin/qbittorrent32.png")));
|
||||
else
|
||||
const QIcon appLogo = Preferences::instance()->useSystemIconTheme()
|
||||
? QIcon::fromTheme("qbittorrent", QIcon(":/icons/skin/qbittorrent-tray.svg"))
|
||||
: QIcon(":/icons/skin/qbittorrent-tray.svg");
|
||||
#else
|
||||
const QIcon appLogo(":/icons/skin/qbittorrent-tray.svg");
|
||||
#endif // Q_OS_UNIX
|
||||
setWindowIcon(QIcon(":/icons/skin/qbittorrent32.png"));
|
||||
setWindowIcon(appLogo);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
#if (defined(Q_OS_UNIX))
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QPixmapCache>
|
||||
#include <QScreen>
|
||||
#include <QStyle>
|
||||
#include <QWidget>
|
||||
@ -45,16 +46,21 @@ void Utils::Gui::resize(QWidget *widget, const QSize &newSize)
|
||||
|
||||
qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
|
||||
{
|
||||
if (!widget)
|
||||
return 1;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
const int screen = qApp->desktop()->screenNumber(widget);
|
||||
return (QApplication::screens()[screen]->logicalDotsPerInch() / 96);
|
||||
#elif defined(Q_OS_MAC)
|
||||
return 1;
|
||||
#else
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
return widget->devicePixelRatioF();
|
||||
#else
|
||||
return widget->devicePixelRatio();
|
||||
#endif
|
||||
#endif // Q_OS_WIN
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, const int height)
|
||||
@ -64,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
|
||||
|
@ -49,6 +49,7 @@ namespace Utils
|
||||
}
|
||||
|
||||
QPixmap scaledPixmap(const QString &path, const QWidget *widget, const int height = 0);
|
||||
QPixmap scaledPixmapSvg(const QString &path, const QWidget *widget, const int baseHeight);
|
||||
QSize smallIconSize(const QWidget *widget = nullptr);
|
||||
QSize mediumIconSize(const QWidget *widget = nullptr);
|
||||
QSize largeIconSize(const QWidget *widget = nullptr);
|
||||
|
@ -361,7 +361,6 @@
|
||||
<file>icons/skin/qbittorrent-tray.svg</file>
|
||||
<file>icons/skin/qbittorrent-tray-dark.svg</file>
|
||||
<file>icons/skin/qbittorrent-tray-light.svg</file>
|
||||
<file>icons/skin/qbittorrent16.png</file>
|
||||
<file>icons/skin/qbittorrent32.png</file>
|
||||
<file>icons/skin/queued.png</file>
|
||||
<file>icons/skin/ratio.png</file>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 986 B |
@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=10" />
|
||||
<title>qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]</title>
|
||||
<link rel="icon" type="image/png" href="images/skin/qbittorrent16.png" />
|
||||
<link rel="icon" type="image/png" href="images/skin/qbittorrent32.png" />
|
||||
<link rel="stylesheet" href="css/dynamicTable.css" type="text/css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css" />
|
||||
<!--<link rel="stylesheet" type="text/css" href="css/Content.css" />-->
|
||||
|
@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>qBittorrent QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]</title>
|
||||
<link rel="icon" type="image/png" href="images/skin/qbittorrent16.png" />
|
||||
<link rel="icon" type="image/png" href="images/skin/qbittorrent32.png" />
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css" />
|
||||
<script src="scripts/lib/mootools-1.2-core-yc.js"></script>
|
||||
<script>
|
||||
|
Loading…
Reference in New Issue
Block a user