ConnectionBasicTab::ConnectionBasicTab(ConnectionSettings *settings) : _settings(settings) { QLabel *connectionDescriptionLabel = new QLabel( "Choose any connection name that will help you to identify this connection."); connectionDescriptionLabel->setWordWrap(true); connectionDescriptionLabel->setContentsMargins(0, -2, 0, 20); QLabel *serverDescriptionLabel = new QLabel( "Specify host and port of MongoDB server. Host can be either IP or domain name."); serverDescriptionLabel->setWordWrap(true); serverDescriptionLabel->setContentsMargins(0, -2, 0, 20); _connectionName = new QLineEdit(QtUtils::toQString(_settings->connectionName())); _serverAddress = new QLineEdit(QtUtils::toQString(_settings->serverHost())); _serverPort = new QLineEdit(QString::number(_settings->serverPort())); _serverPort->setFixedWidth(80); QRegExp rx("\\d+");//(0-65554) _serverPort->setValidator(new QRegExpValidator(rx, this)); _sslSupport = new QCheckBox("SSL support"); _sslSupport->setChecked(_settings->sslInfo()._sslSupport); _sslPEMKeyFile = new QLineEdit(QtUtils::toQString(_settings->sslInfo()._sslPEMKeyFile)); #ifdef Q_OS_WIN QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?"); #else QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$"); #endif // Q_OS_WIN _sslPEMKeyFile->setValidator(new QRegExpValidator(pathx, this)); _selectFileB = new QPushButton("..."); _selectFileB->setFixedSize(20,20); VERIFY(connect(_selectFileB, SIGNAL(clicked()), this, SLOT(setSslPEMKeyFile()))); QGridLayout *connectionLayout = new QGridLayout; connectionLayout->addWidget(new QLabel("Name:"), 1, 0); connectionLayout->addWidget(_connectionName, 1, 1, 1, 3); connectionLayout->addWidget(connectionDescriptionLabel, 2, 1, 1, 3); connectionLayout->addWidget(serverDescriptionLabel, 4, 1, 1, 3); connectionLayout->addWidget(new QLabel("Address:"), 3, 0); connectionLayout->addWidget(_serverAddress, 3, 1); connectionLayout->addWidget(new QLabel(":"), 3, 2); connectionLayout->addWidget(_serverPort, 3, 3); connectionLayout->setAlignment(Qt::AlignTop); connectionLayout->addWidget(_sslSupport, 5, 1); connectionLayout->addWidget(_selectFileB, 5, 2); connectionLayout->addWidget(_sslPEMKeyFile, 5, 3); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(connectionLayout); setLayout(mainLayout); sslSupportStateChange(_sslSupport->checkState()); VERIFY(connect(_sslSupport,SIGNAL(stateChanged(int)),this,SLOT(sslSupportStateChange(int)))); _connectionName->setFocus(); }
ConnectionSslTab::ConnectionSslTab(ConnectionSettings *settings) : _settings(settings) { _sslPemFilePath = new QLineEdit(QtUtils::toQString(_settings->sslInfo()._sslPEMKeyFile)); /* // Commented because of this: // https://github.com/paralect/robomongo/issues/391 #ifdef Q_OS_WIN QRegExp pathx("([a-zA-Z]:)?([\\\\/][a-zA-Z0-9_.-]+)+[\\\\/]?"); #else QRegExp pathx("^\\/?([\\d\\w\\.]+)(/([\\d\\w\\.]+))*\\/?$"); #endif // Q_OS_WIN _sslPemFilePath->setValidator(new QRegExpValidator(pathx, this)); */ _sslSupport = new QCheckBox("Use SSL protocol"); _sslSupport->setStyleSheet("margin-bottom: 7px"); _sslSupport->setChecked(_settings->sslInfo()._sslSupport); _selectPemFileButton = new QPushButton("..."); _selectPemFileButton->setFixedSize(20, 20); VERIFY(connect(_selectPemFileButton, SIGNAL(clicked()), this, SLOT(setSslPEMKeyFile()))); _sslPemLabel = new QLabel("SSL Certificate:"); _sslPemDescriptionLabel = new QLabel( "<nobr>SSL Certificate and SSL Private Key combined into one file (*.pem)"); _sslPemDescriptionLabel->setWordWrap(true); _sslPemDescriptionLabel->setAlignment(Qt::AlignTop); _sslPemDescriptionLabel->setContentsMargins(0, -2, 0, 0); _sslPemDescriptionLabel->setMinimumSize(_sslPemDescriptionLabel->sizeHint()); QLabel *sslNoteLabel = new QLabel( "<b>Note:</b> Support for Certificate Authority (CA) file and " "encrypted SSL Private Keys are planned for future releases."); sslNoteLabel->setWordWrap(true); sslNoteLabel->setAlignment(Qt::AlignTop); sslNoteLabel->setContentsMargins(0, 20, 0, 0); QGridLayout *_authLayout = new QGridLayout; _authLayout->setAlignment(Qt::AlignTop); _authLayout->addWidget(_sslSupport, 0, 0, 1, 3); _authLayout->addWidget(_sslPemLabel, 1, 0); _authLayout->addWidget(_sslPemFilePath, 1, 1, 1, 1); _authLayout->addWidget(_selectPemFileButton, 1, 2, 1, 1); _authLayout->addWidget(_sslPemDescriptionLabel, 2, 1, 1, 2); _authLayout->addWidget(sslNoteLabel, 3, 0, 1, 4); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(_authLayout); setLayout(mainLayout); sslSupportStateChange(_sslSupport->checkState()); VERIFY(connect(_sslSupport, SIGNAL(stateChanged(int)), this, SLOT(sslSupportStateChange(int)))); }