Skip to content

Commit bf45669

Browse files
committed
Merge pull request #1028 from ahuarte47/Issue_9191
Bug #9191-#9190: fix enable/disable issues of buttons
2 parents accd06d + 32d4af2 commit bf45669

7 files changed

+75
-33
lines changed

src/gui/qgsmanageconnectionsdialog.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, Mode mo
4646
{
4747
label->setText( tr( "Select connections to import" ) );
4848
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Import" ) );
49+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
4950
}
5051
else
5152
{
5253
//label->setText( tr( "Select connections to export" ) );
5354
buttonBox->button( QDialogButtonBox::Ok )->setText( tr( "Export" ) );
55+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
5456
}
5557

5658
if ( !populateConnections() )
@@ -61,6 +63,13 @@ QgsManageConnectionsDialog::QgsManageConnectionsDialog( QWidget *parent, Mode mo
6163
// use Ok button for starting import and export operations
6264
disconnect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
6365
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( doExportImport() ) );
66+
67+
connect( listConnections, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );
68+
}
69+
70+
void QgsManageConnectionsDialog::selectionChanged()
71+
{
72+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
6473
}
6574

6675
void QgsManageConnectionsDialog::doExportImport()
@@ -945,9 +954,11 @@ void QgsManageConnectionsDialog::loadOracleConnections( const QDomDocument &doc,
945954
void QgsManageConnectionsDialog::selectAll()
946955
{
947956
listConnections->selectAll();
957+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( !listConnections->selectedItems().isEmpty() );
948958
}
949959

950960
void QgsManageConnectionsDialog::clearSelection()
951961
{
952962
listConnections->clearSelection();
963+
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
953964
}

src/gui/qgsmanageconnectionsdialog.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class GUI_EXPORT QgsManageConnectionsDialog : public QDialog, private Ui::QgsMan
5252
void doExportImport();
5353
void selectAll();
5454
void clearSelection();
55+
void selectionChanged();
5556

5657
private:
5758
bool populateConnections();

src/gui/qgsnewhttpconnection.cpp

+6-1
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

+2
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

+18-15
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,24 @@ 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+
mSaveButton->setEnabled( false );
542+
}
543+
else
544+
{
545+
// Connections - enable various buttons
546+
mConnectButton->setEnabled( true );
547+
mEditButton->setEnabled( true );
548+
mDeleteButton->setEnabled( true );
549+
mSaveButton->setEnabled( true );
550+
}
551+
549552
QgsOWSConnection::setSelectedConnection( mService, mConnectionsComboBox->currentText() );
550553
}
551554

src/providers/wfs/qgswfssourceselect.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,15 @@ void QgsWFSSourceSelect::populateConnectionList()
132132
btnConnect->setEnabled( true );
133133
btnEdit->setEnabled( true );
134134
btnDelete->setEnabled( true );
135+
btnSave->setEnabled( true );
135136
}
136-
137137
else
138138
{
139139
// No connections available - disable various buttons
140140
btnConnect->setEnabled( false );
141141
btnEdit->setEnabled( false );
142142
btnDelete->setEnabled( false );
143+
btnSave->setEnabled( false );
143144
}
144145

145146
//set last used connection
@@ -303,6 +304,23 @@ void QgsWFSSourceSelect::deleteEntryOfServerList()
303304
QgsOWSConnection::deleteConnection( "WFS", cmbConnections->currentText() );
304305
cmbConnections->removeItem( cmbConnections->currentIndex() );
305306
emit connectionsChanged();
307+
308+
if ( cmbConnections->count() > 0 )
309+
{
310+
// Connections available - enable various buttons
311+
btnConnect->setEnabled( true );
312+
btnEdit->setEnabled( true );
313+
btnDelete->setEnabled( true );
314+
btnSave->setEnabled( true );
315+
}
316+
else
317+
{
318+
// No connections available - disable various buttons
319+
btnConnect->setEnabled( false );
320+
btnEdit->setEnabled( false );
321+
btnDelete->setEnabled( false );
322+
btnSave->setEnabled( false );
323+
}
306324
}
307325
}
308326

src/providers/wms/qgswmssourceselect.cpp

+18-16
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,23 @@ 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+
btnSave->setEnabled( false );
1020+
}
1021+
else
1022+
{
1023+
// Connections - enable various buttons
1024+
btnConnect->setEnabled( true );
1025+
btnEdit->setEnabled( true );
1026+
btnDelete->setEnabled( true );
1027+
btnSave->setEnabled( true );
1028+
}
10271029
}
10281030

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

0 commit comments

Comments
 (0)