forked from qt-creator/qt-creator
Mercurial: Inline srcdestdialog.ui
Change-Id: I6866ffbe708600e47dd136e627a6c59207b50815 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -11,5 +11,5 @@ add_qtc_plugin(Mercurial
|
|||||||
mercurialplugin.cpp mercurialplugin.h
|
mercurialplugin.cpp mercurialplugin.h
|
||||||
mercurialsettings.cpp mercurialsettings.h
|
mercurialsettings.cpp mercurialsettings.h
|
||||||
revertdialog.cpp revertdialog.h
|
revertdialog.cpp revertdialog.h
|
||||||
srcdestdialog.cpp srcdestdialog.h srcdestdialog.ui
|
srcdestdialog.cpp srcdestdialog.h
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ QtcPlugin {
|
|||||||
"revertdialog.cpp",
|
"revertdialog.cpp",
|
||||||
"revertdialog.h",
|
"revertdialog.h",
|
||||||
"srcdestdialog.cpp",
|
"srcdestdialog.cpp",
|
||||||
"srcdestdialog.h",
|
"srcdestdialog.h"
|
||||||
"srcdestdialog.ui",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,49 +3,85 @@
|
|||||||
|
|
||||||
#include "authenticationdialog.h"
|
#include "authenticationdialog.h"
|
||||||
#include "srcdestdialog.h"
|
#include "srcdestdialog.h"
|
||||||
#include "ui_srcdestdialog.h"
|
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QRadioButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
|
|
||||||
namespace Mercurial {
|
namespace Mercurial::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
SrcDestDialog::SrcDestDialog(const VcsBasePluginState &state, Direction dir, QWidget *parent) :
|
SrcDestDialog::SrcDestDialog(const VcsBasePluginState &state, Direction dir, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Ui::SrcDestDialog),
|
|
||||||
m_direction(dir),
|
m_direction(dir),
|
||||||
m_state(state)
|
m_state(state)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
resize(400, 187);
|
||||||
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
|
||||||
m_ui->localPathChooser->setHistoryCompleter(QLatin1String("Hg.SourceDir.History"));
|
m_defaultButton = new QRadioButton(tr("Default Location"));
|
||||||
QUrl repoUrl(getRepoUrl());
|
m_defaultButton->setChecked(true);
|
||||||
if (repoUrl.isEmpty())
|
|
||||||
return;
|
m_localButton = new QRadioButton(tr("Local filesystem:"));
|
||||||
|
|
||||||
|
auto urlButton = new QRadioButton(tr("Specify URL:"));
|
||||||
|
urlButton->setToolTip(tr("For example: 'https://[user[:pass]@]host[:port]/[path]'."));
|
||||||
|
|
||||||
|
m_localPathChooser = new Utils::PathChooser;
|
||||||
|
m_localPathChooser->setEnabled(false);
|
||||||
|
m_localPathChooser->setExpectedKind(PathChooser::ExistingDirectory);
|
||||||
|
m_localPathChooser->setHistoryCompleter("Hg.SourceDir.History");
|
||||||
|
|
||||||
|
m_urlLineEdit = new QLineEdit;
|
||||||
|
m_urlLineEdit->setToolTip(tr("For example: 'https://[user[:pass]@]host[:port]/[path]'.", nullptr));
|
||||||
|
m_urlLineEdit->setEnabled(false);
|
||||||
|
|
||||||
|
QUrl repoUrl = getRepoUrl();
|
||||||
if (!repoUrl.password().isEmpty())
|
if (!repoUrl.password().isEmpty())
|
||||||
repoUrl.setPassword(QLatin1String("***"));
|
repoUrl.setPassword(QLatin1String("***"));
|
||||||
m_ui->defaultPath->setText(repoUrl.toString());
|
|
||||||
m_ui->promptForCredentials->setChecked(!repoUrl.scheme().isEmpty() && repoUrl.scheme() != QLatin1String("file"));
|
m_promptForCredentials = new QCheckBox(tr("Prompt for credentials"));
|
||||||
|
m_promptForCredentials->setChecked(!repoUrl.scheme().isEmpty() && repoUrl.scheme() != QLatin1String("file"));
|
||||||
|
|
||||||
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Form {
|
||||||
|
m_defaultButton, Column { repoUrl.toString(), m_promptForCredentials }, br,
|
||||||
|
m_localButton, m_localPathChooser, br,
|
||||||
|
urlButton, m_urlLineEdit, br,
|
||||||
|
},
|
||||||
|
st,
|
||||||
|
buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(urlButton, &QRadioButton::toggled, m_urlLineEdit, &QLineEdit::setEnabled);
|
||||||
|
connect(m_localButton, &QAbstractButton::toggled, m_localPathChooser, &QWidget::setEnabled);
|
||||||
|
|
||||||
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrcDestDialog::~SrcDestDialog()
|
SrcDestDialog::~SrcDestDialog() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SrcDestDialog::setPathChooserKind(Utils::PathChooser::Kind kind)
|
void SrcDestDialog::setPathChooserKind(Utils::PathChooser::Kind kind)
|
||||||
{
|
{
|
||||||
m_ui->localPathChooser->setExpectedKind(kind);
|
m_localPathChooser->setExpectedKind(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SrcDestDialog::getRepositoryString() const
|
QString SrcDestDialog::getRepositoryString() const
|
||||||
{
|
{
|
||||||
if (m_ui->defaultButton->isChecked()) {
|
if (m_defaultButton->isChecked()) {
|
||||||
QUrl repoUrl(getRepoUrl());
|
QUrl repoUrl(getRepoUrl());
|
||||||
if (m_ui->promptForCredentials->isChecked() && !repoUrl.scheme().isEmpty() && repoUrl.scheme() != QLatin1String("file")) {
|
if (m_promptForCredentials->isChecked() && !repoUrl.scheme().isEmpty() && repoUrl.scheme() != QLatin1String("file")) {
|
||||||
QScopedPointer<AuthenticationDialog> authDialog(new AuthenticationDialog(repoUrl.userName(), repoUrl.password()));
|
QScopedPointer<AuthenticationDialog> authDialog(new AuthenticationDialog(repoUrl.userName(), repoUrl.password()));
|
||||||
authDialog->setPasswordEnabled(repoUrl.scheme() != QLatin1String("ssh"));
|
authDialog->setPasswordEnabled(repoUrl.scheme() != QLatin1String("ssh"));
|
||||||
if (authDialog->exec()== 0)
|
if (authDialog->exec()== 0)
|
||||||
@@ -63,14 +99,14 @@ QString SrcDestDialog::getRepositoryString() const
|
|||||||
}
|
}
|
||||||
return repoUrl.toString();
|
return repoUrl.toString();
|
||||||
}
|
}
|
||||||
if (m_ui->localButton->isChecked())
|
if (m_localButton->isChecked())
|
||||||
return m_ui->localPathChooser->filePath().toString();
|
return m_localPathChooser->filePath().toString();
|
||||||
return m_ui->urlLineEdit->text();
|
return m_urlLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath SrcDestDialog::workingDir() const
|
FilePath SrcDestDialog::workingDir() const
|
||||||
{
|
{
|
||||||
return Utils::FilePath::fromString(m_workingdir);
|
return FilePath::fromString(m_workingdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl SrcDestDialog::getRepoUrl() const
|
QUrl SrcDestDialog::getRepoUrl() const
|
||||||
@@ -92,5 +128,4 @@ QUrl SrcDestDialog::getRepoUrl() const
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Mercurial::Internal
|
||||||
} // namespace Mercurial
|
|
||||||
|
|||||||
@@ -4,13 +4,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Mercurial {
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Internal {
|
class QCheckBox;
|
||||||
|
class QLineEdit;
|
||||||
|
class QRadioButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Ui { class SrcDestDialog; }
|
namespace Mercurial::Internal {
|
||||||
|
|
||||||
class SrcDestDialog : public QDialog
|
class SrcDestDialog : public QDialog
|
||||||
{
|
{
|
||||||
@@ -18,6 +23,7 @@ class SrcDestDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum Direction { outgoing, incoming };
|
enum Direction { outgoing, incoming };
|
||||||
|
|
||||||
explicit SrcDestDialog(const VcsBase::VcsBasePluginState &state, Direction dir, QWidget *parent = nullptr);
|
explicit SrcDestDialog(const VcsBase::VcsBasePluginState &state, Direction dir, QWidget *parent = nullptr);
|
||||||
~SrcDestDialog() override;
|
~SrcDestDialog() override;
|
||||||
|
|
||||||
@@ -28,12 +34,15 @@ public:
|
|||||||
private:
|
private:
|
||||||
QUrl getRepoUrl() const;
|
QUrl getRepoUrl() const;
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::SrcDestDialog *m_ui;
|
|
||||||
Direction m_direction;
|
Direction m_direction;
|
||||||
mutable QString m_workingdir;
|
mutable QString m_workingdir;
|
||||||
VcsBase::VcsBasePluginState m_state;
|
VcsBase::VcsBasePluginState m_state;
|
||||||
|
|
||||||
|
QRadioButton *m_defaultButton;
|
||||||
|
QRadioButton *m_localButton;
|
||||||
|
Utils::PathChooser *m_localPathChooser;
|
||||||
|
QLineEdit *m_urlLineEdit;
|
||||||
|
QCheckBox *m_promptForCredentials;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Mercurial::Internal
|
||||||
} // namespace Mercurial
|
|
||||||
|
|||||||
@@ -1,170 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Mercurial::Internal::SrcDestDialog</class>
|
|
||||||
<widget class="QDialog" name="Mercurial::Internal::SrcDestDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>187</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QRadioButton" name="defaultButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Default Location</string>
|
|
||||||
</property>
|
|
||||||
<property name="checked">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QRadioButton" name="localButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Local filesystem:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QRadioButton" name="urlButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>For example: 'https://[user[:pass]@]host[:port]/[path]'.</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Specify URL:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="Utils::PathChooser" name="localPathChooser" native="true">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="urlLineEdit">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>For example: 'https://[user[:pass]@]host[:port]/[path]'.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="defaultPath">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="promptForCredentials">
|
|
||||||
<property name="text">
|
|
||||||
<string>Prompt for credentials</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::PathChooser</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">utils/pathchooser.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Mercurial::Internal::SrcDestDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>257</x>
|
|
||||||
<y>177</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Mercurial::Internal::SrcDestDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>325</x>
|
|
||||||
<y>177</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>urlButton</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>urlLineEdit</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>80</x>
|
|
||||||
<y>121</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>332</x>
|
|
||||||
<y>123</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>localButton</sender>
|
|
||||||
<signal>toggled(bool)</signal>
|
|
||||||
<receiver>localPathChooser</receiver>
|
|
||||||
<slot>setEnabled(bool)</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>112</x>
|
|
||||||
<y>81</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>346</x>
|
|
||||||
<y>81</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user