Skip to content

Commit

Permalink
#9191: fix enable/disable issues of buttons
Browse files Browse the repository at this point in the history
At the http connection dialog, the 'Name' and 'Url' text boxes must be
filled to enable 'ok' button.
Also disable connect-edit-delete buttons when there is not any
connection defined.
  • Loading branch information
ahuarte47 committed Dec 16, 2013
1 parent b192f64 commit 57e9411
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 32 deletions.
7 changes: 6 additions & 1 deletion src/gui/qgsnewhttpconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ QgsNewHttpConnection::~QgsNewHttpConnection()

void QgsNewHttpConnection::on_txtName_textChanged( const QString &text )
{
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( text.isEmpty() );
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
}

void QgsNewHttpConnection::on_txtUrl_textChanged( const QString &text )
{
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
}

void QgsNewHttpConnection::accept()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsnewhttpconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo

void on_txtName_textChanged( const QString & );

void on_txtUrl_textChanged( const QString & );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

private:
Expand Down
31 changes: 16 additions & 15 deletions src/gui/qgsowssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,21 +239,6 @@ void QgsOWSSourceSelect::populateConnectionList()
mConnectionsComboBox->addItems( QgsOWSConnection::connectionList( mService ) );

setConnectionListPosition();

if ( mConnectionsComboBox->count() == 0 )
{
// No connections - disable various buttons
mConnectButton->setEnabled( false );
mEditButton->setEnabled( false );
mDeleteButton->setEnabled( false );
}
else
{
// Connections - enable various buttons
mConnectButton->setEnabled( true );
mEditButton->setEnabled( true );
mDeleteButton->setEnabled( true );
}
}
void QgsOWSSourceSelect::on_mNewButton_clicked()
{
Expand Down Expand Up @@ -546,6 +531,22 @@ void QgsOWSSourceSelect::setConnectionListPosition()
else
mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->count() - 1 );
}

if ( mConnectionsComboBox->count() == 0 )
{
// No connections - disable various buttons
mConnectButton->setEnabled( false );
mEditButton->setEnabled( false );
mDeleteButton->setEnabled( false );
}
else
{
// Connections - enable various buttons
mConnectButton->setEnabled( true );
mEditButton->setEnabled( true );
mDeleteButton->setEnabled( true );
}

QgsOWSConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
}

Expand Down
15 changes: 15 additions & 0 deletions src/providers/wfs/qgswfssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
QgsOWSConnection::deleteConnection( "WFS", cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() );
emit connectionsChanged();

if ( cmbConnections->count() > 0 )
{
// Connections available - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
}
else
{
// No connections available - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
}
}
}

Expand Down
32 changes: 16 additions & 16 deletions src/providers/wms/qgswmssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,6 @@ void QgsWMSSourceSelect::populateConnectionList()
cmbConnections->addItems( QgsWMSConnection::connectionList() );

setConnectionListPosition();

if ( cmbConnections->count() == 0 )
{
// No connections - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
}
else
{
// Connections - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
}
}
void QgsWMSSourceSelect::on_btnNew_clicked()
{
Expand Down Expand Up @@ -214,7 +199,7 @@ void QgsWMSSourceSelect::on_btnDelete_clicked()
if ( result == QMessageBox::Ok )
{
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
cmbConnections->removeItem( cmbConnections->currentIndex() );
setConnectionListPosition();
emit connectionsChanged();
}
Expand Down Expand Up @@ -1024,6 +1009,21 @@ void QgsWMSSourceSelect::setConnectionListPosition()
else
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
}

if ( cmbConnections->count() == 0 )
{
// No connections - disable various buttons
btnConnect->setEnabled( false );
btnEdit->setEnabled( false );
btnDelete->setEnabled( false );
}
else
{
// Connections - enable various buttons
btnConnect->setEnabled( true );
btnEdit->setEnabled( true );
btnDelete->setEnabled( true );
}
}

void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )
Expand Down

0 comments on commit 57e9411

Please sign in to comment.