mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +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
|
liblyxqt.a
|
||||||
ui_*.h
|
ui_*.h
|
||||||
moc_*.cpp
|
moc_*.cpp
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "BulletsModule.h"
|
#include "BulletsModule.h"
|
||||||
|
#include "GuiApplication.h"
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
@ -64,7 +65,7 @@ void BulletsModule::setupPanel(QListWidget * lw, QString const & panelname,
|
|||||||
bulletpaneCO->addItem(panelname);
|
bulletpaneCO->addItem(panelname);
|
||||||
|
|
||||||
// get pixmap with bullets
|
// 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 w = pixmap.width() / 6;
|
||||||
int const h = pixmap.height() / 6;
|
int const h = pixmap.height() / 6;
|
||||||
|
@ -157,16 +157,6 @@ using namespace std;
|
|||||||
using namespace lyx::support;
|
using namespace lyx::support;
|
||||||
|
|
||||||
|
|
||||||
static void initializeResources()
|
|
||||||
{
|
|
||||||
static bool initialized = false;
|
|
||||||
if (!initialized) {
|
|
||||||
Q_INIT_RESOURCE(Resources);
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
frontend::Application * createApplication(int & argc, char * argv[])
|
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
|
// the returned bool is true if the icon needs to be flipped
|
||||||
pair<QString,bool> iconName(FuncRequest const & f, bool unknown, bool rtl)
|
pair<QString,bool> iconName(FuncRequest const & f, bool unknown, bool rtl)
|
||||||
{
|
{
|
||||||
initializeResources();
|
|
||||||
QStringList names;
|
QStringList names;
|
||||||
QString lfunname = toqstr(lyxaction.getActionName(f.action()));
|
QString lfunname = toqstr(lyxaction.getActionName(f.action()));
|
||||||
|
|
||||||
@ -538,34 +527,23 @@ pair<QString,bool> iconName(FuncRequest const & f, bool unknown, bool rtl)
|
|||||||
names << "unknown";
|
names << "unknown";
|
||||||
|
|
||||||
search_mode const mode = theGuiApp()->imageSearchMode();
|
search_mode const mode = theGuiApp()->imageSearchMode();
|
||||||
|
// The folders where icons are searched for
|
||||||
QStringList imagedirs;
|
QStringList imagedirs;
|
||||||
imagedirs << "images/" << "images/ipa/";
|
imagedirs << "images/" << "images/ipa/";
|
||||||
|
// This is used to search for rtl version of icons which have the +rrtl suffix.
|
||||||
QStringList suffixes;
|
QStringList suffixes;
|
||||||
if (rtl)
|
if (rtl)
|
||||||
suffixes << "+rtl";
|
suffixes << "+rtl";
|
||||||
suffixes << QString();
|
suffixes << QString();
|
||||||
|
|
||||||
for (QString const & imagedir : imagedirs)
|
for (QString const & imagedir : imagedirs)
|
||||||
for (QString const & name : names)
|
for (QString const & name : names)
|
||||||
for (QString const & suffix : suffixes) {
|
for (QString const & suffix : suffixes) {
|
||||||
QString id = imagedir;
|
QString id = imagedir;
|
||||||
FileName fname = imageLibFileSearch(id, name + suffix, "svgz,png", mode);
|
FileName fname = imageLibFileSearch(id, name + suffix, "svgz,png", mode);
|
||||||
if (fname.exists())
|
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 \""
|
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());
|
QString fpath = toqstr(fname.absFileName());
|
||||||
QPixmap pixmap = QPixmap();
|
QPixmap pixmap = QPixmap();
|
||||||
|
|
||||||
if (pixmap.load(fpath)) {
|
if (pixmap.load(fpath))
|
||||||
return pixmap;
|
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(",");
|
bool const list = ext.contains(",");
|
||||||
LYXERR0("Cannot load pixmap \""
|
LYXERR(Debug::GUI, "Cannot load pixmap \""
|
||||||
<< path << name << "." << (list ? "{" : "") << ext
|
<< path << "/" << name << "." << (list ? "{" : "") << ext
|
||||||
<< (list ? "}" : "") << "\", please verify resource system!");
|
<< (list ? "}" : "") << "\".");
|
||||||
|
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
@ -630,7 +599,7 @@ QIcon getIcon(FuncRequest const & f, bool unknown, bool rtl)
|
|||||||
//LYXERR(Debug::GUI, "Found icon: " << icon);
|
//LYXERR(Debug::GUI, "Found icon: " << icon);
|
||||||
QPixmap pixmap = QPixmap();
|
QPixmap pixmap = QPixmap();
|
||||||
if (!pixmap.load(icon)) {
|
if (!pixmap.load(icon)) {
|
||||||
LYXERR0("Cannot load icon " << icon << " please verify resource system!");
|
LYXERR0("Cannot load icon " << icon << ".");
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,24 +12,26 @@
|
|||||||
|
|
||||||
#include "GuiCompleter.h"
|
#include "GuiCompleter.h"
|
||||||
|
|
||||||
|
#include "GuiApplication.h"
|
||||||
|
#include "GuiWorkArea.h"
|
||||||
|
#include "GuiView.h"
|
||||||
|
#include "qt_helpers.h"
|
||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "CompletionList.h"
|
#include "CompletionList.h"
|
||||||
#include "Cursor.h"
|
#include "Cursor.h"
|
||||||
#include "Dimension.h"
|
#include "Dimension.h"
|
||||||
#include "GuiWorkArea.h"
|
|
||||||
#include "GuiView.h"
|
|
||||||
#include "LyX.h"
|
#include "LyX.h"
|
||||||
#include "LyXRC.h"
|
#include "LyXRC.h"
|
||||||
#include "Paragraph.h"
|
#include "Paragraph.h"
|
||||||
#include "qt_helpers.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
#include "support/debug.h"
|
||||||
#include "support/lassert.h"
|
#include "support/lassert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/debug.h"
|
#include "support/qstring_helpers.h"
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -137,18 +139,18 @@ public:
|
|||||||
|
|
||||||
// get icon from cache
|
// get icon from cache
|
||||||
QPixmap scaled;
|
QPixmap scaled;
|
||||||
QString const name = ":" + toqstr(list_->icon(index.row()));
|
QString const name = toqstr(list_->icon(index.row()));
|
||||||
if (name == ":")
|
if (name.isEmpty())
|
||||||
return scaled;
|
return scaled;
|
||||||
if (!QPixmapCache::find("completion" + name, &scaled)) {
|
if (!QPixmapCache::find("completion:" + name, &scaled)) {
|
||||||
// load icon from disk
|
// load icon from disk
|
||||||
QPixmap p = QPixmap(name);
|
QPixmap p = getPixmap("images", name, "svgz,png");
|
||||||
if (!p.isNull()) {
|
if (!p.isNull()) {
|
||||||
// scale it to 16x16 or smaller
|
// scale it to 16x16 or smaller
|
||||||
scaled = p.scaled(min(16, p.width()), min(16, p.height()),
|
scaled = p.scaled(min(16, p.width()), min(16, p.height()),
|
||||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
QPixmapCache::insert("completion" + name, scaled);
|
QPixmapCache::insert("completion:" + name, scaled);
|
||||||
}
|
}
|
||||||
return scaled;
|
return scaled;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ include $(top_srcdir)/config/common.am
|
|||||||
|
|
||||||
BUILT_SOURCES = $(UIFILES:%.ui=ui_%.h)
|
BUILT_SOURCES = $(UIFILES:%.ui=ui_%.h)
|
||||||
BUILT_SOURCES += $(MOCEDFILES)
|
BUILT_SOURCES += $(MOCEDFILES)
|
||||||
BUILT_SOURCES += Resources.cpp Resources.qrc
|
|
||||||
|
|
||||||
CLEANFILES = $(BUILT_SOURCES)
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
@ -23,17 +22,6 @@ QT_VERSION = $(shell IFS=.; set -- `echo $(QTLIB_VERSION)`; \
|
|||||||
moc_%.cpp: %.h
|
moc_%.cpp: %.h
|
||||||
$(AM_V_GEN)$(QT_MOC) -DQT_VERSION=$(QT_VERSION) -o $@ $<
|
$(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 #############################
|
######################### LIBRARIES #############################
|
||||||
|
|
||||||
@ -367,8 +355,6 @@ UIFILES = \
|
|||||||
WorkAreaUi.ui \
|
WorkAreaUi.ui \
|
||||||
WrapUi.ui
|
WrapUi.ui
|
||||||
|
|
||||||
nodist_liblyxqt_a_SOURCES = Resources.cpp
|
|
||||||
|
|
||||||
liblyxqt_a_SOURCES = \
|
liblyxqt_a_SOURCES = \
|
||||||
$(SOURCEFILES) \
|
$(SOURCEFILES) \
|
||||||
$(MOCHEADER) \
|
$(MOCHEADER) \
|
||||||
|
@ -1037,14 +1037,6 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype, bool cons
|
|||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
FuncRequest func = lyxaction.lookupFunc(params_.name);
|
FuncRequest func = lyxaction.lookupFunc(params_.name);
|
||||||
docstring icon_name = frontend::Application::iconName(func, true);
|
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));
|
FileName file(to_utf8(icon_name));
|
||||||
if (file.onlyFileNameWithoutExt() == "unknown") {
|
if (file.onlyFileNameWithoutExt() == "unknown") {
|
||||||
string dir = "images";
|
string dir = "images";
|
||||||
|
@ -2180,11 +2180,11 @@ std::string MathCompletionList::icon(size_t idx) const
|
|||||||
else
|
else
|
||||||
cmd = locals[idx];
|
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));
|
docstring icon_name = frontend::Application::mathIcon(cmd.substr(1));
|
||||||
if (icon_name.empty())
|
if (icon_name.empty())
|
||||||
return std::string();
|
return std::string();
|
||||||
return "images/math/" + to_utf8(icon_name);
|
return "math/" + to_utf8(icon_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<docstring> MathCompletionList::globals;
|
std::vector<docstring> MathCompletionList::globals;
|
||||||
|
Loading…
Reference in New Issue
Block a user