2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "messagemanager.h"
|
2019-03-18 17:58:33 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "messageoutputwindow.h"
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2019-03-19 08:18:55 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2019-03-16 18:21:37 +01:00
|
|
|
#include <QFont>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2018-07-21 21:11:46 +02:00
|
|
|
static MessageManager *m_instance = nullptr;
|
2019-03-18 17:58:33 +01:00
|
|
|
static Internal::MessageOutputWindow *m_messageOutputWindow = nullptr;
|
2013-09-05 01:52:17 +02:00
|
|
|
|
2016-06-05 22:22:11 +03:00
|
|
|
MessageManager *MessageManager::instance()
|
2013-09-05 01:52:17 +02:00
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2017-08-29 12:46:53 +02:00
|
|
|
void MessageManager::showOutputPane(Core::MessageManager::PrintToOutputPaneFlags flags)
|
|
|
|
|
{
|
2019-03-18 17:56:22 +01:00
|
|
|
QTC_ASSERT(m_messageOutputWindow, return);
|
|
|
|
|
|
2017-08-29 12:46:53 +02:00
|
|
|
if (flags & Flash) {
|
|
|
|
|
m_messageOutputWindow->flash();
|
|
|
|
|
} else if (flags & Silent) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
} else {
|
|
|
|
|
m_messageOutputWindow->popup(IOutputPane::Flag(int(flags)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
MessageManager::MessageManager()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_instance = this;
|
2018-07-21 21:11:46 +02:00
|
|
|
m_messageOutputWindow = nullptr;
|
2015-02-03 23:48:19 +02:00
|
|
|
qRegisterMetaType<MessageManager::PrintToOutputPaneFlags>();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageManager::~MessageManager()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
if (m_messageOutputWindow) {
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(m_messageOutputWindow);
|
2008-12-02 12:01:29 +01:00
|
|
|
delete m_messageOutputWindow;
|
|
|
|
|
}
|
2018-07-21 21:11:46 +02:00
|
|
|
m_instance = nullptr;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-01-26 14:25:03 +01:00
|
|
|
void MessageManager::init()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_messageOutputWindow = new Internal::MessageOutputWindow;
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_messageOutputWindow);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-16 18:21:37 +01:00
|
|
|
void MessageManager::setFont(const QFont &font)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_messageOutputWindow, return);
|
|
|
|
|
|
|
|
|
|
m_messageOutputWindow->setFont(font);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageManager::setWheelZoomEnabled(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(m_messageOutputWindow, return);
|
|
|
|
|
|
|
|
|
|
m_messageOutputWindow->setWheelZoomEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
void MessageManager::write(const QString &text, PrintToOutputPaneFlags flags)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2019-03-18 17:56:22 +01:00
|
|
|
QTC_ASSERT(m_messageOutputWindow, return);
|
|
|
|
|
|
2017-08-29 12:46:53 +02:00
|
|
|
showOutputPane(flags);
|
2019-03-18 17:58:33 +01:00
|
|
|
m_messageOutputWindow->append(text + '\n');
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|