Salome HOME
Add file dialog options in QtxPathEdit
[modules/gui.git] / src / Qtx / QtxPathEdit.cxx
index 67b5dfa45ddcfdb9c7b6295345d13a9f17c72e68..8dcac94eec04bae436f0b3eed6001d07ef98bcd7 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,6 @@
 #include <QCompleter>
 #include <QKeyEvent>
 #include <QToolButton>
-#include <QFileDialog>
 #include <QRegExpValidator>
 
 static const char* browse_icon[] = {
@@ -185,6 +184,30 @@ void QtxPathEdit::setPathFilter( const QString& f )
   updateState();
 }
 
+/*!
+  \brief Set path file dialog options.
+  \param f new file or directory path options
+  \sa pathOptions()
+*/
+void QtxPathEdit::setPathOptions(const QFileDialog::Options options)
+{
+  if ( myOptions == options )
+    return;
+
+  myOptions = options;
+}
+
+/*!
+  \brief Get currently used path options.
+  \return file or directory path options
+  \sa setPathOptions()
+*/
+QFileDialog::Options QtxPathEdit::pathOptions() const
+{
+  return myOptions;
+}
+
+
 /*!
   \brief Called when user clicks "Browse" button. 
 
@@ -200,18 +223,18 @@ void QtxPathEdit::onBrowse( bool /*on*/ )
   switch ( pathType() )
   {
   case Qtx::PT_OpenFile:
-    path = QFileDialog::getOpenFileName( myPath, QString(), initial, pathFilter() );
+    path = QFileDialog::getOpenFileName( myPath, QString(), initial, pathFilter(), nullptr, pathOptions() );
     break;
   case Qtx::PT_SaveFile:
-    path = QFileDialog::getSaveFileName( myPath, QString(), initial, pathFilter() );
+    path = QFileDialog::getSaveFileName( myPath, QString(), initial, pathFilter(), nullptr, pathOptions() );
     break;
   case Qtx::PT_Directory:
-    path = QFileDialog::getExistingDirectory( myPath, QString(), initial );
+    path = QFileDialog::getExistingDirectory( myPath, QString(), initial, pathOptions() );
     break;
   }
 
   if ( !path.isEmpty() )
-    myPath->setText( QDir::convertSeparators( path ) ); 
+    myPath->setText( QDir::toNativeSeparators( path ) ); 
 
   myPath->setFocus();