Skip to content

Commit

Permalink
[mssql] Don't allow creating connection only when both Host and Provi…
Browse files Browse the repository at this point in the history
…der/DSN are empty
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Sep 3, 2020
1 parent 7fcb12c commit 5ade7b8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/providers/mssql/qgsmssqlnewconnection.cpp
Expand Up @@ -41,6 +41,7 @@ QgsMssqlNewConnection::QgsMssqlNewConnection( QWidget *parent, const QString &co

buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
connect( txtName, &QLineEdit::textChanged, this, &QgsMssqlNewConnection::updateOkButtonState );
connect( txtService, &QLineEdit::textChanged, this, &QgsMssqlNewConnection::updateOkButtonState );
connect( txtHost, &QLineEdit::textChanged, this, &QgsMssqlNewConnection::updateOkButtonState );
connect( listDatabase, &QListWidget::currentItemChanged, this, &QgsMssqlNewConnection::updateOkButtonState );

Expand Down Expand Up @@ -252,6 +253,6 @@ void QgsMssqlNewConnection::showHelp()
void QgsMssqlNewConnection::updateOkButtonState()
{
QListWidgetItem *item = listDatabase->currentItem();
bool enabled = !txtName->text().isEmpty() && !txtHost->text().isEmpty() && item;
buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
bool disabled = txtName->text().isEmpty() || ( txtService->text().isEmpty() && txtHost->text().isEmpty() ) || !item;
buttonBox->button( QDialogButtonBox::Ok )->setDisabled( disabled );
}

0 comments on commit 5ade7b8

Please sign in to comment.