forked from qt-creator/qt-creator
VCS: Consolidate submit editor actions setup
Change-Id: I36754779b6a9aa35de705b368daf8c2a1de058c6 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
f1f506b479
commit
767137157e
@@ -24,24 +24,55 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "basevcssubmiteditorfactory.h"
|
||||
|
||||
#include "vcsbaseplugin.h"
|
||||
#include "vcsbasesubmiteditor.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
namespace VcsBase {
|
||||
|
||||
const char SUBMIT[] = "Vcs.Submit";
|
||||
const char DIFF_SELECTED[] = "Vcs.DiffSelectedFiles";
|
||||
|
||||
VcsSubmitEditorFactory::VcsSubmitEditorFactory
|
||||
(const VcsBaseSubmitEditorParameters *parameters,
|
||||
const EditorCreator &editorCreator,
|
||||
QObject *parent)
|
||||
: IEditorFactory(parent), m_editorCreator(editorCreator)
|
||||
VcsBasePlugin *plugin)
|
||||
: IEditorFactory(plugin), m_editorCreator(editorCreator)
|
||||
{
|
||||
setId(parameters->id);
|
||||
setDisplayName(QLatin1String(parameters->displayName));
|
||||
addMimeType(parameters->mimeType);
|
||||
|
||||
Context context(parameters->id);
|
||||
m_undoAction = new QAction(tr("&Undo"), this);
|
||||
ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context);
|
||||
|
||||
m_redoAction = new QAction(tr("&Redo"), this);
|
||||
ActionManager::registerAction(m_redoAction, Core::Constants::REDO, context);
|
||||
|
||||
QTC_ASSERT(plugin, return);
|
||||
m_submitAction = new QAction(VcsBaseSubmitEditor::submitIcon(),
|
||||
plugin->commitDisplayName(), this);
|
||||
Command *command = ActionManager::registerAction(m_submitAction, SUBMIT, context);
|
||||
command->setAttribute(Command::CA_UpdateText);
|
||||
connect(m_submitAction, &QAction::triggered, plugin, &VcsBasePlugin::commitFromEditor);
|
||||
|
||||
m_diffAction = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
||||
ActionManager::registerAction(m_diffAction, DIFF_SELECTED, context);
|
||||
}
|
||||
|
||||
Core::IEditor *VcsSubmitEditorFactory::createEditor()
|
||||
{
|
||||
return m_editorCreator();
|
||||
VcsBaseSubmitEditor *editor = m_editorCreator();
|
||||
editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
|
||||
return editor;
|
||||
}
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
Reference in New Issue
Block a user