mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
[Attachment widget] Respect relative paths settings by drag&drop (#44798)
This commit is contained in:
parent
8b2a3360b2
commit
0ce7f90350
@ -59,6 +59,7 @@ QgsFileWidget::QgsFileWidget( QWidget *parent )
|
|||||||
mLineEdit->setDragEnabled( true );
|
mLineEdit->setDragEnabled( true );
|
||||||
mLineEdit->setToolTip( tr( "Full path to the file(s), including name and extension" ) );
|
mLineEdit->setToolTip( tr( "Full path to the file(s), including name and extension" ) );
|
||||||
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsFileWidget::textEdited );
|
connect( mLineEdit, &QLineEdit::textChanged, this, &QgsFileWidget::textEdited );
|
||||||
|
connect( mLineEdit, &QgsFileDropEdit::fileDropped, this, &QgsFileWidget::fileDropped );
|
||||||
mLayout->addWidget( mLineEdit );
|
mLayout->addWidget( mLineEdit );
|
||||||
|
|
||||||
mLinkEditButton = new QToolButton( this );
|
mLinkEditButton = new QToolButton( this );
|
||||||
@ -190,6 +191,13 @@ void QgsFileWidget::editLink()
|
|||||||
updateLayout();
|
updateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsFileWidget::fileDropped( const QString &filePath )
|
||||||
|
{
|
||||||
|
setSelectedFileNames( QStringList() << filePath );
|
||||||
|
mLineEdit->selectAll();
|
||||||
|
mLineEdit->setFocus( Qt::MouseFocusReason );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsFileWidget::useLink() const
|
bool QgsFileWidget::useLink() const
|
||||||
{
|
{
|
||||||
return mUseLink;
|
return mUseLink;
|
||||||
@ -585,12 +593,11 @@ void QgsFileDropEdit::dropEvent( QDropEvent *event )
|
|||||||
QString filePath = acceptableFilePath( event );
|
QString filePath = acceptableFilePath( event );
|
||||||
if ( !filePath.isEmpty() )
|
if ( !filePath.isEmpty() )
|
||||||
{
|
{
|
||||||
setText( filePath );
|
|
||||||
selectAll();
|
|
||||||
setFocus( Qt::MouseFocusReason );
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
setHighlighted( false );
|
emit fileDropped( filePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHighlighted( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
///@endcond
|
///@endcond
|
||||||
|
@ -298,6 +298,7 @@ class GUI_EXPORT QgsFileWidget : public QWidget
|
|||||||
void openFileDialog();
|
void openFileDialog();
|
||||||
void textEdited( const QString &path );
|
void textEdited( const QString &path );
|
||||||
void editLink();
|
void editLink();
|
||||||
|
void fileDropped( const QString &filePath );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -379,6 +380,13 @@ class GUI_EXPORT QgsFileDropEdit: public QgsHighlightableLineEdit
|
|||||||
|
|
||||||
void setFilters( const QString &filters );
|
void setFilters( const QString &filters );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted when the file \a filePath is droppen onto the line edit.
|
||||||
|
*/
|
||||||
|
void fileDropped( const QString &filePath );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void dragEnterEvent( QDragEnterEvent *event ) override;
|
void dragEnterEvent( QDragEnterEvent *event ) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user