2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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"
|
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>
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
|
|
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-04 18:16:57 +01:00
|
|
|
editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
|
|
|
|
|
return editor;
|
|
|
|
|
});
|
|
|
|
|
|
2020-02-05 09:27:26 +01:00
|
|
|
Context context(parameters.id);
|
2018-08-28 00:03:59 +03:00
|
|
|
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);
|
2020-01-23 17:22:05 +01:00
|
|
|
connect(m_submitAction, &QAction::triggered, plugin, &VcsBasePluginPrivate::commitFromEditor);
|
2018-08-28 00:03:59 +03:00
|
|
|
|
|
|
|
|
m_diffAction = new QAction(VcsBaseSubmitEditor::diffIcon(), tr("Diff &Selected Files"), this);
|
|
|
|
|
ActionManager::registerAction(m_diffAction, DIFF_SELECTED, context);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|