# HG changeset patch
# User Kai T. Ohlhus <k.ohlhus@gmail.com>
# Date 1542278301 -3600
#      Thu Nov 15 11:38:21 2018 +0100
# Node ID 3f79d3dc0249cd53e494f48ad7d11667c263918d
# Parent  8b6f1731474babae07e0c1eab2d899c63950a0ba
Make use of native file dialogs configurable (bug #54607).

diff -r 8b6f1731474b -r 3f79d3dc0249 libgui/src/m-editor/file-editor-tab.cc
--- a/libgui/src/m-editor/file-editor-tab.cc	Wed Nov 14 10:57:46 2018 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Thu Nov 15 11:38:21 2018 +0100
@@ -2228,6 +2228,12 @@ namespace octave
     fileDialog->setAcceptMode (QFileDialog::AcceptSave);
     fileDialog->setViewMode (QFileDialog::Detail);
 
+    // TODO: Remove, if for all common KDE versions (bug #54607) is resolved.
+    QSettings *settings = resource_manager::get_settings ();
+    if (settings->contains ("use_native_file_dialogs")
+        && ! settings->value ("use_native_file_dialogs", true).toBool ())
+      fileDialog->setOption(QFileDialog::DontUseNativeDialog);
+
     connect (fileDialog, SIGNAL (filterSelected (const QString&)),
              this, SLOT (handle_save_as_filter_selected (const QString&)));
 
diff -r 8b6f1731474b -r 3f79d3dc0249 libgui/src/settings-dialog.cc
--- a/libgui/src/settings-dialog.cc	Wed Nov 14 10:57:46 2018 -0800
+++ b/libgui/src/settings-dialog.cc	Thu Nov 15 11:38:21 2018 +0100
@@ -190,6 +190,12 @@ namespace octave
     sb_3d_title->setValue (settings->value ("DockWidgets/widget_title_3d", 50).toInt ());
     cb_widget_custom_style->setChecked (settings->value ("DockWidgets/widget_title_custom_style", false).toBool ());
 
+    // Native file dialogs.
+    // TODO: This preference can be deprecated / removed if all display
+    //       managers, especially KDE, run those dialogs without hangs or
+    //       delays from the start (bug #54607).
+    cb_use_native_file_dialogs->setChecked (settings->value ("use_native_file_dialogs", true).toBool ());
+
     // Cursor blinking: consider old terminal related setting if not yet set
     // TODO: This pref. can be deprecated / removed if Qt adds support for
     //       getting the cursor blink preferences from all OS environments
@@ -810,6 +816,9 @@ namespace octave
       icon_size = 1;
     settings->setValue ("toolbar_icon_size", icon_size);
 
+    // native file dialogs
+    settings->setValue ("use_native_file_dialogs", cb_use_native_file_dialogs->isChecked ());
+
     // cursor blinking
     settings->setValue ("cursor_blinking", cb_cursor_blinking->isChecked ());
 
diff -r 8b6f1731474b -r 3f79d3dc0249 libgui/src/settings-dialog.ui
--- a/libgui/src/settings-dialog.ui	Wed Nov 14 10:57:46 2018 -0800
+++ b/libgui/src/settings-dialog.ui	Thu Nov 15 11:38:21 2018 +0100
@@ -32,7 +32,7 @@
       </size>
      </property>
      <property name="currentIndex">
-      <number>4</number>
+      <number>0</number>
      </property>
      <widget class="QWidget" name="tab_general">
       <property name="enabled">
@@ -52,8 +52,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_17">
@@ -140,7 +140,7 @@
                   </property>
                  </widget>
                 </item>
-                <item row="7" column="0">
+                <item row="8" column="0">
                  <widget class="QCheckBox" name="cb_prompt_to_exit">
                   <property name="text">
                    <string>Confirm before exiting</string>
@@ -374,7 +374,7 @@
                   </property>
                  </widget>
                 </item>
-                <item row="6" column="0">
+                <item row="7" column="0">
                  <widget class="QCheckBox" name="cb_status_bar">
                   <property name="text">
                    <string>Show status bar</string>
@@ -384,7 +384,7 @@
                   </property>
                  </widget>
                 </item>
-                <item row="5" column="0">
+                <item row="6" column="0">
                  <widget class="QCheckBox" name="cb_cursor_blinking">
                   <property name="text">
                    <string>Cursor blinking</string>
@@ -394,6 +394,16 @@
                   </property>
                  </widget>
                 </item>
+                <item row="5" column="0">
+                 <widget class="QCheckBox" name="cb_use_native_file_dialogs">
+                  <property name="text">
+                   <string>Use native file dialogs</string>
+                  </property>
+                  <property name="checked">
+                   <bool>true</bool>
+                  </property>
+                 </widget>
+                </item>
                </layout>
               </item>
              </layout>
@@ -509,8 +519,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_7">
@@ -790,8 +800,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>645</width>
-            <height>1213</height>
+            <width>647</width>
+            <height>1360</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -2116,8 +2126,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_8">
@@ -2260,8 +2270,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_19">
@@ -2322,8 +2332,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>669</width>
-            <height>558</height>
+            <width>780</width>
+            <height>550</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_vesc_manual">
@@ -2524,8 +2534,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_25">
@@ -2723,8 +2733,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>658</width>
-            <height>571</height>
+            <width>664</width>
+            <height>570</height>
            </rect>
           </property>
           <layout class="QVBoxLayout" name="verticalLayout_20">
