forked from qt-creator/qt-creator
Git: inline remote*.ui
Change-Id: Idb394e69d3976877d091a5cf65a3babfbafe9e6b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -33,8 +33,7 @@ add_qtc_plugin(Git
|
||||
gitutils.cpp gitutils.h
|
||||
logchangedialog.cpp logchangedialog.h
|
||||
mergetool.cpp mergetool.h
|
||||
remoteadditiondialog.ui
|
||||
remotedialog.cpp remotedialog.h remotedialog.ui
|
||||
remotedialog.cpp remotedialog.h
|
||||
remotemodel.cpp remotemodel.h
|
||||
stashdialog.cpp stashdialog.h
|
||||
)
|
||||
|
@@ -54,10 +54,8 @@ QtcPlugin {
|
||||
"logchangedialog.h",
|
||||
"mergetool.cpp",
|
||||
"mergetool.h",
|
||||
"remoteadditiondialog.ui",
|
||||
"remotedialog.cpp",
|
||||
"remotedialog.h",
|
||||
"remotedialog.ui",
|
||||
"remotemodel.cpp",
|
||||
"remotemodel.h",
|
||||
"stashdialog.cpp",
|
||||
|
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Git::Internal::RemoteAdditionDialog</class>
|
||||
<widget class="QDialog" name="Git::Internal::RemoteAdditionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>93</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add Remote</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Utils::FancyLineEdit" name="nameEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="urlLabel">
|
||||
<property name="text">
|
||||
<string>URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Utils::FancyLineEdit" name="urlEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<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::FancyLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">utils/fancylineedit.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Git::Internal::RemoteAdditionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>283</x>
|
||||
<y>81</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>380</x>
|
||||
<y>27</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Git::Internal::RemoteAdditionDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>211</x>
|
||||
<y>81</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>182</x>
|
||||
<y>92</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -28,15 +28,24 @@
|
||||
#include "gitclient.h"
|
||||
#include "gitplugin.h"
|
||||
#include "remotemodel.h"
|
||||
#include "ui_remotedialog.h"
|
||||
#include "ui_remoteadditiondialog.h"
|
||||
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/headerviewstretcher.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QApplication>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QTreeView>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -54,9 +63,11 @@ public:
|
||||
m_invalidRemoteNameChars(GitPlugin::invalidBranchAndRemoteNamePattern()),
|
||||
m_remoteNames(remoteNames)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_ui.nameEdit->setHistoryCompleter("Git.RemoteNames");
|
||||
m_ui.nameEdit->setValidationFunction([this](Utils::FancyLineEdit *edit, QString *errorMessage) {
|
||||
resize(381, 93);
|
||||
|
||||
m_nameEdit = new FancyLineEdit(this);
|
||||
m_nameEdit->setHistoryCompleter("Git.RemoteNames");
|
||||
m_nameEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorMessage) {
|
||||
if (!edit)
|
||||
return false;
|
||||
|
||||
@@ -83,12 +94,10 @@ public:
|
||||
// is a valid remote name
|
||||
return !input.isEmpty();
|
||||
});
|
||||
connect(m_ui.nameEdit, &QLineEdit::textChanged, [this]() {
|
||||
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_ui.nameEdit->isValid());
|
||||
});
|
||||
|
||||
m_ui.urlEdit->setHistoryCompleter("Git.RemoteUrls");
|
||||
m_ui.urlEdit->setValidationFunction([](Utils::FancyLineEdit *edit, QString *errorMessage) {
|
||||
m_urlEdit = new FancyLineEdit(this);
|
||||
m_urlEdit->setHistoryCompleter("Git.RemoteUrls");
|
||||
m_urlEdit->setValidationFunction([](FancyLineEdit *edit, QString *errorMessage) {
|
||||
if (!edit || edit->text().isEmpty())
|
||||
return false;
|
||||
|
||||
@@ -99,21 +108,38 @@ public:
|
||||
return r.isValid;
|
||||
});
|
||||
|
||||
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
using namespace Layouting;
|
||||
Grid {
|
||||
tr("Name:"), m_nameEdit, br,
|
||||
tr("URL:"), m_urlEdit, br,
|
||||
Span(2, buttonBox)
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_nameEdit, &QLineEdit::textChanged, [this, buttonBox] {
|
||||
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_nameEdit->isValid());
|
||||
});
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
}
|
||||
|
||||
QString remoteName() const
|
||||
{
|
||||
return m_ui.nameEdit->text();
|
||||
return m_nameEdit->text();
|
||||
}
|
||||
|
||||
QString remoteUrl() const
|
||||
{
|
||||
return m_ui.urlEdit->text();
|
||||
return m_urlEdit->text();
|
||||
}
|
||||
|
||||
private:
|
||||
Ui::RemoteAdditionDialog m_ui;
|
||||
FancyLineEdit *m_nameEdit;
|
||||
FancyLineEdit *m_urlEdit;
|
||||
|
||||
const QRegularExpression m_invalidRemoteNameChars;
|
||||
QStringList m_remoteNames;
|
||||
};
|
||||
@@ -126,42 +152,78 @@ private:
|
||||
|
||||
RemoteDialog::RemoteDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::RemoteDialog),
|
||||
m_remoteModel(new RemoteModel(this))
|
||||
{
|
||||
setModal(false);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true); // Do not update unnecessarily
|
||||
setWindowTitle(tr("Remotes"));
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_repositoryLabel = new QLabel;
|
||||
|
||||
m_ui->remoteView->setModel(m_remoteModel);
|
||||
new Utils::HeaderViewStretcher(m_ui->remoteView->header(), 1);
|
||||
auto refreshButton = new QPushButton(tr("Re&fresh"));
|
||||
refreshButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
||||
|
||||
connect(m_ui->addButton, &QPushButton::clicked, this, &RemoteDialog::addRemote);
|
||||
connect(m_ui->fetchButton, &QPushButton::clicked, this, &RemoteDialog::fetchFromRemote);
|
||||
connect(m_ui->pushButton, &QPushButton::clicked, this, &RemoteDialog::pushToRemote);
|
||||
connect(m_ui->removeButton, &QPushButton::clicked, this, &RemoteDialog::removeRemote);
|
||||
connect(m_ui->refreshButton, &QPushButton::clicked, this, &RemoteDialog::refreshRemotes);
|
||||
m_remoteView = new QTreeView;
|
||||
m_remoteView->setMinimumSize(QSize(0, 100));
|
||||
m_remoteView->setEditTriggers(QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
|
||||
m_remoteView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_remoteView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_remoteView->setRootIsDecorated(false);
|
||||
m_remoteView->setUniformRowHeights(true);
|
||||
m_remoteView->setModel(m_remoteModel);
|
||||
new HeaderViewStretcher(m_remoteView->header(), 1);
|
||||
|
||||
connect(m_ui->remoteView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
m_addButton = new QPushButton(tr("&Add..."));
|
||||
m_addButton->setAutoDefault(false);
|
||||
|
||||
m_fetchButton = new QPushButton(tr("F&etch"));
|
||||
|
||||
m_pushButton = new QPushButton(tr("&Push"));
|
||||
|
||||
m_removeButton = new QPushButton(tr("&Remove"));
|
||||
m_removeButton->setAutoDefault(false);
|
||||
|
||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
|
||||
using namespace Layouting;
|
||||
Column {
|
||||
Group {
|
||||
Row { m_repositoryLabel, refreshButton }
|
||||
},
|
||||
Group {
|
||||
title(tr("Remotes")),
|
||||
Column {
|
||||
m_remoteView,
|
||||
Row { st, m_addButton, m_fetchButton, m_pushButton, m_removeButton }
|
||||
}
|
||||
},
|
||||
buttonBox,
|
||||
}.attachTo(this);
|
||||
|
||||
connect(m_addButton, &QPushButton::clicked, this, &RemoteDialog::addRemote);
|
||||
connect(m_fetchButton, &QPushButton::clicked, this, &RemoteDialog::fetchFromRemote);
|
||||
connect(m_pushButton, &QPushButton::clicked, this, &RemoteDialog::pushToRemote);
|
||||
connect(m_removeButton, &QPushButton::clicked, this, &RemoteDialog::removeRemote);
|
||||
connect(refreshButton, &QPushButton::clicked, this, &RemoteDialog::refreshRemotes);
|
||||
|
||||
connect(m_remoteView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, &RemoteDialog::updateButtonState);
|
||||
connect(m_remoteModel, &RemoteModel::refreshed,
|
||||
this, &RemoteDialog::updateButtonState);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
updateButtonState();
|
||||
}
|
||||
|
||||
RemoteDialog::~RemoteDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
RemoteDialog::~RemoteDialog() = default;
|
||||
|
||||
void RemoteDialog::refresh(const FilePath &repository, bool force)
|
||||
{
|
||||
if (m_remoteModel->workingDirectory() == repository && !force)
|
||||
return;
|
||||
// Refresh
|
||||
m_ui->repositoryLabel->setText(GitPlugin::msgRepositoryLabel(repository));
|
||||
m_repositoryLabel->setText(GitPlugin::msgRepositoryLabel(repository));
|
||||
if (repository.isEmpty()) {
|
||||
m_remoteModel->clear();
|
||||
} else {
|
||||
@@ -187,7 +249,7 @@ void RemoteDialog::addRemote()
|
||||
|
||||
void RemoteDialog::removeRemote()
|
||||
{
|
||||
const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes();
|
||||
const QModelIndexList indexList = m_remoteView->selectionModel()->selectedIndexes();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -203,7 +265,7 @@ void RemoteDialog::removeRemote()
|
||||
|
||||
void RemoteDialog::pushToRemote()
|
||||
{
|
||||
const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes();
|
||||
const QModelIndexList indexList = m_remoteView->selectionModel()->selectedIndexes();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -214,7 +276,7 @@ void RemoteDialog::pushToRemote()
|
||||
|
||||
void RemoteDialog::fetchFromRemote()
|
||||
{
|
||||
const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes();
|
||||
const QModelIndexList indexList = m_remoteView->selectionModel()->selectedIndexes();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -225,13 +287,13 @@ void RemoteDialog::fetchFromRemote()
|
||||
|
||||
void RemoteDialog::updateButtonState()
|
||||
{
|
||||
const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes();
|
||||
const QModelIndexList indexList = m_remoteView->selectionModel()->selectedIndexes();
|
||||
|
||||
const bool haveSelection = !indexList.isEmpty();
|
||||
m_ui->addButton->setEnabled(true);
|
||||
m_ui->fetchButton->setEnabled(haveSelection);
|
||||
m_ui->pushButton->setEnabled(haveSelection);
|
||||
m_ui->removeButton->setEnabled(haveSelection);
|
||||
m_addButton->setEnabled(true);
|
||||
m_fetchButton->setEnabled(haveSelection);
|
||||
m_pushButton->setEnabled(haveSelection);
|
||||
m_removeButton->setEnabled(haveSelection);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -27,13 +27,16 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLabel;
|
||||
class QTreeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
namespace Ui { class RemoteDialog; }
|
||||
|
||||
class RemoteModel;
|
||||
|
||||
class RemoteDialog : public QDialog
|
||||
@@ -55,9 +58,14 @@ private:
|
||||
|
||||
void updateButtonState();
|
||||
|
||||
Ui::RemoteDialog *m_ui;
|
||||
|
||||
RemoteModel *m_remoteModel;
|
||||
|
||||
QLabel *m_repositoryLabel;
|
||||
QTreeView *m_remoteView;
|
||||
QPushButton *m_addButton;
|
||||
QPushButton *m_fetchButton;
|
||||
QPushButton *m_pushButton;
|
||||
QPushButton *m_removeButton;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -1,166 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Git::Internal::RemoteDialog</class>
|
||||
<widget class="QDialog" name="Git::Internal::RemoteDialog">
|
||||
<property name="windowTitle">
|
||||
<string>Remotes</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="infoGroupBox">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="repositoryLabel">
|
||||
<property name="text">
|
||||
<string notr="true">Repository: Dummy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refreshButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Re&fresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="remoteGroupBox">
|
||||
<property name="title">
|
||||
<string>Remotes</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="remoteView">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addButton">
|
||||
<property name="text">
|
||||
<string>&Add...</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="fetchButton">
|
||||
<property name="text">
|
||||
<string>F&etch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>&Push</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="text">
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Git::Internal::RemoteDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>466</x>
|
||||
<y>614</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>544</x>
|
||||
<y>23</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@@ -34,7 +34,8 @@
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class RemoteModel : public QAbstractTableModel {
|
||||
class RemoteModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RemoteModel(QObject *parent = nullptr);
|
||||
|
Reference in New Issue
Block a user