forked from qt-creator/qt-creator
Git: Add tags from log window
Fixes: QTCREATORBUG-22202 Change-Id: Id6cbaf036d25fe5e9e8fcf2fe4d131649746e128 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
9dd05ec341
commit
0161729c23
@@ -105,14 +105,31 @@ QWidget *BranchValidationDelegate::createEditor(QWidget *parent,
|
|||||||
return lineEdit;
|
return lineEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent) :
|
BranchAddDialog::BranchAddDialog(const QStringList &localBranches, Type type, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Ui::BranchAddDialog)
|
m_ui(new Ui::BranchAddDialog)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->trackingCheckBox->setVisible(false);
|
m_ui->trackingCheckBox->setVisible(false);
|
||||||
setCheckoutVisible(false);
|
setCheckoutVisible(false);
|
||||||
setWindowTitle(addBranch ? tr("Add Branch") : tr("Rename Branch"));
|
|
||||||
|
switch (type) {
|
||||||
|
case BranchAddDialog::AddBranch:
|
||||||
|
setWindowTitle(tr("Add Branch"));
|
||||||
|
break;
|
||||||
|
case BranchAddDialog::RenameBranch:
|
||||||
|
setWindowTitle(tr("Rename Branch"));
|
||||||
|
break;
|
||||||
|
case BranchAddDialog::AddTag:
|
||||||
|
setWindowTitle(tr("Add Tag"));
|
||||||
|
m_ui->branchNameLabel->setText(tr("Tag name:"));
|
||||||
|
break;
|
||||||
|
case BranchAddDialog::RenameTag:
|
||||||
|
setWindowTitle(tr("Rename Tag"));
|
||||||
|
m_ui->branchNameLabel->setText(tr("Tag name:"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
m_ui->branchNameEdit->setValidator(new BranchNameValidator(localBranches, this));
|
m_ui->branchNameEdit->setValidator(new BranchNameValidator(localBranches, this));
|
||||||
connect(m_ui->branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus);
|
connect(m_ui->branchNameEdit, &QLineEdit::textChanged, this, &BranchAddDialog::updateButtonStatus);
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,14 @@ class BranchAddDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent);
|
enum Type {
|
||||||
|
AddBranch,
|
||||||
|
RenameBranch,
|
||||||
|
AddTag,
|
||||||
|
RenameTag
|
||||||
|
};
|
||||||
|
|
||||||
|
BranchAddDialog(const QStringList &localBranches, Type type, QWidget *parent);
|
||||||
~BranchAddDialog() override;
|
~BranchAddDialog() override;
|
||||||
|
|
||||||
void setBranchName(const QString &);
|
void setBranchName(const QString &);
|
||||||
|
@@ -313,7 +313,7 @@ bool BranchView::add()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchAddDialog branchAddDialog(localNames, true, this);
|
BranchAddDialog branchAddDialog(localNames, BranchAddDialog::Type::AddBranch, this);
|
||||||
branchAddDialog.setBranchName(suggestedName);
|
branchAddDialog.setBranchName(suggestedName);
|
||||||
branchAddDialog.setTrackedBranchName(isTracked ? trackedBranch : QString(), !isLocal);
|
branchAddDialog.setTrackedBranchName(isTracked ? trackedBranch : QString(), !isLocal);
|
||||||
branchAddDialog.setCheckoutVisible(true);
|
branchAddDialog.setCheckoutVisible(true);
|
||||||
@@ -444,11 +444,10 @@ bool BranchView::rename()
|
|||||||
if (!isTag)
|
if (!isTag)
|
||||||
localNames = m_model->localBranchNames();
|
localNames = m_model->localBranchNames();
|
||||||
|
|
||||||
BranchAddDialog branchAddDialog(localNames, false, this);
|
const BranchAddDialog::Type type = isTag ? BranchAddDialog::Type::RenameTag
|
||||||
if (isTag)
|
: BranchAddDialog::Type::RenameBranch;
|
||||||
branchAddDialog.setWindowTitle(tr("Rename Tag"));
|
BranchAddDialog branchAddDialog(localNames, type, this);
|
||||||
branchAddDialog.setBranchName(oldName);
|
branchAddDialog.setBranchName(oldName);
|
||||||
branchAddDialog.setTrackedBranchName(QString(), false);
|
|
||||||
|
|
||||||
branchAddDialog.exec();
|
branchAddDialog.exec();
|
||||||
|
|
||||||
|
@@ -1186,7 +1186,7 @@ QStringList GitClient::setupCheckoutArguments(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchAddDialog branchAddDialog(localBranches, true, ICore::dialogParent());
|
BranchAddDialog branchAddDialog(localBranches, BranchAddDialog::Type::AddBranch, ICore::dialogParent());
|
||||||
branchAddDialog.setTrackedBranchName(remoteBranch, true);
|
branchAddDialog.setTrackedBranchName(remoteBranch, true);
|
||||||
|
|
||||||
if (branchAddDialog.exec() != QDialog::Accepted)
|
if (branchAddDialog.exec() != QDialog::Accepted)
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include "giteditor.h"
|
#include "giteditor.h"
|
||||||
|
|
||||||
#include "annotationhighlighter.h"
|
#include "annotationhighlighter.h"
|
||||||
|
#include "branchadddialog.h"
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
#include "gitsettings.h"
|
#include "gitsettings.h"
|
||||||
@@ -305,6 +306,25 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
|||||||
menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
|
menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
|
||||||
GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
|
GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
|
||||||
});
|
});
|
||||||
|
menu->addAction(tr("Add &Tag for Change %1...").arg(change), this, [this] {
|
||||||
|
QString output;
|
||||||
|
QString errorMessage;
|
||||||
|
GitPlugin::client()->synchronousTagCmd(sourceWorkingDirectory(), QStringList(),
|
||||||
|
&output, &errorMessage);
|
||||||
|
|
||||||
|
const QStringList tags = output.split('\n');
|
||||||
|
BranchAddDialog dialog(tags, BranchAddDialog::Type::AddTag, nullptr);
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Rejected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GitPlugin::client()->synchronousTagCmd(sourceWorkingDirectory(),
|
||||||
|
{dialog.branchName(), m_currentChange},
|
||||||
|
&output, &errorMessage);
|
||||||
|
VcsOutputWindow::append(output);
|
||||||
|
if (!errorMessage.isEmpty())
|
||||||
|
VcsOutputWindow::append(errorMessage, VcsOutputWindow::MessageStyle::Error);
|
||||||
|
});
|
||||||
|
|
||||||
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
||||||
resetMenu->addAction(tr("&Hard"), this, [this] { resetChange("hard"); });
|
resetMenu->addAction(tr("&Hard"), this, [this] { resetChange("hard"); });
|
||||||
|
Reference in New Issue
Block a user