diff options
author | Friedemann Kleint <[email protected]> | 2010-01-27 12:47:14 +0100 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2010-01-27 12:47:23 +0100 |
commit | 18ab532e5607b528fde3bf5dcc67cded0c4a1477 (patch) | |
tree | d8b2faff5c1ca59e5fe3818f57728c8ab03d10a3 /src/plugins/git/gitplugin.cpp | |
parent | 8ecc80ec4c11cdd4f13602251348d8c1b087c954 (diff) |
VCS[git]: Make Branchdialog non-modal as is StashDialog.
Give dialogs a consistent look, set
WA_DeleteOnClose on them and improve updating.
Add a Refresh/Diff buttons to branch dialog.
Diffstat (limited to 'src/plugins/git/gitplugin.cpp')
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index cb034ff2a53..4c98ff4b087 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -684,35 +684,38 @@ void GitPlugin::stashPop() m_gitClient->stashPop(state.topLevel()); } +// Create a non-modal dialog with refresh method or raise if it exists +template <class NonModalDialog> + inline void showNonModalDialog(const QString &topLevel, + QPointer<NonModalDialog> &dialog) +{ + if (dialog) { + dialog->show(); + dialog->raise(); + } else { + dialog = new NonModalDialog(Core::ICore::instance()->mainWindow()); + dialog->refresh(topLevel, true); + dialog->show(); + } +} + void GitPlugin::branchList() { - const VCSBase::VCSBasePluginState state = currentState(); - QTC_ASSERT(state.hasTopLevel(), return) - QString errorMessage; - BranchDialog dialog(m_core->mainWindow()); - - if (!dialog.init(m_gitClient, state.topLevel(), &errorMessage)) { - VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); - return; - } - dialog.exec(); + showNonModalDialog(currentState().topLevel(), m_branchDialog); } void GitPlugin::stashList() { - // Raise non-modal stash dialog. - if (m_stashDialog) { - m_stashDialog->show(); - m_stashDialog->raise(); - } else { - m_stashDialog = new StashDialog(Core::ICore::instance()->mainWindow()); - m_stashDialog->refresh(currentState().topLevel(), true); - m_stashDialog->show(); - } + showNonModalDialog(currentState().topLevel(), m_stashDialog); } void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) { + if (m_stashDialog) + m_stashDialog->refresh(currentState().topLevel(), false); + if (m_branchDialog) + m_branchDialog->refresh(currentState().topLevel(), false); + if (!enableMenuAction(as, m_menuAction)) return; // Note: This menu is visible if there is no repository. Only @@ -754,9 +757,6 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as) m_undoRepositoryAction->setEnabled(repositoryEnabled); m_pushAction->setEnabled(repositoryEnabled); - if (m_stashDialog) - m_stashDialog->refresh(currentState().topLevel(), false); - // Prompts for repo. m_showAction->setEnabled(true); } |