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.
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());
}
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");
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();
}
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) {
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);
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;
}
}
/// 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));
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));
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();
}
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);
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;
}
unsigned int smallIconSize;
unsigned int normalIconSize;
unsigned int bigIconSize;
+ unsigned int hugeIconSize;
+ unsigned int giantIconSize;
///
QTimer statusbar_timer_;
/// auto-saving of buffers
// 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
// 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);
}
}
+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,
void smallSizedIcons();
void normalSizedIcons();
void bigSizedIcons();
+ void hugeSizedIcons();
+ void giantSizedIcons();
/// For completion of autosave or export threads.
void processingThreadStarted();
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);
// 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));
#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);
{
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);
// 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'
// 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();
}