# HG changeset patch # User John W. Eaton # Date 1368389868 14400 # Node ID 64f9a3e301d3fdb47e56ebe9f679df2adf3b046d # Parent 0ee7b4d1b940e2778daca8b169457ed0e5ce2a98 don't store default values in resource manager class * QTerminal.h, QTerminal.cc (QTerminal::default_colors, QTerminal::color_names): New functions. (QTerminal::notice_settings): Call default_colors. * workspace-model.h, workspace-model.cc (workspace_model::storage_class_default_colors, workspace_model::storage_class_names): New functions. * resource-manager.cc (resource_manager::storage_class_names, resource_manager::storage_class_default_colors): Get values from workspace_model. (resource_manager::terminal_color_names, resource_manager::terminal_default_colors): Get values from QTerminal. diff -r 0ee7b4d1b940 -r 64f9a3e301d3 libgui/qterminal/libqterminal/QTerminal.cc --- a/libgui/qterminal/libqterminal/QTerminal.cc Sun May 12 15:33:05 2013 -0400 +++ b/libgui/qterminal/libqterminal/QTerminal.cc Sun May 12 16:17:48 2013 -0400 @@ -38,6 +38,38 @@ #endif } +QList +QTerminal::default_colors (void) +{ + static QList colors; + + if (colors.isEmpty ()) + { + colors << QColor(0,0,0) + << QColor(255,255,255) + << QColor(192,192,192) + << QColor(128,128,128); + } + + return colors; +} + +QStringList +QTerminal::color_names (void) +{ + static QStringList names; + + if (names.isEmpty ()) + { + names << QObject::tr ("foreground") + << QObject::tr ("background") + << QObject::tr ("selection") + << QObject::tr ("cursor"); + } + + return names; +} + void QTerminal::notice_settings (const QSettings *settings) { @@ -68,29 +100,22 @@ bool cursorUseForegroundColor = settings->value ("terminal/cursorUseForegroundColor", true).toBool (); - // FIXME -- we shouldn't duplicate this information here and in the - // resource manager. - QList default_colors; - - default_colors << QColor(0,0,0) - << QColor(255,255,255) - << QColor(192,192,192) - << QColor(128,128,128); + QList colors = default_colors (); setForegroundColor (settings->value ("terminal/color_f", - QVariant (default_colors.at (0))).value ()); + QVariant (colors.at (0))).value ()); setBackgroundColor (settings->value ("terminal/color_b", - QVariant (default_colors.at (1))).value ()); + QVariant (colors.at (1))).value ()); setSelectionColor (settings->value ("terminal/color_s", - QVariant (default_colors.at (2))).value ()); + QVariant (colors.at (2))).value ()); setCursorColor (cursorUseForegroundColor, settings->value ("terminal/color_c", - QVariant (default_colors.at (3))).value ()); + QVariant (colors.at (3))).value ()); } diff -r 0ee7b4d1b940 -r 64f9a3e301d3 libgui/qterminal/libqterminal/QTerminal.h --- a/libgui/qterminal/libqterminal/QTerminal.h Sun May 12 15:33:05 2013 -0400 +++ b/libgui/qterminal/libqterminal/QTerminal.h Sun May 12 16:17:48 2013 -0400 @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include class QTerminal : public QWidget @@ -37,6 +39,10 @@ static QTerminal *create (QWidget *xparent = 0); + static QList default_colors (void); + + static QStringList color_names (void); + virtual ~QTerminal (void) { } virtual void setTerminalFont(const QFont& font) = 0; diff -r 0ee7b4d1b940 -r 64f9a3e301d3 libgui/src/resource-manager.cc --- a/libgui/src/resource-manager.cc Sun May 12 15:33:05 2013 -0400 +++ b/libgui/src/resource-manager.cc Sun May 12 16:17:48 2013 -0400 @@ -33,11 +33,14 @@ #include "error.h" #include "file-ops.h" +#include "help.h" #include "oct-env.h" #include "singleton-cleanup.h" #include "defaults.h" +#include "QTerminal.h" +#include "workspace-model.h" #include "resource-manager.h" resource_manager *resource_manager::instance = 0; @@ -198,41 +201,25 @@ QStringList resource_manager::storage_class_names (void) { - return QStringList () << QObject::tr ("automatic") - << QObject::tr ("function") - << QObject::tr ("global") - << QObject::tr ("hidden") - << QObject::tr ("inherited") - << QObject::tr ("persistent"); + return workspace_model::storage_class_names (); } QList resource_manager::storage_class_default_colors (void) { - return QList () << QColor(190,255,255) - << QColor(220,255,220) - << QColor(220,220,255) - << QColor(255,255,190) - << QColor(255,220,220) - << QColor(255,190,255); + return workspace_model::storage_class_default_colors (); } QStringList resource_manager::terminal_color_names (void) { - return QStringList () << QObject::tr ("foreground") - << QObject::tr ("background") - << QObject::tr ("selection") - << QObject::tr ("cursor"); + return QTerminal::color_names (); } QList resource_manager::terminal_default_colors (void) { - return QList () << QColor(0,0,0) - << QColor(255,255,255) - << QColor(192,192,192) - << QColor(128,128,128); + return QTerminal::default_colors (); } const char* diff -r 0ee7b4d1b940 -r 64f9a3e301d3 libgui/src/workspace-model.cc --- a/libgui/src/workspace-model.cc Sun May 12 15:33:05 2013 -0400 +++ b/libgui/src/workspace-model.cc Sun May 12 16:17:48 2013 -0400 @@ -46,6 +46,43 @@ } +QList +workspace_model::storage_class_default_colors (void) +{ + QList colors; + + if (colors.isEmpty ()) + { + colors << QColor (190,255,255) + << QColor (220,255,220) + << QColor (220,220,255) + << QColor (255,255,190) + << QColor (255,220,220) + << QColor (255,190,255); + } + + return colors; +} + + +QStringList +workspace_model::storage_class_names (void) +{ + QStringList names; + + if (names.isEmpty ()) + { + names << QObject::tr ("automatic") + << QObject::tr ("function") + << QObject::tr ("global") + << QObject::tr ("hidden") + << QObject::tr ("inherited") + << QObject::tr ("persistent"); + } + + return names; +} + int workspace_model::rowCount (const QModelIndex&) const { diff -r 0ee7b4d1b940 -r 64f9a3e301d3 libgui/src/workspace-model.h --- a/libgui/src/workspace-model.h Sun May 12 15:33:05 2013 -0400 +++ b/libgui/src/workspace-model.h Sun May 12 16:17:48 2013 -0400 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,10 @@ ~workspace_model (void) { } + static QList storage_class_default_colors (void); + + static QStringList storage_class_names (void); + QVariant data (const QModelIndex& index, int role) const; bool setData (const QModelIndex& index, const QVariant& value,