-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 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
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
#include "QtxPathEdit.h"
+#include <QApplication>
#include <QLayout>
#include <QDirModel>
#include <QLineEdit>
#include <QCompleter>
+#include <QKeyEvent>
#include <QToolButton>
#include <QFileDialog>
#include <QRegExpValidator>
\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();
}
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();
}
}
if ( !path.isEmpty() )
- myPath->setText( QDir::convertSeparators( path ) );
+ myPath->setText( QDir::toNativeSeparators( path ) );
myPath->setFocus();
+
+ if ( !path.isEmpty() && myBrowse )
+ QApplication::postEvent( myPath, new QKeyEvent( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier ) );
}
/*!