Skip to content

Commit

Permalink
[addbuttonlayer] Fix layout of vector dialog
Browse files Browse the repository at this point in the history
This is an attempt to fix the layout of the vector
layer dialog to fit in the unified dialog layout.

The optiomal solution would probably involve
a complete refactoring of the vector layer dialog
to use a stacked widget.
  • Loading branch information
elpaso committed Jun 2, 2017
1 parent 018afc7 commit 828ec13
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
16 changes: 10 additions & 6 deletions src/app/ogr/qgsopenvectorlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@

QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QDialog( parent, fl ),
mWidgetMode( widgetMode )
mWidgetMode( widgetMode ),
mAddButton( nullptr )
{
setupUi( this );

if ( mWidgetMode != QgsProviderRegistry::WidgetMode::None )
{
this->layout()->setSizeConstraint( QLayout::SetNoConstraint );
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Cancel ) );
}

mAddButton = new QPushButton( tr( "&Add" ) );
// TODO: enable/disable according to valid selection
mAddButton->setEnabled( true );
buttonBox->addButton( mAddButton, QDialogButtonBox::AcceptRole );

cmbDatabaseTypes->blockSignals( true );
cmbConnections->blockSignals( true );
radioSrcFile->setChecked( true );
Expand Down Expand Up @@ -279,7 +287,7 @@ void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
if ( !selected.isEmpty() )
{
inputSrcDataset->setText( selected.join( QStringLiteral( ";" ) ) );
buttonBox->button( QDialogButtonBox::Open )->setFocus();
mAddButton->setFocus();
}
}
else if ( radioSrcDirectory->isChecked() )
Expand Down Expand Up @@ -406,7 +414,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "file" );
}
}
Expand All @@ -420,7 +427,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcDirectory_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "directory" );
}
}
Expand All @@ -434,7 +440,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcDatabase_toggled( bool checked )
protocolGroupBox->hide();
dbGroupBox->show();
layout()->blockSignals( false );
layout()->setSizeConstraint( QLayout::SetFixedSize );
setConnectionTypeListPosition();
populateConnectionList();
setConnectionListPosition();
Expand All @@ -449,7 +454,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcProtocol_toggled( bool checked )
fileGroupBox->hide();
dbGroupBox->hide();
protocolGroupBox->show();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "protocol" );
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/ogr/qgsopenvectorlayerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerD
QString mDataSourceType;
//! Embedded dialog (do not call parent's accept) and emit signals
QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;
//! Add layer button
QPushButton *mAddButton = nullptr;

private slots:
//! Opens the create connection dialog to build a new connection
Expand Down
8 changes: 4 additions & 4 deletions src/ui/qgsdatasourcemanagerdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1010</width>
<width>1200</width>
<height>600</height>
</rect>
</property>
Expand All @@ -27,7 +27,7 @@
</property>
<widget class="QFrame" name="mOptionsListFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -40,7 +40,7 @@
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>350</width>
<height>16777215</height>
</size>
</property>
Expand Down Expand Up @@ -79,7 +79,7 @@
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>350</width>
<height>16777215</height>
</size>
</property>
Expand Down
46 changes: 34 additions & 12 deletions src/ui/qgsopenvectorlayerdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -26,9 +26,25 @@
<iconset>
<normaloff>.</normaloff>.</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="5" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="protocolGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
Expand Down Expand Up @@ -68,7 +84,7 @@
<item row="2" column="0">
<widget class="QGroupBox" name="fileGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -123,17 +139,10 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Open</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="dbGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -210,7 +219,7 @@
<item row="0" column="0">
<widget class="QGroupBox" name="srcGroupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -275,6 +284,19 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
Expand Down

0 comments on commit 828ec13

Please sign in to comment.