forked from qt-creator/qt-creator
Git: refactoring ChangeSelectionDialog
> Dialog now combines show, cherry-pick and revert > has fixed path, and no way to change it > not created on stack Change-Id: I7cee0b2e775a80941b51a4ca023064baf0d6575c Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -31,9 +31,15 @@
|
|||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -41,27 +47,53 @@ namespace Internal {
|
|||||||
ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QWidget *parent)
|
ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_process(0)
|
, m_process(0)
|
||||||
|
, m_workingDirectoryLabel(new QLabel(workingDirectory, this))
|
||||||
|
, m_changeNumberEdit(new QLineEdit(this))
|
||||||
|
, m_detailsText(new QPlainTextEdit(this))
|
||||||
|
, m_showButton(new QPushButton(tr("Show"), this))
|
||||||
|
, m_cherryPickButton(new QPushButton(tr("Cherry Pick"), this))
|
||||||
|
, m_revertButton(new QPushButton(tr("Revert"), this))
|
||||||
|
, m_cancelButton(new QPushButton(tr("Cancel"), this))
|
||||||
|
, m_command(NoCommand)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
|
||||||
if (!workingDirectory.isEmpty()) {
|
|
||||||
setWorkingDirectory(workingDirectory);
|
|
||||||
m_ui.workingDirectoryButton->setEnabled(false);
|
|
||||||
m_ui.workingDirectoryEdit->setEnabled(false);
|
|
||||||
}
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
||||||
connect(m_ui.workingDirectoryButton, SIGNAL(clicked()), this, SLOT(selectWorkingDirectory()));
|
|
||||||
setWindowTitle(tr("Select a Git Commit"));
|
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
m_gitBinaryPath = GitPlugin::instance()->gitClient()->gitBinaryPath(&ok);
|
m_gitBinaryPath = GitPlugin::instance()->gitClient()->gitBinaryPath(&ok);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QGridLayout* layout = new QGridLayout(this);
|
||||||
|
layout->addWidget(new QLabel(tr("Working Directory:"), this), 0, 0 , 1, 1);
|
||||||
|
layout->addWidget(m_workingDirectoryLabel, 0, 1, 1, 1);
|
||||||
|
layout->addWidget(new QLabel(tr("Change:"), this),1, 0, 1, 1);
|
||||||
|
layout->addWidget(m_changeNumberEdit, 1, 1, 1, 1);
|
||||||
|
layout->addWidget(m_detailsText, 2, 0, 1, 2);
|
||||||
|
|
||||||
|
QHBoxLayout* buttonsLine = new QHBoxLayout();
|
||||||
|
buttonsLine->addWidget(m_cancelButton);
|
||||||
|
buttonsLine->addStretch();
|
||||||
|
buttonsLine->addWidget(m_revertButton);
|
||||||
|
buttonsLine->addWidget(m_cherryPickButton);
|
||||||
|
buttonsLine->addWidget(m_showButton);
|
||||||
|
|
||||||
|
layout->addLayout(buttonsLine, 3, 0 ,1 ,2);
|
||||||
|
|
||||||
|
m_changeNumberEdit->setFocus(Qt::ActiveWindowFocusReason);
|
||||||
|
m_changeNumberEdit->setText(QLatin1String("HEAD"));
|
||||||
|
m_changeNumberEdit->selectAll();
|
||||||
|
|
||||||
|
setWindowTitle(tr("Select a Git Commit"));
|
||||||
|
setGeometry(0, 0, 550, 350);
|
||||||
|
adjustPosition(parent);
|
||||||
|
|
||||||
m_gitEnvironment = GitPlugin::instance()->gitClient()->processEnvironment();
|
m_gitEnvironment = GitPlugin::instance()->gitClient()->processEnvironment();
|
||||||
connect(m_ui.changeNumberEdit, SIGNAL(textChanged(QString)),
|
connect(m_changeNumberEdit, SIGNAL(textChanged(QString)),
|
||||||
this, SLOT(recalculateDetails(QString)));
|
this, SLOT(recalculateDetails(QString)));
|
||||||
connect(m_ui.workingDirectoryEdit, SIGNAL(textChanged(QString)), this, SLOT(refresh()));
|
connect(m_showButton, SIGNAL(clicked()), this, SLOT(acceptShow()));
|
||||||
refresh();
|
connect(m_cherryPickButton, SIGNAL(clicked()), this, SLOT(acceptCherryPick()));
|
||||||
|
connect(m_revertButton, SIGNAL(clicked()), this, SLOT(acceptRevert()));
|
||||||
|
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
recalculateDetails(m_changeNumberEdit->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeSelectionDialog::~ChangeSelectionDialog()
|
ChangeSelectionDialog::~ChangeSelectionDialog()
|
||||||
@@ -71,49 +103,53 @@ ChangeSelectionDialog::~ChangeSelectionDialog()
|
|||||||
|
|
||||||
QString ChangeSelectionDialog::change() const
|
QString ChangeSelectionDialog::change() const
|
||||||
{
|
{
|
||||||
return m_ui.changeNumberEdit->text();
|
return m_changeNumberEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ChangeSelectionDialog::workingDirectory() const
|
QString ChangeSelectionDialog::workingDirectory() const
|
||||||
{
|
{
|
||||||
return m_ui.workingDirectoryEdit->text();
|
return m_workingDirectoryLabel->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeSelectionDialog::setWorkingDirectory(const QString &s)
|
ChangeCommand ChangeSelectionDialog::command() const
|
||||||
{
|
{
|
||||||
if (s.isEmpty())
|
return m_command;
|
||||||
return;
|
|
||||||
m_ui.workingDirectoryEdit->setText(QDir::toNativeSeparators(s));
|
|
||||||
m_ui.changeNumberEdit->setFocus(Qt::ActiveWindowFocusReason);
|
|
||||||
m_ui.changeNumberEdit->setText(QLatin1String("HEAD"));
|
|
||||||
m_ui.changeNumberEdit->selectAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeSelectionDialog::selectWorkingDirectory()
|
void ChangeSelectionDialog::acceptCherryPick()
|
||||||
{
|
{
|
||||||
QString location = QFileDialog::getExistingDirectory(this, tr("Select Working Directory"),
|
m_command = CherryPick;
|
||||||
m_ui.workingDirectoryEdit->text());
|
accept();
|
||||||
if (location.isEmpty())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
// Verify that the location is a repository
|
void ChangeSelectionDialog::acceptRevert()
|
||||||
// We allow specifying a directory, which is not the head directory of the repository.
|
{
|
||||||
// This is useful for git show commit:./file
|
m_command = Revert;
|
||||||
QString topLevel = GitPlugin::instance()->gitClient()->findRepositoryForDirectory(location);
|
accept();
|
||||||
if (!topLevel.isEmpty())
|
}
|
||||||
m_ui.workingDirectoryEdit->setText(location);
|
|
||||||
else // Did not find a repo
|
void ChangeSelectionDialog::acceptShow()
|
||||||
QMessageBox::critical(this, tr("Error"),
|
{
|
||||||
tr("Selected directory is not a Git repository."));
|
m_command = Show;
|
||||||
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set commit message in details
|
//! Set commit message in details
|
||||||
void ChangeSelectionDialog::setDetails(int exitCode)
|
void ChangeSelectionDialog::setDetails(int exitCode)
|
||||||
{
|
{
|
||||||
if (exitCode == 0)
|
if (exitCode == 0) {
|
||||||
m_ui.detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput()));
|
m_detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput()));
|
||||||
else
|
enableButtons(true);
|
||||||
m_ui.detailsText->setPlainText(tr("Error: Unknown reference"));
|
} else {
|
||||||
|
m_detailsText->setPlainText(tr("Error: Unknown reference"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeSelectionDialog::enableButtons(bool b)
|
||||||
|
{
|
||||||
|
m_showButton->setEnabled(b);
|
||||||
|
m_cherryPickButton->setEnabled(b);
|
||||||
|
m_revertButton->setEnabled(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeSelectionDialog::recalculateDetails(const QString &ref)
|
void ChangeSelectionDialog::recalculateDetails(const QString &ref)
|
||||||
@@ -123,6 +159,7 @@ void ChangeSelectionDialog::recalculateDetails(const QString &ref)
|
|||||||
m_process->waitForFinished();
|
m_process->waitForFinished();
|
||||||
delete m_process;
|
delete m_process;
|
||||||
}
|
}
|
||||||
|
enableButtons(false);
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("log") << QLatin1String("-n1") << ref;
|
args << QLatin1String("log") << QLatin1String("-n1") << ref;
|
||||||
@@ -136,14 +173,9 @@ void ChangeSelectionDialog::recalculateDetails(const QString &ref)
|
|||||||
m_process->start(m_gitBinaryPath, args);
|
m_process->start(m_gitBinaryPath, args);
|
||||||
m_process->closeWriteChannel();
|
m_process->closeWriteChannel();
|
||||||
if (!m_process->waitForStarted())
|
if (!m_process->waitForStarted())
|
||||||
m_ui.detailsText->setPlainText(tr("Error: Could not start Git."));
|
m_detailsText->setPlainText(tr("Error: Could not start Git."));
|
||||||
else
|
else
|
||||||
m_ui.detailsText->setPlainText(tr("Fetching commit data..."));
|
m_detailsText->setPlainText(tr("Fetching commit data..."));
|
||||||
}
|
|
||||||
|
|
||||||
void ChangeSelectionDialog::refresh()
|
|
||||||
{
|
|
||||||
recalculateDetails(m_ui.changeNumberEdit->text());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
@@ -32,38 +32,60 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
QT_FORWARD_DECLARE_CLASS(QProcess)
|
|
||||||
|
|
||||||
#include "ui_changeselectiondialog.h"
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QPushButton;
|
||||||
|
class QLabel;
|
||||||
|
class QLineEdit;
|
||||||
|
class QPlainTextEdit;
|
||||||
|
class QProcess;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
enum ChangeCommand {
|
||||||
|
NoCommand,
|
||||||
|
CherryPick,
|
||||||
|
Revert,
|
||||||
|
Show
|
||||||
|
};
|
||||||
|
|
||||||
class ChangeSelectionDialog : public QDialog
|
class ChangeSelectionDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ChangeSelectionDialog(const QString &workingDirectory = QString(), QWidget *parent = 0);
|
ChangeSelectionDialog(const QString &workingDirectory, QWidget *parent);
|
||||||
~ChangeSelectionDialog();
|
~ChangeSelectionDialog();
|
||||||
|
|
||||||
QString change() const;
|
QString change() const;
|
||||||
|
|
||||||
QString workingDirectory() const;
|
QString workingDirectory() const;
|
||||||
void setWorkingDirectory(const QString &s);
|
ChangeCommand command() const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void selectWorkingDirectory();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setDetails(int exitCode);
|
void setDetails(int exitCode);
|
||||||
void recalculateDetails(const QString &ref);
|
void recalculateDetails(const QString &ref);
|
||||||
void refresh();
|
void acceptCherryPick();
|
||||||
|
void acceptRevert();
|
||||||
|
void acceptShow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_ChangeSelectionDialog m_ui;
|
void enableButtons(bool b);
|
||||||
|
|
||||||
QProcess* m_process;
|
QProcess* m_process;
|
||||||
QString m_gitBinaryPath;
|
QString m_gitBinaryPath;
|
||||||
QProcessEnvironment m_gitEnvironment;
|
QProcessEnvironment m_gitEnvironment;
|
||||||
|
|
||||||
|
QLabel* m_workingDirectoryLabel;
|
||||||
|
QLineEdit* m_changeNumberEdit;
|
||||||
|
QPlainTextEdit* m_detailsText;
|
||||||
|
QPushButton* m_showButton;
|
||||||
|
QPushButton* m_cherryPickButton;
|
||||||
|
QPushButton* m_revertButton;
|
||||||
|
QPushButton* m_cancelButton;
|
||||||
|
|
||||||
|
ChangeCommand m_command;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -1,104 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Git::Internal::ChangeSelectionDialog</class>
|
|
||||||
<widget class="QDialog" name="Git::Internal::ChangeSelectionDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>595</width>
|
|
||||||
<height>396</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<property name="sizeConstraint">
|
|
||||||
<enum>QLayout::SetDefaultConstraint</enum>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="workingDirectoryLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Working directory:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="workingDirectoryEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="workingDirectoryButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Select</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="changeLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Change:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="2">
|
|
||||||
<widget class="QLineEdit" name="changeNumberEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="3">
|
|
||||||
<widget class="QPlainTextEdit" name="detailsText">
|
|
||||||
<property name="undoRedoEnabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="lineWrapMode">
|
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0" colspan="3">
|
|
||||||
<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>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>Git::Internal::ChangeSelectionDialog</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::ChangeSelectionDialog</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>
|
|
@@ -48,8 +48,7 @@ SOURCES += gitplugin.cpp \
|
|||||||
mergetool.cpp \
|
mergetool.cpp \
|
||||||
branchcheckoutdialog.cpp
|
branchcheckoutdialog.cpp
|
||||||
|
|
||||||
FORMS += changeselectiondialog.ui \
|
FORMS += settingspage.ui \
|
||||||
settingspage.ui \
|
|
||||||
gitsubmitpanel.ui \
|
gitsubmitpanel.ui \
|
||||||
branchdialog.ui \
|
branchdialog.ui \
|
||||||
stashdialog.ui \
|
stashdialog.ui \
|
||||||
|
@@ -28,7 +28,6 @@ QtcPlugin {
|
|||||||
"branchmodel.h",
|
"branchmodel.h",
|
||||||
"changeselectiondialog.cpp",
|
"changeselectiondialog.cpp",
|
||||||
"changeselectiondialog.h",
|
"changeselectiondialog.h",
|
||||||
"changeselectiondialog.ui",
|
|
||||||
"clonewizard.cpp",
|
"clonewizard.cpp",
|
||||||
"clonewizard.h",
|
"clonewizard.h",
|
||||||
"clonewizardpage.cpp",
|
"clonewizardpage.cpp",
|
||||||
|
@@ -130,7 +130,6 @@ GitPlugin *GitPlugin::m_instance = 0;
|
|||||||
GitPlugin::GitPlugin() :
|
GitPlugin::GitPlugin() :
|
||||||
VcsBase::VcsBasePlugin(Git::Constants::GITSUBMITEDITOR_ID),
|
VcsBase::VcsBasePlugin(Git::Constants::GITSUBMITEDITOR_ID),
|
||||||
m_commandLocator(0),
|
m_commandLocator(0),
|
||||||
m_showAction(0),
|
|
||||||
m_submitCurrentAction(0),
|
m_submitCurrentAction(0),
|
||||||
m_diffSelectedFilesAction(0),
|
m_diffSelectedFilesAction(0),
|
||||||
m_undoAction(0),
|
m_undoAction(0),
|
||||||
@@ -138,7 +137,6 @@ GitPlugin::GitPlugin() :
|
|||||||
m_menuAction(0),
|
m_menuAction(0),
|
||||||
m_applyCurrentFilePatchAction(0),
|
m_applyCurrentFilePatchAction(0),
|
||||||
m_gitClient(0),
|
m_gitClient(0),
|
||||||
m_changeSelectionDialog(0),
|
|
||||||
m_submitActionTriggered(false)
|
m_submitActionTriggered(false)
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
@@ -440,12 +438,8 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
globalcontext, true, SLOT(startRebase()));
|
globalcontext, true, SLOT(startRebase()));
|
||||||
|
|
||||||
createRepositoryAction(localRepositoryMenu,
|
createRepositoryAction(localRepositoryMenu,
|
||||||
tr("Revert Single Commit..."), Core::Id("Git.Revert"),
|
tr("Change-related Actions..."), Core::Id("Git.ChangeRelatedActions"),
|
||||||
globalcontext, true, SLOT(startRevertCommit()));
|
globalcontext, true, SLOT(startChangeRelatedAction()));
|
||||||
|
|
||||||
createRepositoryAction(localRepositoryMenu,
|
|
||||||
tr("Cherry-Pick Commit..."), Core::Id("Git.CherryPick"),
|
|
||||||
globalcontext, true, SLOT(startCherryPickCommit()));
|
|
||||||
|
|
||||||
// --------------
|
// --------------
|
||||||
localRepositoryMenu->addSeparator(globalcontext);
|
localRepositoryMenu->addSeparator(globalcontext);
|
||||||
@@ -589,11 +583,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
// --------------
|
// --------------
|
||||||
gitContainer->addSeparator(globalcontext);
|
gitContainer->addSeparator(globalcontext);
|
||||||
|
|
||||||
m_showAction
|
|
||||||
= createRepositoryAction(gitContainer,
|
|
||||||
tr("Show..."), Core::Id("Git.ShowCommit"),
|
|
||||||
globalcontext, true, SLOT(showCommit())).first;
|
|
||||||
|
|
||||||
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
||||||
Core::Command *createRepositoryCommand = Core::ActionManager::registerAction(m_createRepositoryAction, "Git.CreateRepository", globalcontext);
|
Core::Command *createRepositoryCommand = Core::ActionManager::registerAction(m_createRepositoryAction, "Git.CreateRepository", globalcontext);
|
||||||
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
|
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
|
||||||
@@ -741,40 +730,51 @@ void GitPlugin::startRebase()
|
|||||||
m_gitClient->interactiveRebase(workingDirectory, change);
|
m_gitClient->interactiveRebase(workingDirectory, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::startRevertCommit()
|
void GitPlugin::startChangeRelatedAction()
|
||||||
{
|
{
|
||||||
const VcsBase::VcsBasePluginState state = currentState();
|
const VcsBase::VcsBasePluginState state = currentState();
|
||||||
QString workingDirectory = state.currentDirectoryOrTopLevel();
|
const QString workingDirectory = state.currentDirectoryOrTopLevel();
|
||||||
if (workingDirectory.isEmpty())
|
if (workingDirectory.isEmpty())
|
||||||
return;
|
return;
|
||||||
GitClient::StashGuard stashGuard(workingDirectory, QLatin1String("Revert"));
|
|
||||||
if (stashGuard.stashingFailed(true))
|
|
||||||
return;
|
|
||||||
ChangeSelectionDialog changeSelectionDialog(workingDirectory);
|
|
||||||
|
|
||||||
if (changeSelectionDialog.exec() != QDialog::Accepted)
|
QPointer<ChangeSelectionDialog> dialog = new ChangeSelectionDialog
|
||||||
|
(workingDirectory, Core::ICore::mainWindow());
|
||||||
|
|
||||||
|
int result = dialog->exec();
|
||||||
|
|
||||||
|
if (dialog.isNull() || (result == QDialog::Rejected) || dialog->change().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QString change = dialog->change();
|
||||||
|
|
||||||
|
if (dialog->command() == Show) {
|
||||||
|
m_gitClient->show(workingDirectory, change);
|
||||||
return;
|
return;
|
||||||
const QString change = changeSelectionDialog.change();
|
|
||||||
if (!change.isEmpty() && !m_gitClient->revertCommit(workingDirectory, change))
|
|
||||||
stashGuard.preventPop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::startCherryPickCommit()
|
QString command;
|
||||||
{
|
bool (GitClient::*commandFunction)(const QString&, const QString&);
|
||||||
const VcsBase::VcsBasePluginState state = currentState();
|
switch (dialog->command()) {
|
||||||
QString workingDirectory = state.currentDirectoryOrTopLevel();
|
case CherryPick:
|
||||||
if (workingDirectory.isEmpty())
|
command = QLatin1String("Cherry-pick");
|
||||||
|
commandFunction = &GitClient::cherryPickCommit;
|
||||||
|
break;
|
||||||
|
case Revert:
|
||||||
|
command = QLatin1String("Revert");
|
||||||
|
commandFunction = &GitClient::revertCommit;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
return;
|
return;
|
||||||
GitClient::StashGuard stashGuard(state.topLevel(), QLatin1String("Cherry-pick"));
|
}
|
||||||
|
|
||||||
|
GitClient::StashGuard stashGuard(workingDirectory, command);
|
||||||
if (stashGuard.stashingFailed(true))
|
if (stashGuard.stashingFailed(true))
|
||||||
return;
|
return;
|
||||||
ChangeSelectionDialog changeSelectionDialog(workingDirectory);
|
|
||||||
|
|
||||||
if (changeSelectionDialog.exec() != QDialog::Accepted)
|
if (!(m_gitClient->*commandFunction)(workingDirectory, change))
|
||||||
return;
|
|
||||||
const QString change = changeSelectionDialog.change();
|
|
||||||
if (!change.isEmpty() && !m_gitClient->cherryPickCommit(workingDirectory, change))
|
|
||||||
stashGuard.preventPop();
|
stashGuard.preventPop();
|
||||||
|
|
||||||
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::stageFile()
|
void GitPlugin::stageFile()
|
||||||
@@ -1228,9 +1228,6 @@ void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
|||||||
foreach (QAction *repositoryAction, m_repositoryActions)
|
foreach (QAction *repositoryAction, m_repositoryActions)
|
||||||
repositoryAction->setEnabled(repositoryEnabled);
|
repositoryAction->setEnabled(repositoryEnabled);
|
||||||
updateRepositoryBrowserAction();
|
updateRepositoryBrowserAction();
|
||||||
|
|
||||||
// Prompts for repo.
|
|
||||||
m_showAction->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::updateRepositoryBrowserAction()
|
void GitPlugin::updateRepositoryBrowserAction()
|
||||||
@@ -1240,24 +1237,6 @@ void GitPlugin::updateRepositoryBrowserAction()
|
|||||||
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
|
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::showCommit()
|
|
||||||
{
|
|
||||||
const VcsBase::VcsBasePluginState state = currentState();
|
|
||||||
|
|
||||||
if (!m_changeSelectionDialog)
|
|
||||||
m_changeSelectionDialog = new ChangeSelectionDialog();
|
|
||||||
|
|
||||||
m_changeSelectionDialog->setWorkingDirectory(state.currentDirectoryOrTopLevel());
|
|
||||||
|
|
||||||
if (m_changeSelectionDialog->exec() != QDialog::Accepted)
|
|
||||||
return;
|
|
||||||
const QString change = m_changeSelectionDialog->change();
|
|
||||||
if (change.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_gitClient->show(m_changeSelectionDialog->workingDirectory(), change);
|
|
||||||
}
|
|
||||||
|
|
||||||
const GitSettings &GitPlugin::settings() const
|
const GitSettings &GitPlugin::settings() const
|
||||||
{
|
{
|
||||||
return m_settings;
|
return m_settings;
|
||||||
|
@@ -68,7 +68,6 @@ namespace Internal {
|
|||||||
|
|
||||||
class GitVersionControl;
|
class GitVersionControl;
|
||||||
class GitClient;
|
class GitClient;
|
||||||
class ChangeSelectionDialog;
|
|
||||||
class GitSubmitEditor;
|
class GitSubmitEditor;
|
||||||
class CommitData;
|
class CommitData;
|
||||||
class StashDialog;
|
class StashDialog;
|
||||||
@@ -117,8 +116,7 @@ private slots:
|
|||||||
void undoUnstagedFileChanges();
|
void undoUnstagedFileChanges();
|
||||||
void resetRepository();
|
void resetRepository();
|
||||||
void startRebase();
|
void startRebase();
|
||||||
void startRevertCommit();
|
void startChangeRelatedAction();
|
||||||
void startCherryPickCommit();
|
|
||||||
void stageFile();
|
void stageFile();
|
||||||
void unstageFile();
|
void unstageFile();
|
||||||
void gitkForCurrentFile();
|
void gitkForCurrentFile();
|
||||||
@@ -129,7 +127,6 @@ private slots:
|
|||||||
void promptApplyPatch();
|
void promptApplyPatch();
|
||||||
void gitClientMemberFuncRepositoryAction();
|
void gitClientMemberFuncRepositoryAction();
|
||||||
|
|
||||||
void showCommit();
|
|
||||||
void startAmendCommit();
|
void startAmendCommit();
|
||||||
void stash();
|
void stash();
|
||||||
void stashSnapshot();
|
void stashSnapshot();
|
||||||
@@ -201,8 +198,6 @@ private:
|
|||||||
Locator::CommandLocator *m_commandLocator;
|
Locator::CommandLocator *m_commandLocator;
|
||||||
QAction *m_createRepositoryAction;
|
QAction *m_createRepositoryAction;
|
||||||
|
|
||||||
QAction *m_showAction;
|
|
||||||
|
|
||||||
QAction *m_submitCurrentAction;
|
QAction *m_submitCurrentAction;
|
||||||
QAction *m_diffSelectedFilesAction;
|
QAction *m_diffSelectedFilesAction;
|
||||||
QAction *m_undoAction;
|
QAction *m_undoAction;
|
||||||
@@ -216,7 +211,6 @@ private:
|
|||||||
Utils::ParameterAction *m_applyCurrentFilePatchAction;
|
Utils::ParameterAction *m_applyCurrentFilePatchAction;
|
||||||
|
|
||||||
GitClient *m_gitClient;
|
GitClient *m_gitClient;
|
||||||
ChangeSelectionDialog *m_changeSelectionDialog;
|
|
||||||
QPointer<StashDialog> m_stashDialog;
|
QPointer<StashDialog> m_stashDialog;
|
||||||
QPointer<BranchDialog> m_branchDialog;
|
QPointer<BranchDialog> m_branchDialog;
|
||||||
QPointer<RemoteDialog> m_remoteDialog;
|
QPointer<RemoteDialog> m_remoteDialog;
|
||||||
|
Reference in New Issue
Block a user