changeset 18946:0be65bd7f369 gui-release

add an user preference for loading changed files without a prompt (bug #42678) * file-editor-tab.cc (file_has_changed): check user preference before prompting for reloading the file; (notice-settings): get flag for prompting before reloading file from settings; * file-editor-tab.h: new flag _always_reload_changed files * settings-dialog.ui: new check box for new preference * settings-dialog.cc (constructor): get state of new check box from settings; (write_changes_settings): write state of new check box into settings
author Torsten <ttl@justmail.de>
date Sun, 20 Jul 2014 21:23:32 +0200
parents d2100cb2331a
children c6b89c4a9e63
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui
diffstat 4 files changed, 37 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sun Jul 20 20:52:08 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Jul 20 21:23:32 2014 +0200
@@ -1432,21 +1432,28 @@
 
   if (QFile::exists (_file_name))
     {
-      // Create a WindowModal message that blocks the edit area
-      // by making _edit_area parent.
-      QMessageBox* msgBox
-        = new QMessageBox (QMessageBox::Warning,
-                           tr ("Octave Editor"),
-                           tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?").
-                           arg (_file_name),
-                           QMessageBox::Yes | QMessageBox::No, this);
+      if (_always_reload_changed_files)
+
+              load_file (_file_name);
 
-      connect (msgBox, SIGNAL (finished (int)),
-               this, SLOT (handle_file_reload_answer (int)));
+      else
+        {
+          // Create a WindowModal message that blocks the edit area
+          // by making _edit_area parent.
+          QMessageBox* msgBox
+            = new QMessageBox (QMessageBox::Warning,
+                               tr ("Octave Editor"),
+                               tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?").
+                               arg (_file_name),
+                               QMessageBox::Yes | QMessageBox::No, this);
 
-      msgBox->setWindowModality (Qt::WindowModal);
-      msgBox->setAttribute (Qt::WA_DeleteOnClose);
-      msgBox->show ();
+          connect (msgBox, SIGNAL (finished (int)),
+                   this, SLOT (handle_file_reload_answer (int)));
+
+          msgBox->setWindowModality (Qt::WindowModal);
+          msgBox->setAttribute (Qt::WA_DeleteOnClose);
+          msgBox->show ();
+        }
     }
   else
     {
@@ -1577,6 +1584,9 @@
   else
     _edit_area->setEdgeMode (QsciScintilla::EdgeNone);
 
+  // reload changed files
+  _always_reload_changed_files = 
+        settings->value ("editor/always_reload_changed_files",false).toBool ();
 }
 
 void
--- a/libgui/src/m-editor/file-editor-tab.h	Sun Jul 20 20:52:08 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.h	Sun Jul 20 21:23:32 2014 +0200
@@ -224,6 +224,7 @@
   bool _app_closing;
   bool _is_octave_file;
   bool _modal_dialog;
+  bool _always_reload_changed_files;
 
   QFileSystemWatcher _file_system_watcher;
 
--- a/libgui/src/settings-dialog.cc	Sun Jul 20 20:52:08 2014 +0200
+++ b/libgui/src/settings-dialog.cc	Sun Jul 20 21:23:32 2014 +0200
@@ -206,6 +206,8 @@
     settings->value ("editor/restoreSession", true).toBool ());
   ui->editor_create_new_file->setChecked (
     settings->value ("editor/create_new_file",false).toBool ());
+  ui->editor_reload_changed_files->setChecked (
+    settings->value ("editor/always_reload_changed_files",false).toBool ());
 
   // terminal
   ui->terminal_fontName->setCurrentFont (QFont (
@@ -649,6 +651,8 @@
                       ui->editor_restoreSession->isChecked ());
   settings->setValue ("editor/create_new_file",
                       ui->editor_create_new_file->isChecked ());
+  settings->setValue ("editor/always_reload_changed_files",
+                      ui->editor_reload_changed_files->isChecked ());
   settings->setValue ("terminal/fontSize", ui->terminal_fontSize->value ());
   settings->setValue ("terminal/fontName",
                       ui->terminal_fontName->currentFont ().family ());
--- a/libgui/src/settings-dialog.ui	Sun Jul 20 20:52:08 2014 +0200
+++ b/libgui/src/settings-dialog.ui	Sun Jul 20 21:23:32 2014 +0200
@@ -404,9 +404,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>-146</y>
+            <y>-175</y>
             <width>662</width>
-            <height>553</height>
+            <height>580</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -1083,6 +1083,13 @@
                  </property>
                 </widget>
                </item>
+               <item>
+                <widget class="QCheckBox" name="editor_reload_changed_files">
+                 <property name="text">
+                  <string>Reload externally changed files without prompt</string>
+                 </property>
+                </widget>
+               </item>
               </layout>
              </item>
              <item>