Commit dd235e2b authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Fixes: Random enabling of submit/diff buttons when switching contexts (viewing...

Fixes: Random enabling of submit/diff buttons when switching contexts (viewing diffs) from the submit editor

Details: Register actions directly
parent 12636605
......@@ -210,11 +210,7 @@ GitPlugin *GitPlugin::instance()
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
Git::Constants::SUBMIT_MIMETYPE,
Git::Constants::GITSUBMITEDITOR_KIND,
Git::Constants::C_GITSUBMITEDITOR,
Core::Constants::UNDO,
Core::Constants::REDO,
Git::Constants::SUBMIT_CURRENT,
Git::Constants::DIFF_SELECTED
Git::Constants::C_GITSUBMITEDITOR
};
static Core::ICommand *createSeparator(Core::ActionManagerInterface *am,
......@@ -640,10 +636,7 @@ Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const Commit
QTC_ASSERT(submitEditor, return 0);
// The actions are for some reason enabled by the context switching
// mechanism. Disable them correctly.
m_submitCurrentAction->setEnabled(!cd.stagedFiles.empty());
m_diffSelectedFilesAction->setEnabled(false);
m_undoAction->setEnabled(false);
m_redoAction->setEnabled(false);
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
submitEditor->setCommitData(cd);
connect(submitEditor, SIGNAL(diffStaged(QStringList)), this, SLOT(submitEditorDiffStaged(QStringList)));
connect(submitEditor, SIGNAL(diffUnstaged(QStringList)), this, SLOT(submitEditorDiffUnstaged(QStringList)));
......
......@@ -179,11 +179,7 @@ PerforcePlugin::PerforcePlugin() :
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
Perforce::Constants::SUBMIT_MIMETYPE,
Perforce::Constants::PERFORCESUBMITEDITOR_KIND,
Perforce::Constants::C_PERFORCESUBMITEDITOR,
Core::Constants::UNDO,
Core::Constants::REDO,
Perforce::Constants::SUBMIT_CURRENT,
Perforce::Constants::DIFF_SELECTED
Perforce::Constants::C_PERFORCESUBMITEDITOR
};
bool PerforcePlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
......@@ -558,12 +554,8 @@ Core::IEditor *PerforcePlugin::openPerforceSubmitEditor(const QString &fileName,
PerforceSubmitEditor *submitEditor = dynamic_cast<PerforceSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return 0);
submitEditor->restrictToProjectFiles(depotFileNames);
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentLogAction, m_diffSelectedFiles);
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotDiff(QStringList)));
// The actions are for some reason enabled by the context switching
// mechanism. Disable them correctly.
m_diffSelectedFiles->setEnabled(false);
m_undoAction->setEnabled(false);
m_redoAction->setEnabled(false);
return editor;
}
......
......@@ -245,11 +245,7 @@ void SubversionPlugin::cleanChangeTmpFile()
static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
Subversion::Constants::SUBVERSION_SUBMIT_MIMETYPE,
Subversion::Constants::SUBVERSIONCOMMITEDITOR_KIND,
Subversion::Constants::SUBVERSIONCOMMITEDITOR,
Core::Constants::UNDO,
Core::Constants::REDO,
Subversion::Constants::SUBMIT_CURRENT,
Subversion::Constants::DIFF_SELECTED
Subversion::Constants::SUBVERSIONCOMMITEDITOR
};
bool SubversionPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
......@@ -529,11 +525,7 @@ SubversionSubmitEditor *SubversionPlugin::openSubversionSubmitEditor(const QStri
Core::IEditor *editor = m_coreInstance->editorManager()->openEditor(fileName, QLatin1String(Constants::SUBVERSIONCOMMITEDITOR_KIND));
SubversionSubmitEditor *submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, /**/);
// The actions are for some reason enabled by the context switching
// mechanism. Disable them correctly.
m_submitDiffAction->setEnabled(false);
m_submitUndoAction->setEnabled(false);
m_submitRedoAction->setEnabled(false);
submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffFiles(QStringList)));
return submitEditor;
......
......@@ -57,17 +57,6 @@
enum { debug = 0 };
enum { wantToolBar = 0 };
static inline QAction *actionFromId(const Core::ICore *core, const char *id)
{
QAction *rc = 0;
if (id)
if (const Core::ICommand *cmd = core->actionManager()->command(id))
rc = cmd->action();
if (debug)
qDebug() << Q_FUNC_INFO << id << rc;
return rc;
}
namespace VCSBase {
struct VCSBaseSubmitEditorPrivate {
......@@ -83,10 +72,8 @@ struct VCSBaseSubmitEditorPrivate {
VCSBase::Internal::SubmitEditorFile *m_file;
QList<int> m_contexts;
QPointer<QAction> m_undoAction;
QPointer<QAction> m_redoAction;
QPointer<QAction> m_submitAction;
QPointer<QAction> m_diffAction;
QPointer<QAction> m_submitAction;
};
VCSBaseSubmitEditorPrivate::VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditorParameters *parameters,
......@@ -96,11 +83,7 @@ VCSBaseSubmitEditorPrivate::VCSBaseSubmitEditorPrivate(const VCSBaseSubmitEditor
m_widget(editorWidget),
m_toolWidget(0),
m_parameters(parameters),
m_file(new VCSBase::Internal::SubmitEditorFile(QLatin1String(m_parameters->mimeType), q)),
m_undoAction(actionFromId(m_core, m_parameters->undoActionId)),
m_redoAction(actionFromId(m_core, m_parameters->redoActionId)),
m_submitAction(actionFromId(m_core, m_parameters->submitActionId)),
m_diffAction(actionFromId(m_core, m_parameters->diffActionId))
m_file(new VCSBase::Internal::SubmitEditorFile(QLatin1String(m_parameters->mimeType), q))
{
m_contexts << m_core->uniqueIDManager()->uniqueIdentifier(m_parameters->context);
}
......@@ -113,7 +96,6 @@ VCSBaseSubmitEditor::VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *pa
// We are always clean to prevent the editor manager from asking to save.
connect(m_d->m_file, SIGNAL(saveMe(QString)), this, SLOT(save(QString)));
m_d->m_widget->registerActions(m_d->m_undoAction, m_d->m_redoAction, m_d->m_submitAction, m_d->m_diffAction);
connect(m_d->m_widget, SIGNAL(diffSelected(QStringList)), this, SLOT(slotDiffSelectedVCSFiles(QStringList)));
connect(m_d->m_widget->descriptionEdit(), SIGNAL(textChanged()), this, SLOT(slotDescriptionChanged()));
......@@ -129,6 +111,20 @@ VCSBaseSubmitEditor::~VCSBaseSubmitEditor()
delete m_d;
}
void VCSBaseSubmitEditor::registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
QAction *submitAction, QAction *diffAction)\
{
m_d->m_widget->registerActions(editorUndoAction, editorRedoAction, submitAction, diffAction);
m_d->m_diffAction = diffAction;
m_d->m_submitAction = submitAction;
}
void VCSBaseSubmitEditor::unregisterActions(QAction *editorUndoAction, QAction *editorRedoAction,
QAction *submitAction, QAction *diffAction)
{
m_d->m_widget->unregisterActions(editorUndoAction, editorRedoAction, submitAction, diffAction);
m_d->m_diffAction = m_d->m_submitAction = 0;
}
int VCSBaseSubmitEditor::fileNameColumn() const
{
return m_d->m_widget->fileNameColumn();
......
......@@ -44,6 +44,7 @@
QT_BEGIN_NAMESPACE
class QIcon;
class QAbstractItemModel;
class QAction;
QT_END_NAMESPACE
namespace Core {
......@@ -61,10 +62,6 @@ struct VCSBASE_EXPORT VCSBaseSubmitEditorParameters {
const char *mimeType;
const char *kind;
const char *context;
const char *undoActionId;
const char *redoActionId;
const char *submitActionId;
const char *diffActionId;
};
/* Base class for a submit editor based on the Core::Utils::SubmitEditorWidget
......@@ -86,7 +83,8 @@ struct VCSBASE_EXPORT VCSBaseSubmitEditorParameters {
* signal and then asking the IFile interface of the editor to save the file
* within a IFileManager::blockFileChange() section
* and to launch the submit process. In addition, the action registered
* for submit should be connected to a slot triggering the close of the
* for submit sho src/libs/utils/submiteditorwidget.h
uld be connected to a slot triggering the close of the
* current editor in the editor manager. */
class VCSBASE_EXPORT VCSBaseSubmitEditor : public Core::IEditor
......@@ -102,6 +100,12 @@ protected:
Core::Utils::SubmitEditorWidget *editorWidget);
public:
// Register the actions with the submit editor widget.
void registerActions(QAction *editorUndoAction, QAction *editorRedoAction,
QAction *submitAction = 0, QAction *diffAction = 0);
void unregisterActions(QAction *editorUndoAction, QAction *editorRedoAction,
QAction *submitAction = 0, QAction *diffAction = 0);
virtual ~VCSBaseSubmitEditor();
int fileNameColumn() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment