Skip to content
Permalink
Browse files

[addbuttonlayer] Fix layout of vector dialog

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 828ec13430617ff6dcfc96f8b9a175ca79dedec5
@@ -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 );
@@ -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() )
@@ -406,7 +414,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "file" );
}
}
@@ -420,7 +427,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcDirectory_toggled( bool checked )
fileGroupBox->show();
dbGroupBox->hide();
protocolGroupBox->hide();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "directory" );
}
}
@@ -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();
@@ -449,7 +454,6 @@ void QgsOpenVectorLayerDialog::on_radioSrcProtocol_toggled( bool checked )
fileGroupBox->hide();
dbGroupBox->hide();
protocolGroupBox->show();
layout()->setSizeConstraint( QLayout::SetFixedSize );
mDataSourceType = QStringLiteral( "protocol" );
}
}
@@ -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
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1010</width>
<width>1200</width>
<height>600</height>
</rect>
</property>
@@ -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>
@@ -40,7 +40,7 @@
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>350</width>
<height>16777215</height>
</size>
</property>
@@ -79,7 +79,7 @@
</property>
<property name="maximumSize">
<size>
<width>200</width>
<width>350</width>
<height>16777215</height>
</size>
</property>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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"/>

0 comments on commit 828ec13

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