Skip to content
Snippets Groups Projects
gitplugin.cpp 41.9 KiB
Newer Older
    showNonModalDialog(currentState().topLevel(), m_stashDialog);
con's avatar
con 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);

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);
    // Prompts for repo.
    m_showAction->setEnabled(true);
con's avatar
con committed
}

void GitPlugin::showCommit()
{
    const VCSBase::VCSBasePluginState state = currentState();

con's avatar
con committed
    if (!m_changeSelectionDialog)
        m_changeSelectionDialog = new ChangeSelectionDialog();

    if (state.hasTopLevel())
        m_changeSelectionDialog->setRepository(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->repository(), change);
con's avatar
con committed
}

GitSettings GitPlugin::settings() const
{
    return m_gitClient->settings();
}

void GitPlugin::setSettings(const GitSettings &s)
{
    m_gitClient->setSettings(s);
}

GitClient *GitPlugin::gitClient() const
{
    return m_gitClient;
}

con's avatar
con committed
Q_EXPORT_PLUGIN(GitPlugin)