mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
#9130 Text in main work area isn't rendered with high resolution
Add search mode check_hidpi to ease the lookup for images with double size to use for displays with high resolution.
This commit is contained in:
parent
9135dcee07
commit
e7163a0999
@ -27,7 +27,6 @@
|
||||
|
||||
#include "support/convert.h"
|
||||
#include "support/debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/foreach.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
@ -60,17 +59,17 @@ using namespace lyx::support;
|
||||
namespace lyx {
|
||||
|
||||
FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext)
|
||||
QString const & ext, search_mode mode)
|
||||
{
|
||||
return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext));
|
||||
return support::libFileSearch(fromqstr(dir), fromqstr(name), fromqstr(ext), mode);
|
||||
}
|
||||
|
||||
|
||||
FileName imageLibFileSearch(QString & dir, QString const & name,
|
||||
QString const & ext)
|
||||
QString const & ext, search_mode mode)
|
||||
{
|
||||
string tmp = fromqstr(dir);
|
||||
FileName fn = support::imageLibFileSearch(tmp, fromqstr(name), fromqstr(ext));
|
||||
FileName fn = support::imageLibFileSearch(tmp, fromqstr(name), fromqstr(ext), mode);
|
||||
dir = toqstr(tmp);
|
||||
return fn;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "Length.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
#include "support/filetools.h"
|
||||
#include "qt_i18n.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
@ -91,11 +92,13 @@ QString const qt_(QString const & qstr);
|
||||
|
||||
///
|
||||
support::FileName libFileSearch(QString const & dir, QString const & name,
|
||||
QString const & ext = QString());
|
||||
QString const & ext = QString(),
|
||||
support::search_mode mode = support::must_exist);
|
||||
|
||||
///
|
||||
support::FileName imageLibFileSearch(QString & dir, QString const & name,
|
||||
QString const & ext = QString());
|
||||
QString const & ext = QString(),
|
||||
support::search_mode mode = support::must_exist);
|
||||
|
||||
/** Wrappers around browseFile which try to provide a filename
|
||||
relative to relpath.
|
||||
|
@ -300,8 +300,14 @@ FileName const fileSearch(string const & path, string const & name,
|
||||
return mode == may_not_exist ? fullname : FileName();
|
||||
// Only add the extension if it is not already the extension of
|
||||
// fullname.
|
||||
if (getExtension(fullname.absFileName()) != ext)
|
||||
if (getExtension(fullname.absFileName()) != ext) {
|
||||
if (mode == check_hidpi) {
|
||||
FileName fullname2x = FileName(addExtension(fullname.absFileName() + "@2x", ext));
|
||||
if (fullname2x.isReadableFile())
|
||||
return fullname2x;
|
||||
}
|
||||
fullname = FileName(addExtension(fullname.absFileName(), ext));
|
||||
}
|
||||
if (fullname.isReadableFile() || mode == may_not_exist)
|
||||
return fullname;
|
||||
return FileName();
|
||||
@ -313,20 +319,21 @@ FileName const fileSearch(string const & path, string const & name,
|
||||
// 2) build_lyxdir (if not empty)
|
||||
// 3) system_lyxdir
|
||||
FileName const libFileSearch(string const & dir, string const & name,
|
||||
string const & ext)
|
||||
string const & ext, search_mode mode)
|
||||
{
|
||||
FileName fullname = fileSearch(addPath(package().user_support().absFileName(), dir),
|
||||
name, ext);
|
||||
name, ext, mode);
|
||||
if (!fullname.empty())
|
||||
return fullname;
|
||||
|
||||
if (!package().build_support().empty())
|
||||
fullname = fileSearch(addPath(package().build_support().absFileName(), dir),
|
||||
name, ext);
|
||||
name, ext, mode);
|
||||
if (!fullname.empty())
|
||||
return fullname;
|
||||
|
||||
return fileSearch(addPath(package().system_support().absFileName(), dir), name, ext);
|
||||
return fileSearch(addPath(package().system_support().absFileName(), dir),
|
||||
name, ext, mode);
|
||||
}
|
||||
|
||||
|
||||
@ -381,17 +388,17 @@ FileName const i18nLibFileSearch(string const & dir, string const & name,
|
||||
|
||||
|
||||
FileName const imageLibFileSearch(string & dir, string const & name,
|
||||
string const & ext)
|
||||
string const & ext, search_mode mode)
|
||||
{
|
||||
if (!lyx::lyxrc.icon_set.empty()) {
|
||||
string const imagedir = addPath(dir, lyx::lyxrc.icon_set);
|
||||
FileName const fn = libFileSearch(imagedir, name, ext);
|
||||
FileName const fn = libFileSearch(imagedir, name, ext, mode);
|
||||
if (fn.exists()) {
|
||||
dir = imagedir;
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
return libFileSearch(dir, name, ext);
|
||||
return libFileSearch(dir, name, ext, mode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,7 +50,12 @@ enum search_mode {
|
||||
must_exist,
|
||||
/// Only do file name expansion, return the complete name even if
|
||||
/// the file does not exist
|
||||
may_not_exist
|
||||
may_not_exist,
|
||||
/// The (image) file may be present with hi-dpi resolution -
|
||||
/// the lookup checks for a file named "image" + "@2x" + ".ext" first.
|
||||
/// If found it will return e.g. "image@2x.png" instead of "image.png".
|
||||
/// Otherwise it will work as must_exist.
|
||||
check_hidpi
|
||||
};
|
||||
|
||||
/** Returns the real name of file name in directory path, with optional
|
||||
@ -90,7 +95,8 @@ bool isBinaryFile(FileName const & filename);
|
||||
*/
|
||||
FileName const libFileSearch(std::string const & dir,
|
||||
std::string const & name,
|
||||
std::string const & ext = std::string());
|
||||
std::string const & ext = std::string(),
|
||||
search_mode mode = must_exist);
|
||||
|
||||
/** Same as libFileSearch(), but tries first to find an
|
||||
internationalized version of the file by prepending $LANG_ to the
|
||||
@ -106,7 +112,8 @@ i18nLibFileSearch(std::string const & dir,
|
||||
*/
|
||||
FileName const
|
||||
imageLibFileSearch(std::string & dir, std::string const & name,
|
||||
std::string const & ext = std::string());
|
||||
std::string const & ext = std::string(),
|
||||
search_mode mode = must_exist);
|
||||
|
||||
/// How to quote a filename
|
||||
enum quote_style {
|
||||
|
Loading…
Reference in New Issue
Block a user