mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Get rid of Qt resources
It turns out that the resources were mostly not used anyway. Removing them shrinks LyX binary by ~6MB. Only autotools have been adapted. cmake will require the same simplification.
This commit is contained in:
parent
6b221751c1
commit
2d48072e66
2
src/frontends/qt/.gitignore
vendored
2
src/frontends/qt/.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
Resources.cpp
|
||||
Resources.qrc
|
||||
liblyxqt.a
|
||||
ui_*.h
|
||||
moc_*.cpp
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "BulletsModule.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include <QPixmap>
|
||||
@ -64,7 +65,7 @@ void BulletsModule::setupPanel(QListWidget * lw, QString const & panelname,
|
||||
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;
|
||||
|
@ -157,16 +157,6 @@ using namespace std;
|
||||
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[])
|
||||
@ -490,7 +480,6 @@ QString themeIconName(QString const & action)
|
||||
// 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()));
|
||||
|
||||
@ -538,34 +527,23 @@ pair<QString,bool> iconName(FuncRequest const & f, bool unknown, bool rtl)
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
return make_pair(toqstr(fname.absFileName()),
|
||||
rtl && suffix.isEmpty());
|
||||
}
|
||||
|
||||
LYXERR(Debug::GUI, "Cannot find icon for command \""
|
||||
@ -583,22 +561,13 @@ QPixmap getPixmap(QString const & path, QString const & name, QString const & ex
|
||||
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();
|
||||
}
|
||||
@ -630,7 +599,7 @@ QIcon getIcon(FuncRequest const & f, bool unknown, bool rtl)
|
||||
//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();
|
||||
}
|
||||
|
||||
|
@ -12,24 +12,26 @@
|
||||
|
||||
#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>
|
||||
@ -137,18 +139,18 @@ public:
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ include $(top_srcdir)/config/common.am
|
||||
|
||||
BUILT_SOURCES = $(UIFILES:%.ui=ui_%.h)
|
||||
BUILT_SOURCES += $(MOCEDFILES)
|
||||
BUILT_SOURCES += Resources.cpp Resources.qrc
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
@ -23,17 +22,6 @@ QT_VERSION = $(shell IFS=.; set -- `echo $(QTLIB_VERSION)`; \
|
||||
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 #############################
|
||||
|
||||
@ -367,8 +355,6 @@ UIFILES = \
|
||||
WorkAreaUi.ui \
|
||||
WrapUi.ui
|
||||
|
||||
nodist_liblyxqt_a_SOURCES = Resources.cpp
|
||||
|
||||
liblyxqt_a_SOURCES = \
|
||||
$(SOURCEFILES) \
|
||||
$(MOCHEADER) \
|
||||
|
@ -1037,14 +1037,6 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
|
||||
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";
|
||||
|
@ -2180,11 +2180,11 @@ std::string MathCompletionList::icon(size_t idx) const
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user