forked from qt-creator/qt-creator
Git: Remove setting for side-by-side diff
Use the diff switcher state as a permanent setting Change-Id: I6c3669090082787ae750596cf3e62973c04d94c3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
003e25d488
commit
63e7fe19b9
@@ -99,19 +99,19 @@ public:
|
||||
DiffShow
|
||||
};
|
||||
|
||||
GitDiffSwitcher(Core::IEditor *parentEditor, GitClient *gitClient, GitClient::DiffEditorType switchToType)
|
||||
GitDiffSwitcher(Core::IEditor *parentEditor, GitClient *gitClient)
|
||||
: QObject(parentEditor),
|
||||
m_editor(parentEditor),
|
||||
m_gitClient(gitClient),
|
||||
m_editorType(switchToType)
|
||||
m_gitClient(gitClient)
|
||||
{
|
||||
QIcon actionIcon = switchToType == GitClient::SideBySideDiffEditor
|
||||
? QIcon(QLatin1String(Core::Constants::ICON_SIDE_BY_SIDE_DIFF))
|
||||
: QIcon(QLatin1String(Core::Constants::ICON_TEXT_DIFF));
|
||||
m_usingDiffEditor = gitClient->settings()->boolValue(GitSettings::useDiffEditorKey);
|
||||
QIcon actionIcon = m_usingDiffEditor
|
||||
? QIcon(QLatin1String(Core::Constants::ICON_TEXT_DIFF))
|
||||
: QIcon(QLatin1String(Core::Constants::ICON_SIDE_BY_SIDE_DIFF));
|
||||
|
||||
const QString actionToolTip = switchToType == GitClient::SideBySideDiffEditor
|
||||
? tr("Switch to Side By Side Diff Editor")
|
||||
: tr("Switch to Text Diff Editor");
|
||||
const QString actionToolTip = m_usingDiffEditor
|
||||
? tr("Switch to Text Diff Editor")
|
||||
: tr("Switch to Side By Side Diff Editor");
|
||||
|
||||
QAction *switchAction = new QAction(actionIcon, actionToolTip, parentEditor);
|
||||
parentEditor->toolBar()->addAction(switchAction);
|
||||
@@ -140,7 +140,7 @@ private:
|
||||
GitClient *m_gitClient;
|
||||
QString m_workingDirectory;
|
||||
DiffType m_diffType;
|
||||
GitClient::DiffEditorType m_editorType;
|
||||
bool m_usingDiffEditor;
|
||||
QString m_fileName;
|
||||
QStringList m_stagedFiles;
|
||||
QStringList m_unstagedFiles;
|
||||
@@ -153,24 +153,25 @@ private:
|
||||
|
||||
void GitDiffSwitcher::execute()
|
||||
{
|
||||
m_gitClient->settings()->setValue(GitSettings::useDiffEditorKey, !m_usingDiffEditor);
|
||||
switch (m_diffType) {
|
||||
case DiffRepository:
|
||||
m_gitClient->diff(m_workingDirectory, QStringList(), QStringList(), m_editorType);
|
||||
m_gitClient->diff(m_workingDirectory, QStringList(), QStringList());
|
||||
break;
|
||||
case DiffFile:
|
||||
m_gitClient->diff(m_workingDirectory, m_fileName, m_editorType);
|
||||
m_gitClient->diff(m_workingDirectory, m_fileName);
|
||||
break;
|
||||
case DiffFileList:
|
||||
m_gitClient->diff(m_workingDirectory, m_unstagedFiles, m_stagedFiles, m_editorType);
|
||||
m_gitClient->diff(m_workingDirectory, m_unstagedFiles, m_stagedFiles);
|
||||
break;
|
||||
case DiffProjectList:
|
||||
m_gitClient->diff(m_workingDirectory, m_projectFiles, QStringList(), m_editorType);
|
||||
m_gitClient->diff(m_workingDirectory, m_projectFiles, QStringList());
|
||||
break;
|
||||
case DiffBranch:
|
||||
m_gitClient->diffBranch(m_workingDirectory, m_baseArguments, m_branchName, m_editorType);
|
||||
m_gitClient->diffBranch(m_workingDirectory, m_baseArguments, m_branchName);
|
||||
break;
|
||||
case DiffShow:
|
||||
m_gitClient->show(m_fileName, m_id, m_baseArguments, m_displayName, m_editorType);
|
||||
m_gitClient->show(m_fileName, m_id, m_baseArguments, m_displayName);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -594,8 +595,7 @@ public:
|
||||
|
||||
void executeCommand()
|
||||
{
|
||||
m_client->diff(m_workingDirectory, m_unstagedFileNames, m_stagedFileNames,
|
||||
GitClient::SimpleTextDiffEditor);
|
||||
m_client->diff(m_workingDirectory, m_unstagedFileNames, m_stagedFileNames);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -615,7 +615,7 @@ public:
|
||||
|
||||
void executeCommand()
|
||||
{
|
||||
m_client->diff(m_workingDirectory, m_fileName, GitClient::SimpleTextDiffEditor);
|
||||
m_client->diff(m_workingDirectory, m_fileName);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -634,8 +634,7 @@ public:
|
||||
|
||||
void executeCommand()
|
||||
{
|
||||
m_client->diffBranch(m_workingDirectory, baseArguments(), m_branchName,
|
||||
GitClient::SimpleTextDiffEditor);
|
||||
m_client->diffBranch(m_workingDirectory, baseArguments(), m_branchName);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -670,8 +669,7 @@ public:
|
||||
|
||||
void executeCommand()
|
||||
{
|
||||
m_client->show(m_workingDirectory, m_id, baseArguments(), QString(),
|
||||
GitClient::SimpleTextDiffEditor);
|
||||
m_client->show(m_workingDirectory, m_id, baseArguments());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1064,16 +1062,12 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(
|
||||
|
||||
void GitClient::diff(const QString &workingDirectory,
|
||||
const QStringList &unstagedFileNames,
|
||||
const QStringList &stagedFileNames,
|
||||
DiffEditorType editorType)
|
||||
const QStringList &stagedFileNames)
|
||||
{
|
||||
const QString title = tr("Git Diff");
|
||||
const int timeout = settings()->intValue(GitSettings::timeoutKey);
|
||||
const bool showSideBySideEditor = (editorType == DefaultDiffEditor
|
||||
&& settings()->boolValue(GitSettings::useDiffEditorKey))
|
||||
|| editorType == SideBySideDiffEditor;
|
||||
Core::IEditor *newEditor = 0;
|
||||
if (showSideBySideEditor) {
|
||||
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
||||
const char *propertyName = "sideBySideOriginalFileName";
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, workingDirectory);
|
||||
if (!diffEditor) {
|
||||
@@ -1168,8 +1162,7 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
command->execute();
|
||||
}
|
||||
if (newEditor) {
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this,
|
||||
showSideBySideEditor ? SimpleTextDiffEditor : SideBySideDiffEditor);
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this);
|
||||
switcher->setWorkingDirectory(workingDirectory);
|
||||
if (unstagedFileNames.empty() && stagedFileNames.empty()) {
|
||||
// local repository diff
|
||||
@@ -1186,17 +1179,12 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
}
|
||||
}
|
||||
|
||||
void GitClient::diff(const QString &workingDirectory,
|
||||
const QString &fileName,
|
||||
DiffEditorType editorType)
|
||||
void GitClient::diff(const QString &workingDirectory, const QString &fileName)
|
||||
{
|
||||
const QString title = tr("Git Diff \"%1\"").arg(fileName);
|
||||
const bool showSideBySideEditor = (editorType == DefaultDiffEditor
|
||||
&& settings()->boolValue(GitSettings::useDiffEditorKey))
|
||||
|| editorType == SideBySideDiffEditor;
|
||||
const QString sourceFile = VcsBase::VcsBaseEditorWidget::getSource(workingDirectory, fileName);
|
||||
Core::IEditor *newEditor = 0;
|
||||
if (showSideBySideEditor) {
|
||||
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
||||
const char *propertyName = "sideBySideOriginalFileName";
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, sourceFile);
|
||||
if (!diffEditor) {
|
||||
@@ -1244,8 +1232,7 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
executeGit(workingDirectory, cmdArgs, vcsEditor);
|
||||
}
|
||||
if (newEditor) {
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this,
|
||||
showSideBySideEditor ? SimpleTextDiffEditor : SideBySideDiffEditor);
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this);
|
||||
switcher->setWorkingDirectory(workingDirectory);
|
||||
switcher->setDiffType(GitDiffSwitcher::DiffFile);
|
||||
switcher->setFileName(fileName);
|
||||
@@ -1254,15 +1241,11 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
|
||||
void GitClient::diffBranch(const QString &workingDirectory,
|
||||
const QStringList &diffArgs,
|
||||
const QString &branchName,
|
||||
DiffEditorType editorType)
|
||||
const QString &branchName)
|
||||
{
|
||||
const QString title = tr("Git Diff Branch \"%1\"").arg(branchName);
|
||||
const bool showSideBySideEditor = (editorType == DefaultDiffEditor
|
||||
&& settings()->boolValue(GitSettings::useDiffEditorKey))
|
||||
|| editorType == SideBySideDiffEditor;
|
||||
Core::IEditor *newEditor = 0;
|
||||
if (showSideBySideEditor) {
|
||||
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
||||
const char *propertyName = "sideBySideBranchName";
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, branchName);
|
||||
if (!diffEditor) {
|
||||
@@ -1308,8 +1291,7 @@ void GitClient::diffBranch(const QString &workingDirectory,
|
||||
executeGit(workingDirectory, cmdArgs, vcsEditor);
|
||||
}
|
||||
if (newEditor) {
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this,
|
||||
showSideBySideEditor ? SimpleTextDiffEditor : SideBySideDiffEditor);
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this);
|
||||
switcher->setWorkingDirectory(workingDirectory);
|
||||
switcher->setDiffType(GitDiffSwitcher::DiffBranch);
|
||||
switcher->setBaseArguments(diffArgs);
|
||||
@@ -1409,8 +1391,7 @@ static inline QString msgCannotShow(const QString &sha)
|
||||
}
|
||||
|
||||
void GitClient::show(const QString &source, const QString &id,
|
||||
const QStringList &args, const QString &name,
|
||||
DiffEditorType editorType)
|
||||
const QStringList &args, const QString &name)
|
||||
{
|
||||
if (!canShow(id)) {
|
||||
outputWindow()->appendError(msgCannotShow(id));
|
||||
@@ -1420,11 +1401,8 @@ void GitClient::show(const QString &source, const QString &id,
|
||||
const QString title = tr("Git Show \"%1\"").arg(name.isEmpty() ? id : name);
|
||||
const QFileInfo sourceFi(source);
|
||||
const QString workingDirectory = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
|
||||
const bool showSideBySideEditor = (editorType == DefaultDiffEditor
|
||||
&& settings()->boolValue(GitSettings::useDiffEditorKey))
|
||||
|| editorType == SideBySideDiffEditor;
|
||||
Core::IEditor *newEditor = 0;
|
||||
if (showSideBySideEditor) {
|
||||
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
||||
const char *propertyName = "sideBySideShow";
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, id);
|
||||
if (!diffEditor) {
|
||||
@@ -1470,8 +1448,7 @@ void GitClient::show(const QString &source, const QString &id,
|
||||
executeGit(workingDirectory, arguments, vcsEditor);
|
||||
}
|
||||
if (newEditor) {
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this,
|
||||
showSideBySideEditor ? SimpleTextDiffEditor : SideBySideDiffEditor);
|
||||
GitDiffSwitcher *switcher = new GitDiffSwitcher(newEditor, this);
|
||||
switcher->setDiffType(GitDiffSwitcher::DiffShow);
|
||||
switcher->setFileName(source);
|
||||
switcher->setBaseArguments(args);
|
||||
|
||||
@@ -127,12 +127,6 @@ public:
|
||||
StashFlag m_flags;
|
||||
};
|
||||
|
||||
enum DiffEditorType {
|
||||
DefaultDiffEditor, // value taken from settings
|
||||
SideBySideDiffEditor,
|
||||
SimpleTextDiffEditor
|
||||
};
|
||||
|
||||
static const char *stashNamePrefix;
|
||||
|
||||
explicit GitClient(GitSettings *settings);
|
||||
@@ -144,17 +138,13 @@ public:
|
||||
QString findRepositoryForDirectory(const QString &dir);
|
||||
QString findGitDirForRepository(const QString &repositoryDir) const;
|
||||
|
||||
void diff(const QString &workingDirectory,
|
||||
const QString &fileName,
|
||||
DiffEditorType editorType = DefaultDiffEditor);
|
||||
void diff(const QString &workingDirectory, const QString &fileName);
|
||||
void diff(const QString &workingDirectory,
|
||||
const QStringList &unstagedFileNames,
|
||||
const QStringList &stagedFileNames = QStringList(),
|
||||
DiffEditorType editorType = DefaultDiffEditor);
|
||||
const QStringList &stagedFileNames = QStringList());
|
||||
void diffBranch(const QString &workingDirectory,
|
||||
const QStringList &diffArgs,
|
||||
const QString &branchName,
|
||||
DiffEditorType editorType = DefaultDiffEditor);
|
||||
const QString &branchName);
|
||||
void merge(const QString &workingDirectory, const QStringList &unmergedFileNames = QStringList());
|
||||
|
||||
void status(const QString &workingDirectory);
|
||||
@@ -341,8 +331,7 @@ public slots:
|
||||
void show(const QString &source,
|
||||
const QString &id,
|
||||
const QStringList &args = QStringList(),
|
||||
const QString &name = QString(),
|
||||
DiffEditorType editorType = DefaultDiffEditor);
|
||||
const QString &name = QString());
|
||||
void saveSettings();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -70,7 +70,6 @@ GitSettings SettingsPageWidget::settings() const
|
||||
rc.setValue(GitSettings::pathKey, m_ui.pathLineEdit->text());
|
||||
rc.setValue(GitSettings::logCountKey, m_ui.logCountSpinBox->value());
|
||||
rc.setValue(GitSettings::timeoutKey, m_ui.timeoutSpinBox->value());
|
||||
rc.setValue(GitSettings::useDiffEditorKey, m_ui.useDiffEditorCheckBox->isChecked());
|
||||
rc.setValue(GitSettings::pullRebaseKey, m_ui.pullRebaseCheckBox->isChecked());
|
||||
rc.setValue(GitSettings::showTagsKey, m_ui.showTagsCheckBox->isChecked());
|
||||
rc.setValue(GitSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked());
|
||||
@@ -85,7 +84,6 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
|
||||
m_ui.pathLineEdit->setText(s.stringValue(GitSettings::pathKey));
|
||||
m_ui.logCountSpinBox->setValue(s.intValue(GitSettings::logCountKey));
|
||||
m_ui.timeoutSpinBox->setValue(s.intValue(GitSettings::timeoutKey));
|
||||
m_ui.useDiffEditorCheckBox->setChecked(s.boolValue(GitSettings::useDiffEditorKey));
|
||||
m_ui.pullRebaseCheckBox->setChecked(s.boolValue(GitSettings::pullRebaseKey));
|
||||
m_ui.showTagsCheckBox->setChecked(s.boolValue(GitSettings::showTagsKey));
|
||||
m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(GitSettings::promptOnSubmitKey));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>705</width>
|
||||
<height>436</height>
|
||||
<height>459</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -60,32 +60,25 @@
|
||||
<string>Miscellaneous</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="logCountLabel">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="pullRebaseCheckBox">
|
||||
<property name="text">
|
||||
<string>Log count:</string>
|
||||
<string>Pull with rebase</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="logCountSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>Note that huge amount of commits might take some time.</string>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>211</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="timeoutLabel">
|
||||
<property name="text">
|
||||
<string>Timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QSpinBox" name="timeoutSpinBox">
|
||||
@@ -103,19 +96,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>211</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="promptToSubmitCheckBox">
|
||||
<property name="text">
|
||||
@@ -123,27 +103,40 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="pullRebaseCheckBox">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="logCountLabel">
|
||||
<property name="text">
|
||||
<string>Pull with rebase</string>
|
||||
<string>Log count:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="2">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="timeoutLabel">
|
||||
<property name="text">
|
||||
<string>Timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="logCountSpinBox">
|
||||
<property name="toolTip">
|
||||
<string>Note that huge amount of commits might take some time.</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="showTagsCheckBox">
|
||||
<property name="text">
|
||||
<string>Show tags in Branches dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QCheckBox" name="useDiffEditorCheckBox">
|
||||
<property name="text">
|
||||
<string>Show diff side-by-side</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user