On 10/12/12 22:25, Richard Heck wrote: > On 12/10/2012 05:16 PM, Tommaso Cucinotta wrote: >> On 10/12/12 21:46, Tommaso Cucinotta wrote: >>> when exporting from the command-line, theApp() doesn't exist. Any >>> possible/meaningful replacement for these hexName() call ? >> Just came across the attached solution that seems better. Any comment ? >> Objections to commit ? >> Don't know why I had to add "QtGui/" in a couple of includes in >> ColorCache.h. Different CPPFLAGS are provided for the objects in graphics/ >> and >> the ones in qt4/ ? > Are we sure you attached the right patch? This one seems to have my name on > it, and no QtGui/ business that I can see.
Ehm, I just made a big mess with git :-), sorry about that. Pls, see the attached one instead. T.
commit 9cda3c2 Author: Tommaso Cucinotta <tomm...@lyx.org> Date: Mon Dec 10 23:22:10 2012 +0000 While exporting from the command-line, theApp() doesn't exist. It was only needed for getting hex names of colors. So, get them directly from a ColorCache object with default mapping. diff --git a/src/frontends/qt4/ColorCache.h b/src/frontends/qt4/ColorCache.h index e1ad6ae..79a25eb 100644 --- a/src/frontends/qt4/ColorCache.h +++ b/src/frontends/qt4/ColorCache.h @@ -14,8 +14,8 @@ #include "Color.h" -#include <QColor> -#include <QPalette> +#include <QtGui/QColor> +#include <QtGui/QPalette> namespace lyx { diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp index 6185681..ce273aa 100644 --- a/src/graphics/PreviewLoader.cpp +++ b/src/graphics/PreviewLoader.cpp @@ -27,6 +27,7 @@ #include "TexRow.h" #include "frontends/Application.h" // hexName +#include "frontends/qt4/ColorCache.h" #include "insets/Inset.h" @@ -36,6 +37,7 @@ #include "support/filetools.h" #include "support/ForkedCalls.h" #include "support/lstrings.h" +#include "support/qstring_helpers.h" #include "support/bind.h" @@ -587,16 +589,26 @@ void PreviewLoader::Impl::startLoading(bool wait) // FIXME XHTML // The colors should be customizable. ColorCode const bg = buffer_.isExporting() - ? Color_white : PreviewLoader::backgroundColor(); + ? Color_white : PreviewLoader::backgroundColor(); ColorCode const fg = buffer_.isExporting() - ? Color_black : PreviewLoader::foregroundColor(); + ? Color_black : PreviewLoader::foregroundColor(); + std::string bg_name, fg_name; + if (theApp()) { + fg_name = theApp()->hexName(fg); + bg_name = theApp()->hexName(bg); + } else { + ColorCache cc; + fg_name = ltrim(fromqstr(cc.get(fg).name()), "#"); + bg_name = ltrim(fromqstr(cc.get(bg).name()), "#"); + } + // The conversion command. ostringstream cs; cs << pconverter_->command << " " << quoteName(latexfile.toFilesystemEncoding()) << " --dpi " << int(font_scaling_factor) - << " --fg " << theApp()->hexName(fg) - << " --bg " << theApp()->hexName(bg); + << " --fg " << fg_name + << " --bg " << bg_name; // FIXME what about LuaTeX? if (buffer_.params().useNonTeXFonts) cs << " --latex=xelatex";