-Resources.cpp
-Resources.qrc
liblyxqt.a
ui_*.h
moc_*.cpp
#include <config.h>
#include "BulletsModule.h"
+#include "GuiApplication.h"
#include "qt_helpers.h"
#include <QPixmap>
bulletpaneCO->addItem(panelname);
// get pixmap with bullets
- QPixmap pixmap(":/images/" + toqstr(fname) + ".png");
+ QPixmap pixmap = getPixmap("images", toqstr(fname), ".png");
int const w = pixmap.width() / 6;
int const h = pixmap.height() / 6;
using namespace lyx::support;
-static void initializeResources()
-{
- static bool initialized = false;
- if (!initialized) {
- Q_INIT_RESOURCE(Resources);
- initialized = true;
- }
-}
-
-
namespace lyx {
frontend::Application * createApplication(int & argc, char * argv[])
// the returned bool is true if the icon needs to be flipped
pair<QString,bool> iconName(FuncRequest const & f, bool unknown, bool rtl)
{
- initializeResources();
QStringList names;
QString lfunname = toqstr(lyxaction.getActionName(f.action()));
names << "unknown";
search_mode const mode = theGuiApp()->imageSearchMode();
+ // The folders where icons are searched for
QStringList imagedirs;
imagedirs << "images/" << "images/ipa/";
+ // This is used to search for rtl version of icons which have the +rrtl suffix.
QStringList suffixes;
if (rtl)
suffixes << "+rtl";
suffixes << QString();
+
for (QString const & imagedir : imagedirs)
for (QString const & name : names)
for (QString const & suffix : suffixes) {
QString id = imagedir;
FileName fname = imageLibFileSearch(id, name + suffix, "svgz,png", mode);
if (fname.exists())
- return make_pair(toqstr(fname.absFileName()), rtl && suffix.isEmpty());
+ return make_pair(toqstr(fname.absFileName()),
+ rtl && suffix.isEmpty());
}
- QString const resdir(":/images/");
- QDir res(resdir);
- if (!res.exists()) {
- LYXERR0("Directory :/images/ not found in resource!");
- return make_pair(QString(), false);
- }
-
- for (QString const & name : names)
- for (QString const & suffix : suffixes) {
- if (res.exists(name + suffix + ".svgz"))
- return make_pair(resdir + name + ".svgz", rtl && suffix.isEmpty());
- if (res.exists(name + suffix + ".png"))
- return make_pair(resdir + name + ".png", rtl && suffix.isEmpty());
- }
-
LYXERR(Debug::GUI, "Cannot find icon for command \""
<< lyxaction.getActionName(f.action())
<< '(' << to_utf8(f.argument()) << ")\"");
QString fpath = toqstr(fname.absFileName());
QPixmap pixmap = QPixmap();
- if (pixmap.load(fpath)) {
+ if (pixmap.load(fpath))
return pixmap;
- }
-
- 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 << "." << (list ? "{" : "") << ext
- << (list ? "}" : "") << "\", please verify resource system!");
+ LYXERR(Debug::GUI, "Cannot load pixmap \""
+ << path << "/" << name << "." << (list ? "{" : "") << ext
+ << (list ? "}" : "") << "\".");
return QPixmap();
}
//LYXERR(Debug::GUI, "Found icon: " << icon);
QPixmap pixmap = QPixmap();
if (!pixmap.load(icon)) {
- LYXERR0("Cannot load icon " << icon << " please verify resource system!");
+ LYXERR0("Cannot load icon " << icon << ".");
return QIcon();
}
#include "GuiCompleter.h"
+#include "GuiApplication.h"
+#include "GuiWorkArea.h"
+#include "GuiView.h"
+#include "qt_helpers.h"
+
#include "Buffer.h"
#include "BufferView.h"
#include "CompletionList.h"
#include "Cursor.h"
#include "Dimension.h"
-#include "GuiWorkArea.h"
-#include "GuiView.h"
#include "LyX.h"
#include "LyXRC.h"
#include "Paragraph.h"
-#include "qt_helpers.h"
#include "version.h"
+#include "support/debug.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-#include "support/debug.h"
+#include "support/qstring_helpers.h"
-#include <QApplication>
#include <QHeaderView>
#include <QKeyEvent>
#include <QPainter>
// get icon from cache
QPixmap scaled;
- QString const name = ":" + toqstr(list_->icon(index.row()));
- if (name == ":")
+ QString const name = toqstr(list_->icon(index.row()));
+ if (name.isEmpty())
return scaled;
- if (!QPixmapCache::find("completion" + name, &scaled)) {
+ if (!QPixmapCache::find("completion:" + name, &scaled)) {
// load icon from disk
- QPixmap p = QPixmap(name);
+ QPixmap p = getPixmap("images", name, "svgz,png");
if (!p.isNull()) {
// scale it to 16x16 or smaller
scaled = p.scaled(min(16, p.width()), min(16, p.height()),
Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
- QPixmapCache::insert("completion" + name, scaled);
+ QPixmapCache::insert("completion:" + name, scaled);
}
return scaled;
}
BUILT_SOURCES = $(UIFILES:%.ui=ui_%.h)
BUILT_SOURCES += $(MOCEDFILES)
-BUILT_SOURCES += Resources.cpp Resources.qrc
CLEANFILES = $(BUILT_SOURCES)
moc_%.cpp: %.h
$(AM_V_GEN)$(QT_MOC) -DQT_VERSION=$(QT_VERSION) -o $@ $<
-Resources.qrc: Makefile
- $(AM_V_GEN)echo "<!DOCTYPE RCC><RCC version='1.0'><qresource>" > $@ ; \
- find $(top_srcdir)/lib/images -name '*.svgz' -o -name '*.png' -o -name '*.gif' \
- | LC_ALL=C sort \
- | sed -e 's:$(top_srcdir)/lib/\(.*\):<file alias="\1">&</file>:' \
- >> $@ ;\
- echo "</qresource></RCC>" >> $@
-
-Resources.cpp: Resources.qrc
- $(AM_V_GEN)$(QT_RCC) $< -name Resources -o $@
-
######################### LIBRARIES #############################
WorkAreaUi.ui \
WrapUi.ui
-nodist_liblyxqt_a_SOURCES = Resources.cpp
-
liblyxqt_a_SOURCES = \
$(SOURCEFILES) \
$(MOCHEADER) \
initialized_ = true;
FuncRequest func = lyxaction.lookupFunc(params_.name);
docstring icon_name = frontend::Application::iconName(func, true);
- // FIXME: We should use the icon directly instead of
- // going through FileName. The code below won't work
- // if the icon is embedded in the executable through
- // the Qt resource system.
- // This is only a negligible performance problem:
- // If the installed icon differs from the resource icon the
- // installed one is preferred anyway, and all icons that are
- // embedded in the resources are installed as well.
FileName file(to_utf8(icon_name));
if (file.onlyFileNameWithoutExt() == "unknown") {
string dir = "images";
else
cmd = locals[idx];
- // get the icon resource name by stripping the backslash
+ // get the icon name by stripping the backslash
docstring icon_name = frontend::Application::mathIcon(cmd.substr(1));
if (icon_name.empty())
return std::string();
- return "images/math/" + to_utf8(icon_name);
+ return "math/" + to_utf8(icon_name);
}
std::vector<docstring> MathCompletionList::globals;