Skip to content
Snippets Groups Projects
gitplugin.cpp 42.5 KiB
Newer Older
void GitPlugin::remoteList()
{
    showNonModalDialog(currentState().topLevel(), m_remoteDialog);
}

    showNonModalDialog(currentState().topLevel(), m_stashDialog);
con's avatar
con committed
}

hjk's avatar
hjk committed
void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
con's avatar
con committed
{
Friedemann Kleint's avatar
Friedemann Kleint committed
    const bool repositoryEnabled = currentState().hasTopLevel();
    if (m_stashDialog)
        m_stashDialog->refresh(currentState().topLevel(), false);
    if (m_branchDialog)
        m_branchDialog->refresh(currentState().topLevel(), false);
    if (m_remoteDialog)
        m_remoteDialog->refresh(currentState().topLevel(), false);
Friedemann Kleint's avatar
Friedemann Kleint committed
    m_commandLocator->setEnabled(repositoryEnabled);
    if (!enableMenuAction(as, m_menuAction))
    // Note: This menu is visible if there is no repository. Only
    // 'Create Repository'/'Show' actions should be available.
    const QString fileName = currentState().currentFileName();
    foreach (Utils::ParameterAction *fileAction, m_fileActions)
        fileAction->setParameter(fileName);
    // If the current file looks like a patch, offer to apply
    m_applyCurrentFilePatchAction->setParameter(currentState().currentPatchFileDisplayName());
con's avatar
con committed

    const QString projectName = currentState().currentProjectName();
    foreach (Utils::ParameterAction *projectAction, m_projectActions)
        projectAction->setParameter(projectName);

    foreach (QAction *repositoryAction, m_repositoryActions)
        repositoryAction->setEnabled(repositoryEnabled);
    updateRepositoryBrowserAction();
    // Prompts for repo.
    m_showAction->setEnabled(true);
con's avatar
con committed
}

void GitPlugin::updateRepositoryBrowserAction()
{
    const bool repositoryEnabled = currentState().hasTopLevel();
    const bool hasRepositoryBrowserCmd = !settings().stringValue(GitSettings::repositoryBrowserCmd).isEmpty();
    m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
}

con's avatar
con committed
void GitPlugin::showCommit()
{
hjk's avatar
hjk committed
    const VcsBase::VcsBasePluginState state = currentState();
con's avatar
con committed
    if (!m_changeSelectionDialog)
        m_changeSelectionDialog = new ChangeSelectionDialog();

    if (state.hasFile())
        m_changeSelectionDialog->setWorkingDirectory(state.currentFileDirectory());
    else if (state.hasTopLevel())
        m_changeSelectionDialog->setWorkingDirectory(state.topLevel());
con's avatar
con committed

    if (m_changeSelectionDialog->exec() != QDialog::Accepted)
        return;
    const QString change = m_changeSelectionDialog->change();
con's avatar
con committed
        return;

    m_gitClient->show(m_changeSelectionDialog->workingDirectory(), change);
con's avatar
con committed
}

const GitSettings &GitPlugin::settings() const
    return m_settings;
}

void GitPlugin::setSettings(const GitSettings &s)
{
    if (s == m_settings)
        return;

    m_settings = s;
Tobias Hunger's avatar
Tobias Hunger committed
    m_gitClient->saveSettings();
    static_cast<GitVersionControl *>(versionControl())->emitConfigurationChanged();
    updateRepositoryBrowserAction();
GitClient *GitPlugin::gitClient() const
{
    return m_gitClient;
}

con's avatar
con committed
Q_EXPORT_PLUGIN(GitPlugin)