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"
|
|
|
|
|
#include "messageoutputwindow.h"
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2013-06-25 13:37:21 +02:00
|
|
|
static MessageManager *m_instance = 0;
|
2013-09-05 01:52:17 +02:00
|
|
|
Internal::MessageOutputWindow *m_messageOutputWindow = 0;
|
|
|
|
|
|
|
|
|
|
QObject *MessageManager::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
MessageManager::MessageManager()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_instance = this;
|
2013-09-05 01:52:17 +02:00
|
|
|
m_messageOutputWindow = 0;
|
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;
|
|
|
|
|
}
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageManager::showOutputPane()
|
|
|
|
|
{
|
|
|
|
|
if (m_messageOutputWindow)
|
2012-09-13 15:50:06 +02:00
|
|
|
m_messageOutputWindow->popup(IOutputPane::ModeSwitch);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-05 01:52:17 +02:00
|
|
|
void MessageManager::write(const QString &text)
|
|
|
|
|
{
|
|
|
|
|
write(text, NoModeSwitch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MessageManager::write(const QString &text, PrintToOutputPaneFlags flags)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (!m_messageOutputWindow)
|
|
|
|
|
return;
|
2013-03-12 16:13:34 +01:00
|
|
|
if (flags & Flash) {
|
|
|
|
|
m_messageOutputWindow->flash();
|
|
|
|
|
} else if (flags & Silent) {
|
|
|
|
|
// Do nothing
|
|
|
|
|
} else {
|
2014-11-16 10:52:41 +02:00
|
|
|
m_messageOutputWindow->popup(IOutputPane::Flag(int(flags)));
|
2013-03-12 16:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-28 15:52:34 +02:00
|
|
|
m_messageOutputWindow->append(text + QLatin1Char('\n'));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2009-10-23 18:00:20 +02:00
|
|
|
|