forked from qt-creator/qt-creator
Git: inline branchadddialog.h
Change-Id: I8919f69bfdfd670855167bace62fb55603595270 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@ add_qtc_plugin(Git
|
|||||||
PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase
|
PLUGIN_DEPENDS Core DiffEditor TextEditor VcsBase
|
||||||
SOURCES
|
SOURCES
|
||||||
annotationhighlighter.cpp annotationhighlighter.h
|
annotationhighlighter.cpp annotationhighlighter.h
|
||||||
branchadddialog.cpp branchadddialog.h branchadddialog.ui
|
branchadddialog.cpp branchadddialog.h
|
||||||
branchcheckoutdialog.cpp branchcheckoutdialog.h branchcheckoutdialog.ui
|
branchcheckoutdialog.cpp branchcheckoutdialog.h branchcheckoutdialog.ui
|
||||||
branchmodel.cpp branchmodel.h
|
branchmodel.cpp branchmodel.h
|
||||||
branchview.cpp branchview.h
|
branchview.cpp branchview.h
|
||||||
|
@@ -24,13 +24,19 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "branchadddialog.h"
|
#include "branchadddialog.h"
|
||||||
|
|
||||||
#include "branchmodel.h"
|
#include "branchmodel.h"
|
||||||
#include "ui_branchadddialog.h"
|
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QValidator>
|
#include <QValidator>
|
||||||
@@ -106,11 +112,22 @@ QWidget *BranchValidationDelegate::createEditor(QWidget *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QWidget *parent) :
|
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent)
|
||||||
m_ui(new Ui::BranchAddDialog)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
resize(590, 138);
|
||||||
m_ui->trackingCheckBox->setVisible(false);
|
|
||||||
|
auto branchNameLabel = new QLabel(tr("Branch Name:"));
|
||||||
|
|
||||||
|
m_branchNameEdit = new QLineEdit(this);
|
||||||
|
m_branchNameEdit->setValidator(new BranchNameValidator(localBranches, this));
|
||||||
|
|
||||||
|
m_checkoutCheckBox = new QCheckBox(tr("Checkout new branch"));
|
||||||
|
|
||||||
|
m_trackingCheckBox = new QCheckBox(this);
|
||||||
|
m_trackingCheckBox->setVisible(false);
|
||||||
|
|
||||||
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
setCheckoutVisible(false);
|
setCheckoutVisible(false);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -122,67 +139,75 @@ BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QW
|
|||||||
break;
|
break;
|
||||||
case BranchAddDialog::AddTag:
|
case BranchAddDialog::AddTag:
|
||||||
setWindowTitle(tr("Add Tag"));
|
setWindowTitle(tr("Add Tag"));
|
||||||
m_ui->branchNameLabel->setText(tr("Tag name:"));
|
branchNameLabel->setText(tr("Tag name:"));
|
||||||
break;
|
break;
|
||||||
case BranchAddDialog::RenameTag:
|
case BranchAddDialog::RenameTag:
|
||||||
setWindowTitle(tr("Rename Tag"));
|
setWindowTitle(tr("Rename Tag"));
|
||||||
m_ui->branchNameLabel->setText(tr("Tag name:"));
|
branchNameLabel->setText(tr("Tag name:"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->branchNameEdit->setValidator(new BranchNameValidator(localBranches, this));
|
using namespace Utils::Layouting;
|
||||||
connect(m_ui->branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus);
|
|
||||||
|
Column {
|
||||||
|
Row { branchNameLabel, m_branchNameEdit },
|
||||||
|
m_checkoutCheckBox,
|
||||||
|
m_trackingCheckBox,
|
||||||
|
st,
|
||||||
|
m_buttonBox
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchAddDialog::~BranchAddDialog()
|
BranchAddDialog::~BranchAddDialog() = default;
|
||||||
{
|
|
||||||
delete m_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BranchAddDialog::setBranchName(const QString &n)
|
void BranchAddDialog::setBranchName(const QString &n)
|
||||||
{
|
{
|
||||||
m_ui->branchNameEdit->setText(n);
|
m_branchNameEdit->setText(n);
|
||||||
m_ui->branchNameEdit->selectAll();
|
m_branchNameEdit->selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BranchAddDialog::branchName() const
|
QString BranchAddDialog::branchName() const
|
||||||
{
|
{
|
||||||
return m_ui->branchNameEdit->text();
|
return m_branchNameEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchAddDialog::setTrackedBranchName(const QString &name, bool remote)
|
void BranchAddDialog::setTrackedBranchName(const QString &name, bool remote)
|
||||||
{
|
{
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
m_ui->trackingCheckBox->setVisible(false);
|
m_trackingCheckBox->setVisible(false);
|
||||||
m_ui->trackingCheckBox->setChecked(false);
|
m_trackingCheckBox->setChecked(false);
|
||||||
} else {
|
} else {
|
||||||
m_ui->trackingCheckBox->setText(remote ? tr("Track remote branch \"%1\"").arg(name) :
|
m_trackingCheckBox->setText(remote ? tr("Track remote branch \"%1\"").arg(name)
|
||||||
tr("Track local branch \"%1\"").arg(name));
|
: tr("Track local branch \"%1\"").arg(name));
|
||||||
m_ui->trackingCheckBox->setVisible(true);
|
m_trackingCheckBox->setVisible(true);
|
||||||
m_ui->trackingCheckBox->setChecked(remote);
|
m_trackingCheckBox->setChecked(remote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BranchAddDialog::track() const
|
bool BranchAddDialog::track() const
|
||||||
{
|
{
|
||||||
return m_ui->trackingCheckBox->isChecked();
|
return m_trackingCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchAddDialog::setCheckoutVisible(bool visible)
|
void BranchAddDialog::setCheckoutVisible(bool visible)
|
||||||
{
|
{
|
||||||
m_ui->checkoutCheckBox->setVisible(visible);
|
m_checkoutCheckBox->setVisible(visible);
|
||||||
m_ui->checkoutCheckBox->setChecked(visible);
|
m_checkoutCheckBox->setChecked(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BranchAddDialog::checkout() const
|
bool BranchAddDialog::checkout() const
|
||||||
{
|
{
|
||||||
return m_ui->checkoutCheckBox->isChecked();
|
return m_checkoutCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Updates the ok button enabled state of the dialog according to the validity of the branch name. */
|
/*! Updates the ok button enabled state of the dialog according to the validity of the branch name. */
|
||||||
void BranchAddDialog::updateButtonStatus()
|
void BranchAddDialog::updateButtonStatus()
|
||||||
{
|
{
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_ui->branchNameEdit->hasAcceptableInput());
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(m_branchNameEdit->hasAcceptableInput());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -28,13 +28,17 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QCheckBox;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QLineEdit;
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BranchModel;
|
class BranchModel;
|
||||||
|
|
||||||
namespace Ui { class BranchAddDialog; }
|
|
||||||
|
|
||||||
class BranchValidationDelegate : public QItemDelegate
|
class BranchValidationDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -74,7 +78,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
void updateButtonStatus();
|
void updateButtonStatus();
|
||||||
|
|
||||||
Ui::BranchAddDialog *m_ui;
|
QLineEdit *m_branchNameEdit;
|
||||||
|
QCheckBox *m_checkoutCheckBox;
|
||||||
|
QCheckBox *m_trackingCheckBox;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -1,97 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Git::Internal::BranchAddDialog</class>
|
|
||||||
<widget class="QDialog" name="Git::Internal::BranchAddDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>590</width>
|
|
||||||
<height>138</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="branchNameLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Branch Name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="branchNameEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QCheckBox" name="checkoutCheckBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Checkout new branch</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="2">
|
|
||||||
<widget class="QCheckBox" name="trackingCheckBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="4" 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>
|
|
||||||
<item row="3" column="0" colspan="2">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Git::Internal::BranchAddDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>Git::Internal::BranchAddDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@@ -18,7 +18,6 @@ QtcPlugin {
|
|||||||
"annotationhighlighter.h",
|
"annotationhighlighter.h",
|
||||||
"branchadddialog.cpp",
|
"branchadddialog.cpp",
|
||||||
"branchadddialog.h",
|
"branchadddialog.h",
|
||||||
"branchadddialog.ui",
|
|
||||||
"branchcheckoutdialog.cpp",
|
"branchcheckoutdialog.cpp",
|
||||||
"branchcheckoutdialog.h",
|
"branchcheckoutdialog.h",
|
||||||
"branchcheckoutdialog.ui",
|
"branchcheckoutdialog.ui",
|
||||||
|
Reference in New Issue
Block a user