comparison libgui/src/resource-manager.cc @ 31615:40b151abbb9b

don't attempt to restore settings from old qt-settings config file We changed the default settings file name in 2019. It's time to let the old name go. * resource-manager.cc (resource_manager::resource_manager): Don't attempt to copy settings from old qt-settings file used by Octave prior to March 2019.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Dec 2022 10:07:32 -0500
parents 59c9da7c43d6
children 726d2628752c
comparison
equal deleted inserted replaced
31614:59c9da7c43d6 31615:40b151abbb9b
74 74
75 m_settings_file = m_default_settings->fileName (); 75 m_settings_file = m_default_settings->fileName ();
76 76
77 QFileInfo sfile (m_settings_file); 77 QFileInfo sfile (m_settings_file);
78 m_settings_directory = sfile.absolutePath (); 78 m_settings_directory = sfile.absolutePath ();
79
80 QString xdg_config_home
81 = QString::fromLocal8Bit (qgetenv ("XDG_CONFIG_HOME"));
82
83 if ((! sfile.exists ()) && xdg_config_home.isEmpty ())
84 {
85 // File does not exist yet: Look for a settings file at the old
86 // location ($HOME/.config/octave/qt-settings) for impoting all
87 // available keys into the new settings file.
88 // Do not look for an old settings file if XDG_CONFIG_HOME is set,
89 // since then a nonexistent new settings file does not necessarily
90 // indicate a first run of octave with new config file locations.
91 #if defined (HAVE_QSTANDARDPATHS)
92 QString home_path
93 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation);
94 #else
95 QString home_path
96 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation);
97 #endif
98
99 QString old_settings_directory = home_path + "/.config/octave";
100 QString old_settings_file = old_settings_directory + "/qt-settings";
101
102 QFile ofile (old_settings_file);
103
104 if (ofile.exists ())
105 {
106 // Old settings file exists; create a gui_settings object related
107 // to it and copy all available keys to the new settings
108 gui_settings old_settings (old_settings_file, QSettings::IniFormat);
109
110 QStringList keys = old_settings.allKeys ();
111 for (int i = 0; i < keys.count(); i++)
112 m_default_settings->setValue (keys.at(i),
113 old_settings.value(keys.at(i)));
114
115 m_default_settings->sync (); // Done, make sure keys are written
116 }
117 }
118 } 79 }
119 80
120 resource_manager::~resource_manager (void) 81 resource_manager::~resource_manager (void)
121 { 82 {
122 delete m_settings; 83 delete m_settings;