# HG changeset patch # User Torsten # Date 1357677312 -3600 # Node ID 85f9aca30c76a2281f7bc174b4844bb3ec830616 # Parent 8e38eac05230dcc75f235218f34ca29912394a40 gui: reorganized handling of different icons for dock widgets * main-window.cc(notice-settings): icon set is stored with its short name instead of a number; if no valid value is read from the settings, no special icons are set for the widgets * settings-dialog.cc(settings_dialog): changes for short names of icons; set radio buttom of no special icon per default (if settings value is not value) if value from settings file is invalid; * settings-dialog.cc(write_changes settings): changes for short names of icons * resource-manager.h: remove enum declaration for icon sets diff -r 8e38eac05230 -r 85f9aca30c76 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sun Jan 06 21:52:29 2013 -0800 +++ b/libgui/src/main-window.cc Tue Jan 08 21:35:12 2013 +0100 @@ -200,24 +200,15 @@ delete settingsDialog; } + void main_window::notice_settings () { - // FIXME -- was this supposed to be configurable in some way? If so, - // maybe it should be moved back to resource-manager.{h,cc}, but not - // as a static variable. - static const char *WIDGET_ICON_SET_PREFIX[] = - { - ":/actions/icons/logo.png", - ":/actions/icons/graphic_logo_", - ":/actions/icons/letter_logo_" - }; - - // Set terminal font: QSettings *settings = resource_manager::get_settings (); // FIXME -- what should happen if settings is 0? + // Set terminal font: QFont term_font = QFont(); term_font.setFamily(settings->value("terminal/fontName").toString()); term_font.setPointSize(settings->value("terminal/fontSize").toInt ()); @@ -234,8 +225,32 @@ cursorBlinking); // the widget's icons (when floating) - int icon_set = settings->value ("DockWidgets/widget_icon_set",0).toInt (); - QString icon_prefix = QString (WIDGET_ICON_SET_PREFIX[icon_set]); + QString icon_set = settings->value ("DockWidgets/widget_icon_set","NONE"). + toString (); + static struct + { + QString name; + QString path; + } + widget_icon_data[] = + { // array of possible icon sets (name, path (complete for NONE)) + // the first entry here is the default! + {"NONE", ":/actions/icons/logo.png"}, + {"GRAPHIC", ":/actions/icons/graphic_logo_"}, + {"LETTER", ":/actions/icons/letter_logo_"}, + {"", ""} // end marker has empty name + }; + int count = 0; + int icon_set_found = 0; // default + while (!widget_icon_data[count].name.isEmpty ()) + { // while not end of data + if (widget_icon_data[count].name == icon_set) + { // data of desired icon set found + icon_set_found = count; + break; + } + count++; + } QString icon; foreach (QObject *obj, children ()) { @@ -243,9 +258,9 @@ if (obj->inherits("QDockWidget") && ! name.isEmpty ()) { // if children is a dockwidget with a name QDockWidget *widget = qobject_cast (obj); - icon = icon_prefix; // prefix or octave-logo - if (icon_set) // > 0 : each widget has individual icon - icon = icon + name + QString(".png"); + icon = widget_icon_data[icon_set_found].path; // prefix or octave-logo + if (widget_icon_data[icon_set_found].name != "NONE") + icon = icon + name + ".png"; // add widget name and ext. widget->setWindowIcon (QIcon (icon)); } } @@ -253,6 +268,7 @@ resource_manager::update_network_settings (); } + void main_window::prepare_for_quit () { diff -r 8e38eac05230 -r 85f9aca30c76 libgui/src/resource-manager.h --- a/libgui/src/resource-manager.h Sun Jan 06 21:52:29 2013 -0800 +++ b/libgui/src/resource-manager.h Tue Jan 08 21:35:12 2013 +0100 @@ -28,13 +28,6 @@ #include #include -// constants for the widget's icons -enum widget_icon_set - { - NO_ICON_SET = 0, - GRAPHIC_ICON_SET, - LETTER_ICON_SET - }; class resource_manager { @@ -114,6 +107,7 @@ void do_update_network_settings (void); bool do_is_first_run (void); + }; #endif // RESOURCEMANAGER_H diff -r 8e38eac05230 -r 85f9aca30c76 libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Sun Jan 06 21:52:29 2013 -0800 +++ b/libgui/src/settings-dialog.cc Tue Jan 08 21:35:12 2013 +0100 @@ -38,10 +38,12 @@ // FIXME -- what should happen if settings is 0? - int widget_icon_set = settings->value ("DockWidgets/widget_icon_set",0).toInt (); - ui->general_icon_octave-> setChecked (NO_ICON_SET == widget_icon_set); - ui->general_icon_graphic-> setChecked (GRAPHIC_ICON_SET == widget_icon_set); - ui->general_icon_letter-> setChecked (LETTER_ICON_SET == widget_icon_set); + QString widget_icon_set = + settings->value ("DockWidgets/widget_icon_set","NONE").toString (); + ui->general_icon_octave-> setChecked (true); // the default (if invalid set) + ui->general_icon_octave-> setChecked (widget_icon_set == "NONE"); + ui->general_icon_graphic-> setChecked (widget_icon_set == "GRAPHIC"); + ui->general_icon_letter-> setChecked (widget_icon_set == "LETTER"); ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor").toBool ()); ui->customFileEditor->setText (settings->value ("customFileEditor").toString ()); @@ -105,11 +107,11 @@ // FIXME -- what should happen if settings is 0? - int widget_icon_set = NO_ICON_SET; + QString widget_icon_set = "NONE"; if (ui->general_icon_letter->isChecked ()) - widget_icon_set = LETTER_ICON_SET; + widget_icon_set = "LETTER"; else if (ui->general_icon_graphic->isChecked ()) - widget_icon_set = GRAPHIC_ICON_SET; + widget_icon_set = "GRAPHIC"; settings->setValue ("DockWidgets/widget_icon_set",widget_icon_set); settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); settings->setValue ("customFileEditor", ui->customFileEditor->text ());