forked from qt-creator/qt-creator
		
	VCS[git]: Add menu option to launch gitk.
Task-number: QTCREATORBUG-1577
This commit is contained in:
		@@ -1141,7 +1141,7 @@ bool GitClient::fullySynchronousGit(const QString &workingDirectory,
 | 
			
		||||
 | 
			
		||||
    if (!Utils::SynchronousProcess::readDataFromProcess(process, m_settings.timeoutSeconds * 1000,
 | 
			
		||||
                                                        outputText, errorText, true)) {
 | 
			
		||||
        *errorText->append(GitCommand::msgTimeout(m_settings.timeoutSeconds).toLocal8Bit());
 | 
			
		||||
        errorText->append(GitCommand::msgTimeout(m_settings.timeoutSeconds).toLocal8Bit());
 | 
			
		||||
        Utils::SynchronousProcess::stopProcess(process);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
@@ -1254,6 +1254,45 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory,
 | 
			
		||||
    return StatusChanged;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void GitClient::launchGitK(const QString &workingDirectory)
 | 
			
		||||
{
 | 
			
		||||
    VCSBase::VCSBaseOutputWindow *outwin = VCSBase::VCSBaseOutputWindow::instance();
 | 
			
		||||
    // Locate git in (potentially) custom path. m_binaryPath can be absolute,
 | 
			
		||||
    // which will be handled correctly.
 | 
			
		||||
    QTC_ASSERT(!m_binaryPath.isEmpty(), return);
 | 
			
		||||
    const QString gitBinary = QLatin1String(Constants::GIT_BINARY);
 | 
			
		||||
    const QProcessEnvironment env = processEnvironment();
 | 
			
		||||
    const QString path = env.value(QLatin1String("PATH"));
 | 
			
		||||
    const QString fullGitBinary = Utils::SynchronousProcess::locateBinary(path, m_binaryPath);
 | 
			
		||||
    if (fullGitBinary.isEmpty()) {
 | 
			
		||||
        outwin->appendError(tr("Cannot locate %1.").arg(gitBinary));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    const QString gitBinDirectory = QFileInfo(fullGitBinary).absolutePath();
 | 
			
		||||
#ifdef Q_OS_WIN
 | 
			
		||||
    // Launch 'wish' shell from git binary directory with the gitk located there
 | 
			
		||||
    const QString binary = gitBinDirectory + QLatin1String("/wish");
 | 
			
		||||
    const QStringList arguments(gitBinDirectory + QLatin1String("/gitk"));
 | 
			
		||||
#else
 | 
			
		||||
    // Simple: Run gitk from binary path
 | 
			
		||||
    const QString binary = gitBinDirectory + QLatin1String("/gitk");
 | 
			
		||||
    const QStringList arguments;
 | 
			
		||||
#endif
 | 
			
		||||
    outwin->appendCommand(workingDirectory, binary, arguments);
 | 
			
		||||
    // This should use QProcess::startDetached ideally, but that does not have
 | 
			
		||||
    // an environment parameter.
 | 
			
		||||
    QProcess *process = new QProcess(this);
 | 
			
		||||
    process->setWorkingDirectory(workingDirectory);
 | 
			
		||||
    process->setProcessEnvironment(env);
 | 
			
		||||
    process->start(binary, arguments);
 | 
			
		||||
    if (!process->waitForStarted()) {
 | 
			
		||||
        outwin->appendError(tr("Unable to launch %1.").arg(binary));
 | 
			
		||||
        delete process;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool GitClient::getCommitData(const QString &workingDirectory,
 | 
			
		||||
                              QString *commitTemplate,
 | 
			
		||||
                              CommitData *d,
 | 
			
		||||
 
 | 
			
		||||
@@ -203,6 +203,8 @@ public:
 | 
			
		||||
                           QString *errorMessage = 0,
 | 
			
		||||
                           bool *onBranch = 0);
 | 
			
		||||
 | 
			
		||||
    void launchGitK(const QString &workingDirectory);
 | 
			
		||||
 | 
			
		||||
    GitSettings  settings() const;
 | 
			
		||||
    void setSettings(const GitSettings &s);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -416,6 +416,10 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
 | 
			
		||||
                           tr("Clean Repository..."), QLatin1String("Git.CleanRepository"),
 | 
			
		||||
                           globalcontext, true, SLOT(cleanRepository()));
 | 
			
		||||
 | 
			
		||||
    createRepositoryAction(actionManager, gitContainer,
 | 
			
		||||
                           tr("Launch gitk"), QLatin1String("Git.LaunchGitK"),
 | 
			
		||||
                           globalcontext, false, &GitClient::launchGitK);
 | 
			
		||||
 | 
			
		||||
    gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Global"), this));
 | 
			
		||||
 | 
			
		||||
    ActionCommandPair actionCommand =
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user