forked from qt-creator/qt-creator
Git: Add customizable repository browser command.
Change-Id: Iac297e3665b18d97ca80097c4dd33dd70e64b9a1 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
2ba3f6c929
commit
4d1bbebf2a
@@ -1605,6 +1605,13 @@ void GitClient::launchGitK(const QString &workingDirectory)
|
||||
tryLauchingGitK(env, workingDirectory, foundBinDir.path() + QLatin1String("/bin"), false);
|
||||
}
|
||||
|
||||
void GitClient::launchRepositoryBrowser(const QString &workingDirectory)
|
||||
{
|
||||
const QString repBrowserBinary = settings()->stringValue(GitSettings::repositoryBrowserCmd);
|
||||
if (!repBrowserBinary.isEmpty())
|
||||
QProcess::startDetached(repBrowserBinary, QStringList(workingDirectory), workingDirectory);
|
||||
}
|
||||
|
||||
bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
||||
const QString &workingDirectory,
|
||||
const QString &gitBinDirectory,
|
||||
|
@@ -215,6 +215,8 @@ public:
|
||||
QString *errorMessage = 0, bool *onBranch = 0);
|
||||
|
||||
void launchGitK(const QString &workingDirectory);
|
||||
void launchRepositoryBrowser(const QString &workingDirectory);
|
||||
|
||||
QStringList synchronousRepositoryBranches(const QString &repositoryURL);
|
||||
|
||||
GitSettings *settings() const;
|
||||
|
@@ -430,6 +430,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
tr("Launch gitk"), Core::Id("Git.LaunchGitK"),
|
||||
globalcontext, true, &GitClient::launchGitK);
|
||||
|
||||
m_repositoryBrowserAction
|
||||
= createRepositoryAction(actionManager, gitContainer,
|
||||
tr("Launch repository browser"), Core::Id("Git.LaunchRepositoryBrowser"),
|
||||
globalcontext, true, &GitClient::launchRepositoryBrowser).first;
|
||||
|
||||
createRepositoryAction(actionManager, gitContainer,
|
||||
tr("Branches..."), Core::Id("Git.BranchList"),
|
||||
globalcontext, true, SLOT(branchList()));
|
||||
@@ -1031,11 +1036,19 @@ void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
||||
|
||||
foreach (QAction *repositoryAction, m_repositoryActions)
|
||||
repositoryAction->setEnabled(repositoryEnabled);
|
||||
updateRepositoryBrowserAction();
|
||||
|
||||
// Prompts for repo.
|
||||
m_showAction->setEnabled(true);
|
||||
}
|
||||
|
||||
void GitPlugin::updateRepositoryBrowserAction()
|
||||
{
|
||||
const bool repositoryEnabled = currentState().hasTopLevel();
|
||||
const bool hasRepositoryBrowserCmd = !settings().stringValue(GitSettings::repositoryBrowserCmd).isEmpty();
|
||||
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
|
||||
}
|
||||
|
||||
void GitPlugin::showCommit()
|
||||
{
|
||||
const VcsBase::VcsBasePluginState state = currentState();
|
||||
@@ -1070,6 +1083,7 @@ void GitPlugin::setSettings(const GitSettings &s)
|
||||
m_settings = s;
|
||||
m_gitClient->saveSettings();
|
||||
static_cast<GitVersionControl *>(versionControl())->emitConfigurationChanged();
|
||||
updateRepositoryBrowserAction();
|
||||
}
|
||||
|
||||
GitClient *GitPlugin::gitClient() const
|
||||
|
@@ -175,6 +175,7 @@ private:
|
||||
const Core::Context &context,
|
||||
bool addToLocator, GitClientMemberFunc);
|
||||
|
||||
void updateRepositoryBrowserAction();
|
||||
bool isCommitEditorOpen() const;
|
||||
Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend);
|
||||
void cleanCommitMessageFile();
|
||||
@@ -193,6 +194,7 @@ private:
|
||||
QAction *m_undoAction;
|
||||
QAction *m_redoAction;
|
||||
QAction *m_menuAction;
|
||||
QAction *m_repositoryBrowserAction;
|
||||
|
||||
QVector<Utils::ParameterAction *> m_fileActions;
|
||||
QVector<Utils::ParameterAction *> m_projectActions;
|
||||
|
@@ -49,6 +49,7 @@ const QLatin1String GitSettings::winSetHomeEnvironmentKey("WinSetHomeEnvironment
|
||||
const QLatin1String GitSettings::showPrettyFormatKey("DiffPrettyFormat");
|
||||
const QLatin1String GitSettings::gitkOptionsKey("GitKOptions");
|
||||
const QLatin1String GitSettings::logDiffKey("LogDiff");
|
||||
const QLatin1String GitSettings::repositoryBrowserCmd("RepositoryBrowserCmd");
|
||||
|
||||
GitSettings::GitSettings()
|
||||
{
|
||||
@@ -70,6 +71,7 @@ GitSettings::GitSettings()
|
||||
declareKey(gitkOptionsKey, QString());
|
||||
declareKey(showPrettyFormatKey, 2);
|
||||
declareKey(logDiffKey, false);
|
||||
declareKey(repositoryBrowserCmd, QString());
|
||||
}
|
||||
|
||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
|
@@ -56,6 +56,7 @@ public:
|
||||
static const QLatin1String showPrettyFormatKey;
|
||||
static const QLatin1String gitkOptionsKey;
|
||||
static const QLatin1String logDiffKey;
|
||||
static const QLatin1String repositoryBrowserCmd;
|
||||
|
||||
QString gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "gitclient.h"
|
||||
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
@@ -65,6 +66,8 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
|
||||
#else
|
||||
m_ui.winHomeCheckBox->setVisible(false);
|
||||
#endif
|
||||
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
|
||||
}
|
||||
|
||||
GitSettings SettingsPageWidget::settings() const
|
||||
@@ -77,6 +80,7 @@ GitSettings SettingsPageWidget::settings() const
|
||||
rc.setValue(GitSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked());
|
||||
rc.setValue(GitSettings::winSetHomeEnvironmentKey, m_ui.winHomeCheckBox->isChecked());
|
||||
rc.setValue(GitSettings::gitkOptionsKey, m_ui.gitkOptionsLineEdit->text().trimmed());
|
||||
rc.setValue(GitSettings::repositoryBrowserCmd, m_ui.repBrowserCommandPathChooser->path().trimmed());
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -89,6 +93,7 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
|
||||
m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(GitSettings::promptOnSubmitKey));
|
||||
m_ui.winHomeCheckBox->setChecked(s.boolValue(GitSettings::winSetHomeEnvironmentKey));
|
||||
m_ui.gitkOptionsLineEdit->setText(s.stringValue(GitSettings::gitkOptionsKey));
|
||||
m_ui.repBrowserCommandPathChooser->setPath(s.stringValue(GitSettings::repositoryBrowserCmd));
|
||||
}
|
||||
|
||||
QString SettingsPageWidget::searchKeywords() const
|
||||
@@ -105,6 +110,8 @@ QString SettingsPageWidget::searchKeywords() const
|
||||
<< sep << m_ui.promptToSubmitCheckBox->text()
|
||||
<< sep << m_ui.gitkGroupBox->title()
|
||||
<< sep << m_ui.gitkOptionsLabel->text()
|
||||
<< sep << m_ui.repBrowserGroupBox->title()
|
||||
<< sep << m_ui.repBrowserCommandLabel->text()
|
||||
;
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
|
@@ -152,6 +152,32 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="repBrowserGroupBox">
|
||||
<property name="title">
|
||||
<string>Repository browser</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="repBrowserCommandLabel">
|
||||
<property name="text">
|
||||
<string>Command:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Utils::PathChooser" name="repBrowserCommandPathChooser" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@@ -167,6 +193,18 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Utils::PathChooser</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
<container>1</container>
|
||||
<slots>
|
||||
<signal>editingFinished()</signal>
|
||||
<signal>browsingFinished()</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>pathLineEdit</tabstop>
|
||||
</tabstops>
|
||||
|
Reference in New Issue
Block a user