forked from qt-creator/qt-creator
debugger/analyzer: inline the small start dialogs
Easier to refactor. Change-Id: I151364182df841e7e543f480b1836a1b1897e913 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -32,53 +32,143 @@
|
||||
|
||||
#include "startremotedialog.h"
|
||||
|
||||
#include "ui_startremotedialog.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
namespace Analyzer {
|
||||
namespace Internal {
|
||||
|
||||
class StartRemoteDialogPrivate
|
||||
{
|
||||
public:
|
||||
QLabel *hostLabel;
|
||||
QLineEdit *host;
|
||||
QLabel *userLabel;
|
||||
QLineEdit *user;
|
||||
QLabel *portLabel;
|
||||
QSpinBox *port;
|
||||
QLabel *passwordLabel;
|
||||
QLineEdit *password;
|
||||
QLabel *keyFileLabel;
|
||||
Utils::PathChooser *keyFile;
|
||||
QFormLayout *formLayout;
|
||||
QLabel *executableLabel;
|
||||
QLineEdit *executable;
|
||||
QLabel *argumentsLabel;
|
||||
QLineEdit *arguments;
|
||||
QLabel *workingDirectoryLabel;
|
||||
QLineEdit *workingDirectory;
|
||||
QDialogButtonBox *buttonBox;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
StartRemoteDialog::StartRemoteDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Internal::Ui::StartRemoteDialog)
|
||||
, d(new Internal::StartRemoteDialogPrivate)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setWindowTitle(tr("Start Remote Analysis"));
|
||||
|
||||
m_ui->keyFile->setExpectedKind(Utils::PathChooser::File);
|
||||
QGroupBox *groupBox = new QGroupBox(tr("Remote"), this);
|
||||
|
||||
d->host = new QLineEdit(groupBox);
|
||||
d->hostLabel = new QLabel(tr("Host:"), groupBox);
|
||||
|
||||
d->user = new QLineEdit(groupBox);
|
||||
d->userLabel = new QLabel(tr("User:"), groupBox);
|
||||
|
||||
d->port = new QSpinBox(groupBox);
|
||||
d->port->setMaximum(65535);
|
||||
d->port->setSingleStep(1);
|
||||
d->port->setValue(22);
|
||||
d->portLabel = new QLabel(tr("Port:"), groupBox);
|
||||
|
||||
d->passwordLabel = new QLabel(tr("Password:"), groupBox);
|
||||
d->passwordLabel->setToolTip(tr("You need to pass either a password or an SSH key."));
|
||||
|
||||
d->password = new QLineEdit(groupBox);
|
||||
d->password->setEchoMode(QLineEdit::Password);
|
||||
|
||||
d->keyFileLabel = new QLabel(tr("Private key:"), groupBox);
|
||||
d->keyFileLabel->setToolTip(tr("You need to pass either a password or an SSH key."));
|
||||
|
||||
d->keyFile = new Utils::PathChooser(groupBox);
|
||||
|
||||
QGroupBox *groupBox2 = new QGroupBox(tr("Target"), this);
|
||||
|
||||
d->executable = new QLineEdit(groupBox2);
|
||||
d->executableLabel = new QLabel(tr("Executable:"), groupBox2);
|
||||
|
||||
d->arguments = new QLineEdit(groupBox2);
|
||||
d->argumentsLabel = new QLabel(tr("Arguments:"), groupBox2);
|
||||
|
||||
d->workingDirectory = new QLineEdit(groupBox2);
|
||||
d->workingDirectoryLabel = new QLabel(tr("Working directory:"), groupBox2);
|
||||
|
||||
d->buttonBox = new QDialogButtonBox(this);
|
||||
d->buttonBox->setOrientation(Qt::Horizontal);
|
||||
d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
|
||||
QFormLayout *formLayout = new QFormLayout(groupBox);
|
||||
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||
formLayout->addRow(d->hostLabel, d->host);
|
||||
formLayout->addRow(d->userLabel, d->user);
|
||||
formLayout->addRow(d->portLabel, d->port);
|
||||
formLayout->addRow(d->passwordLabel, d->password);
|
||||
formLayout->addRow(d->keyFileLabel, d->keyFile);
|
||||
|
||||
QFormLayout *formLayout2 = new QFormLayout(groupBox2);
|
||||
formLayout2->addRow(d->executableLabel, d->executable);
|
||||
formLayout2->addRow(d->argumentsLabel, d->arguments);
|
||||
formLayout2->addRow(d->workingDirectoryLabel, d->workingDirectory);
|
||||
|
||||
QVBoxLayout *verticalLayout = new QVBoxLayout(this);
|
||||
verticalLayout->addWidget(groupBox);
|
||||
verticalLayout->addWidget(groupBox2);
|
||||
verticalLayout->addWidget(d->buttonBox);
|
||||
|
||||
d->keyFile->setExpectedKind(Utils::PathChooser::File);
|
||||
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog"));
|
||||
m_ui->host->setText(settings->value(QLatin1String("host")).toString());
|
||||
m_ui->port->setValue(settings->value(QLatin1String("port"), 22).toInt());
|
||||
m_ui->user->setText(settings->value(QLatin1String("user"), qgetenv("USER")).toString());
|
||||
m_ui->keyFile->setPath(settings->value(QLatin1String("keyFile")).toString());
|
||||
m_ui->executable->setText(settings->value(QLatin1String("executable")).toString());
|
||||
m_ui->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString());
|
||||
m_ui->arguments->setText(settings->value(QLatin1String("arguments")).toString());
|
||||
d->host->setText(settings->value(QLatin1String("host")).toString());
|
||||
d->port->setValue(settings->value(QLatin1String("port"), 22).toInt());
|
||||
d->user->setText(settings->value(QLatin1String("user"), qgetenv("USER")).toString());
|
||||
d->keyFile->setPath(settings->value(QLatin1String("keyFile")).toString());
|
||||
d->executable->setText(settings->value(QLatin1String("executable")).toString());
|
||||
d->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString());
|
||||
d->arguments->setText(settings->value(QLatin1String("arguments")).toString());
|
||||
settings->endGroup();
|
||||
|
||||
connect(m_ui->host, SIGNAL(textChanged(QString)),
|
||||
connect(d->host, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(validate()));
|
||||
connect(m_ui->port, SIGNAL(valueChanged(int)),
|
||||
connect(d->port, SIGNAL(valueChanged(int)),
|
||||
this, SLOT(validate()));
|
||||
connect(m_ui->password, SIGNAL(textChanged(QString)),
|
||||
connect(d->password, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(validate()));
|
||||
connect(m_ui->keyFile, SIGNAL(changed(QString)),
|
||||
connect(d->keyFile, SIGNAL(changed(QString)),
|
||||
this, SLOT(validate()));
|
||||
|
||||
connect(m_ui->executable, SIGNAL(textChanged(QString)),
|
||||
connect(d->executable, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(validate()));
|
||||
connect(m_ui->workingDirectory, SIGNAL(textChanged(QString)),
|
||||
connect(d->workingDirectory, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(validate()));
|
||||
connect(m_ui->arguments, SIGNAL(textChanged(QString)),
|
||||
connect(d->arguments, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(validate()));
|
||||
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()),
|
||||
connect(d->buttonBox, SIGNAL(accepted()),
|
||||
this, SLOT(accept()));
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()),
|
||||
connect(d->buttonBox, SIGNAL(rejected()),
|
||||
this, SLOT(reject()));
|
||||
|
||||
validate();
|
||||
@@ -86,20 +176,20 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent)
|
||||
|
||||
StartRemoteDialog::~StartRemoteDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void StartRemoteDialog::accept()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog"));
|
||||
settings->setValue(QLatin1String("host"), m_ui->host->text());
|
||||
settings->setValue(QLatin1String("port"), m_ui->port->value());
|
||||
settings->setValue(QLatin1String("user"), m_ui->user->text());
|
||||
settings->setValue(QLatin1String("keyFile"), m_ui->keyFile->path());
|
||||
settings->setValue(QLatin1String("executable"), m_ui->executable->text());
|
||||
settings->setValue(QLatin1String("workingDirectory"), m_ui->workingDirectory->text());
|
||||
settings->setValue(QLatin1String("arguments"), m_ui->arguments->text());
|
||||
settings->setValue(QLatin1String("host"), d->host->text());
|
||||
settings->setValue(QLatin1String("port"), d->port->value());
|
||||
settings->setValue(QLatin1String("user"), d->user->text());
|
||||
settings->setValue(QLatin1String("keyFile"), d->keyFile->path());
|
||||
settings->setValue(QLatin1String("executable"), d->executable->text());
|
||||
settings->setValue(QLatin1String("workingDirectory"), d->workingDirectory->text());
|
||||
settings->setValue(QLatin1String("arguments"), d->arguments->text());
|
||||
settings->endGroup();
|
||||
|
||||
QDialog::accept();
|
||||
@@ -107,42 +197,42 @@ void StartRemoteDialog::accept()
|
||||
|
||||
void StartRemoteDialog::validate()
|
||||
{
|
||||
bool valid = !m_ui->host->text().isEmpty() && !m_ui->user->text().isEmpty()
|
||||
&& !m_ui->executable->text().isEmpty();
|
||||
valid = valid && (!m_ui->password->text().isEmpty() || m_ui->keyFile->isValid());
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
|
||||
bool valid = !d->host->text().isEmpty() && !d->user->text().isEmpty()
|
||||
&& !d->executable->text().isEmpty();
|
||||
valid = valid && (!d->password->text().isEmpty() || d->keyFile->isValid());
|
||||
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
|
||||
}
|
||||
|
||||
QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const
|
||||
{
|
||||
QSsh::SshConnectionParameters params;
|
||||
params.host = m_ui->host->text();
|
||||
params.userName = m_ui->user->text();
|
||||
if (m_ui->keyFile->isValid()) {
|
||||
params.host = d->host->text();
|
||||
params.userName = d->user->text();
|
||||
if (d->keyFile->isValid()) {
|
||||
params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByKey;
|
||||
params.privateKeyFile = m_ui->keyFile->path();
|
||||
params.privateKeyFile = d->keyFile->path();
|
||||
} else {
|
||||
params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByPassword;
|
||||
params.password = m_ui->password->text();
|
||||
params.password = d->password->text();
|
||||
}
|
||||
params.port = m_ui->port->value();
|
||||
params.port = d->port->value();
|
||||
params.timeout = 10;
|
||||
return params;
|
||||
}
|
||||
|
||||
QString StartRemoteDialog::executable() const
|
||||
{
|
||||
return m_ui->executable->text();
|
||||
return d->executable->text();
|
||||
}
|
||||
|
||||
QString StartRemoteDialog::arguments() const
|
||||
{
|
||||
return m_ui->arguments->text();
|
||||
return d->arguments->text();
|
||||
}
|
||||
|
||||
QString StartRemoteDialog::workingDirectory() const
|
||||
{
|
||||
return m_ui->workingDirectory->text();
|
||||
return d->workingDirectory->text();
|
||||
}
|
||||
|
||||
} // namespace Analyzer
|
||||
|
||||
Reference in New Issue
Block a user