Skip to content
Permalink
Browse files

Add qgsfilewidget to dxf export dialog

  • Loading branch information
DelazJ authored and nyalldawson committed Jan 13, 2018
1 parent 10ee75b commit c875840f60ed97aa4240bfd0357fe30ae5441146
Showing with 84 additions and 51 deletions.
  1. +21 −21 src/app/qgsdxfexportdialog.cpp
  2. +0 −1 src/app/qgsdxfexportdialog.h
  3. +63 −29 src/ui/qgsdxfexportdialogbase.ui
@@ -423,7 +423,6 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
: QDialog( parent, f )
{
setupUi( this );
connect( mFileSelectionButton, &QToolButton::clicked, this, &QgsDxfExportDialog::mFileSelectionButton_clicked );
QgsGui::instance()->enableAutoGeometryRestore( this );

connect( mVisibilityPresets, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsDxfExportDialog::mVisibilityPresets_currentIndexChanged );
@@ -442,13 +441,24 @@ QgsDxfExportDialog::QgsDxfExportDialog( QWidget *parent, Qt::WindowFlags f )
mTreeView->resizeColumnToContents( 0 );
mTreeView->header()->show();

connect( mFileLineEdit, &QLineEdit::textChanged, this, &QgsDxfExportDialog::setOkEnabled );
mFileName->setStorageMode( QgsFileWidget::SaveFile );
mFileName->setFilter( tr( "DXF files" ) + " (*.dxf *.DXF)" );
mFileName->setDialogTitle( tr( "Export as DXF" ) );
mFileName->setDefaultRoot( s.value( QStringLiteral( "qgis/lastDxfDir" ), QDir::homePath() ).toString() );

connect( this, &QDialog::accepted, this, &QgsDxfExportDialog::saveSettings );
connect( mSelectAllButton, &QAbstractButton::clicked, this, &QgsDxfExportDialog::selectAll );
connect( mDeselectAllButton, &QAbstractButton::clicked, this, &QgsDxfExportDialog::deSelectAll );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDxfExportDialog::showHelp );

mFileLineEdit->setFocus();
connect( mFileName, &QgsFileWidget::fileChanged, this, [ = ]( const QString & filePath )
{
QgsSettings settings;
QFileInfo tmplFileInfo( filePath );
settings.setValue( QStringLiteral( "qgis/lastDxfDir" ), tmplFileInfo.absolutePath() );

setOkEnabled();
} );

//last dxf symbology mode
QgsSettings s;
@@ -558,7 +568,7 @@ double QgsDxfExportDialog::symbologyScale() const

QString QgsDxfExportDialog::saveFile() const
{
return mFileLineEdit->text();
return mFileName->filePath();
}


@@ -568,32 +578,22 @@ QgsDxfExport::SymbologyExport QgsDxfExportDialog::symbologyMode() const
}


void QgsDxfExportDialog::mFileSelectionButton_clicked()
{
//get last dxf save directory
QgsSettings s;
QString lastSavePath = s.value( QStringLiteral( "qgis/lastDxfDir" ), QDir::homePath() ).toString();

QString filePath = QFileDialog::getSaveFileName( nullptr, tr( "Export as DXF" ), lastSavePath, tr( "DXF files *.dxf *.DXF" ) );
if ( !filePath.isEmpty() )
{
mFileLineEdit->setText( filePath );
}
}


void QgsDxfExportDialog::setOkEnabled()
{
QPushButton *btn = buttonBox->button( QDialogButtonBox::Ok );

QString filePath = mFileLineEdit->text();
QString filePath = mFileName->filePath();
if ( filePath.isEmpty() )
{
btn->setEnabled( false );
return;
}

QFileInfo fi( filePath );
btn->setEnabled( fi.absoluteDir().exists() );

bool ok = ( fi.absoluteDir().exists() && !fi.baseName().isEmpty() );
btn->setEnabled( ok );

}


@@ -620,7 +620,7 @@ bool QgsDxfExportDialog::useMText() const
void QgsDxfExportDialog::saveSettings()
{
QgsSettings s;
QFileInfo dxfFileInfo( mFileLineEdit->text() );
QFileInfo dxfFileInfo( mFileName->filePath() );
s.setValue( QStringLiteral( "qgis/lastDxfDir" ), dxfFileInfo.absolutePath() );
s.setValue( QStringLiteral( "qgis/lastDxfSymbologyMode" ), mSymbologyModeComboBox->currentIndex() );
s.setValue( QStringLiteral( "qgis/lastSymbologyExportScale" ), mScaleWidget->scale() != 0 ? 1.0 / mScaleWidget->scale() : 0 );
@@ -98,7 +98,6 @@ class QgsDxfExportDialog : public QDialog, private Ui::QgsDxfExportDialogBase
void deSelectAll();

private slots:
void mFileSelectionButton_clicked();
void setOkEnabled();
void saveSettings();
void mVisibilityPresets_currentIndexChanged( int index );
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1049</width>
<width>698</width>
<height>680</height>
</rect>
</property>
@@ -16,26 +16,31 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="mSymbologyModeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Symbology mode</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mSaveAsLabel">
<property name="text">
<string>Save as</string>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mFileSelectionButton">
<property name="text">
<string></string>
<string>Save as</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<item row="1" column="1">
<widget class="QComboBox" name="mSymbologyModeComboBox">
<item>
<property name="text">
@@ -56,15 +61,21 @@
</item>
<item row="2" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Symbology scale</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<item row="3" column="1">
<widget class="QComboBox" name="mEncoding"/>
</item>
<item row="7" column="0" colspan="3">
<item row="7" column="0" colspan="2">
<widget class="QgsLayerTreeView" name="mTreeView">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
@@ -74,7 +85,7 @@
</attribute>
</widget>
</item>
<item row="2" column="1" colspan="2">
<item row="2" column="1">
<widget class="QgsScaleWidget" name="mScaleWidget" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
@@ -84,37 +95,33 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<item row="4" column="1">
<widget class="QgsProjectionSelectionWidget" name="mCrsSelector" native="true">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<item row="5" column="1">
<widget class="QComboBox" name="mVisibilityPresets"/>
</item>
<item row="15" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mFileLineEdit"/>
<widget class="QgsFileWidget" name="mFileName" native="true"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>CRS</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<item row="9" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QPushButton" name="mSelectAllButton">
@@ -147,19 +154,31 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Encoding</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="mSymbologyScaleLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Map themes</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="3">
<item row="11" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QCheckBox" name="mMapExtentCheckBox">
@@ -207,6 +226,16 @@
</item>
</layout>
</item>
<item row="15" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
@@ -226,10 +255,15 @@
<extends>QTreeView</extends>
<header>qgslayertreeview.h</header>
</customwidget>
<customwidget>
<class>QgsFileWidget</class>
<extends>QWidget</extends>
<header>qgsfilewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mFileLineEdit</tabstop>
<tabstop>mFileSelectionButton</tabstop>
<tabstop>mFileName</tabstop>
<tabstop>mSymbologyModeComboBox</tabstop>
<tabstop>mScaleWidget</tabstop>
<tabstop>mEncoding</tabstop>

0 comments on commit c875840

Please sign in to comment.
You can’t perform that action at this time.