changeset 17740:e6ed77b75aec

new preference in settings: editor creates nonexisting files wihtout prompt * settings-dialog.ui: adding checkbox for new preference * settings-dialog.cc(constructor): reading new option from the settings and initializing new checkbox; (write_changed_settings): write checkbox state into the settings file * file_editor.cc(request_opren_file): when file to open does not exist read new option from the settings and skip the dialog accordingly
author Torsten <ttl@justmail.de>
date Wed, 23 Oct 2013 22:20:06 +0200
parents 0640892429a8
children f6293489fe88
files libgui/src/m-editor/file-editor.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui
diffstat 3 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Wed Oct 23 21:05:53 2013 +0200
+++ b/libgui/src/m-editor/file-editor.cc	Wed Oct 23 22:20:06 2013 +0200
@@ -312,17 +312,24 @@
                     }
                   else
                     {
-                      // File does not exist
-                      QMessageBox *msgBox
-                        = new QMessageBox (QMessageBox::Question,
-                           tr ("Octave Editor"),
-                           tr ("File\n%1\ndoes not exist. "
-                               "Do you want to create it?").arg (openFileName),
-                           QMessageBox::Yes | QMessageBox::No, this);
+                      // File does not exist, should it be crated?
+                      QMessageBox *msgBox;
+                      int answer;
+                      if (settings->value ("editor/create_new_file",false).toBool ())
+                        {
+                          answer = QMessageBox::Yes;
+                        }
+                      else
+                        {
+                           msgBox = new QMessageBox (QMessageBox::Question,
+                               tr ("Octave Editor"),
+                               tr ("File\n%1\ndoes not exist. "
+                                   "Do you want to create it?").arg (openFileName),
+                               QMessageBox::Yes | QMessageBox::No, this);
 
-                      // msgBox->setWindowModality (Qt::Modal);
-                      msgBox->setAttribute (Qt::WA_DeleteOnClose);
-                      int answer = msgBox->exec ();
+                          msgBox->setAttribute (Qt::WA_DeleteOnClose);
+                          answer = msgBox->exec ();
+                        }
 
                       if (answer == QMessageBox::Yes)
                         {
--- a/libgui/src/settings-dialog.cc	Wed Oct 23 21:05:53 2013 +0200
+++ b/libgui/src/settings-dialog.cc	Wed Oct 23 22:20:06 2013 +0200
@@ -119,6 +119,7 @@
   ui->editor_tab_width_spinbox->setValue (settings->value ("editor/tab_width",2).toInt ());
   ui->editor_longWindowTitle->setChecked (settings->value ("editor/longWindowTitle",false).toBool ());
   ui->editor_restoreSession->setChecked (settings->value ("editor/restoreSession",true).toBool ());
+  ui->editor_create_new_file->setChecked (settings->value ("editor/create_new_file",false).toBool ());
   ui->terminal_fontName->setCurrentFont (QFont (settings->value ("terminal/fontName","Courier New").toString()) );
   ui->terminal_fontSize->setValue (settings->value ("terminal/fontSize",10).toInt ());
   ui->showFileSize->setChecked (settings->value ("filesdockwidget/showFileSize",false).toBool());
@@ -443,6 +444,7 @@
   settings->setValue ("editor/tab_width", ui->editor_tab_width_spinbox->value ());
   settings->setValue ("editor/longWindowTitle", ui->editor_longWindowTitle->isChecked());
   settings->setValue ("editor/restoreSession", ui->editor_restoreSession->isChecked ());
+  settings->setValue ("editor/create_new_file", ui->editor_create_new_file->isChecked ());
   settings->setValue ("terminal/fontSize", ui->terminal_fontSize->value());
   settings->setValue ("terminal/fontName", ui->terminal_fontName->currentFont().family());
   settings->setValue ("filesdockwidget/showFileSize", ui->showFileSize->isChecked ());
--- a/libgui/src/settings-dialog.ui	Wed Oct 23 21:05:53 2013 +0200
+++ b/libgui/src/settings-dialog.ui	Wed Oct 23 22:20:06 2013 +0200
@@ -710,6 +710,19 @@
              </property>
             </widget>
            </item>
+           <item>
+            <widget class="QCheckBox" name="editor_create_new file">
+             <property name="sizePolicy">
+              <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="text">
+              <string>Create non existing files without prompting</string>
+             </property>
+            </widget>
+           </item>
           </layout>
          </item>
         </layout>