From 4d51ad339f952ddc51d2950440626eceb1350c8c Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Sat, 18 Oct 2014 15:50:22 +0200 Subject: [PATCH] #9130 Text in main work area isn't rendered with high resolution Load images with search mode check_hidpi to read images with double size when present. --- src/frontends/qt4/GuiApplication.cpp | 13 +++++++------ src/frontends/qt4/GuiApplication.h | 12 +++++++++++- src/frontends/qt4/GuiToolbar.cpp | 5 +++-- src/frontends/qt4/GuiView.cpp | 7 ++++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 2697abeb61..5c56b0a2d0 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -505,13 +505,14 @@ QString iconName(FuncRequest const & f, bool unknown) QStringList imagedirs; imagedirs << "images/" << "images/ipa/"; - for (int i = 0; i < imagedirs.size(); ++i) { + search_mode mode = theGuiApp()->imageSearchMode(); + for (int i = 0; i < imagedirs.size(); ++i) { QString imagedir = imagedirs.at(i) + path; - FileName fname = imageLibFileSearch(imagedir, name1, "png"); + FileName fname = imageLibFileSearch(imagedir, name1, "png", mode); if (fname.exists()) return toqstr(fname.absFileName()); - fname = imageLibFileSearch(imagedir, name2, "png"); + fname = imageLibFileSearch(imagedir, name2, "png", mode); if (fname.exists()) return toqstr(fname.absFileName()); } @@ -540,7 +541,7 @@ QString iconName(FuncRequest const & f, bool unknown) if (unknown) { QString imagedir = "images/"; - FileName fname = imageLibFileSearch(imagedir, "unknown", "png"); + FileName fname = imageLibFileSearch(imagedir, "unknown", "png", mode); if (fname.exists()) return toqstr(fname.absFileName()); return QString(":/images/unknown.png"); @@ -553,7 +554,7 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex { QPixmap pixmap; QString imagedir = path; - FileName fname = imageLibFileSearch(imagedir, name, ext); + FileName fname = imageLibFileSearch(imagedir, name, ext, theGuiApp()->imageSearchMode()); QString path1 = toqstr(fname.absFileName()); QString path2 = ":/" + path + name + "." + ext; @@ -1040,7 +1041,7 @@ GuiApplication * theGuiApp() double GuiApplication::pixelRatio() const { -#if QT_VERSION > 0x050000 +#if QT_VERSION >= 0x050000 return devicePixelRatio(); #else return 1.0; diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 410ccc4426..58a46d67f8 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -14,6 +14,7 @@ #define GUIAPPLICATION_H #include "frontends/Application.h" +#include "support/filetools.h" #include #include @@ -142,7 +143,16 @@ public: /// Current ratio between physical pixels and device-independent pixels double pixelRatio() const; - + + /// How to load image files + support::search_mode imageSearchMode() const { +#if QT_VERSION >= 0x050000 + return support::check_hidpi; +#else + return support::must_exist; +#endif + } + void processKeySym(KeySymbol const & key, KeyModifier state); /// return the status bar state string docstring viewStatusMessage(); diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index a80accdddc..6b5170d481 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -194,9 +194,10 @@ MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const st QString const name = toqstr(tbitem_.name_); QStringList imagedirs; imagedirs << "images/math/" << "images/"; - for (int i = 0; i < imagedirs.size(); ++i) { + for (int i = 0; i < imagedirs.size(); ++i) { QString imagedir = imagedirs.at(i); - FileName const fname = imageLibFileSearch(imagedir, name, "png"); + FileName const fname = imageLibFileSearch(imagedir, name, "png", + theGuiApp()->imageSearchMode()); if (fname.exists()) { setIcon(QIcon(getPixmap(imagedir, name, "png"))); break; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 8c5080763f..09a329938c 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -173,7 +173,7 @@ public: void paintEvent(QPaintEvent *) { QRectF r = splash_.rect(); -#if QT_VERSION > 0x050000 +#if QT_VERSION >= 0x050000 r.setWidth(r.width() / splash_.devicePixelRatio()); r.setHeight(r.height() / splash_.devicePixelRatio()); #endif @@ -477,7 +477,8 @@ GuiView::GuiView(int id) // add busy indicator to statusbar QLabel * busylabel = new QLabel(statusBar()); statusBar()->addPermanentWidget(busylabel); - QString fn = toqstr(lyx::libFileSearch("images", "busy.gif").absFileName()); + search_mode mode = theGuiApp()->imageSearchMode(); + QString fn = toqstr(lyx::libFileSearch("images", "busy", "gif", mode).absFileName()); QMovie * busyanim = new QMovie(fn, QByteArray(), busylabel); busylabel->setMovie(busyanim); busyanim->start(); @@ -1211,7 +1212,7 @@ void GuiView::setBusy(bool busy) double GuiView::pixelRatio() const { -#if QT_VERSION > 0x050000 +#if QT_VERSION >= 0x050000 return devicePixelRatio(); #else return 1.0;