forked from qt-creator/qt-creator
Core: Replace ICoreListener by std::functions
ICoreListener::coreAboutToClose() remains in the core, ICoreListener::editorAboutToClose() is handled by a new EditorManager::addCloseEditorListener() function. This removes the need for some boiler plate code resulting from the need to implement the interface in custom classes (DesignModeCoreListener, EditorClosingCoreListener, PojectEplorer::CoreListener and VcsBase::CoreListener). EditorManager::addCloseEditorListener Change-Id: Ie554c987b5455b555be6d77b77e4013639201d22 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -101,7 +101,6 @@ SOURCES += corejsextensions.cpp \
|
|||||||
removefiledialog.cpp \
|
removefiledialog.cpp \
|
||||||
iversioncontrol.cpp \
|
iversioncontrol.cpp \
|
||||||
dialogs/addtovcsdialog.cpp \
|
dialogs/addtovcsdialog.cpp \
|
||||||
icorelistener.cpp \
|
|
||||||
ioutputpane.cpp \
|
ioutputpane.cpp \
|
||||||
patchtool.cpp \
|
patchtool.cpp \
|
||||||
windowsupport.cpp \
|
windowsupport.cpp \
|
||||||
@@ -177,7 +176,6 @@ HEADERS += corejsextensions.h \
|
|||||||
coreconstants.h \
|
coreconstants.h \
|
||||||
iversioncontrol.h \
|
iversioncontrol.h \
|
||||||
ifilewizardextension.h \
|
ifilewizardextension.h \
|
||||||
icorelistener.h \
|
|
||||||
versiondialog.h \
|
versiondialog.h \
|
||||||
core_global.h \
|
core_global.h \
|
||||||
statusbarwidget.h \
|
statusbarwidget.h \
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ QtcPlugin {
|
|||||||
"helpmanager.cpp", "helpmanager.h",
|
"helpmanager.cpp", "helpmanager.h",
|
||||||
"icontext.cpp", "icontext.h",
|
"icontext.cpp", "icontext.h",
|
||||||
"icore.cpp", "icore.h",
|
"icore.cpp", "icore.h",
|
||||||
"icorelistener.cpp", "icorelistener.h",
|
|
||||||
"id.cpp", "id.h",
|
"id.cpp", "id.h",
|
||||||
"idocument.cpp", "idocument.h",
|
"idocument.cpp", "idocument.h",
|
||||||
"idocumentfactory.cpp", "idocumentfactory.h",
|
"idocumentfactory.cpp", "idocumentfactory.h",
|
||||||
|
|||||||
@@ -35,9 +35,7 @@
|
|||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icorelistener.h>
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -49,36 +47,6 @@ static Core::DesignMode *m_instance = 0;
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class EditorManager;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
debug = false
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class DesignModeCoreListener : public ICoreListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DesignModeCoreListener(DesignMode* mode);
|
|
||||||
bool coreAboutToClose();
|
|
||||||
private:
|
|
||||||
DesignMode *m_mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
DesignModeCoreListener::DesignModeCoreListener(DesignMode *mode) :
|
|
||||||
m_mode(mode)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DesignModeCoreListener::coreAboutToClose()
|
|
||||||
{
|
|
||||||
m_mode->currentEditorChanged(0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
struct DesignEditorInfo
|
struct DesignEditorInfo
|
||||||
{
|
{
|
||||||
int widgetIndex;
|
int widgetIndex;
|
||||||
@@ -90,10 +58,9 @@ struct DesignEditorInfo
|
|||||||
class DesignModePrivate
|
class DesignModePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DesignModePrivate(DesignMode *q);
|
DesignModePrivate();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Internal::DesignModeCoreListener *m_coreListener;
|
|
||||||
QPointer<IEditor> m_currentEditor;
|
QPointer<IEditor> m_currentEditor;
|
||||||
bool m_isActive;
|
bool m_isActive;
|
||||||
bool m_isRequired;
|
bool m_isRequired;
|
||||||
@@ -102,18 +69,22 @@ public:
|
|||||||
Context m_activeContext;
|
Context m_activeContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
DesignModePrivate::DesignModePrivate(DesignMode *q)
|
DesignModePrivate::DesignModePrivate()
|
||||||
: m_coreListener(new Internal::DesignModeCoreListener(q)),
|
: m_isActive(false),
|
||||||
m_isActive(false),
|
|
||||||
m_isRequired(false),
|
m_isRequired(false),
|
||||||
m_stackWidget(new QStackedWidget)
|
m_stackWidget(new QStackedWidget)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
DesignMode::DesignMode()
|
DesignMode::DesignMode()
|
||||||
: d(new DesignModePrivate(this))
|
: d(new DesignModePrivate)
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
|
|
||||||
|
ICore::addPreCloseListener([]() -> bool {
|
||||||
|
m_instance->currentEditorChanged(0);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
setObjectName(QLatin1String("DesignMode"));
|
setObjectName(QLatin1String("DesignMode"));
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
setContext(Context(Constants::C_DESIGN_MODE));
|
setContext(Context(Constants::C_DESIGN_MODE));
|
||||||
@@ -123,8 +94,6 @@ DesignMode::DesignMode()
|
|||||||
setPriority(Constants::P_MODE_DESIGN);
|
setPriority(Constants::P_MODE_DESIGN);
|
||||||
setId(Constants::MODE_DESIGN);
|
setId(Constants::MODE_DESIGN);
|
||||||
|
|
||||||
ExtensionSystem::PluginManager::addObject(d->m_coreListener);
|
|
||||||
|
|
||||||
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
connect(EditorManager::instance(), &EditorManager::currentEditorChanged,
|
||||||
this, &DesignMode::currentEditorChanged);
|
this, &DesignMode::currentEditorChanged);
|
||||||
|
|
||||||
@@ -134,9 +103,6 @@ DesignMode::DesignMode()
|
|||||||
|
|
||||||
DesignMode::~DesignMode()
|
DesignMode::~DesignMode()
|
||||||
{
|
{
|
||||||
ExtensionSystem::PluginManager::removeObject(d->m_coreListener);
|
|
||||||
delete d->m_coreListener;
|
|
||||||
|
|
||||||
qDeleteAll(d->m_editors);
|
qDeleteAll(d->m_editors);
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
#include <coreplugin/fileutils.h>
|
#include <coreplugin/fileutils.h>
|
||||||
#include <coreplugin/findplaceholder.h>
|
#include <coreplugin/findplaceholder.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/icorelistener.h>
|
|
||||||
#include <coreplugin/imode.h>
|
#include <coreplugin/imode.h>
|
||||||
#include <coreplugin/infobar.h>
|
#include <coreplugin/infobar.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
@@ -115,26 +114,6 @@ static const char fileSystemCaseSensitivityKey[] = "Core/FileSystemCaseSensitivi
|
|||||||
|
|
||||||
static const char scratchBufferKey[] = "_q_emScratchBuffer";
|
static const char scratchBufferKey[] = "_q_emScratchBuffer";
|
||||||
|
|
||||||
//===================EditorClosingCoreListener======================
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class EditorClosingCoreListener : public ICoreListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool editorAboutToClose(IEditor *) { return true; }
|
|
||||||
bool coreAboutToClose()
|
|
||||||
{
|
|
||||||
// Do not ask for files to save.
|
|
||||||
// MainWindow::closeEvent has already done that.
|
|
||||||
return EditorManager::closeAllEditors(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -284,7 +263,6 @@ EditorManagerPrivate::EditorManagerPrivate(QObject *parent) :
|
|||||||
m_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), this)),
|
m_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), this)),
|
||||||
m_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), this)),
|
m_findInDirectoryAction(new QAction(FileUtils::msgFindInDirectory(), this)),
|
||||||
m_windowPopup(0),
|
m_windowPopup(0),
|
||||||
m_coreListener(0),
|
|
||||||
m_reloadSetting(IDocument::AlwaysAsk),
|
m_reloadSetting(IDocument::AlwaysAsk),
|
||||||
m_autoSaveEnabled(true),
|
m_autoSaveEnabled(true),
|
||||||
m_autoSaveInterval(5),
|
m_autoSaveInterval(5),
|
||||||
@@ -297,10 +275,6 @@ EditorManagerPrivate::EditorManagerPrivate(QObject *parent) :
|
|||||||
EditorManagerPrivate::~EditorManagerPrivate()
|
EditorManagerPrivate::~EditorManagerPrivate()
|
||||||
{
|
{
|
||||||
if (ICore::instance()) {
|
if (ICore::instance()) {
|
||||||
if (m_coreListener) {
|
|
||||||
ExtensionSystem::PluginManager::removeObject(m_coreListener);
|
|
||||||
delete m_coreListener;
|
|
||||||
}
|
|
||||||
ExtensionSystem::PluginManager::removeObject(m_openEditorsFactory);
|
ExtensionSystem::PluginManager::removeObject(m_openEditorsFactory);
|
||||||
delete m_openEditorsFactory;
|
delete m_openEditorsFactory;
|
||||||
}
|
}
|
||||||
@@ -516,8 +490,9 @@ void EditorManagerPrivate::init()
|
|||||||
connect(m_autoSaveTimer, SIGNAL(timeout()), SLOT(autoSave()));
|
connect(m_autoSaveTimer, SIGNAL(timeout()), SLOT(autoSave()));
|
||||||
updateAutoSave();
|
updateAutoSave();
|
||||||
|
|
||||||
d->m_coreListener = new EditorClosingCoreListener();
|
// Do not ask for files to save.
|
||||||
ExtensionSystem::PluginManager::addObject(d->m_coreListener);
|
// MainWindow::closeEvent has already done that.
|
||||||
|
ICore::addPreCloseListener([]() -> bool { return EditorManager::closeAllEditors(false); });
|
||||||
|
|
||||||
d->m_openEditorsFactory = new OpenEditorsViewFactory();
|
d->m_openEditorsFactory = new OpenEditorsViewFactory();
|
||||||
ExtensionSystem::PluginManager::addObject(d->m_openEditorsFactory);
|
ExtensionSystem::PluginManager::addObject(d->m_openEditorsFactory);
|
||||||
@@ -2351,12 +2326,10 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
|||||||
// 2. keep track of the document and all the editors that might remain open for it
|
// 2. keep track of the document and all the editors that might remain open for it
|
||||||
QSet<IEditor*> acceptedEditors;
|
QSet<IEditor*> acceptedEditors;
|
||||||
QMap<IDocument *, QList<IEditor *> > documentMap;
|
QMap<IDocument *, QList<IEditor *> > documentMap;
|
||||||
const QList<ICoreListener *> listeners =
|
|
||||||
ExtensionSystem::PluginManager::getObjects<ICoreListener>();
|
|
||||||
foreach (IEditor *editor, editorsToClose) {
|
foreach (IEditor *editor, editorsToClose) {
|
||||||
bool editorAccepted = true;
|
bool editorAccepted = true;
|
||||||
foreach (ICoreListener *listener, listeners) {
|
foreach (const std::function<bool(IEditor*)> listener, d->m_closeEditorListeners) {
|
||||||
if (!listener->editorAboutToClose(editor)) {
|
if (!listener(editor)) {
|
||||||
editorAccepted = false;
|
editorAccepted = false;
|
||||||
closingFailed = true;
|
closingFailed = true;
|
||||||
break;
|
break;
|
||||||
@@ -2620,6 +2593,22 @@ bool EditorManager::openExternalEditor(const QString &fileName, Id editorId)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn EditorManager::addCloseEditorListener
|
||||||
|
|
||||||
|
\brief The \c EditorManager::addCloseEditorListener function provides
|
||||||
|
a hook for plugins to veto on closing editors.
|
||||||
|
|
||||||
|
When an editor requests a close, all listeners are called. If one of these
|
||||||
|
calls returns \c false, the process is aborted and the event is ignored.
|
||||||
|
If all calls return \c true, \c EditorManager::editorAboutToClose()
|
||||||
|
is emitted and the event is accepted.
|
||||||
|
*/
|
||||||
|
void EditorManager::addCloseEditorListener(const std::function<bool (IEditor *)> &listener)
|
||||||
|
{
|
||||||
|
d->m_closeEditorListeners.append(listener);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList EditorManager::getOpenFileNames()
|
QStringList EditorManager::getOpenFileNames()
|
||||||
{
|
{
|
||||||
QString selectedFilter;
|
QString selectedFilter;
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ public:
|
|||||||
OpenEditorFlags flags = NoFlags);
|
OpenEditorFlags flags = NoFlags);
|
||||||
|
|
||||||
static bool openExternalEditor(const QString &fileName, Id editorId);
|
static bool openExternalEditor(const QString &fileName, Id editorId);
|
||||||
|
static void addCloseEditorListener(const std::function<bool(IEditor *)> &listener);
|
||||||
|
|
||||||
static QStringList getOpenFileNames();
|
static QStringList getOpenFileNames();
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ class EditorManager;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class EditorClosingCoreListener;
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class OpenEditorsViewFactory;
|
class OpenEditorsViewFactory;
|
||||||
class OpenEditorsWindow;
|
class OpenEditorsWindow;
|
||||||
@@ -243,7 +242,6 @@ private:
|
|||||||
IEditor *m_contextMenuEditor;
|
IEditor *m_contextMenuEditor;
|
||||||
|
|
||||||
OpenEditorsWindow *m_windowPopup;
|
OpenEditorsWindow *m_windowPopup;
|
||||||
EditorClosingCoreListener *m_coreListener;
|
|
||||||
|
|
||||||
QMap<QString, QVariant> m_editorStates;
|
QMap<QString, QVariant> m_editorStates;
|
||||||
OpenEditorsViewFactory *m_openEditorsFactory;
|
OpenEditorsViewFactory *m_openEditorsFactory;
|
||||||
@@ -260,6 +258,7 @@ private:
|
|||||||
int m_bigFileSizeLimitInMB;
|
int m_bigFileSizeLimitInMB;
|
||||||
|
|
||||||
QString m_placeholderText;
|
QString m_placeholderText;
|
||||||
|
QList<std::function<bool(IEditor *)>> m_closeEditorListeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
|||||||
@@ -564,6 +564,23 @@ void ICore::openFiles(const QStringList &arguments, ICore::OpenFilesFlags flags)
|
|||||||
m_mainwindow->openFiles(arguments, flags);
|
m_mainwindow->openFiles(arguments, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn ICore::addCloseCoreListener
|
||||||
|
|
||||||
|
\brief The \c ICore::addCloseCoreListener function provides a hook for plugins
|
||||||
|
to veto on closing the application.
|
||||||
|
|
||||||
|
When the application window requests a close, all listeners are called.
|
||||||
|
If one if these calls returns \c false, the process is aborted and the
|
||||||
|
event is ignored. If all calls return \c true, \c ICore::coreAboutToClose()
|
||||||
|
is emitted and the event is accepted or performed..
|
||||||
|
*/
|
||||||
|
void ICore::addPreCloseListener(const std::function<bool ()> &listener)
|
||||||
|
{
|
||||||
|
m_mainwindow->addPreCloseListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
void ICore::saveSettings()
|
void ICore::saveSettings()
|
||||||
{
|
{
|
||||||
emit m_instance->saveSettingsRequested();
|
emit m_instance->saveSettingsRequested();
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
class QStatusBar;
|
class QStatusBar;
|
||||||
@@ -132,6 +134,8 @@ public:
|
|||||||
};
|
};
|
||||||
static void openFiles(const QStringList &fileNames, OpenFilesFlags flags = None);
|
static void openFiles(const QStringList &fileNames, OpenFilesFlags flags = None);
|
||||||
|
|
||||||
|
static void addPreCloseListener(const std::function<bool()> &listener);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
static void saveSettings();
|
static void saveSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "icorelistener.h"
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class Core::ICoreListener
|
|
||||||
|
|
||||||
\brief The ICoreListener class provides a hook for plugins to veto on
|
|
||||||
certain events emitted from the core plugin.
|
|
||||||
|
|
||||||
Implement this interface to prevent certain events from occurring. For
|
|
||||||
example, to prevent the closing of the whole application
|
|
||||||
or to prevent the closing of an editor window under certain conditions.
|
|
||||||
|
|
||||||
For example, if the application window requests a close,
|
|
||||||
\c ICoreListener::coreAboutToClose() is called (in arbitrary order) on all
|
|
||||||
registered objects implementing this interface. If one if these calls
|
|
||||||
returns \c false, the process is aborted and the event is ignored. If all
|
|
||||||
calls return \c true, the corresponding signal is emitted and the event is
|
|
||||||
accepted or performed.
|
|
||||||
|
|
||||||
Guidelines for implementing the class:
|
|
||||||
\list
|
|
||||||
\li Return \c false from the implemented function if you want to prevent
|
|
||||||
the event.
|
|
||||||
\li Add your implementing object to the plugin managers objects:
|
|
||||||
\c{ExtensionSystem::PluginManager::instance()->addObject(yourImplementingObject)}
|
|
||||||
\li Do not forget to remove the object again at deconstruction
|
|
||||||
(for example, in the destructor of your plugin).
|
|
||||||
\endlist
|
|
||||||
*/
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ICORELISTENER_H
|
|
||||||
#define ICORELISTENER_H
|
|
||||||
|
|
||||||
#include "core_global.h"
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class IEditor;
|
|
||||||
|
|
||||||
class CORE_EXPORT ICoreListener : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ICoreListener(QObject *parent = 0) : QObject(parent) {}
|
|
||||||
virtual ~ICoreListener() {}
|
|
||||||
|
|
||||||
virtual bool editorAboutToClose(IEditor * /*editor*/) { return true; }
|
|
||||||
virtual bool coreAboutToClose() { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
#endif // ICORELISTENER_H
|
|
||||||
@@ -69,7 +69,6 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager_p.h>
|
#include <coreplugin/editormanager/editormanager_p.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/icorelistener.h>
|
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
#include <coreplugin/inavigationwidgetfactory.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager_p.h>
|
#include <coreplugin/progressmanager/progressmanager_p.h>
|
||||||
#include <coreplugin/progressmanager/progressview.h>
|
#include <coreplugin/progressmanager/progressview.h>
|
||||||
@@ -250,6 +249,11 @@ void MainWindow::appendAboutInformation(const QString &line)
|
|||||||
m_aboutInformation.append(line);
|
m_aboutInformation.append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addPreCloseListener(const std::function<bool ()> &listener)
|
||||||
|
{
|
||||||
|
m_preCloseListeners.append(listener);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
// explicitly delete window support, because that calls methods from ICore that call methods
|
// explicitly delete window support, because that calls methods from ICore that call methods
|
||||||
@@ -370,10 +374,8 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ICoreListener *> listeners =
|
foreach (const std::function<bool()> &listener, m_preCloseListeners) {
|
||||||
PluginManager::getObjects<ICoreListener>();
|
if (!listener()) {
|
||||||
foreach (ICoreListener *listener, listeners) {
|
|
||||||
if (!listener->coreAboutToClose()) {
|
|
||||||
event->ignore();
|
event->ignore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@
|
|||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
@@ -113,6 +115,8 @@ public:
|
|||||||
QStringList additionalAboutInformation() const;
|
QStringList additionalAboutInformation() const;
|
||||||
void appendAboutInformation(const QString &line);
|
void appendAboutInformation(const QString &line);
|
||||||
|
|
||||||
|
void addPreCloseListener(const std::function<bool()> &listener);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newItemDialogRunningChanged();
|
void newItemDialogRunningChanged();
|
||||||
|
|
||||||
@@ -201,6 +205,7 @@ private:
|
|||||||
|
|
||||||
QToolButton *m_toggleSideBarButton;
|
QToolButton *m_toggleSideBarButton;
|
||||||
QColor m_overrideColor;
|
QColor m_overrideColor;
|
||||||
|
QList<std::function<bool()>> m_preCloseListeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "corelistenercheckingforrunningbuild.h"
|
|
||||||
#include "projectexplorer.h"
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
CoreListener::CoreListener()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CoreListener::coreAboutToClose()
|
|
||||||
{
|
|
||||||
return ProjectExplorerPlugin::coreAboutToClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CORELISTENERCHECKINGFORRUNNINGBUILD_H
|
|
||||||
#define CORELISTENERCHECKINGFORRUNNINGBUILD_H
|
|
||||||
|
|
||||||
#include <coreplugin/icorelistener.h>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class CoreListener : public Core::ICoreListener
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
CoreListener();
|
|
||||||
|
|
||||||
bool coreAboutToClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
|
||||||
#endif // CORELISTENERCHECKINGFORRUNNINGBUILD_H
|
|
||||||
@@ -79,7 +79,6 @@
|
|||||||
#include "projectnodes.h"
|
#include "projectnodes.h"
|
||||||
#include "sessiondialog.h"
|
#include "sessiondialog.h"
|
||||||
#include "projectexplorersettingspage.h"
|
#include "projectexplorersettingspage.h"
|
||||||
#include "corelistenercheckingforrunningbuild.h"
|
|
||||||
#include "buildconfiguration.h"
|
#include "buildconfiguration.h"
|
||||||
#include "miniprojecttargetselector.h"
|
#include "miniprojecttargetselector.h"
|
||||||
#include "taskhub.h"
|
#include "taskhub.h"
|
||||||
@@ -559,7 +558,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
|||||||
addAutoReleasedObject(new RemoveTaskHandler);
|
addAutoReleasedObject(new RemoveTaskHandler);
|
||||||
addAutoReleasedObject(new ConfigTaskHandler(Task::compilerMissingTask(),
|
addAutoReleasedObject(new ConfigTaskHandler(Task::compilerMissingTask(),
|
||||||
Constants::KITS_SETTINGS_PAGE_ID));
|
Constants::KITS_SETTINGS_PAGE_ID));
|
||||||
addAutoReleasedObject(new CoreListener);
|
|
||||||
|
ICore::addPreCloseListener([]() -> bool { return coreAboutToClose(); });
|
||||||
|
|
||||||
dd->m_outputPane = new AppOutputPane;
|
dd->m_outputPane = new AppOutputPane;
|
||||||
addAutoReleasedObject(dd->m_outputPane);
|
addAutoReleasedObject(dd->m_outputPane);
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ public:
|
|||||||
// internal public for FlatModel
|
// internal public for FlatModel
|
||||||
static void renameFile(Node *node, const QString &newFilePath);
|
static void renameFile(Node *node, const QString &newFilePath);
|
||||||
static QStringList projectFilePatterns();
|
static QStringList projectFilePatterns();
|
||||||
static bool coreAboutToClose();
|
|
||||||
static QList<QPair<QString, QString> > recentProjects();
|
static QList<QPair<QString, QString> > recentProjects();
|
||||||
|
|
||||||
static bool canRun(Project *pro, Core::Id runMode, QString *whyNot = 0);
|
static bool canRun(Project *pro, Core::Id runMode, QString *whyNot = 0);
|
||||||
@@ -160,6 +159,9 @@ public:
|
|||||||
|
|
||||||
static void updateContextMenuActions();
|
static void updateContextMenuActions();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool coreAboutToClose();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void runControlStarted(ProjectExplorer::RunControl *rc);
|
void runControlStarted(ProjectExplorer::RunControl *rc);
|
||||||
void runControlFinished(ProjectExplorer::RunControl *rc);
|
void runControlFinished(ProjectExplorer::RunControl *rc);
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ HEADERS += projectexplorer.h \
|
|||||||
gnumakeparser.h \
|
gnumakeparser.h \
|
||||||
projectexplorerconstants.h \
|
projectexplorerconstants.h \
|
||||||
projectexplorersettings.h \
|
projectexplorersettings.h \
|
||||||
corelistenercheckingforrunningbuild.h \
|
|
||||||
project.h \
|
project.h \
|
||||||
iprojectmanager.h \
|
iprojectmanager.h \
|
||||||
currentprojectfilter.h \
|
currentprojectfilter.h \
|
||||||
@@ -238,7 +237,6 @@ SOURCES += projectexplorer.cpp \
|
|||||||
cesdkhandler.cpp \
|
cesdkhandler.cpp \
|
||||||
gccparser.cpp \
|
gccparser.cpp \
|
||||||
projectexplorersettingspage.cpp \
|
projectexplorersettingspage.cpp \
|
||||||
corelistenercheckingforrunningbuild.cpp \
|
|
||||||
baseprojectwizarddialog.cpp \
|
baseprojectwizarddialog.cpp \
|
||||||
miniprojecttargetselector.cpp \
|
miniprojecttargetselector.cpp \
|
||||||
targetselector.cpp \
|
targetselector.cpp \
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ QtcPlugin {
|
|||||||
"compileoutputwindow.cpp", "compileoutputwindow.h",
|
"compileoutputwindow.cpp", "compileoutputwindow.h",
|
||||||
"configtaskhandler.cpp", "configtaskhandler.h",
|
"configtaskhandler.cpp", "configtaskhandler.h",
|
||||||
"copytaskhandler.cpp", "copytaskhandler.h",
|
"copytaskhandler.cpp", "copytaskhandler.h",
|
||||||
"corelistenercheckingforrunningbuild.cpp", "corelistenercheckingforrunningbuild.h",
|
|
||||||
"currentprojectfilter.cpp", "currentprojectfilter.h",
|
"currentprojectfilter.cpp", "currentprojectfilter.h",
|
||||||
"currentprojectfind.cpp", "currentprojectfind.h",
|
"currentprojectfind.cpp", "currentprojectfind.h",
|
||||||
"customparser.cpp", "customparser.h",
|
"customparser.cpp", "customparser.h",
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "corelistener.h"
|
|
||||||
#include "vcsbasesubmiteditor.h"
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class VcsBase::Internal::CoreListener
|
|
||||||
|
|
||||||
\brief The CoreListener class catches the closing of a submit editor.
|
|
||||||
|
|
||||||
Catches the closing of a submit editor to trigger the submit.
|
|
||||||
One instance of this class exists, connected to the instances
|
|
||||||
of VcsBasePlugin, which dispatch if the editor kind matches theirs
|
|
||||||
(which is why the approach of passing the bool result was chosen).
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace VcsBase {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
CoreListener::CoreListener(QObject *parent) :
|
|
||||||
ICoreListener(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CoreListener::editorAboutToClose(Core::IEditor *editor)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
if (editor)
|
|
||||||
if (VcsBase::VcsBaseSubmitEditor *se = qobject_cast<VcsBase::VcsBaseSubmitEditor *>(editor))
|
|
||||||
emit submitEditorAboutToClose(se, &result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace VcsBase
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** 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
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms and
|
|
||||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
|
||||||
** use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
||||||
** General Public License version 2.1 or version 3 as published by the Free
|
|
||||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
||||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
||||||
** following information to ensure the GNU Lesser General Public License
|
|
||||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
||||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
||||||
** rights. These rights are described in The Qt Company LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CORELISTENER_H
|
|
||||||
#define CORELISTENER_H
|
|
||||||
|
|
||||||
#include <coreplugin/icorelistener.h>
|
|
||||||
|
|
||||||
namespace VcsBase {
|
|
||||||
|
|
||||||
class VcsBaseSubmitEditor;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class CoreListener : public Core::ICoreListener
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CoreListener(QObject *parent = 0);
|
|
||||||
bool editorAboutToClose(Core::IEditor *editor);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void submitEditorAboutToClose(VcsBaseSubmitEditor *e, bool *result);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace VcsBase
|
|
||||||
|
|
||||||
#endif // CORELISTENER_H
|
|
||||||
@@ -7,7 +7,6 @@ HEADERS += vcsbase_global.h \
|
|||||||
wizard/vcscommandpage.h \
|
wizard/vcscommandpage.h \
|
||||||
wizard/vcsjsextension.h \
|
wizard/vcsjsextension.h \
|
||||||
vcsplugin.h \
|
vcsplugin.h \
|
||||||
corelistener.h \
|
|
||||||
vcsbaseplugin.h \
|
vcsbaseplugin.h \
|
||||||
baseannotationhighlighter.h \
|
baseannotationhighlighter.h \
|
||||||
diffandloghighlighter.h \
|
diffandloghighlighter.h \
|
||||||
@@ -36,7 +35,6 @@ SOURCES += vcsplugin.cpp \
|
|||||||
wizard/vcsconfigurationpage.cpp \
|
wizard/vcsconfigurationpage.cpp \
|
||||||
wizard/vcscommandpage.cpp \
|
wizard/vcscommandpage.cpp \
|
||||||
wizard/vcsjsextension.cpp \
|
wizard/vcsjsextension.cpp \
|
||||||
corelistener.cpp \
|
|
||||||
baseannotationhighlighter.cpp \
|
baseannotationhighlighter.cpp \
|
||||||
diffandloghighlighter.cpp \
|
diffandloghighlighter.cpp \
|
||||||
vcsbaseeditor.cpp \
|
vcsbaseeditor.cpp \
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ QtcPlugin {
|
|||||||
"commonsettingspage.ui",
|
"commonsettingspage.ui",
|
||||||
"commonvcssettings.cpp",
|
"commonvcssettings.cpp",
|
||||||
"commonvcssettings.h",
|
"commonvcssettings.h",
|
||||||
"corelistener.cpp",
|
|
||||||
"corelistener.h",
|
|
||||||
"diffandloghighlighter.cpp",
|
"diffandloghighlighter.cpp",
|
||||||
"diffandloghighlighter.h",
|
"diffandloghighlighter.h",
|
||||||
"nicknamedialog.cpp",
|
"nicknamedialog.cpp",
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include "vcsplugin.h"
|
#include "vcsplugin.h"
|
||||||
#include "commonvcssettings.h"
|
#include "commonvcssettings.h"
|
||||||
#include "vcsoutputwindow.h"
|
#include "vcsoutputwindow.h"
|
||||||
#include "corelistener.h"
|
|
||||||
#include "vcscommand.h"
|
#include "vcscommand.h"
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
@@ -567,7 +566,7 @@ void VcsBasePlugin::initializeVcs(IVersionControl *vc, const Context &context)
|
|||||||
addAutoReleasedObject(vc);
|
addAutoReleasedObject(vc);
|
||||||
|
|
||||||
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
|
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
|
||||||
connect(plugin->coreListener(), &Internal::CoreListener::submitEditorAboutToClose,
|
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
|
||||||
this, &VcsBasePlugin::slotSubmitEditorAboutToClose);
|
this, &VcsBasePlugin::slotSubmitEditorAboutToClose);
|
||||||
// First time: create new listener
|
// First time: create new listener
|
||||||
if (!VcsBasePluginPrivate::m_listener)
|
if (!VcsBasePluginPrivate::m_listener)
|
||||||
|
|||||||
@@ -31,16 +31,18 @@
|
|||||||
#include "vcsplugin.h"
|
#include "vcsplugin.h"
|
||||||
|
|
||||||
#include "vcsbaseconstants.h"
|
#include "vcsbaseconstants.h"
|
||||||
|
#include "vcsbasesubmiteditor.h"
|
||||||
|
|
||||||
#include "commonsettingspage.h"
|
#include "commonsettingspage.h"
|
||||||
#include "nicknamedialog.h"
|
#include "nicknamedialog.h"
|
||||||
#include "vcsoutputwindow.h"
|
#include "vcsoutputwindow.h"
|
||||||
#include "vcsprojectcache.h"
|
#include "vcsprojectcache.h"
|
||||||
#include "corelistener.h"
|
|
||||||
#include "wizard/vcscommandpage.h"
|
#include "wizard/vcscommandpage.h"
|
||||||
#include "wizard/vcsconfigurationpage.h"
|
#include "wizard/vcsconfigurationpage.h"
|
||||||
#include "wizard/vcsjsextension.h"
|
#include "wizard/vcsjsextension.h"
|
||||||
|
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/jsexpander.h>
|
#include <coreplugin/jsexpander.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
@@ -64,8 +66,7 @@ VcsPlugin *VcsPlugin::m_instance = 0;
|
|||||||
|
|
||||||
VcsPlugin::VcsPlugin() :
|
VcsPlugin::VcsPlugin() :
|
||||||
m_settingsPage(0),
|
m_settingsPage(0),
|
||||||
m_nickNameModel(0),
|
m_nickNameModel(0)
|
||||||
m_coreListener(0)
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
}
|
}
|
||||||
@@ -81,8 +82,12 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
Q_UNUSED(errorMessage)
|
Q_UNUSED(errorMessage)
|
||||||
|
|
||||||
m_coreListener = new CoreListener;
|
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
|
||||||
addAutoReleasedObject(m_coreListener);
|
bool result = true;
|
||||||
|
if (auto se = qobject_cast<VcsBaseSubmitEditor *>(editor))
|
||||||
|
emit submitEditorAboutToClose(se, &result);
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
m_settingsPage = new CommonOptionsPage;
|
m_settingsPage = new CommonOptionsPage;
|
||||||
addAutoReleasedObject(m_settingsPage);
|
addAutoReleasedObject(m_settingsPage);
|
||||||
@@ -139,11 +144,6 @@ VcsPlugin *VcsPlugin::instance()
|
|||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreListener *VcsPlugin::coreListener() const
|
|
||||||
{
|
|
||||||
return m_coreListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommonVcsSettings VcsPlugin::settings() const
|
CommonVcsSettings VcsPlugin::settings() const
|
||||||
{
|
{
|
||||||
return m_settingsPage->settings();
|
return m_settingsPage->settings();
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ class QStandardItemModel;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
|
class VcsBaseSubmitEditor;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CommonVcsSettings;
|
class CommonVcsSettings;
|
||||||
@@ -59,8 +62,6 @@ public:
|
|||||||
|
|
||||||
static VcsPlugin *instance();
|
static VcsPlugin *instance();
|
||||||
|
|
||||||
CoreListener *coreListener() const;
|
|
||||||
|
|
||||||
CommonVcsSettings settings() const;
|
CommonVcsSettings settings() const;
|
||||||
|
|
||||||
// Model of user nick names used for the submit
|
// Model of user nick names used for the submit
|
||||||
@@ -70,6 +71,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void settingsChanged(const VcsBase::Internal::CommonVcsSettings &s);
|
void settingsChanged(const VcsBase::Internal::CommonVcsSettings &s);
|
||||||
|
void submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *e, bool *result);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotSettingsChanged();
|
void slotSettingsChanged();
|
||||||
@@ -80,7 +82,6 @@ private:
|
|||||||
static VcsPlugin *m_instance;
|
static VcsPlugin *m_instance;
|
||||||
CommonOptionsPage *m_settingsPage;
|
CommonOptionsPage *m_settingsPage;
|
||||||
QStandardItemModel *m_nickNameModel;
|
QStandardItemModel *m_nickNameModel;
|
||||||
CoreListener *m_coreListener;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user