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
|
||||
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
|
||||
@@ -504,18 +501,19 @@ static Internal::StateListener *m_listener = nullptr;
|
||||
VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context)
|
||||
: m_context(context)
|
||||
{
|
||||
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
|
||||
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
|
||||
this, [this](VcsBaseSubmitEditor *submitEditor, bool *result) {
|
||||
if (submitEditor == m_submitEditor) {
|
||||
*result = submitEditor->promptSubmit(this);
|
||||
if (*result)
|
||||
EditorManager::addCloseEditorListener([this](IEditor *editor) {
|
||||
bool result = true;
|
||||
if (editor == m_submitEditor) {
|
||||
result = m_submitEditor->promptSubmit(this);
|
||||
if (result)
|
||||
discardCommit();
|
||||
}
|
||||
return result;
|
||||
});
|
||||
|
||||
// First time: create new listener
|
||||
if (!m_listener)
|
||||
m_listener = new Internal::StateListener(plugin);
|
||||
m_listener = new Internal::StateListener(Internal::VcsPlugin::instance());
|
||||
connect(m_listener, &Internal::StateListener::stateChanged,
|
||||
this, &VcsBasePluginPrivate::slotStateChanged);
|
||||
// VCSes might have become (un-)available, so clear the VCS directory cache
|
||||
|
@@ -96,13 +96,6 @@ void VcsPlugin::initialize()
|
||||
{
|
||||
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");
|
||||
|
||||
MacroExpander *expander = globalMacroExpander();
|
||||
|
@@ -33,9 +33,6 @@ public:
|
||||
// initialization and updating on settings change.
|
||||
QStandardItemModel *nickNameModel();
|
||||
|
||||
signals:
|
||||
void submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *e, bool *result);
|
||||
|
||||
private:
|
||||
class VcsPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
Reference in New Issue
Block a user