diff --git a/src/frontends/qt4/ColorCache.C b/src/frontends/qt4/ColorCache.C index daa697ccb5..80e9ad18ed 100644 --- a/src/frontends/qt4/ColorCache.C +++ b/src/frontends/qt4/ColorCache.C @@ -15,8 +15,6 @@ #include "LColor.h" -ColorCache lcolorcache; - const QColor grey40(0x66, 0x66, 0x66); const QColor grey60(0x99, 0x99, 0x99); const QColor grey80(0xcc, 0xcc, 0xcc); diff --git a/src/frontends/qt4/ColorCache.h b/src/frontends/qt4/ColorCache.h index df1c595382..0404a8a81f 100644 --- a/src/frontends/qt4/ColorCache.h +++ b/src/frontends/qt4/ColorCache.h @@ -44,9 +44,6 @@ private: mutable lcolor_map colormap; }; -/// singleton instance -extern ColorCache lcolorcache; - /// QColor const rgb2qcolor(lyx::RGBColor const &); #endif // COLORCACHE_H diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 8e11369c9e..aace15e84e 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -13,6 +13,7 @@ #ifndef QT4_APPLICATION_H #define QT4_APPLICATION_H +#include "ColorCache.h" #include "FontLoader.h" #include "GuiClipboard.h" #include "GuiImplementation.h" @@ -59,6 +60,8 @@ public: virtual void exit(int status); //@} + /// + ColorCache & colorCache() { return color_cache_; } /// FontLoader & fontLoader() { return font_loader_; } @@ -75,6 +78,8 @@ private: GuiSelection selection_; /// FontLoader font_loader_; + /// + ColorCache color_cache_; #ifdef Q_WS_X11 public: diff --git a/src/frontends/qt4/GuiWorkArea.C b/src/frontends/qt4/GuiWorkArea.C index da8a331081..dfbf30fbca 100644 --- a/src/frontends/qt4/GuiWorkArea.C +++ b/src/frontends/qt4/GuiWorkArea.C @@ -14,7 +14,6 @@ #include "GuiWorkArea.h" #include "GuiApplication.h" -#include "ColorCache.h" #include "QLPainter.h" #include "QLyXKeySym.h" #include "qt_helpers.h" @@ -493,7 +492,7 @@ void GuiWorkArea::showCursor(int x, int y, int h, CursorShape shape) show_vcursor_ = true; - QColor const & required_color = lcolorcache.get(LColor::cursor); + QColor const & required_color = guiApp->colorCache().get(LColor::cursor); if (x==cursor_x_ && y==cursor_y_ && h==cursor_h_ && cursor_color_ == required_color diff --git a/src/frontends/qt4/QBranches.C b/src/frontends/qt4/QBranches.C index 250b9b386b..eafdc536ae 100644 --- a/src/frontends/qt4/QBranches.C +++ b/src/frontends/qt4/QBranches.C @@ -13,7 +13,7 @@ #include "QBranches.h" -#include "ColorCache.h" +#include "GuiApplication.h" #include "validators.h" #include "qt_helpers.h" diff --git a/src/frontends/qt4/QLPainter.C b/src/frontends/qt4/QLPainter.C index a3c2383ac9..62976f682d 100644 --- a/src/frontends/qt4/QLPainter.C +++ b/src/frontends/qt4/QLPainter.C @@ -13,9 +13,9 @@ #include "QLPainter.h" +#include "GuiApplication.h" #include "GuiWorkArea.h" #include "QLImage.h" -#include "ColorCache.h" #include "FontLoader.h" #include "GuiApplication.h" @@ -93,7 +93,7 @@ void QLPainter::setQPainterPen(LColor_color col, QPen pen = qp_.get()->pen(); - pen.setColor(lcolorcache.get(col)); + pen.setColor(guiApp->colorCache().get(col)); switch (ls) { case line_solid: pen.setStyle(Qt::SolidLine); break; @@ -158,7 +158,7 @@ void QLPainter::rectangle(int x, int y, int w, int h, void QLPainter::fillRectangle(int x, int y, int w, int h, LColor_color col) { - qp_->fillRect(x, y, w, h, lcolorcache.get(col)); + qp_->fillRect(x, y, w, h, guiApp->colorCache().get(col)); } diff --git a/src/frontends/qt4/QPrefs.C b/src/frontends/qt4/QPrefs.C index 4f2e3f51ff..063ed36b07 100644 --- a/src/frontends/qt4/QPrefs.C +++ b/src/frontends/qt4/QPrefs.C @@ -13,7 +13,6 @@ #include "QPrefs.h" #include "QPrefsDialog.h" -#include "ColorCache.h" #include "Qt2BC.h" #include "qt_helpers.h" diff --git a/src/frontends/qt4/QPrefsDialog.C b/src/frontends/qt4/QPrefsDialog.C index 733018cb10..d3b5104b7d 100644 --- a/src/frontends/qt4/QPrefsDialog.C +++ b/src/frontends/qt4/QPrefsDialog.C @@ -13,7 +13,7 @@ #include "debug.h" #include "qt_helpers.h" -#include "ColorCache.h" +#include "GuiApplication.h" #include "Qt2BC.h" #include "qt_helpers.h" @@ -40,7 +40,6 @@ #include "gettext.h" #include "LColor.h" -#include "ColorCache.h" #include "controllers/ControlPrefs.h" @@ -519,7 +518,7 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent) || lc == LColor::ignore) continue; lcolors_.push_back(lc); - QColor color = QColor(lcolorcache.get(lc)); + QColor color = QColor(guiApp->colorCache().get(lc)); prefcolors_.push_back(color.name()); QPixmap coloritem(32, 32); coloritem.fill(color); diff --git a/src/frontends/qt4/lyx_gui.C b/src/frontends/qt4/lyx_gui.C index 7f3d51d526..a7255ddc5b 100644 --- a/src/frontends/qt4/lyx_gui.C +++ b/src/frontends/qt4/lyx_gui.C @@ -30,7 +30,6 @@ #include "GuiView.h" -#include "ColorCache.h" #include "FontLoader.h" #include "QLImage.h" #include "qt_helpers.h" @@ -167,7 +166,7 @@ FuncStatus getStatus(FuncRequest const & ev) bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol) { - QColor const & qcol = lcolorcache.get(col); + QColor const & qcol = guiApp->colorCache().get(col); if (!qcol.isValid()) { rgbcol.r = 0; rgbcol.g = 0; @@ -183,14 +182,14 @@ bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol) string const hexname(LColor_color col) { - return ltrim(fromqstr(lcolorcache.get(col).name()), "#"); + return ltrim(fromqstr(guiApp->colorCache().get(col).name()), "#"); } void update_color(LColor_color) { // FIXME: Bleh, can't we just clear them all at once ? - lcolorcache.clear(); + guiApp->colorCache().clear(); }