Skip to content

Commit 57e9411

Browse files
committed
#9191: fix enable/disable issues of buttons
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.
1 parent b192f64 commit 57e9411

File tree

5 files changed

+55
-32
lines changed

5 files changed

+55
-32
lines changed

src/gui/qgsnewhttpconnection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ QgsNewHttpConnection::~QgsNewHttpConnection()
141141

142142
void QgsNewHttpConnection::on_txtName_textChanged( const QString &text )
143143
{
144-
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( text.isEmpty() );
144+
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
145+
}
146+
147+
void QgsNewHttpConnection::on_txtUrl_textChanged( const QString &text )
148+
{
149+
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
145150
}
146151

147152
void QgsNewHttpConnection::accept()

src/gui/qgsnewhttpconnection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
3838

3939
void on_txtName_textChanged( const QString & );
4040

41+
void on_txtUrl_textChanged( const QString & );
42+
4143
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
4244

4345
private:

src/gui/qgsowssourceselect.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,6 @@ void QgsOWSSourceSelect::populateConnectionList()
239239
mConnectionsComboBox->addItems( QgsOWSConnection::connectionList( mService ) );
240240

241241
setConnectionListPosition();
242-
243-
if ( mConnectionsComboBox->count() == 0 )
244-
{
245-
// No connections - disable various buttons
246-
mConnectButton->setEnabled( false );
247-
mEditButton->setEnabled( false );
248-
mDeleteButton->setEnabled( false );
249-
}
250-
else
251-
{
252-
// Connections - enable various buttons
253-
mConnectButton->setEnabled( true );
254-
mEditButton->setEnabled( true );
255-
mDeleteButton->setEnabled( true );
256-
}
257242
}
258243
void QgsOWSSourceSelect::on_mNewButton_clicked()
259244
{
@@ -546,6 +531,22 @@ void QgsOWSSourceSelect::setConnectionListPosition()
546531
else
547532
mConnectionsComboBox->setCurrentIndex( mConnectionsComboBox->count() - 1 );
548533
}
534+
535+
if ( mConnectionsComboBox->count() == 0 )
536+
{
537+
// No connections - disable various buttons
538+
mConnectButton->setEnabled( false );
539+
mEditButton->setEnabled( false );
540+
mDeleteButton->setEnabled( false );
541+
}
542+
else
543+
{
544+
// Connections - enable various buttons
545+
mConnectButton->setEnabled( true );
546+
mEditButton->setEnabled( true );
547+
mDeleteButton->setEnabled( true );
548+
}
549+
549550
QgsOWSConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
550551
}
551552

src/providers/wfs/qgswfssourceselect.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,21 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
303303
QgsOWSConnection::deleteConnection( "WFS", cmbConnections->currentText() );
304304
cmbConnections->removeItem( cmbConnections->currentIndex() );
305305
emit connectionsChanged();
306+
307+
if ( cmbConnections->count() > 0 )
308+
{
309+
// Connections available - enable various buttons
310+
btnConnect->setEnabled( true );
311+
btnEdit->setEnabled( true );
312+
btnDelete->setEnabled( true );
313+
}
314+
else
315+
{
316+
// No connections available - disable various buttons
317+
btnConnect->setEnabled( false );
318+
btnEdit->setEnabled( false );
319+
btnDelete->setEnabled( false );
320+
}
306321
}
307322
}
308323

src/providers/wms/qgswmssourceselect.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,6 @@ void QgsWMSSourceSelect::populateConnectionList()
164164
cmbConnections->addItems( QgsWMSConnection::connectionList() );
165165

166166
setConnectionListPosition();
167-
168-
if ( cmbConnections->count() == 0 )
169-
{
170-
// No connections - disable various buttons
171-
btnConnect->setEnabled( false );
172-
btnEdit->setEnabled( false );
173-
btnDelete->setEnabled( false );
174-
}
175-
else
176-
{
177-
// Connections - enable various buttons
178-
btnConnect->setEnabled( true );
179-
btnEdit->setEnabled( true );
180-
btnDelete->setEnabled( true );
181-
}
182167
}
183168
void QgsWMSSourceSelect::on_btnNew_clicked()
184169
{
@@ -214,7 +199,7 @@ void QgsWMSSourceSelect::on_btnDelete_clicked()
214199
if ( result == QMessageBox::Ok )
215200
{
216201
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
217-
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
202+
cmbConnections->removeItem( cmbConnections->currentIndex() );
218203
setConnectionListPosition();
219204
emit connectionsChanged();
220205
}
@@ -1024,6 +1009,21 @@ void QgsWMSSourceSelect::setConnectionListPosition()
10241009
else
10251010
cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
10261011
}
1012+
1013+
if ( cmbConnections->count() == 0 )
1014+
{
1015+
// No connections - disable various buttons
1016+
btnConnect->setEnabled( false );
1017+
btnEdit->setEnabled( false );
1018+
btnDelete->setEnabled( false );
1019+
}
1020+
else
1021+
{
1022+
// Connections - enable various buttons
1023+
btnConnect->setEnabled( true );
1024+
btnEdit->setEnabled( true );
1025+
btnDelete->setEnabled( true );
1026+
}
10271027
}
10281028

10291029
void QgsWMSSourceSelect::showStatusMessage( QString const &theMessage )

0 commit comments

Comments
 (0)