forked from qt-creator/qt-creator
Gerrit: Add curl to settings
Will be used for REST queries. Change-Id: Iad5c70c8451764da691120b42e45d0991a757149 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
bcc20d1a2b
commit
d319e66811
@@ -85,6 +85,7 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
|
|||||||
, m_hostLineEdit(new QLineEdit(this))
|
, m_hostLineEdit(new QLineEdit(this))
|
||||||
, m_userLineEdit(new QLineEdit(this))
|
, m_userLineEdit(new QLineEdit(this))
|
||||||
, m_sshChooser(new Utils::PathChooser)
|
, m_sshChooser(new Utils::PathChooser)
|
||||||
|
, m_curlChooser(new Utils::PathChooser)
|
||||||
, m_portSpinBox(new QSpinBox(this))
|
, m_portSpinBox(new QSpinBox(this))
|
||||||
, m_httpsCheckBox(new QCheckBox(tr("HTTPS")))
|
, m_httpsCheckBox(new QCheckBox(tr("HTTPS")))
|
||||||
{
|
{
|
||||||
@@ -96,15 +97,19 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
|
|||||||
m_sshChooser->setCommandVersionArguments({"-V"});
|
m_sshChooser->setCommandVersionArguments({"-V"});
|
||||||
m_sshChooser->setHistoryCompleter("Git.SshCommand.History");
|
m_sshChooser->setHistoryCompleter("Git.SshCommand.History");
|
||||||
formLayout->addRow(tr("&ssh:"), m_sshChooser);
|
formLayout->addRow(tr("&ssh:"), m_sshChooser);
|
||||||
|
m_curlChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||||
|
m_curlChooser->setCommandVersionArguments({"-V"});
|
||||||
|
formLayout->addRow(tr("cur&l:"), m_curlChooser);
|
||||||
m_portSpinBox->setMinimum(1);
|
m_portSpinBox->setMinimum(1);
|
||||||
m_portSpinBox->setMaximum(65535);
|
m_portSpinBox->setMaximum(65535);
|
||||||
formLayout->addRow(tr("&Port:"), m_portSpinBox);
|
formLayout->addRow(tr("SSH &Port:"), m_portSpinBox);
|
||||||
formLayout->addRow(tr("P&rotocol:"), m_httpsCheckBox);
|
formLayout->addRow(tr("P&rotocol:"), m_httpsCheckBox);
|
||||||
m_httpsCheckBox->setToolTip(tr(
|
m_httpsCheckBox->setToolTip(tr(
|
||||||
"Determines the protocol used to form a URL in case\n"
|
"Determines the protocol used to form a URL in case\n"
|
||||||
"\"canonicalWebUrl\" is not configured in the file\n"
|
"\"canonicalWebUrl\" is not configured in the file\n"
|
||||||
"\"gerrit.config\"."));
|
"\"gerrit.config\"."));
|
||||||
setTabOrder(m_sshChooser, m_portSpinBox);
|
setTabOrder(m_sshChooser, m_curlChooser);
|
||||||
|
setTabOrder(m_curlChooser, m_portSpinBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
GerritParameters GerritOptionsWidget::parameters() const
|
GerritParameters GerritOptionsWidget::parameters() const
|
||||||
@@ -115,6 +120,7 @@ GerritParameters GerritOptionsWidget::parameters() const
|
|||||||
m_userLineEdit->text().trimmed(),
|
m_userLineEdit->text().trimmed(),
|
||||||
GerritServer::Ssh);
|
GerritServer::Ssh);
|
||||||
result.ssh = m_sshChooser->path();
|
result.ssh = m_sshChooser->path();
|
||||||
|
result.curl = m_curlChooser->path();
|
||||||
result.https = m_httpsCheckBox->isChecked();
|
result.https = m_httpsCheckBox->isChecked();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -124,6 +130,7 @@ void GerritOptionsWidget::setParameters(const GerritParameters &p)
|
|||||||
m_hostLineEdit->setText(p.server.host);
|
m_hostLineEdit->setText(p.server.host);
|
||||||
m_userLineEdit->setText(p.server.user);
|
m_userLineEdit->setText(p.server.user);
|
||||||
m_sshChooser->setPath(p.ssh);
|
m_sshChooser->setPath(p.ssh);
|
||||||
|
m_curlChooser->setPath(p.curl);
|
||||||
m_portSpinBox->setValue(p.server.port);
|
m_portSpinBox->setValue(p.server.port);
|
||||||
m_httpsCheckBox->setChecked(p.https);
|
m_httpsCheckBox->setChecked(p.https);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ private:
|
|||||||
QLineEdit *m_hostLineEdit;
|
QLineEdit *m_hostLineEdit;
|
||||||
QLineEdit *m_userLineEdit;
|
QLineEdit *m_userLineEdit;
|
||||||
Utils::PathChooser *m_sshChooser;
|
Utils::PathChooser *m_sshChooser;
|
||||||
|
Utils::PathChooser *m_curlChooser;
|
||||||
QSpinBox *m_portSpinBox;
|
QSpinBox *m_portSpinBox;
|
||||||
QCheckBox *m_httpsCheckBox;
|
QCheckBox *m_httpsCheckBox;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,30 +46,35 @@ static const char userKeyC[] = "User";
|
|||||||
static const char portKeyC[] = "Port";
|
static const char portKeyC[] = "Port";
|
||||||
static const char portFlagKeyC[] = "PortFlag";
|
static const char portFlagKeyC[] = "PortFlag";
|
||||||
static const char sshKeyC[] = "Ssh";
|
static const char sshKeyC[] = "Ssh";
|
||||||
|
static const char curlKeyC[] = "Curl";
|
||||||
static const char httpsKeyC[] = "Https";
|
static const char httpsKeyC[] = "Https";
|
||||||
static const char defaultHostC[] = "codereview.qt-project.org";
|
static const char defaultHostC[] = "codereview.qt-project.org";
|
||||||
static const char defaultSshC[] = "ssh";
|
|
||||||
static const char savedQueriesKeyC[] = "SavedQueries";
|
static const char savedQueriesKeyC[] = "SavedQueries";
|
||||||
|
|
||||||
static const char defaultPortFlag[] = "-p";
|
static const char defaultPortFlag[] = "-p";
|
||||||
|
|
||||||
enum { defaultPort = 29418 };
|
enum { defaultPort = 29418 };
|
||||||
|
|
||||||
|
static inline QString detectApp(const char *defaultExe)
|
||||||
|
{
|
||||||
|
const QString defaultApp = HostOsInfo::withExecutableSuffix(QLatin1String(defaultExe));
|
||||||
|
QString app = QStandardPaths::findExecutable(defaultApp);
|
||||||
|
if (!app.isEmpty())
|
||||||
|
return app;
|
||||||
|
if (HostOsInfo::isWindowsHost()) { // Windows: Use app.exe from git if it cannot be found.
|
||||||
|
FileName path = GerritPlugin::gitBinDirectory();
|
||||||
|
if (!path.isEmpty())
|
||||||
|
app = path.appendPath(defaultApp).toString();
|
||||||
|
}
|
||||||
|
return app;
|
||||||
|
}
|
||||||
|
|
||||||
static inline QString detectSsh()
|
static inline QString detectSsh()
|
||||||
{
|
{
|
||||||
const QByteArray gitSsh = qgetenv("GIT_SSH");
|
const QByteArray gitSsh = qgetenv("GIT_SSH");
|
||||||
if (!gitSsh.isEmpty())
|
if (!gitSsh.isEmpty())
|
||||||
return QString::fromLocal8Bit(gitSsh);
|
return QString::fromLocal8Bit(gitSsh);
|
||||||
const QString defaultSsh = Utils::HostOsInfo::withExecutableSuffix(defaultSshC);
|
return detectApp("ssh");
|
||||||
QString ssh = QStandardPaths::findExecutable(defaultSsh);
|
|
||||||
if (!ssh.isEmpty())
|
|
||||||
return ssh;
|
|
||||||
if (HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
|
|
||||||
FileName path = GerritPlugin::gitBinDirectory();
|
|
||||||
if (!path.isEmpty())
|
|
||||||
ssh = path.appendPath(defaultSsh).toString();
|
|
||||||
}
|
|
||||||
return ssh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GerritServer::GerritServer()
|
GerritServer::GerritServer()
|
||||||
@@ -156,7 +161,7 @@ bool GerritServer::fillFromRemote(const QString &remote, const QString &defaultU
|
|||||||
|
|
||||||
bool GerritParameters::equals(const GerritParameters &rhs) const
|
bool GerritParameters::equals(const GerritParameters &rhs) const
|
||||||
{
|
{
|
||||||
return server == rhs.server && ssh == rhs.ssh && https == rhs.https;
|
return server == rhs.server && ssh == rhs.ssh && curl == rhs.curl && https == rhs.https;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritParameters::toSettings(QSettings *s) const
|
void GerritParameters::toSettings(QSettings *s) const
|
||||||
@@ -167,6 +172,7 @@ void GerritParameters::toSettings(QSettings *s) const
|
|||||||
s->setValue(portKeyC, server.port);
|
s->setValue(portKeyC, server.port);
|
||||||
s->setValue(portFlagKeyC, portFlag);
|
s->setValue(portFlagKeyC, portFlag);
|
||||||
s->setValue(sshKeyC, ssh);
|
s->setValue(sshKeyC, ssh);
|
||||||
|
s->setValue(curlKeyC, curl);
|
||||||
s->setValue(httpsKeyC, https);
|
s->setValue(httpsKeyC, https);
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
@@ -184,6 +190,7 @@ void GerritParameters::fromSettings(const QSettings *s)
|
|||||||
server.host = s->value(rootKey + hostKeyC, defaultHostC).toString();
|
server.host = s->value(rootKey + hostKeyC, defaultHostC).toString();
|
||||||
server.user = s->value(rootKey + userKeyC, QString()).toString();
|
server.user = s->value(rootKey + userKeyC, QString()).toString();
|
||||||
ssh = s->value(rootKey + sshKeyC, QString()).toString();
|
ssh = s->value(rootKey + sshKeyC, QString()).toString();
|
||||||
|
curl = s->value(rootKey + curlKeyC).toString();
|
||||||
server.port = s->value(rootKey + portKeyC, QVariant(int(defaultPort))).toInt();
|
server.port = s->value(rootKey + portKeyC, QVariant(int(defaultPort))).toInt();
|
||||||
portFlag = s->value(rootKey + portFlagKeyC, defaultPortFlag).toString();
|
portFlag = s->value(rootKey + portFlagKeyC, defaultPortFlag).toString();
|
||||||
savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
|
savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
|
||||||
@@ -191,6 +198,8 @@ void GerritParameters::fromSettings(const QSettings *s)
|
|||||||
https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
|
https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
|
||||||
if (ssh.isEmpty() || !QFile::exists(ssh))
|
if (ssh.isEmpty() || !QFile::exists(ssh))
|
||||||
ssh = detectSsh();
|
ssh = detectSsh();
|
||||||
|
if (curl.isEmpty() || !QFile::exists(curl))
|
||||||
|
curl = detectApp("curl");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GerritParameters::isValid() const
|
bool GerritParameters::isValid() const
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
GerritServer server;
|
GerritServer server;
|
||||||
QString ssh;
|
QString ssh;
|
||||||
|
QString curl;
|
||||||
QStringList savedQueries;
|
QStringList savedQueries;
|
||||||
bool https;
|
bool https;
|
||||||
QString portFlag;
|
QString portFlag;
|
||||||
|
|||||||
Reference in New Issue
Block a user