changeset 26927:df9fe0026f73

use user cache location for keyword lists for auto completion (bug #55855) * file-editor-tab.cc (update_lexer_settings): get user cache location, set path for prepared apis files to this location where application name is temporarily set to octave (not GNU Octave) preventing blanks in the path
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 15 Mar 2019 22:54:19 +0100
parents 71724787d972
children c8055304ad21
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 19 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Mar 15 21:09:19 2019 +0000
+++ b/libgui/src/m-editor/file-editor-tab.cc	Fri Mar 15 22:54:19 2019 +0100
@@ -638,9 +638,23 @@
 
         bool update_apis = false;  // flag, whether update of apis files
 
-        // get path to prepared api info
-        QFileInfo settings_file = resource_manager::get_settings_file ();
-        QString prep_apis_path = settings_file.absolutePath () + "/"
+        // Get path to prepared api info (cache). Temporarily set the
+        // application name to 'octave' instead of 'GNU Octave' name for
+        // not having blanks in the path.
+        QString tmp_app_name = QCoreApplication::applicationName ();
+        QCoreApplication::setApplicationName ("octave");  // Set new name
+
+#if defined (HAVE_QSTANDARDPATHS)
+        QString local_data_path
+          = QStandardPaths::writableLocation (QStandardPaths::CacheLocation);
+#else
+        QString local_data_path
+          = QDesktopServices::storageLocation (QDesktopServices::CacheLocation);
+#endif
+
+        QCoreApplication::setApplicationName ("octave");  // Set temp. name
+
+        QString prep_apis_path = local_data_path + "/"
                                   + QString (OCTAVE_VERSION) + "/qsci/";
 
         // get settings which infos are used for octave
@@ -649,6 +663,8 @@
         bool octave_functions = settings->value (
                                   "editor/codeCompletion_octave_functions", true).toBool ();
 
+        QCoreApplication::setApplicationName (tmp_app_name);  // Restore name
+
         if (_is_octave_file)
           {
             // Keywords and Builtins do not change, these informations can be