mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Prefer svg icons.
If a compressed svg icon is present, load it instead of a png one. Also introduce two more sizes (huge and giant icons) that should be useful when using hires displays, as svg icons automatically scale to the desired size without loss of quality.
This commit is contained in:
parent
d00dcc2ca7
commit
7be2a5d815
@ -519,11 +519,11 @@ QString iconName(FuncRequest const & f, bool unknown)
|
||||
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", mode);
|
||||
FileName fname = imageLibFileSearch(imagedir, name1, "svgz,png", mode);
|
||||
if (fname.exists())
|
||||
return toqstr(fname.absFileName());
|
||||
|
||||
fname = imageLibFileSearch(imagedir, name2, "png", mode);
|
||||
fname = imageLibFileSearch(imagedir, name2, "svgz,png", mode);
|
||||
if (fname.exists())
|
||||
return toqstr(fname.absFileName());
|
||||
}
|
||||
@ -534,25 +534,27 @@ QString iconName(FuncRequest const & f, bool unknown)
|
||||
LYXERR0("Directory " << path << " not found in resource!");
|
||||
return QString();
|
||||
}
|
||||
name1 += ".png";
|
||||
if (res.exists(name1))
|
||||
return path + name1;
|
||||
if (res.exists(name1 + ".svgz"))
|
||||
return path + name1 + ".svgz";
|
||||
else if (res.exists(name1 + ".png"))
|
||||
return path + name1 + ".png";
|
||||
|
||||
name2 += ".png";
|
||||
if (res.exists(name2))
|
||||
return path + name2;
|
||||
if (res.exists(name2 + ".svgz"))
|
||||
return path + name2 + ".svgz";
|
||||
else if (res.exists(name2 + ".png"))
|
||||
return path + name2 + ".png";
|
||||
|
||||
LYXERR(Debug::GUI, "Cannot find icon with filename "
|
||||
<< "\"" << name1 << "\""
|
||||
<< "\"" << name1 << ".{svgz,png}\""
|
||||
<< " or filename "
|
||||
<< "\"" << name2 << "\""
|
||||
<< "\"" << name2 << ".{svgz,png}\""
|
||||
<< " for command \""
|
||||
<< lyxaction.getActionName(f.action())
|
||||
<< '(' << to_utf8(f.argument()) << ")\"");
|
||||
|
||||
if (unknown) {
|
||||
QString imagedir = "images/";
|
||||
FileName fname = imageLibFileSearch(imagedir, "unknown", "png", mode);
|
||||
FileName fname = imageLibFileSearch(imagedir, "unknown", "svgz,png", mode);
|
||||
if (fname.exists())
|
||||
return toqstr(fname.absFileName());
|
||||
return QString(":/images/unknown.png");
|
||||
@ -566,19 +568,23 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex
|
||||
QPixmap pixmap;
|
||||
QString imagedir = path;
|
||||
FileName fname = imageLibFileSearch(imagedir, name, ext, theGuiApp()->imageSearchMode());
|
||||
QString path1 = toqstr(fname.absFileName());
|
||||
QString path2 = ":/" + path + name + "." + ext;
|
||||
QString fpath = toqstr(fname.absFileName());
|
||||
|
||||
if (pixmap.load(path1)) {
|
||||
return pixmap;
|
||||
}
|
||||
else if (pixmap.load(path2)) {
|
||||
if (pixmap.load(fpath)) {
|
||||
return pixmap;
|
||||
} else {
|
||||
QStringList exts = ext.split(",");
|
||||
fpath = ":/" + path + name + ".";
|
||||
for (int i = 0; i < exts.size(); ++i) {
|
||||
if (pixmap.load(fpath + exts.at(i)))
|
||||
return pixmap;
|
||||
}
|
||||
}
|
||||
|
||||
bool const list = ext.contains(",");
|
||||
LYXERR0("Cannot load pixmap \""
|
||||
<< path << name << '.' << ext
|
||||
<< "\", please verify resource system!");
|
||||
<< path << name << "." << (list ? "{" : "") << ext
|
||||
<< (list ? "}" : "") << "\", please verify resource system!");
|
||||
|
||||
return QPixmap();
|
||||
}
|
||||
@ -2400,8 +2406,8 @@ QAbstractItemModel * GuiApplication::languageModel()
|
||||
QStandardItemModel * lang_model = new QStandardItemModel(this);
|
||||
lang_model->insertColumns(0, 3);
|
||||
int current_row;
|
||||
QIcon speller(getPixmap("images/", "dialog-show_spellchecker", "png"));
|
||||
QIcon saurus(getPixmap("images/", "thesaurus-entry", "png"));
|
||||
QIcon speller(getPixmap("images/", "dialog-show_spellchecker", "svgz,png"));
|
||||
QIcon saurus(getPixmap("images/", "thesaurus-entry", "svgz,png"));
|
||||
Languages::const_iterator it = lyx::languages.begin();
|
||||
Languages::const_iterator end = lyx::languages.end();
|
||||
for (; it != end; ++it) {
|
||||
|
@ -88,8 +88,8 @@ GuiCommandBuffer::GuiCommandBuffer(GuiView * view)
|
||||
transform(lyxaction.func_begin(), lyxaction.func_end(),
|
||||
back_inserter(commands_), firster());
|
||||
|
||||
QPixmap qpup = getPixmap("images/", "up", "png");
|
||||
QPixmap qpdown = getPixmap("images/", "down", "png");
|
||||
QPixmap qpup = getPixmap("images/", "up", "svgz,png");
|
||||
QPixmap qpdown = getPixmap("images/", "down", "svgz,png");
|
||||
|
||||
QVBoxLayout * top = new QVBoxLayout(this);
|
||||
QHBoxLayout * layout = new QHBoxLayout(0);
|
||||
|
@ -196,10 +196,10 @@ MenuButton::MenuButton(GuiToolbar * bar, ToolbarItem const & item, bool const st
|
||||
imagedirs << "images/math/" << "images/";
|
||||
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, "svgz,png",
|
||||
theGuiApp()->imageSearchMode());
|
||||
if (fname.exists()) {
|
||||
setIcon(QIcon(getPixmap(imagedir, name, "png")));
|
||||
setIcon(QIcon(getPixmap(imagedir, name, "svgz,png")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public:
|
||||
/// The text to be written on top of the pixmap
|
||||
QString const text = lyx_version ?
|
||||
qt_("version ") + lyx_version : qt_("unknown version");
|
||||
splash_ = getPixmap("images/", "banner", "png");
|
||||
splash_ = getPixmap("images/", "banner", "svgz,png");
|
||||
|
||||
QPainter pain(&splash_);
|
||||
pain.setPen(QColor(0, 0, 0));
|
||||
@ -247,6 +247,8 @@ struct GuiView::GuiViewPrivate
|
||||
smallIconSize = 16; // scaling problems
|
||||
normalIconSize = 20; // ok, default if iconsize.png is missing
|
||||
bigIconSize = 26; // better for some math icons
|
||||
hugeIconSize = 32; // better for hires displays
|
||||
giantIconSize = 48;
|
||||
|
||||
// if it exists, use width of iconsize.png as normal size
|
||||
QString const dir = toqstr(addPath("images", lyxrc.icon_set));
|
||||
@ -255,8 +257,8 @@ struct GuiView::GuiViewPrivate
|
||||
QImage image(toqstr(fn.absFileName()));
|
||||
if (image.width() < int(smallIconSize))
|
||||
normalIconSize = smallIconSize;
|
||||
else if (image.width() > int(bigIconSize))
|
||||
normalIconSize = bigIconSize;
|
||||
else if (image.width() > int(giantIconSize))
|
||||
normalIconSize = giantIconSize;
|
||||
else
|
||||
normalIconSize = image.width();
|
||||
}
|
||||
@ -318,6 +320,20 @@ struct GuiView::GuiViewPrivate
|
||||
parent, SLOT(bigSizedIcons()));
|
||||
menu->addAction(bigIcons);
|
||||
|
||||
QAction * hugeIcons = new QAction(iconSizeGroup);
|
||||
hugeIcons->setText(qt_("Huge-sized icons"));
|
||||
hugeIcons->setCheckable(true);
|
||||
QObject::connect(hugeIcons, SIGNAL(triggered()),
|
||||
parent, SLOT(hugeSizedIcons()));
|
||||
menu->addAction(hugeIcons);
|
||||
|
||||
QAction * giantIcons = new QAction(iconSizeGroup);
|
||||
giantIcons->setText(qt_("Giant-sized icons"));
|
||||
giantIcons->setCheckable(true);
|
||||
QObject::connect(giantIcons, SIGNAL(triggered()),
|
||||
parent, SLOT(giantSizedIcons()));
|
||||
menu->addAction(giantIcons);
|
||||
|
||||
unsigned int cur = parent->iconSize().width();
|
||||
if ( cur == parent->d.smallIconSize)
|
||||
smallIcons->setChecked(true);
|
||||
@ -325,6 +341,10 @@ struct GuiView::GuiViewPrivate
|
||||
normalIcons->setChecked(true);
|
||||
else if (cur == parent->d.bigIconSize)
|
||||
bigIcons->setChecked(true);
|
||||
else if (cur == parent->d.hugeIconSize)
|
||||
hugeIcons->setChecked(true);
|
||||
else if (cur == parent->d.giantIconSize)
|
||||
giantIcons->setChecked(true);
|
||||
|
||||
return menu;
|
||||
}
|
||||
@ -412,6 +432,8 @@ public:
|
||||
unsigned int smallIconSize;
|
||||
unsigned int normalIconSize;
|
||||
unsigned int bigIconSize;
|
||||
unsigned int hugeIconSize;
|
||||
unsigned int giantIconSize;
|
||||
///
|
||||
QTimer statusbar_timer_;
|
||||
/// auto-saving of buffers
|
||||
@ -487,9 +509,9 @@ GuiView::GuiView(int id)
|
||||
// assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
|
||||
// since the icon is provided in the application bundle. We use a themed
|
||||
// version when available and use the bundled one as fallback.
|
||||
setWindowIcon(QIcon::fromTheme("lyx", getPixmap("images/", "lyx", "png")));
|
||||
setWindowIcon(QIcon::fromTheme("lyx", getPixmap("images/", "lyx", "svg,png")));
|
||||
#else
|
||||
setWindowIcon(getPixmap("images/", "lyx", "png"));
|
||||
setWindowIcon(getPixmap("images/", "lyx", "svg,png"));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -673,7 +695,9 @@ bool GuiView::restoreLayout()
|
||||
// Check whether session size changed.
|
||||
if (icon_size.width() != int(d.smallIconSize) &&
|
||||
icon_size.width() != int(d.normalIconSize) &&
|
||||
icon_size.width() != int(d.bigIconSize)) {
|
||||
icon_size.width() != int(d.bigIconSize) &&
|
||||
icon_size.width() != int(d.hugeIconSize) &&
|
||||
icon_size.width() != int(d.giantIconSize)) {
|
||||
icon_size.setWidth(d.normalIconSize);
|
||||
icon_size.setHeight(d.normalIconSize);
|
||||
}
|
||||
@ -1017,6 +1041,18 @@ void GuiView::bigSizedIcons()
|
||||
}
|
||||
|
||||
|
||||
void GuiView::hugeSizedIcons()
|
||||
{
|
||||
setIconSize(QSize(d.hugeIconSize, d.hugeIconSize));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::giantSizedIcons()
|
||||
{
|
||||
setIconSize(QSize(d.giantIconSize, d.giantIconSize));
|
||||
}
|
||||
|
||||
|
||||
void GuiView::clearMessage()
|
||||
{
|
||||
// FIXME: This code was introduced in r19643 to fix bug #4123. However,
|
||||
|
@ -229,6 +229,8 @@ private Q_SLOTS:
|
||||
void smallSizedIcons();
|
||||
void normalSizedIcons();
|
||||
void bigSizedIcons();
|
||||
void hugeSizedIcons();
|
||||
void giantSizedIcons();
|
||||
|
||||
/// For completion of autosave or export threads.
|
||||
void processingThreadStarted();
|
||||
|
@ -1560,7 +1560,7 @@ TabWorkArea::TabWorkArea(QWidget * parent)
|
||||
closeBufferButton = new QToolButton(this);
|
||||
closeBufferButton->setPalette(pal);
|
||||
// FIXME: rename the icon to closebuffer.png
|
||||
closeBufferButton->setIcon(QIcon(getPixmap("images/", "closetab", "png")));
|
||||
closeBufferButton->setIcon(QIcon(getPixmap("images/", "closetab", "svgz,png")));
|
||||
closeBufferButton->setText("Close File");
|
||||
closeBufferButton->setAutoRaise(true);
|
||||
closeBufferButton->setCursor(Qt::ArrowCursor);
|
||||
@ -2026,9 +2026,9 @@ void TabWorkArea::showContextMenu(const QPoint & pos)
|
||||
|
||||
// show tab popup
|
||||
QMenu popup;
|
||||
popup.addAction(QIcon(getPixmap("images/", "hidetab", "png")),
|
||||
popup.addAction(QIcon(getPixmap("images/", "hidetab", "svgz,png")),
|
||||
qt_("Hide tab"), this, SLOT(hideCurrentTab()));
|
||||
popup.addAction(QIcon(getPixmap("images/", "closetab", "png")),
|
||||
popup.addAction(QIcon(getPixmap("images/", "closetab", "svgz,png")),
|
||||
qt_("Close tab"), this, SLOT(closeCurrentBuffer()));
|
||||
popup.exec(tabBar()->mapToGlobal(pos));
|
||||
|
||||
|
@ -75,7 +75,7 @@ PanelStack::PanelStack(QWidget * parent)
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040600
|
||||
search_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "png"));
|
||||
search_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png"));
|
||||
search_->setButtonVisible(FancyLineEdit::Right, true);
|
||||
search_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
|
||||
search_->setAutoHideButton(FancyLineEdit::Right, true);
|
||||
|
@ -52,11 +52,11 @@ TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
moveOutTB->setIcon(QIcon(getPixmap("images/", "promote", "png")));
|
||||
moveInTB->setIcon(QIcon(getPixmap("images/", "demote", "png")));
|
||||
moveUpTB->setIcon(QIcon(getPixmap("images/", "up", "png")));
|
||||
moveDownTB->setIcon(QIcon(getPixmap("images/", "down", "png")));
|
||||
updateTB->setIcon(QIcon(getPixmap("images/", "reload", "png")));
|
||||
moveOutTB->setIcon(QIcon(getPixmap("images/", "promote", "svgz,png")));
|
||||
moveInTB->setIcon(QIcon(getPixmap("images/", "demote", "svgz,png")));
|
||||
moveUpTB->setIcon(QIcon(getPixmap("images/", "up", "svgz,png")));
|
||||
moveDownTB->setIcon(QIcon(getPixmap("images/", "down", "svgz,png")));
|
||||
updateTB->setIcon(QIcon(getPixmap("images/", "reload", "svgz,png")));
|
||||
|
||||
// avoid flickering
|
||||
tocTV->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
|
@ -292,7 +292,7 @@ FileName const fileOpenSearch(string const & path, string const & name,
|
||||
// Returns the real name of file name in directory path, with optional
|
||||
// extension ext.
|
||||
FileName const fileSearch(string const & path, string const & name,
|
||||
string const & ext, search_mode mode)
|
||||
string const & exts, search_mode mode)
|
||||
{
|
||||
// if `name' is an absolute path, we ignore the setting of `path'
|
||||
// Expand Environmentvariables in 'name'
|
||||
@ -301,21 +301,29 @@ FileName const fileSearch(string const & path, string const & name,
|
||||
// search first without extension, then with it.
|
||||
if (fullname.isReadableFile())
|
||||
return fullname;
|
||||
if (ext.empty())
|
||||
if (exts.empty())
|
||||
// We are done.
|
||||
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 (mode == check_hidpi) {
|
||||
FileName fullname2x = FileName(addExtension(fullname.absFileName() + "@2x", ext));
|
||||
if (fullname2x.isReadableFile())
|
||||
return fullname2x;
|
||||
int n = 0;
|
||||
string ext = token(exts, ',', n);
|
||||
while (!ext.empty()) {
|
||||
// Only add the extension if it is not already the extension of
|
||||
// fullname.
|
||||
bool addext = getExtension(fullname.absFileName()) != ext;
|
||||
if (addext) {
|
||||
if (mode == check_hidpi) {
|
||||
FileName fullname2x = FileName(addExtension(fullname.absFileName() + "@2x", ext));
|
||||
if (fullname2x.isReadableFile())
|
||||
return fullname2x;
|
||||
}
|
||||
fullname = FileName(addExtension(fullname.absFileName(), ext));
|
||||
}
|
||||
fullname = FileName(addExtension(fullname.absFileName(), ext));
|
||||
if (fullname.isReadableFile() || mode == may_not_exist)
|
||||
return fullname;
|
||||
if (addext)
|
||||
fullname.changeExtension("");
|
||||
ext = token(exts, ',', ++n);
|
||||
}
|
||||
if (fullname.isReadableFile() || mode == may_not_exist)
|
||||
return fullname;
|
||||
return FileName();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user