From c240295a7469cd5b86fcfec33a8bd8d5b71186b3 Mon Sep 17 00:00:00 2001 From: John Preston <johnprestonmail@gmail.com> Date: Fri, 5 Feb 2016 22:53:01 +0300 Subject: [PATCH] retina settings fixed for os x tray icon --- Telegram/SourceFiles/application.cpp | 45 +++++++++++++++++----------- Telegram/SourceFiles/application.h | 5 +++- Telegram/SourceFiles/window.cpp | 2 +- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index 051d171f8..f5d565abd 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -281,7 +281,7 @@ void Application::singleInstanceChecked() { } else if (status == SignalHandlers::LastCrashed) { new LastCrashedWindow(); } else { - new AppClass(); + Sandboxer::startSandbox(); } } } @@ -636,13 +636,38 @@ namespace Sandboxer { } } +#endif + void connect(const char *signal, QObject *object, const char *method) { if (Application *a = application()) { a->connect(a, signal, object, method); } } -#endif + void startSandbox() { + t_assert(application() != 0); + + float64 dpi = Application::primaryScreen()->logicalDotsPerInch(); + if (dpi <= 108) { // 0-96-108 + cSetScreenScale(dbisOne); + } else if (dpi <= 132) { // 108-120-132 + cSetScreenScale(dbisOneAndQuarter); + } else if (dpi <= 168) { // 132-144-168 + cSetScreenScale(dbisOneAndHalf); + } else { // 168-192-inf + cSetScreenScale(dbisTwo); + } + + if (application()->devicePixelRatio() > 1) { + cSetRetina(true); + cSetRetinaFactor(application()->devicePixelRatio()); + cSetIntRetinaFactor(int32(cRetinaFactor())); + cSetConfigScale(dbisOne); + cSetRealScale(dbisOne); + } + + new AppClass(); + } } @@ -667,21 +692,7 @@ AppClass::AppClass() : QObject() application()->installEventFilter(new EventFilterForKeys(this)); - float64 dpi = QApplication::primaryScreen()->logicalDotsPerInch(); - if (dpi <= 108) { // 0-96-108 - cSetScreenScale(dbisOne); - } else if (dpi <= 132) { // 108-120-132 - cSetScreenScale(dbisOneAndQuarter); - } else if (dpi <= 168) { // 132-144-168 - cSetScreenScale(dbisOneAndHalf); - } else { // 168-192-inf - cSetScreenScale(dbisTwo); - } - - if (application()->devicePixelRatio() > 1) { - cSetRetina(true); - cSetRetinaFactor(application()->devicePixelRatio()); - cSetIntRetinaFactor(int32(cRetinaFactor())); + if (cRetina()) { cSetConfigScale(dbisOne); cSetRealScale(dbisOne); } diff --git a/Telegram/SourceFiles/application.h b/Telegram/SourceFiles/application.h index 26b443955..d1a0f857c 100644 --- a/Telegram/SourceFiles/application.h +++ b/Telegram/SourceFiles/application.h @@ -128,10 +128,13 @@ namespace Sandboxer { void updateProgress(qint64 ready, qint64 total); void updateFailed(); void updateReady(); - void connect(const char *signal, QObject *object, const char *method); #endif + void connect(const char *signal, QObject *object, const char *method); + + void startSandbox(); + } class MainWidget; diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index 43c2b25a8..9c5272553 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -2692,7 +2692,7 @@ void LastCrashedWindow::onContinue() { if (SignalHandlers::restart() == SignalHandlers::CantOpen) { new NotStartedWindow(); } else { - new AppClass(); + Sandboxer::startSandbox(); } close(); }