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