forked from qt-creator/qt-creator
VcsBase: Move listening to closing submit editors into plugins
Change-Id: Iaab385621f84bcb6e1f6e79cffc198fbd0554c30 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -489,9 +489,6 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
|
|||||||
|
|
||||||
When triggering an action, a copy of the state should be made to
|
When triggering an action, a copy of the state should be made to
|
||||||
keep it, as it may rapidly change due to context changes, etc.
|
keep it, as it may rapidly change due to context changes, etc.
|
||||||
|
|
||||||
The class also detects the VCS plugin submit editor closing and calls
|
|
||||||
the virtual submitEditorAboutToClose() to trigger the submit process.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool VcsBasePluginPrivate::supportsRepositoryCreation() const
|
bool VcsBasePluginPrivate::supportsRepositoryCreation() const
|
||||||
@@ -504,18 +501,19 @@ static Internal::StateListener *m_listener = nullptr;
|
|||||||
VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context)
|
VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context)
|
||||||
: m_context(context)
|
: m_context(context)
|
||||||
{
|
{
|
||||||
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
|
EditorManager::addCloseEditorListener([this](IEditor *editor) {
|
||||||
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
|
bool result = true;
|
||||||
this, [this](VcsBaseSubmitEditor *submitEditor, bool *result) {
|
if (editor == m_submitEditor) {
|
||||||
if (submitEditor == m_submitEditor) {
|
result = m_submitEditor->promptSubmit(this);
|
||||||
*result = submitEditor->promptSubmit(this);
|
if (result)
|
||||||
if (*result)
|
|
||||||
discardCommit();
|
discardCommit();
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
// First time: create new listener
|
// First time: create new listener
|
||||||
if (!m_listener)
|
if (!m_listener)
|
||||||
m_listener = new Internal::StateListener(plugin);
|
m_listener = new Internal::StateListener(Internal::VcsPlugin::instance());
|
||||||
connect(m_listener, &Internal::StateListener::stateChanged,
|
connect(m_listener, &Internal::StateListener::stateChanged,
|
||||||
this, &VcsBasePluginPrivate::slotStateChanged);
|
this, &VcsBasePluginPrivate::slotStateChanged);
|
||||||
// VCSes might have become (un-)available, so clear the VCS directory cache
|
// VCSes might have become (un-)available, so clear the VCS directory cache
|
||||||
|
@@ -96,13 +96,6 @@ void VcsPlugin::initialize()
|
|||||||
{
|
{
|
||||||
d = new VcsPluginPrivate(this);
|
d = new VcsPluginPrivate(this);
|
||||||
|
|
||||||
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
|
|
||||||
bool result = true;
|
|
||||||
if (auto se = qobject_cast<VcsBaseSubmitEditor *>(editor))
|
|
||||||
emit submitEditorAboutToClose(se, &result);
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
JsExpander::registerGlobalObject<VcsJsExtension>("Vcs");
|
JsExpander::registerGlobalObject<VcsJsExtension>("Vcs");
|
||||||
|
|
||||||
MacroExpander *expander = globalMacroExpander();
|
MacroExpander *expander = globalMacroExpander();
|
||||||
|
@@ -33,9 +33,6 @@ public:
|
|||||||
// initialization and updating on settings change.
|
// initialization and updating on settings change.
|
||||||
QStandardItemModel *nickNameModel();
|
QStandardItemModel *nickNameModel();
|
||||||
|
|
||||||
signals:
|
|
||||||
void submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *e, bool *result);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class VcsPluginPrivate *d = nullptr;
|
class VcsPluginPrivate *d = nullptr;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user