From b3c73b78682a4e1d1a86dbd8a15973ac1569b840 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 16 Mar 2017 21:58:43 +0800 Subject: [PATCH 1/4] Refactor --- src/app/application.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 204550b5f..52108b368 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -133,14 +133,18 @@ Application::Application(const QString &id, int &argc, char **argv) QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); } #endif + + setApplicationName("qBittorrent"); initializeTranslation(); -#ifndef DISABLE_GUI + +#if !defined(DISABLE_GUI) setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support setQuitOnLastWindowClosed(false); -#ifdef Q_OS_WIN +#endif + +#if defined(Q_OS_WIN) && !defined(DISABLE_GUI) connect(this, SIGNAL(commitDataRequest(QSessionManager &)), this, SLOT(shutdownCleanup(QSessionManager &)), Qt::DirectConnection); -#endif // Q_OS_WIN -#endif // DISABLE_GUI +#endif connect(this, SIGNAL(messageReceived(const QString &)), SLOT(processMessage(const QString &))); connect(this, SIGNAL(aboutToQuit()), SLOT(cleanup())); From a1cad86bbfb6f029c403fd126b0f1aad0cb70e34 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 16 Mar 2017 22:04:39 +0800 Subject: [PATCH 2/4] Remove workaround Upstream confirmed bug fixed in Qt 5.2 --- src/app/application.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 52108b368..3a3acabdc 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -126,14 +126,6 @@ Application::Application(const QString &id, int &argc, char **argv) Preferences::instance()->setWebUiPort(m_commandLineArgs.webUiPort); } -#if defined(Q_OS_MACX) && !defined(DISABLE_GUI) - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) { - // fix Mac OS X 10.9 (mavericks) font issue - // https://bugreports.qt-project.org/browse/QTBUG-32789 - QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); - } -#endif - setApplicationName("qBittorrent"); initializeTranslation(); From 893ce32f1d99243d775a3f8e190681bbf7f1699e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 1 May 2017 00:45:27 +0800 Subject: [PATCH 3/4] Remove curly braces --- src/app/application.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 3a3acabdc..4dc8b61dd 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -122,9 +122,8 @@ Application::Application(const QString &id, int &argc, char **argv) SettingsStorage::initInstance(); Preferences::initInstance(); - if (m_commandLineArgs.webUiPort > 0) { // it will be -1 when user did not set any value + if (m_commandLineArgs.webUiPort > 0) // it will be -1 when user did not set any value Preferences::instance()->setWebUiPort(m_commandLineArgs.webUiPort); - } setApplicationName("qBittorrent"); initializeTranslation(); From 6bcb07649e5d04d8dc176031808ba05abc7a1811 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 20 Mar 2017 14:11:49 +0800 Subject: [PATCH 4/4] Setup DPI at startup --- src/app/main.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 7defc5293..c48ea9d59 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -41,6 +41,7 @@ #include #include #include + #ifdef QBT_STATIC_QT #include Q_IMPORT_PLUGIN(QICOPlugin) @@ -89,13 +90,18 @@ const char *sysSigName[] = { }; #endif -#ifndef DISABLE_GUI -void showSplashScreen(); -#endif void displayVersion(); bool userAgreesWithLegalNotice(); void displayBadArgMessage(const QString &message); +#if !defined(DISABLE_GUI) +void showSplashScreen(); + +#if defined(Q_OS_UNIX) +void setupDpi(); +#endif // Q_OS_UNIX +#endif // DISABLE_GUI + // Main int main(int argc, char *argv[]) { @@ -108,15 +114,21 @@ int main(int argc, char *argv[]) macMigratePlists(); #endif +#if !defined(DISABLE_GUI) && defined(Q_OS_UNIX) + setupDpi(); +#endif + try { // Create Application QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString(); QScopedPointer app(new Application(appId, argc, argv)); + #ifndef DISABLE_GUI // after the application object creation because we need a profile to be set already // for the migration migrateRSS(); #endif + const QBtCommandLineParameters ¶ms = app->commandLineArgs(); if (!params.unknownParameter.isEmpty()) { @@ -280,7 +292,7 @@ void sigAbnormalHandler(int signum) } #endif // defined(Q_OS_UNIX) || defined(STACKTRACE_WIN) -#ifndef DISABLE_GUI +#if !defined(DISABLE_GUI) void showSplashScreen() { QPixmap splash_img(":/icons/skin/splash.png"); @@ -294,7 +306,15 @@ void showSplashScreen() QTimer::singleShot(1500, splash, SLOT(deleteLater())); qApp->processEvents(); } -#endif + +#if defined(Q_OS_UNIX) +void setupDpi() +{ + if (qgetenv("QT_AUTO_SCREEN_SCALE_FACTOR").isEmpty()) + qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); +} +#endif // Q_OS_UNIX +#endif // DISABLE_GUI void displayVersion() {