# HG changeset patch # User Torsten # Date 1511122517 -3600 # Node ID a669809df61276c39a6c5a471fac29d70cd91796 # Parent bda0c5b38bda9adb9840160a26d01f1d0cd50802 update wrong setting keys accidentally introduced into the settings file * octave-dock-widget.cc (handle_settings): check whether wrong settings keys fixed with cset bda0c5b38bda exist in the settings file and update them if so; * resource-manager.cc (do_update_settings_key): new function for testing existence of wrong settings key and copying it to the new one if necessary; * resource-manager.h (update_settings_key): static wrapper for new function do_update_settings_key diff -r bda0c5b38bda -r a669809df612 libgui/src/octave-dock-widget.cc --- a/libgui/src/octave-dock-widget.cc Sun Nov 12 22:10:46 2017 +0100 +++ b/libgui/src/octave-dock-widget.cc Sun Nov 19 21:15:17 2017 +0100 @@ -430,6 +430,20 @@ _title_3d = settings->value ("DockWidgets/widget_title_3d",50).toInt (); + // TODO: Until cset bda0c5b38bda, the wrong keys "Dockwidget/..." were used + // here. This had no effects in Qt4, but in Qt5. In the following, the four + // wrong keys are updated if still present in the settings files. The keys + // are also used in the settings dialog, but octave_dock_widget::handle_settings + // is already called at program start. + // These tests can be removed in a future version of octave + resource_manager::update_settings_key ("Dockwidgets/title_bg_color", + "DockWidgets/title_bg_color"); + resource_manager::update_settings_key ("Dockwidgets/title_bg_color_active", + "DockWidgets/title_bg_color_active"); + resource_manager::update_settings_key ("Dockwidgets/title_fg_color", + "DockWidgets/title_fg_color"); + resource_manager::update_settings_key ("Dockwidgets/title_fg_color_active", + "DockWidgets/title_fg_color_active"); QColor default_var = QColor (0,0,0); _fg_color = settings->value ("DockWidgets/title_fg_color", default_var).value (); diff -r bda0c5b38bda -r a669809df612 libgui/src/resource-manager.cc --- a/libgui/src/resource-manager.cc Sun Nov 12 22:10:46 2017 +0100 +++ b/libgui/src/resource-manager.cc Sun Nov 19 21:15:17 2017 +0100 @@ -256,6 +256,21 @@ } bool +resource_manager::do_update_settings_key (const QString& old_key, const QString& new_key) +{ + if (settings->contains (old_key)) + { + QVariant preference = settings->value (old_key); + settings->setValue (new_key, preference); + settings->remove (old_key); + return true; + } + + return false; +} + + +bool resource_manager::do_is_first_run (void) const { return ! QFile::exists (settings_file); diff -r bda0c5b38bda -r a669809df612 libgui/src/resource-manager.h --- a/libgui/src/resource-manager.h Sun Nov 12 22:10:46 2017 +0100 +++ b/libgui/src/resource-manager.h Sun Nov 19 21:15:17 2017 +0100 @@ -77,6 +77,12 @@ instance->do_set_settings (file); } + static bool update_settings_key (const QString& new_key, const QString& old_key) + { + return instance_ok () ? + instance->do_update_settings_key (new_key, old_key) : false; + } + static void combo_encoding (QComboBox *combo, QString current = QString ()) { if (instance_ok ()) @@ -138,6 +144,8 @@ void do_set_settings (const QString& file); + bool do_update_settings_key (const QString& new_key, const QString& old_key); + void do_update_network_settings (void); bool do_is_first_run (void) const;