Skip to content
Permalink
Browse files

[mssql] Don't allow creating connection only when both Host and Provi…

…der/DSN are empty
  • Loading branch information
github-actions authored and nyalldawson committed Sep 3, 2020
1 parent 7fcb12c commit 5ade7b8803f72bc187c2b3f6da11b4f7e8b0b01e
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/providers/mssql/qgsmssqlnewconnection.cpp
@@ -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 );

@@ -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.
You can’t perform that action at this time.