2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "basevcssubmiteditorfactory.h"
|
2018-08-28 00:03:59 +03:00
|
|
|
|
|
|
|
|
#include "vcsbaseplugin.h"
|
2023-01-18 09:38:35 +01:00
|
|
|
#include "vcsbasetr.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "vcsbasesubmiteditor.h"
|
|
|
|
|
|
2018-08-28 00:03:59 +03:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-08-28 00:03:59 +03:00
|
|
|
const char SUBMIT[] = "Vcs.Submit";
|
|
|
|
|
const char DIFF_SELECTED[] = "Vcs.DiffSelectedFiles";
|
|
|
|
|
|
2014-08-28 22:23:29 +02:00
|
|
|
VcsSubmitEditorFactory::VcsSubmitEditorFactory
|
2020-02-05 09:27:26 +01:00
|
|
|
(const VcsBaseSubmitEditorParameters ¶meters,
|
2018-02-02 10:08:21 +01:00
|
|
|
const EditorCreator &editorCreator,
|
2020-02-07 15:48:26 +01:00
|
|
|
VcsBasePluginPrivate *plugin)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2020-02-05 09:27:26 +01:00
|
|
|
setId(parameters.id);
|
|
|
|
|
setDisplayName(QLatin1String(parameters.displayName));
|
2020-02-06 08:11:13 +01:00
|
|
|
addMimeType(QLatin1String(parameters.mimeType));
|
2018-08-28 00:03:59 +03:00
|
|
|
|
2020-02-05 09:27:26 +01:00
|
|
|
setEditorCreator([this, editorCreator, parameters] {
|
2020-02-04 18:16:57 +01:00
|
|
|
VcsBaseSubmitEditor *editor = editorCreator();
|
2020-02-05 09:27:26 +01:00
|
|
|
editor->setParameters(parameters);
|
2020-02-11 17:54:18 +01:00
|
|
|
editor->registerActions(&m_undoAction, &m_redoAction, &m_submitAction, &m_diffAction);
|
2020-02-04 18:16:57 +01:00
|
|
|
return editor;
|
|
|
|
|
});
|
|
|
|
|
|
2020-02-05 09:27:26 +01:00
|
|
|
Context context(parameters.id);
|
2023-01-18 09:38:35 +01:00
|
|
|
m_undoAction.setText(Tr::tr("&Undo"));
|
2020-02-11 17:54:18 +01:00
|
|
|
ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, context);
|
2018-08-28 00:03:59 +03:00
|
|
|
|
2023-01-18 09:38:35 +01:00
|
|
|
m_redoAction.setText(Tr::tr("&Redo"));
|
2020-02-11 17:54:18 +01:00
|
|
|
ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, context);
|
2018-08-28 00:03:59 +03:00
|
|
|
|
|
|
|
|
QTC_ASSERT(plugin, return);
|
2020-02-11 17:54:18 +01:00
|
|
|
m_submitAction.setIcon(VcsBaseSubmitEditor::submitIcon());
|
|
|
|
|
m_submitAction.setText(plugin->commitDisplayName());
|
|
|
|
|
|
|
|
|
|
Command *command = ActionManager::registerAction(&m_submitAction, SUBMIT, context);
|
2018-08-28 00:03:59 +03:00
|
|
|
command->setAttribute(Command::CA_UpdateText);
|
2020-02-11 17:54:18 +01:00
|
|
|
QObject::connect(&m_submitAction, &QAction::triggered, plugin, &VcsBasePluginPrivate::commitFromEditor);
|
2018-08-28 00:03:59 +03:00
|
|
|
|
2020-02-11 17:54:18 +01:00
|
|
|
m_diffAction.setIcon(VcsBaseSubmitEditor::diffIcon());
|
2023-01-18 09:38:35 +01:00
|
|
|
m_diffAction.setText(Tr::tr("Diff &Selected Files"));
|
2020-02-11 17:54:18 +01:00
|
|
|
ActionManager::registerAction(&m_diffAction, DIFF_SELECTED, context);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2022-06-22 13:05:45 +02:00
|
|
|
VcsSubmitEditorFactory::~VcsSubmitEditorFactory() = default;
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|