Re: [Patch] use Qt resources
Andre Poenitz wrote: On Fri, Oct 19, 2007 at 10:26:57AM +0200, Helge Hafting wrote: Abdelrazak Younes wrote: Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Good - faster startup is always a good thing, the delay is noticeable now. It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually, but not bad either. Everything helps :-) It's hard to get 'real numbers' as after the first start there's a lot chached by the system (total time then 2s here). 2s to start LyX from cache, 3s to start LyX with some document. More when there's no cache of course. Helge Hafting
Re: [Patch] use Qt resources
Andre Poenitz wrote: On Fri, Oct 19, 2007 at 10:26:57AM +0200, Helge Hafting wrote: Abdelrazak Younes wrote: Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo "" > $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):&:' \ >> $@ echo "" >> $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Good - faster startup is always a good thing, the delay is noticeable now. It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually, but not bad either. Everything helps :-) It's hard to get 'real numbers' as after the first start there's a lot chached by the system (total time then <2s here). 2s to start LyX from cache, 3s to start LyX with some document. More when there's no cache of course. Helge Hafting
Re: [Patch] use Qt resources
Andre Poenitz [EMAIL PROTECTED] writes: On Thu, Oct 18, 2007 at 08:47:18AM -0500, Bo Peng wrote: Scons? There's a Resources.cpp to be build and compiled in frontends/qt4. There is no such file. Did you add it to svn? This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ It would be better to use the list of icons that we have anyway in Makefile.am. JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Because in the second case the change could actually mean *slower* startup times... A/
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 11:07:19AM +0200, Alfredo Braunstein wrote: Abdelrazak Younes wrote: Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math Didn't this start as a presumable startup time improvement? No. It started as code decontamination. I did not even mention speed. directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. Could depend on the filesystem and thje tools used to compute 'size'. used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm - png change had some impact on load time? I wonder why you try to invent problems. In rev 19000 we have 1169691 for wc -c {*,*/*}.* in lib/images, in current trunk it is 235212. That's a bit more than a fifth of the original size. Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 11:04:18AM +0200, Abdelrazak Younes wrote: Alfredo Braunstein wrote: Abdelrazak Younes wrote: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math directory is only 6 megs in size. I don't know how the resource file is used within Qt but I guess that not everything is put in memory... not sure though. One can have external resources, but the patch uses internal resources, and it results in a increase of the binary of 261 k. Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:37:46AM +0200, Alfredo Braunstein wrote: Abdelrazak Younes wrote: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Because in the second case the change could actually mean *slower* startup times... They were read at once. I checked that with strace (that's btw why I stumbled over that funny new cache...) Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 09:43:00AM +0200, Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Faster load times (one mmap vs 600 stat + 600 read), faster installation (especially on Windows lots of small files are poison to performance) and last but not least nicer user-side code. Compare FileName const file = support::libFileSearch(images, closetab, xpm); closeTabButton-setIcon(QPixmap(toqstr(file.absFilename())); to closeTabButton-setIcon(:/images/closetab.png); Andre'
Re: [Patch] use Qt resources
Bo Peng wrote: Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Please apply even a temporary fix. I can not compile under linux with this. Just go ahead and apply your suggested fix with #ifdef. Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Hum not so good as we are both wrong! We should not count the .svn/ directory... images/math/ is actually 2.9M. Haha you're right. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm - png change had some impact on load time? No the size are approximately the same, see above... Oh, that's a relief actually ;-) A/
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Abdelrazak Younes wrote: Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math Didn't this start as a presumable startup time improvement? I guess that was Andre' rationale yes. I am just giving some insight that's all :-) directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. Right, we make a good team! used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm - png change had some impact on load time? dunno... Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math Didn't this start as a presumable startup time improvement? directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm - png change had some impact on load time? A/
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Abdelrazak Younes wrote: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math directory is only 6 megs in size. I don't know how the resource file is used within Qt but I guess that not everything is put in memory... not sure though. Abdel.
Re: [Patch] use Qt resources
Jean-Marc Lasgouttes wrote: Abdelrazak Younes [EMAIL PROTECTED] writes: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Is it still possible for a user to provide his own icons for the toolbar? As far as I see no, not yet. Otherwise the patch is a big regression for me (especially with 'presumed' faster loading). This should be fixed yes. We probably need an API for icon loading; but wait, we already have that in GuiToolbar.cpp: static QIcon getIcon(FuncRequest const f, bool unknown) So, what do we want to support? I guess adding one or two cases for user icons should be easy. Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes [EMAIL PROTECTED] writes: This should be fixed yes. We probably need an API for icon loading; but wait, we already have that in GuiToolbar.cpp: static QIcon getIcon(FuncRequest const f, bool unknown) So, what do we want to support? I guess adding one or two cases for user icons should be easy. Yes it should. JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Good - faster startup is always a good thing, the delay is noticeable now. Helge Hafting
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Abdel.
Re: [Patch] use Qt resources
Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Note that it's a genuine question, I simply don't know. A/
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:45:30AM +0200, Jean-Marc Lasgouttes wrote: Abdelrazak Younes [EMAIL PROTECTED] writes: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Is it still possible for a user to provide his own icons for the toolbar? Otherwise the patch is a big regression for me (especially with 'presumed' faster loading). *grr* Have you ever done that? Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:26:57AM +0200, Helge Hafting wrote: Abdelrazak Younes wrote: Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file | alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Good - faster startup is always a good thing, the delay is noticeable now. It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually, but not bad either. It's hard to get 'real numbers' as after the first start there's a lot chached by the system (total time then 2s here). Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:06:21AM -0500, Bo Peng wrote: Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Please apply even a temporary fix. I can not compile under linux with this. I am going to fix it. The problem is that cmake adds the -name parameter to the rcc call. -- Enrico
Re: [Patch] use Qt resources
Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Please apply even a temporary fix. I can not compile under linux with this. Bo
Re: [Patch] use Qt resources
Abdelrazak Younes [EMAIL PROTECTED] writes: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Is it still possible for a user to provide his own icons for the toolbar? Otherwise the patch is a big regression for me (especially with 'presumed' faster loading). JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Alfredo Braunstein wrote: directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. Right, we make a good team! Hum not so good as we are both wrong! We should not count the .svn/ directory... images/math/ is actually 2.9M. used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm - png change had some impact on load time? No the size are approximately the same, see above... Abdel.
Re: [Patch] use Qt resources
Andre Poenitz <[EMAIL PROTECTED]> writes: > On Thu, Oct 18, 2007 at 08:47:18AM -0500, Bo Peng wrote: >> > Scons? >> > >> > There's a Resources.cpp to be build and compiled in frontends/qt4. >> >> There is no such file. Did you add it to svn? > > This is a generated file built by > > Resources.qrc: > echo "" > $@ > find $(top_srcdir)/lib/images -name '*.png' \ > | sed -e 's:$(top_srcdir)/lib/\(.*\): alias="\1">&:' \ > >> $@ > echo "" >> $@ It would be better to use the list of icons that we have anyway in Makefile.am. JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: >> And this is an advantage because? > > Presumably faster loading. I haven't tested yet but I can imagine that > reading one big file on disk is faster than reading 600 small files > (this is for sure on Windows). Note that most of the icons are loaded on > startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Because in the second case the change could actually mean *slower* startup times... A/
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 11:07:19AM +0200, Alfredo Braunstein wrote: > Abdelrazak Younes wrote: > > > Good question. > > > >> Because in the > >> second case the change could actually mean *slower* startup times... > > > > I don't think the difference would be noticeable... the lib/images/math > > Didn't this start as a presumable startup time improvement? No. It started as code decontamination. I did not even mention speed. > > > directory is only 6 megs in size. I don't know how the resource file is > > Note that lib/images (*including* lib/images/math) is just 7.9M. Could depend on the filesystem and thje tools used to compute 'size'. > > > used within Qt but I guess that not everything is put in memory... not > > sure though. > > Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm > images was only 2.9M. Did the xpm -> png change had some impact on load > time? I wonder why you try to invent problems. In rev 19000 we have 1169691 for wc -c {*,*/*}.* in lib/images, in current trunk it is 235212. That's a bit more than a fifth of the original size. Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 11:04:18AM +0200, Abdelrazak Younes wrote: > Alfredo Braunstein wrote: > >Abdelrazak Younes wrote: > > > >>>And this is an advantage because? > >>Presumably faster loading. I haven't tested yet but I can imagine that > >>reading one big file on disk is faster than reading 600 small files > >>(this is for sure on Windows). Note that most of the icons are loaded on > >>startup now that we have the math panels in the toolbars. > > > >Just trying to upset Andre'. Icons are really read on startup or just the > >first time the panel is created (if it is an auto panel)? > > Good question. > > >Because in the > >second case the change could actually mean *slower* startup times... > > I don't think the difference would be noticeable... the lib/images/math > directory is only 6 megs in size. I don't know how the resource file is > used within Qt but I guess that not everything is put in memory... not > sure though. One can have external resources, but the patch uses internal resources, and it results in a increase of the binary of 261 k. Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:37:46AM +0200, Alfredo Braunstein wrote: > Abdelrazak Younes wrote: > > >> And this is an advantage because? > > > > Presumably faster loading. I haven't tested yet but I can imagine that > > reading one big file on disk is faster than reading 600 small files > > (this is for sure on Windows). Note that most of the icons are loaded on > > startup now that we have the math panels in the toolbars. > > Just trying to upset Andre'. Icons are really read on startup or just the > first time the panel is created (if it is an auto panel)? Because in the > second case the change could actually mean *slower* startup times... They were read at once. I checked that with strace (that's btw why I stumbled over that funny new cache...) Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 09:43:00AM +0200, Alfredo Braunstein wrote: > Andre Poenitz wrote: > > > On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: > >> > This is a generated file built by > >> > > >> > Resources.qrc: > >> > echo "" > $@ > >> > find $(top_srcdir)/lib/images -name '*.png' \ > >> > | sed -e 's:$(top_srcdir)/lib/\(.*\): >> > | alias="\1">&:' \ > >> > >> $@ > >> > echo "" >> $@ > >> > >> What is the advantage of doing all these? > > > > Compiled-in resources vs 600 seperately installed files? > > And this is an advantage because? Faster load times (one mmap vs 600 stat + 600 read), faster installation (especially on Windows lots of small files are poison to performance) and last but not least nicer user-side code. Compare FileName const file = support::libFileSearch("images", "closetab", "xpm"); closeTabButton->setIcon(QPixmap(toqstr(file.absFilename())); to closeTabButton->setIcon(":/images/closetab.png"); Andre'
Re: [Patch] use Qt resources
Bo Peng wrote: Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Please apply even a temporary fix. I can not compile under linux with this. Just go ahead and apply your suggested fix with #ifdef. Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: > Hum not so good as we are both wrong! > We should not count the .svn/ directory... images/math/ is actually 2.9M. Haha you're right. >>> Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm >>> images was only 2.9M. Did the xpm -> png change had some impact on load >>> time? > > No the size are approximately the same, see above... Oh, that's a relief actually ;-) A/
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Abdelrazak Younes wrote: Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math Didn't this start as a presumable startup time improvement? I guess that was Andre' rationale yes. I am just giving some insight that's all :-) directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. Right, we make a good team! used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm -> png change had some impact on load time? dunno... Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: > Good question. > >> Because in the >> second case the change could actually mean *slower* startup times... > > I don't think the difference would be noticeable... the lib/images/math Didn't this start as a presumable startup time improvement? > directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. > used within Qt but I guess that not everything is put in memory... not > sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm -> png change had some impact on load time? A/
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Abdelrazak Younes wrote: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Just trying to upset Andre'. Icons are really read on startup or just the first time the panel is created (if it is an auto panel)? Good question. Because in the second case the change could actually mean *slower* startup times... I don't think the difference would be noticeable... the lib/images/math directory is only 6 megs in size. I don't know how the resource file is used within Qt but I guess that not everything is put in memory... not sure though. Abdel.
Re: [Patch] use Qt resources
Jean-Marc Lasgouttes wrote: Abdelrazak Younes <[EMAIL PROTECTED]> writes: And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Is it still possible for a user to provide his own icons for the toolbar? As far as I see no, not yet. Otherwise the patch is a big regression for me (especially with 'presumed' faster loading). This should be fixed yes. We probably need an API for icon loading; but wait, we already have that in GuiToolbar.cpp: static QIcon getIcon(FuncRequest const & f, bool unknown) So, what do we want to support? I guess adding one or two cases for user icons should be easy. Abdel.
Re: [Patch] use Qt resources
Abdelrazak Younes <[EMAIL PROTECTED]> writes: > This should be fixed yes. We probably need an API for icon loading; > but wait, we already have that in GuiToolbar.cpp: > > static QIcon getIcon(FuncRequest const & f, bool unknown) > > So, what do we want to support? I guess adding one or two cases for > user icons should be easy. Yes it should. JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo "" > $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):&:' \ >> $@ echo "" >> $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Good - faster startup is always a good thing, the delay is noticeable now. Helge Hafting
Re: [Patch] use Qt resources
Alfredo Braunstein wrote: Andre Poenitz wrote: On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo "" > $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):&:' \ >> $@ echo "" >> $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Presumably faster loading. I haven't tested yet but I can imagine that reading one big file on disk is faster than reading 600 small files (this is for sure on Windows). Note that most of the icons are loaded on startup now that we have the math panels in the toolbars. Abdel.
Re: [Patch] use Qt resources
Andre Poenitz wrote: > On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: >> > This is a generated file built by >> > >> > Resources.qrc: >> > echo "" > $@ >> > find $(top_srcdir)/lib/images -name '*.png' \ >> > | sed -e 's:$(top_srcdir)/lib/\(.*\):> > | alias="\1">&:' \ >> > >> $@ >> > echo "" >> $@ >> >> What is the advantage of doing all these? > > Compiled-in resources vs 600 seperately installed files? And this is an advantage because? Note that it's a genuine question, I simply don't know. A/
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:45:30AM +0200, Jean-Marc Lasgouttes wrote: > Abdelrazak Younes <[EMAIL PROTECTED]> writes: > > >> And this is an advantage because? > > > > Presumably faster loading. I haven't tested yet but I can imagine that > > reading one big file on disk is faster than reading 600 small files > > (this is for sure on Windows). Note that most of the icons are loaded > > on startup now that we have the math panels in the toolbars. > > Is it still possible for a user to provide his own icons for the > toolbar? Otherwise the patch is a big regression for me (especially > with 'presumed' faster loading). *grr* Have you ever done that? Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:26:57AM +0200, Helge Hafting wrote: > Abdelrazak Younes wrote: > >Alfredo Braunstein wrote: > >>Andre Poenitz wrote: > >> > >>>On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: > >This is a generated file built by > > > >Resources.qrc: > >echo "" > $@ > >find $(top_srcdir)/lib/images -name '*.png' \ > >| sed -e 's:$(top_srcdir)/lib/\(.*\): >| alias="\1">&:' \ > >>> $@ > >echo "" >> $@ > What is the advantage of doing all these? > >>>Compiled-in resources vs 600 seperately installed files? > >> > >>And this is an advantage because? > > > >Presumably faster loading. I haven't tested yet but I can imagine that > >reading one big file on disk is faster than reading 600 small files > >(this is for sure on Windows). Note that most of the icons are loaded > >on startup now that we have the math panels in the toolbars. > Good - faster startup is always a good thing, the delay is noticeable now. It removes ~0.4s out of a total ~7s here, so ~5%. Not too much actually, but not bad either. It's hard to get 'real numbers' as after the first start there's a lot chached by the system (total time then <2s here). Andre'
Re: [Patch] use Qt resources
On Fri, Oct 19, 2007 at 10:06:21AM -0500, Bo Peng wrote: > > Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc > > -name option?) > > Please apply even a temporary fix. I can not compile under linux with this. I am going to fix it. The problem is that cmake adds the -name parameter to the rcc call. -- Enrico
Re: [Patch] use Qt resources
> Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc > -name option?) Please apply even a temporary fix. I can not compile under linux with this. Bo
Re: [Patch] use Qt resources
Abdelrazak Younes <[EMAIL PROTECTED]> writes: >> And this is an advantage because? > > Presumably faster loading. I haven't tested yet but I can imagine that > reading one big file on disk is faster than reading 600 small files > (this is for sure on Windows). Note that most of the icons are loaded > on startup now that we have the math panels in the toolbars. Is it still possible for a user to provide his own icons for the toolbar? Otherwise the patch is a big regression for me (especially with 'presumed' faster loading). JMarc
Re: [Patch] use Qt resources
Abdelrazak Younes wrote: Alfredo Braunstein wrote: directory is only 6 megs in size. I don't know how the resource file is Note that lib/images (*including* lib/images/math) is just 7.9M. Right, we make a good team! Hum not so good as we are both wrong! We should not count the .svn/ directory... images/math/ is actually 2.9M. used within Qt but I guess that not everything is put in memory... not sure though. Another thing that makes me wonder, the 1.5.x lib/images dir with .xpm images was only 2.9M. Did the xpm -> png change had some impact on load time? No the size are approximately the same, see above... Abdel.
Re: [Patch] use Qt resources
On Wed, Oct 17, 2007 at 09:55:53PM -0500, Bo Peng wrote: On 10/16/07, Andre Poenitz [EMAIL PROTECTED] wrote: On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: Could somebody on Windows please try this one? [It should work] Also anu observations on startup speed are welcome. Slightly more complete patch attached. I get src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()' collect2: ld returned 1 exit status Scons? There's a Resources.cpp to be build and compiled in frontends/qt4. Andre'
Re: [Patch] use Qt resources
Scons? There's a Resources.cpp to be build and compiled in frontends/qt4. There is no such file. Did you add it to svn? Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 08:47:18AM -0500, Bo Peng wrote: Scons? There's a Resources.cpp to be build and compiled in frontends/qt4. There is no such file. Did you add it to svn? This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ Resources.cpp: Resources.qrc $(RCC4) $ -o $@ in the automake version. As resources do not change very often we could add Resources.cpp to svn but I'd rather always generate it. Andre'
Re: [Patch] use Qt resources
This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 01:32:44PM -0500, Bo Peng wrote: On 10/18/07, Bo Peng [EMAIL PROTECTED] wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ OK. Scons is fixed for this. Abdel seems to have the same problem with cmake. I did ask people to test he patch, didn't I? Andre'
Re: [Patch] use Qt resources
What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? Makes sense. Thanks. BTW, you use find to get all the images under lib/images, but some of them are unused. Scons only compiles the used ones that are listed in scons_manifest. Bo
Re: [Patch] use Qt resources
OK. Scons is fixed for this. Abdel seems to have the same problem with cmake. I did ask people to test he patch, didn't I? You did ask, but I had no idea what your patch was about, and did not test. Bo
Re: [Patch] use Qt resources
On 10/18/07, Bo Peng [EMAIL PROTECTED] wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ OK. Scons is fixed for this. Abdel seems to have the same problem with cmake. Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: This is a generated file built by Resources.qrc: echo !DOCTYPE RCCRCC version='1.0'qresource $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):file alias=\1/file:' \ $@ echo /qresource/RCC $@ What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? Andre'
Re: [Patch] use Qt resources
Andre Poenitz wrote: On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: Could somebody on Windows please try this one? [It should work] Also anu observations on startup speed are welcome. Slightly more complete patch attached. Andre' + +static void initializeResources() +{ + extern void qInitResources(); + static bool initialized = false; + if (!initialized) { + qInitResources(); + initialized = true; + } +} + + I've replaced your qInitResources() with the 'official' Qt Q_INIT_RESOURCE(Resources) because on windows the rcc generates qInitResources_Resources(). Also cmake is now up to date. Peter
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 01:51:35PM -0500, Bo Peng wrote: What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? Makes sense. Thanks. BTW, you use find to get all the images under lib/images, but some of them are unused. Scons only compiles the used ones that are listed in scons_manifest. Would anybody object to remove the unused ones? Andre'
Re: [Patch] use Qt resources
BTW, you use find to get all the images under lib/images, but some of them are unused. Scons only compiles the used ones that are listed in scons_manifest. Would anybody object to remove the unused ones? I am not quite sure. For example, I can add font-bold to ui/stdtoolbar.inc, and font-bold.png would better be there... Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 04:07:56PM -0500, Bo Peng wrote: BTW, you use find to get all the images under lib/images, but some of them are unused. Scons only compiles the used ones that are listed in scons_manifest. Would anybody object to remove the unused ones? I am not quite sure. For example, I can add font-bold to ui/stdtoolbar.inc, and font-bold.png would better be there... Bo +1 (Surely you mean font-strong.png :-) - Martin
Re: [Patch] use Qt resources
I've replaced your qInitResources() with the 'official' Qt Q_INIT_RESOURCE(Resources) because on windows the rcc generates qInitResources_Resources(). I do not know what is going on here, but Linux/qt does not have qInitResources_Resources()... and now I am getting src/frontends/qt4/GuiToolbar.cpp:50: undefined reference to `qInitResources_Resources()' Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Bo
Re: [Patch] use Qt resources
On Wed, Oct 17, 2007 at 09:55:53PM -0500, Bo Peng wrote: > On 10/16/07, Andre Poenitz <[EMAIL PROTECTED]> wrote: > > On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: > > > > > > Could somebody on Windows please try this one? > > > > > > [It should work] > > > > > > Also anu observations on startup speed are welcome. > > > > Slightly more complete patch attached. > > I get > > src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()' > collect2: ld returned 1 exit status Scons? There's a Resources.cpp to be build and compiled in frontends/qt4. Andre'
Re: [Patch] use Qt resources
> Scons? > > There's a Resources.cpp to be build and compiled in frontends/qt4. There is no such file. Did you add it to svn? Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 08:47:18AM -0500, Bo Peng wrote: > > Scons? > > > > There's a Resources.cpp to be build and compiled in frontends/qt4. > > There is no such file. Did you add it to svn? This is a generated file built by Resources.qrc: echo "" > $@ find $(top_srcdir)/lib/images -name '*.png' \ | sed -e 's:$(top_srcdir)/lib/\(.*\):&:' \ >> $@ echo "" >> $@ Resources.cpp: Resources.qrc $(RCC4) $< -o $@ in the automake version. As resources do not change very often we could add Resources.cpp to svn but I'd rather always generate it. Andre'
Re: [Patch] use Qt resources
> This is a generated file built by > > Resources.qrc: > echo "" > $@ > find $(top_srcdir)/lib/images -name '*.png' \ > | sed -e 's:$(top_srcdir)/lib/\(.*\): alias="\1">&:' \ > >> $@ > echo "" >> $@ What is the advantage of doing all these? Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 01:32:44PM -0500, Bo Peng wrote: > On 10/18/07, Bo Peng <[EMAIL PROTECTED]> wrote: > > > This is a generated file built by > > > > > > Resources.qrc: > > > echo "" > $@ > > > find $(top_srcdir)/lib/images -name '*.png' \ > > > | sed -e 's:$(top_srcdir)/lib/\(.*\): > > alias="\1">&:' \ > > > >> $@ > > > echo "" >> $@ > > OK. Scons is fixed for this. Abdel seems to have the same problem with cmake. I did ask people to test he patch, didn't I? Andre'
Re: [Patch] use Qt resources
> > What is the advantage of doing all these? > > Compiled-in resources vs 600 seperately installed files? Makes sense. Thanks. BTW, you use find to get all the images under lib/images, but some of them are unused. Scons only compiles the used ones that are listed in scons_manifest. Bo
Re: [Patch] use Qt resources
> > OK. Scons is fixed for this. Abdel seems to have the same problem with > > cmake. > > I did ask people to test he patch, didn't I? You did ask, but I had no idea what your patch was about, and did not test. Bo
Re: [Patch] use Qt resources
On 10/18/07, Bo Peng <[EMAIL PROTECTED]> wrote: > > This is a generated file built by > > > > Resources.qrc: > > echo "" > $@ > > find $(top_srcdir)/lib/images -name '*.png' \ > > | sed -e 's:$(top_srcdir)/lib/\(.*\): > alias="\1">&:' \ > > >> $@ > > echo "" >> $@ OK. Scons is fixed for this. Abdel seems to have the same problem with cmake. Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 12:20:23PM -0500, Bo Peng wrote: > > This is a generated file built by > > > > Resources.qrc: > > echo "" > $@ > > find $(top_srcdir)/lib/images -name '*.png' \ > > | sed -e 's:$(top_srcdir)/lib/\(.*\): > alias="\1">&:' \ > > >> $@ > > echo "" >> $@ > > What is the advantage of doing all these? Compiled-in resources vs 600 seperately installed files? Andre'
Re: [Patch] use Qt resources
Andre Poenitz wrote: On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: Could somebody on Windows please try this one? [It should work] Also anu observations on startup speed are welcome. Slightly more complete patch attached. Andre' + +static void initializeResources() +{ + extern void qInitResources(); + static bool initialized = false; + if (!initialized) { + qInitResources(); + initialized = true; + } +} + + I've replaced your qInitResources() with the 'official' Qt Q_INIT_RESOURCE(Resources) because on windows the rcc generates qInitResources_Resources(). Also cmake is now up to date. Peter
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 01:51:35PM -0500, Bo Peng wrote: > > > What is the advantage of doing all these? > > > > Compiled-in resources vs 600 seperately installed files? > > Makes sense. Thanks. > > BTW, you use find to get all the images under lib/images, but some of > them are unused. Scons only compiles the used ones that are listed in > scons_manifest. Would anybody object to remove the unused ones? Andre'
Re: [Patch] use Qt resources
> > BTW, you use find to get all the images under lib/images, but some of > > them are unused. Scons only compiles the used ones that are listed in > > scons_manifest. > > Would anybody object to remove the unused ones? I am not quite sure. For example, I can add font-bold to ui/stdtoolbar.inc, and font-bold.png would better be there... Bo
Re: [Patch] use Qt resources
On Thu, Oct 18, 2007 at 04:07:56PM -0500, Bo Peng wrote: > > > BTW, you use find to get all the images under lib/images, but some of > > > them are unused. Scons only compiles the used ones that are listed in > > > scons_manifest. > > > > Would anybody object to remove the unused ones? > > I am not quite sure. For example, I can add font-bold to > ui/stdtoolbar.inc, and font-bold.png would better be there... > > Bo +1 (Surely you mean font-strong.png :-) - Martin
Re: [Patch] use Qt resources
> I've replaced your qInitResources() with the 'official' Qt > Q_INIT_RESOURCE(Resources) because on windows the > rcc generates qInitResources_Resources(). > I do not know what is going on here, but Linux/qt does not have qInitResources_Resources()... and now I am getting src/frontends/qt4/GuiToolbar.cpp:50: undefined reference to `qInitResources_Resources()' Please #ifdef WIN32, or apply a proper solution. (Or should I use rcc -name option?) Bo
Re: [Patch] use Qt resources
On 10/16/07, Andre Poenitz [EMAIL PROTECTED] wrote: On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: Could somebody on Windows please try this one? [It should work] Also anu observations on startup speed are welcome. Slightly more complete patch attached. I get src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()' collect2: ld returned 1 exit status Bo
Re: [Patch] use Qt resources
On 10/16/07, Andre Poenitz <[EMAIL PROTECTED]> wrote: > On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: > > > > Could somebody on Windows please try this one? > > > > [It should work] > > > > Also anu observations on startup speed are welcome. > > Slightly more complete patch attached. I get src/frontends/qt4/GuiToolbar.cpp:51: undefined reference to `qInitResources()' collect2: ld returned 1 exit status Bo
Re: [Patch] use Qt resources
On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: Could somebody on Windows please try this one? [It should work] Also anu observations on startup speed are welcome. Slightly more complete patch attached. Andre' Index: GuiToolbar.cpp === --- GuiToolbar.cpp (revision 20995) +++ GuiToolbar.cpp (working copy) @@ -33,7 +33,6 @@ #include qt_helpers.h #include InsertTableWidget.h -#include support/filetools.h #include support/lstrings.h #include support/lyxalgo.h // sorted @@ -43,20 +42,28 @@ #include QAction #include QPixmap + +static void initializeResources() +{ + extern void qInitResources(); + static bool initialized = false; + if (!initialized) { + qInitResources(); + initialized = true; + } +} + + namespace lyx { +namespace frontend { using std::string; using std::endl; -using support::FileName; -using support::libFileSearch; using support::subst; using support::compare; -namespace frontend { - - namespace { struct PngMap { @@ -152,8 +159,7 @@ LYXERR(Debug::GUI) find_png( name )\n Looking for math PNG called \ png_name '' std::endl; - - return libFileSearch(images/math/, png_name, png).absFilename(); + return png_name; } } // namespace anon @@ -162,44 +168,41 @@ /// return a icon for the given action static QIcon getIcon(FuncRequest const f, bool unknown) { - string fullname; + initializeResources(); + QPixmap pm; + string name1; + string name2; switch (f.action) { case LFUN_MATH_INSERT: if (!f.argument().empty()) - fullname = find_png(to_utf8(f.argument()).substr(1)); + name1 = math/ + find_png(to_utf8(f.argument()).substr(1)); break; case LFUN_MATH_DELIM: case LFUN_MATH_BIGDELIM: - fullname = find_png(to_utf8(f.argument())); + name1 = find_png(to_utf8(f.argument())); break; default: - string const name = lyxaction.getActionName(f.action); - string png_name = name; + name2 = lyxaction.getActionName(f.action); + name1 = name2; if (!f.argument().empty()) - png_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_'); + name1 = subst(name2 + ' ' + to_utf8(f.argument()), ' ', '_'); + } - fullname = libFileSearch(images, png_name, png).absFilename(); + if (pm.load(:/images/ + toqstr(name1) + .png)) + return pm; - if (fullname.empty()) { - // try without the argument - fullname = libFileSearch(images, name, png).absFilename(); - } - } + if (pm.load(:/images/ + toqstr(name2) + .png)) + return pm; - if (!fullname.empty()) { - LYXERR(Debug::GUI) Full icon name is ` - fullname '\'' endl; - return QIcon(toqstr(fullname)); - } - LYXERR(Debug::GUI) Cannot find icon for command \ lyxaction.getActionName(f.action) '(' to_utf8(f.argument()) )\ endl; if (unknown) - return QIcon(toqstr(libFileSearch(images, unknown, png).absFilename())); - return QIcon(); + pm.load(:/images/unknown.png); + + return pm; } @@ -261,8 +264,7 @@ TextClass::const_iterator const end = tc.end(); for (; it != end; ++it) { // ignore obsolete entries - if ((*it)-obsoleted_by().empty()) - addItem(toqstr(translateIfPossible((*it)-name(; + addItem(toqstr(translateIfPossible((*it)-name(; } // needed to recalculate size hint @@ -290,8 +292,7 @@ return; } } - lyxerr ERROR (layoutSelected): layout not found! - endl; + lyxerr ERROR (layoutSelected): layout not found! endl; } @@ -396,8 +397,7 @@ tb-setToolTip(qt_(to_ascii(item.label_))); tb-setStatusTip(qt_(to_ascii(item.label_))); tb-setText(qt_(to_ascii(item.label_))); - FileName icon_path = libFileSearch(images/math, item.name_, png); - tb-setIcon(QIcon(toqstr(icon_path.absFilename(; + tb-setIcon(QPixmap(:images/math/ + toqstr(item.name_) + .png)); connect(this, SIGNAL(iconSizeChanged(QSize)), tb, SLOT(setIconSize(QSize)));
Re: [Patch] use Qt resources
On Tue, Oct 16, 2007 at 11:11:23PM +0200, Andre Poenitz wrote: > > Could somebody on Windows please try this one? > > [It should work] > > Also anu observations on startup speed are welcome. Slightly more complete patch attached. Andre' Index: GuiToolbar.cpp === --- GuiToolbar.cpp (revision 20995) +++ GuiToolbar.cpp (working copy) @@ -33,7 +33,6 @@ #include "qt_helpers.h" #include "InsertTableWidget.h" -#include "support/filetools.h" #include "support/lstrings.h" #include "support/lyxalgo.h" // sorted @@ -43,20 +42,28 @@ #include #include + +static void initializeResources() +{ + extern void qInitResources(); + static bool initialized = false; + if (!initialized) { + qInitResources(); + initialized = true; + } +} + + namespace lyx { +namespace frontend { using std::string; using std::endl; -using support::FileName; -using support::libFileSearch; using support::subst; using support::compare; -namespace frontend { - - namespace { struct PngMap { @@ -152,8 +159,7 @@ LYXERR(Debug::GUI) << "find_png(" << name << ")\n" << "Looking for math PNG called \"" << png_name << '"' << std::endl; - - return libFileSearch("images/math/", png_name, "png").absFilename(); + return png_name; } } // namespace anon @@ -162,44 +168,41 @@ /// return a icon for the given action static QIcon getIcon(FuncRequest const & f, bool unknown) { - string fullname; + initializeResources(); + QPixmap pm; + string name1; + string name2; switch (f.action) { case LFUN_MATH_INSERT: if (!f.argument().empty()) - fullname = find_png(to_utf8(f.argument()).substr(1)); + name1 = "math/" + find_png(to_utf8(f.argument()).substr(1)); break; case LFUN_MATH_DELIM: case LFUN_MATH_BIGDELIM: - fullname = find_png(to_utf8(f.argument())); + name1 = find_png(to_utf8(f.argument())); break; default: - string const name = lyxaction.getActionName(f.action); - string png_name = name; + name2 = lyxaction.getActionName(f.action); + name1 = name2; if (!f.argument().empty()) - png_name = subst(name + ' ' + to_utf8(f.argument()), ' ', '_'); + name1 = subst(name2 + ' ' + to_utf8(f.argument()), ' ', '_'); + } - fullname = libFileSearch("images", png_name, "png").absFilename(); + if (pm.load(":/images/" + toqstr(name1) + ".png")) + return pm; - if (fullname.empty()) { - // try without the argument - fullname = libFileSearch("images", name, "png").absFilename(); - } - } + if (pm.load(":/images/" + toqstr(name2) + ".png")) + return pm; - if (!fullname.empty()) { - LYXERR(Debug::GUI) << "Full icon name is `" - << fullname << '\'' << endl; - return QIcon(toqstr(fullname)); - } - LYXERR(Debug::GUI) << "Cannot find icon for command \"" << lyxaction.getActionName(f.action) << '(' << to_utf8(f.argument()) << ")\"" << endl; if (unknown) - return QIcon(toqstr(libFileSearch("images", "unknown", "png").absFilename())); - return QIcon(); + pm.load(":/images/unknown.png"); + + return pm; } @@ -261,8 +264,7 @@ TextClass::const_iterator const end = tc.end(); for (; it != end; ++it) { // ignore obsolete entries - if ((*it)->obsoleted_by().empty()) - addItem(toqstr(translateIfPossible((*it)->name(; + addItem(toqstr(translateIfPossible((*it)->name(; } // needed to recalculate size hint @@ -290,8 +292,7 @@ return; } } - lyxerr << "ERROR (layoutSelected): layout not found!" - << endl; + lyxerr << "ERROR (layoutSelected): layout not found!" << endl; } @@ -396,8 +397,7 @@ tb->setToolTip(qt_(to_ascii(item.label_))); tb->setStatusTip(qt_(to_ascii(item.label_))); tb->setText(qt_(to_ascii(item.label_))); - FileName icon_path = libFileSearch("images/math", item.name_, "png"); - tb->setIcon(QIcon(toqstr(icon_path.absFilename(; + tb->setIcon(QPixmap(":images/math/" + toqstr(item.name_) + ".png")); connect(this, SIGNAL(iconSizeChanged(QSize)), tb, SLOT(setIconSize(QSize)));