forked from qt-creator/qt-creator
MessageManager: Transform MessageManager class into namespace
Rename internal static m_messageOutputWindow into s_messageOutputWindow. Make is a std::unique_ptr. Change-Id: I27e9abf3dfa514d21f85d811e3647f65c26ddf31 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -301,7 +301,6 @@ public:
|
|||||||
WindowSupport *m_windowSupport = nullptr;
|
WindowSupport *m_windowSupport = nullptr;
|
||||||
EditorManager *m_editorManager = nullptr;
|
EditorManager *m_editorManager = nullptr;
|
||||||
ExternalToolManager *m_externalToolManager = nullptr;
|
ExternalToolManager *m_externalToolManager = nullptr;
|
||||||
MessageManager *m_messageManager = nullptr;
|
|
||||||
ProgressManagerPrivate *m_progressManager = nullptr;
|
ProgressManagerPrivate *m_progressManager = nullptr;
|
||||||
JsExpander *m_jsExpander = nullptr;
|
JsExpander *m_jsExpander = nullptr;
|
||||||
VcsManager *m_vcsManager = nullptr;
|
VcsManager *m_vcsManager = nullptr;
|
||||||
@@ -1395,7 +1394,6 @@ void ICorePrivate::init()
|
|||||||
m_rightNavigationWidget = new NavigationWidget(m_toggleRightSideBarAction, Side::Right);
|
m_rightNavigationWidget = new NavigationWidget(m_toggleRightSideBarAction, Side::Right);
|
||||||
m_rightPaneWidget = new RightPaneWidget();
|
m_rightPaneWidget = new RightPaneWidget();
|
||||||
|
|
||||||
m_messageManager = new MessageManager;
|
|
||||||
m_editorManager = new EditorManager(this);
|
m_editorManager = new EditorManager(this);
|
||||||
m_externalToolManager = new ExternalToolManager();
|
m_externalToolManager = new ExternalToolManager();
|
||||||
|
|
||||||
@@ -1454,8 +1452,7 @@ ICorePrivate::~ICorePrivate()
|
|||||||
|
|
||||||
delete m_externalToolManager;
|
delete m_externalToolManager;
|
||||||
m_externalToolManager = nullptr;
|
m_externalToolManager = nullptr;
|
||||||
delete m_messageManager;
|
MessageManager::destroy();
|
||||||
m_messageManager = nullptr;
|
|
||||||
delete m_shortcutSettings;
|
delete m_shortcutSettings;
|
||||||
m_shortcutSettings = nullptr;
|
m_shortcutSettings = nullptr;
|
||||||
delete m_toolSettings;
|
delete m_toolSettings;
|
||||||
|
@@ -5,113 +5,88 @@
|
|||||||
|
|
||||||
#include "messageoutputwindow.h"
|
#include "messageoutputwindow.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QThread>
|
|
||||||
#include <QTime>
|
#include <memory>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::MessageManager
|
\namespace Core::MessageManager
|
||||||
\inheaderfile coreplugin/messagemanager.h
|
\inheaderfile coreplugin/messagemanager.h
|
||||||
\ingroup mainclasses
|
\ingroup mainclasses
|
||||||
\inmodule QtCreator
|
\inmodule QtCreator
|
||||||
|
|
||||||
\brief The MessageManager class is used to post messages in the
|
\brief The MessageManager namespace is used to post messages in the
|
||||||
\uicontrol{General Messages} pane.
|
\uicontrol{General Messages} pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::MessageManager {
|
||||||
|
|
||||||
static MessageManager *m_instance = nullptr;
|
static std::unique_ptr<Internal::MessageOutputWindow> s_messageOutputWindow;
|
||||||
static Internal::MessageOutputWindow *m_messageOutputWindow = nullptr;
|
|
||||||
|
|
||||||
enum class Flag { Silent, Flash, Disrupt };
|
enum class Flag { Silent, Flash, Disrupt };
|
||||||
|
|
||||||
static void showOutputPane(Flag flags)
|
static void showOutputPane(Flag flags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
QTC_ASSERT(s_messageOutputWindow, return);
|
||||||
|
|
||||||
switch (flags) {
|
switch (flags) {
|
||||||
case Core::Flag::Silent:
|
case Flag::Silent:
|
||||||
break;
|
break;
|
||||||
case Core::Flag::Flash:
|
case Flag::Flash:
|
||||||
m_messageOutputWindow->flash();
|
s_messageOutputWindow->flash();
|
||||||
break;
|
break;
|
||||||
case Core::Flag::Disrupt:
|
case Flag::Disrupt:
|
||||||
m_messageOutputWindow->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
s_messageOutputWindow->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doWrite(const QString &text, Flag flags)
|
static void doWrite(const QString &text, Flag flags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
QTC_ASSERT(s_messageOutputWindow, return);
|
||||||
|
|
||||||
showOutputPane(flags);
|
showOutputPane(flags);
|
||||||
m_messageOutputWindow->append(text + '\n');
|
s_messageOutputWindow->append(text + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write(const QString &text, Flag flags)
|
static void writeImpl(const QString &text, Flag flags)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_instance, return);
|
QTC_ASSERT(s_messageOutputWindow, return);
|
||||||
if (QThread::currentThread() == m_instance->thread())
|
QMetaObject::invokeMethod(s_messageOutputWindow.get(), [text, flags] { doWrite(text, flags); });
|
||||||
doWrite(text, flags);
|
|
||||||
else
|
|
||||||
QMetaObject::invokeMethod(m_instance, [text, flags] {
|
|
||||||
doWrite(text, flags);
|
|
||||||
}, Qt::QueuedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
MessageManager::MessageManager()
|
void init()
|
||||||
{
|
{
|
||||||
m_instance = this;
|
s_messageOutputWindow.reset(new Internal::MessageOutputWindow);
|
||||||
m_messageOutputWindow = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
MessageManager::~MessageManager()
|
void destroy()
|
||||||
{
|
{
|
||||||
if (m_messageOutputWindow) {
|
s_messageOutputWindow.reset();
|
||||||
ExtensionSystem::PluginManager::removeObject(m_messageOutputWindow);
|
|
||||||
delete m_messageOutputWindow;
|
|
||||||
}
|
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
void MessageManager::init()
|
void setFont(const QFont &font)
|
||||||
{
|
{
|
||||||
m_messageOutputWindow = new Internal::MessageOutputWindow;
|
QTC_ASSERT(s_messageOutputWindow, return);
|
||||||
ExtensionSystem::PluginManager::addObject(m_messageOutputWindow);
|
s_messageOutputWindow->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
void MessageManager::setFont(const QFont &font)
|
void setWheelZoomEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
QTC_ASSERT(s_messageOutputWindow, return);
|
||||||
|
s_messageOutputWindow->setWheelZoomEnabled(enabled);
|
||||||
m_messageOutputWindow->setFont(font);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\internal
|
|
||||||
*/
|
|
||||||
void MessageManager::setWheelZoomEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_messageOutputWindow, return);
|
|
||||||
|
|
||||||
m_messageOutputWindow->setWheelZoomEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -124,9 +99,9 @@ void MessageManager::setWheelZoomEnabled(bool enabled)
|
|||||||
\sa writeFlashing()
|
\sa writeFlashing()
|
||||||
\sa writeDisrupting()
|
\sa writeDisrupting()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeSilently(const QString &message)
|
void writeSilently(const QString &message)
|
||||||
{
|
{
|
||||||
Core::write(message, Flag::Silent);
|
writeImpl(message, Flag::Silent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -141,9 +116,9 @@ void MessageManager::writeSilently(const QString &message)
|
|||||||
\sa writeSilently()
|
\sa writeSilently()
|
||||||
\sa writeDisrupting()
|
\sa writeDisrupting()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeFlashing(const QString &message)
|
void writeFlashing(const QString &message)
|
||||||
{
|
{
|
||||||
Core::write(message, Flag::Flash);
|
writeImpl(message, Flag::Flash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -156,15 +131,15 @@ void MessageManager::writeFlashing(const QString &message)
|
|||||||
\sa writeSilently()
|
\sa writeSilently()
|
||||||
\sa writeFlashing()
|
\sa writeFlashing()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeDisrupting(const QString &message)
|
void writeDisrupting(const QString &message)
|
||||||
{
|
{
|
||||||
Core::write(message, Flag::Disrupt);
|
writeImpl(message, Flag::Disrupt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\overload writeSilently()
|
\overload writeSilently()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeSilently(const QStringList &messages)
|
void writeSilently(const QStringList &messages)
|
||||||
{
|
{
|
||||||
writeSilently(messages.join('\n'));
|
writeSilently(messages.join('\n'));
|
||||||
}
|
}
|
||||||
@@ -172,7 +147,7 @@ void MessageManager::writeSilently(const QStringList &messages)
|
|||||||
/*!
|
/*!
|
||||||
\overload writeFlashing()
|
\overload writeFlashing()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeFlashing(const QStringList &messages)
|
void writeFlashing(const QStringList &messages)
|
||||||
{
|
{
|
||||||
writeFlashing(messages.join('\n'));
|
writeFlashing(messages.join('\n'));
|
||||||
}
|
}
|
||||||
@@ -180,9 +155,9 @@ void MessageManager::writeFlashing(const QStringList &messages)
|
|||||||
/*!
|
/*!
|
||||||
\overload writeDisrupting()
|
\overload writeDisrupting()
|
||||||
*/
|
*/
|
||||||
void MessageManager::writeDisrupting(const QStringList &messages)
|
void writeDisrupting(const QStringList &messages)
|
||||||
{
|
{
|
||||||
writeDisrupting(messages.join('\n'));
|
writeDisrupting(messages.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core::MessageManager
|
||||||
|
@@ -5,47 +5,26 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QStringList>
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QFont;
|
class QFont;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::MessageManager {
|
||||||
|
|
||||||
class ICore;
|
CORE_EXPORT void setFont(const QFont &font);
|
||||||
|
CORE_EXPORT void setWheelZoomEnabled(bool enabled);
|
||||||
|
|
||||||
namespace Internal {
|
CORE_EXPORT void writeSilently(const QString &message);
|
||||||
class ICorePrivate;
|
CORE_EXPORT void writeFlashing(const QString &message);
|
||||||
class MainWindow;
|
CORE_EXPORT void writeDisrupting(const QString &message);
|
||||||
}
|
|
||||||
|
|
||||||
class CORE_EXPORT MessageManager : public QObject
|
CORE_EXPORT void writeSilently(const QStringList &messages);
|
||||||
{
|
CORE_EXPORT void writeFlashing(const QStringList &messages);
|
||||||
Q_OBJECT
|
CORE_EXPORT void writeDisrupting(const QStringList &messages);
|
||||||
|
|
||||||
public:
|
void init();
|
||||||
static void setFont(const QFont &font);
|
void destroy();
|
||||||
static void setWheelZoomEnabled(bool enabled);
|
|
||||||
|
|
||||||
static void writeSilently(const QString &message);
|
} // namespace Core::MessageManager
|
||||||
static void writeFlashing(const QString &message);
|
|
||||||
static void writeDisrupting(const QString &message);
|
|
||||||
|
|
||||||
static void writeSilently(const QStringList &messages);
|
|
||||||
static void writeFlashing(const QStringList &messages);
|
|
||||||
static void writeDisrupting(const QStringList &messages);
|
|
||||||
|
|
||||||
private:
|
|
||||||
MessageManager();
|
|
||||||
~MessageManager() override;
|
|
||||||
|
|
||||||
static void init();
|
|
||||||
|
|
||||||
friend class ICore;
|
|
||||||
friend class Internal::ICorePrivate;
|
|
||||||
friend class Internal::MainWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Core
|
|
||||||
|
Reference in New Issue
Block a user