forked from qt-creator/qt-creator
Vcs: Remove some indirection in BaseVcsSubmitEditorFactory
Change-Id: I6ddc818412c9104a06495e2dd8f245de1132e7c2 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -31,8 +31,6 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QAction>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
@@ -52,26 +50,28 @@ VcsSubmitEditorFactory::VcsSubmitEditorFactory
|
|||||||
setEditorCreator([this, editorCreator, parameters] {
|
setEditorCreator([this, editorCreator, parameters] {
|
||||||
VcsBaseSubmitEditor *editor = editorCreator();
|
VcsBaseSubmitEditor *editor = editorCreator();
|
||||||
editor->setParameters(parameters);
|
editor->setParameters(parameters);
|
||||||
editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
|
editor->registerActions(&m_undoAction, &m_redoAction, &m_submitAction, &m_diffAction);
|
||||||
return editor;
|
return editor;
|
||||||
});
|
});
|
||||||
|
|
||||||
Context context(parameters.id);
|
Context context(parameters.id);
|
||||||
m_undoAction = new QAction(tr("&Undo"), this);
|
m_undoAction.setText(tr("&Undo"));
|
||||||
ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context);
|
ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, context);
|
||||||
|
|
||||||
m_redoAction = new QAction(tr("&Redo"), this);
|
m_redoAction.setText(tr("&Redo"));
|
||||||
ActionManager::registerAction(m_redoAction, Core::Constants::REDO, context);
|
ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, context);
|
||||||
|
|
||||||
QTC_ASSERT(plugin, return);
|
QTC_ASSERT(plugin, return);
|
||||||
m_submitAction = new QAction(VcsBaseSubmitEditor::submitIcon(),
|
m_submitAction.setIcon(VcsBaseSubmitEditor::submitIcon());
|
||||||
plugin->commitDisplayName(), this);
|
m_submitAction.setText(plugin->commitDisplayName());
|
||||||
Command *command = ActionManager::registerAction(m_submitAction, SUBMIT, context);
|
|
||||||
command->setAttribute(Command::CA_UpdateText);
|
|
||||||
connect(m_submitAction, &QAction::triggered, plugin, &VcsBasePluginPrivate::commitFromEditor);
|
|
||||||
|
|
||||||
m_diffAction = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
Command *command = ActionManager::registerAction(&m_submitAction, SUBMIT, context);
|
||||||
ActionManager::registerAction(m_diffAction, DIFF_SELECTED, context);
|
command->setAttribute(Command::CA_UpdateText);
|
||||||
|
QObject::connect(&m_submitAction, &QAction::triggered, plugin, &VcsBasePluginPrivate::commitFromEditor);
|
||||||
|
|
||||||
|
m_diffAction.setIcon(VcsBaseSubmitEditor::diffIcon());
|
||||||
|
m_diffAction.setText(tr("Diff &Selected Files"));
|
||||||
|
ActionManager::registerAction(&m_diffAction, DIFF_SELECTED, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAction);
|
#include <QAction>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
@@ -40,9 +41,10 @@ class VcsBasePluginPrivate;
|
|||||||
|
|
||||||
// Parametrizable base class for editor factories creating instances of
|
// Parametrizable base class for editor factories creating instances of
|
||||||
// VcsBaseSubmitEditor subclasses.
|
// VcsBaseSubmitEditor subclasses.
|
||||||
|
|
||||||
class VCSBASE_EXPORT VcsSubmitEditorFactory : public Core::IEditorFactory
|
class VCSBASE_EXPORT VcsSubmitEditorFactory : public Core::IEditorFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_DECLARE_TR_FUNCTIONS(VcsBase::VcsSubmitEditorFactory)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
|
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
|
||||||
@@ -52,10 +54,10 @@ public:
|
|||||||
VcsBasePluginPrivate *plugin);
|
VcsBasePluginPrivate *plugin);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *m_submitAction = nullptr;
|
QAction m_submitAction;
|
||||||
QAction *m_diffAction = nullptr;
|
QAction m_diffAction;
|
||||||
QAction *m_undoAction = nullptr;
|
QAction m_undoAction;
|
||||||
QAction *m_redoAction = nullptr;
|
QAction m_redoAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|||||||
Reference in New Issue
Block a user