From: kga Date: Wed, 27 Feb 2013 07:15:26 +0000 (+0000) Subject: Fix a bug with PathList preference item X-Git-Tag: V6_main_FINAL~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea212046fa2913029c17c14e53ff9c4a707c7ac3;p=modules%2Fgui.git Fix a bug with PathList preference item --- diff --git a/src/Qtx/QtxPathEdit.cxx b/src/Qtx/QtxPathEdit.cxx index ae0dbfc69..57b6a8b04 100644 --- a/src/Qtx/QtxPathEdit.cxx +++ b/src/Qtx/QtxPathEdit.cxx @@ -22,10 +22,12 @@ // #include "QtxPathEdit.h" +#include #include #include #include #include +#include #include #include #include @@ -78,11 +80,14 @@ static const char* browse_icon[] = { \brief Constructor \param type widget mode (Qtx::PathType) \param parent parent widget + \param browse if \c true, automatically finish editing of file path when + user presses OK in "Select File/Directory" dialog box \sa pathType(), setPathType() */ -QtxPathEdit::QtxPathEdit( const Qtx::PathType type, QWidget* parent ) +QtxPathEdit::QtxPathEdit( const Qtx::PathType type, QWidget* parent, bool browse ) : QFrame( parent ), - myType( type ) + myType( type ), + myBrowse ( browse ) { initialize(); } @@ -93,11 +98,14 @@ QtxPathEdit::QtxPathEdit( const Qtx::PathType type, QWidget* parent ) Qtx::PT_OpenFile mode is used by default. \param parent parent widget + \param browse if \c true, automatically finish editing of file path when + user presses OK in "Select File/Directory" dialog box \sa pathType(), setPathType() */ -QtxPathEdit::QtxPathEdit( QWidget* parent ) +QtxPathEdit::QtxPathEdit( QWidget* parent, bool browse ) : QFrame( parent ), - myType( Qtx::PT_OpenFile ) + myType( Qtx::PT_OpenFile ), + myBrowse ( browse ) { initialize(); } @@ -206,6 +214,9 @@ void QtxPathEdit::onBrowse( bool /*on*/ ) myPath->setText( QDir::convertSeparators( path ) ); myPath->setFocus(); + + if ( !path.isEmpty() && myBrowse ) + QApplication::postEvent( myPath, new QKeyEvent( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier ) ); } /*! diff --git a/src/Qtx/QtxPathEdit.h b/src/Qtx/QtxPathEdit.h index de991be89..eb5100edd 100644 --- a/src/Qtx/QtxPathEdit.h +++ b/src/Qtx/QtxPathEdit.h @@ -34,8 +34,8 @@ class QTX_EXPORT QtxPathEdit : public QFrame Q_OBJECT public: - QtxPathEdit( const Qtx::PathType, QWidget* = 0 ); - QtxPathEdit( QWidget* = 0 ); + QtxPathEdit( const Qtx::PathType, QWidget* = 0, bool = false ); + QtxPathEdit( QWidget* = 0, bool = false ); virtual ~QtxPathEdit(); QString path() const; @@ -61,6 +61,7 @@ private: QLineEdit* myPath; Qtx::PathType myType; QString myFilter; + bool myBrowse; }; #endif diff --git a/src/Qtx/QtxPathListEdit.cxx b/src/Qtx/QtxPathListEdit.cxx index 17b3044f9..5a9f98379 100644 --- a/src/Qtx/QtxPathListEdit.cxx +++ b/src/Qtx/QtxPathListEdit.cxx @@ -143,7 +143,7 @@ public: \brief Constructor \internal */ - Editor( QWidget* parent = 0 ) : QtxPathEdit( parent ) + Editor( QWidget* parent = 0 ) : QtxPathEdit( parent, true ) { layout()->setSpacing( 0 ); lineEdit()->setFrame( false );