2012-10-05 11:50:16 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2012-10-09 12:19:37 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
2012-10-09 12:19:37 +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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2012-10-05 11:50:16 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-09 12:19:37 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** 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.
|
2012-10-09 12:19:37 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-10-05 11:50:16 +02:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-09 12:19:37 +02:00
|
|
|
****************************************************************************/
|
2012-10-05 11:50:16 +02:00
|
|
|
|
2012-10-04 14:54:59 +02:00
|
|
|
#include "qmlconsolepane.h"
|
|
|
|
|
#include "qmlconsoleview.h"
|
|
|
|
|
#include "qmlconsoleproxymodel.h"
|
|
|
|
|
#include "qmlconsoleitemdelegate.h"
|
|
|
|
|
|
2014-06-13 11:19:54 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2015-11-23 16:41:54 +01:00
|
|
|
#include <coreplugin/coreicons.h>
|
2012-10-04 14:54:59 +02:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
|
#include <utils/savedaction.h>
|
|
|
|
|
#include <aggregation/aggregate.h>
|
2014-07-31 18:15:19 +02:00
|
|
|
#include <coreplugin/find/itemviewfind.h>
|
2012-10-04 14:54:59 +02:00
|
|
|
|
|
|
|
|
#include <QToolButton>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
static const char CONSOLE[] = "Console";
|
|
|
|
|
static const char SHOW_LOG[] = "showLog";
|
|
|
|
|
static const char SHOW_WARNING[] = "showWarning";
|
|
|
|
|
static const char SHOW_ERROR[] = "showError";
|
|
|
|
|
|
|
|
|
|
namespace QmlJSTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QmlConsolePane
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
QmlConsolePane::QmlConsolePane(QObject *parent)
|
|
|
|
|
: Core::IOutputPane(parent)
|
|
|
|
|
{
|
|
|
|
|
m_consoleWidget = new QWidget;
|
|
|
|
|
m_consoleWidget->setWindowTitle(displayName());
|
|
|
|
|
m_consoleWidget->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(m_consoleWidget);
|
|
|
|
|
vbox->setMargin(0);
|
|
|
|
|
vbox->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_consoleView = new QmlConsoleView(m_consoleWidget);
|
|
|
|
|
m_proxyModel = new QmlConsoleProxyModel(this);
|
|
|
|
|
m_proxyModel->setSourceModel(QmlConsoleModel::qmlConsoleItemModel());
|
|
|
|
|
connect(QmlConsoleModel::qmlConsoleItemModel(),
|
2015-01-30 11:02:24 +01:00
|
|
|
&QmlConsoleItemModel::selectEditableRow,
|
2012-10-04 14:54:59 +02:00
|
|
|
m_proxyModel,
|
2015-01-30 11:02:24 +01:00
|
|
|
&QmlConsoleProxyModel::selectEditableRow);
|
2012-10-04 14:54:59 +02:00
|
|
|
|
|
|
|
|
//Scroll to bottom when rows matching current filter settings are inserted
|
|
|
|
|
//Not connecting rowsRemoved as the only way to remove rows is to clear the
|
|
|
|
|
//model which will automatically reset the view.
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(QmlConsoleModel::qmlConsoleItemModel(), &QAbstractItemModel::rowsInserted,
|
|
|
|
|
m_proxyModel, &QmlConsoleProxyModel::onRowsInserted);
|
2012-10-04 14:54:59 +02:00
|
|
|
m_consoleView->setModel(m_proxyModel);
|
|
|
|
|
|
|
|
|
|
connect(m_proxyModel,
|
|
|
|
|
SIGNAL(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)),
|
|
|
|
|
m_consoleView->selectionModel(),
|
|
|
|
|
SLOT(setCurrentIndex(QModelIndex,QItemSelectionModel::SelectionFlags)));
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_proxyModel, &QmlConsoleProxyModel::scrollToBottom,
|
|
|
|
|
m_consoleView, &QmlConsoleView::onScrollToBottom);
|
2012-10-04 14:54:59 +02:00
|
|
|
|
|
|
|
|
m_itemDelegate = new QmlConsoleItemDelegate(this);
|
|
|
|
|
connect(m_consoleView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
|
|
|
|
|
m_itemDelegate, SLOT(currentChanged(QModelIndex,QModelIndex)));
|
|
|
|
|
m_consoleView->setItemDelegate(m_itemDelegate);
|
|
|
|
|
|
|
|
|
|
Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
|
|
|
|
|
aggregate->add(m_consoleView);
|
2014-07-31 18:15:19 +02:00
|
|
|
aggregate->add(new Core::ItemViewFind(m_consoleView));
|
2012-10-04 14:54:59 +02:00
|
|
|
|
|
|
|
|
vbox->addWidget(m_consoleView);
|
|
|
|
|
vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));
|
|
|
|
|
|
|
|
|
|
m_showDebugButton = new QToolButton(m_consoleWidget);
|
|
|
|
|
m_showDebugButton->setAutoRaise(true);
|
|
|
|
|
|
|
|
|
|
m_showDebugButtonAction = new Utils::SavedAction(this);
|
|
|
|
|
m_showDebugButtonAction->setDefaultValue(true);
|
|
|
|
|
m_showDebugButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_LOG));
|
|
|
|
|
m_showDebugButtonAction->setToolTip(tr("Show debug, log, and info messages."));
|
|
|
|
|
m_showDebugButtonAction->setCheckable(true);
|
2015-08-25 15:26:48 +02:00
|
|
|
m_showDebugButtonAction->setChecked(true);
|
2015-12-04 19:21:05 +01:00
|
|
|
m_showDebugButtonAction->setIcon(Core::Icons::INFO_TOOLBAR.icon());
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_showDebugButtonAction, &Utils::SavedAction::toggled,
|
|
|
|
|
m_proxyModel, &QmlConsoleProxyModel::setShowLogs);
|
2012-10-04 14:54:59 +02:00
|
|
|
m_showDebugButton->setDefaultAction(m_showDebugButtonAction);
|
|
|
|
|
|
|
|
|
|
m_showWarningButton = new QToolButton(m_consoleWidget);
|
|
|
|
|
m_showWarningButton->setAutoRaise(true);
|
|
|
|
|
|
|
|
|
|
m_showWarningButtonAction = new Utils::SavedAction(this);
|
|
|
|
|
m_showWarningButtonAction->setDefaultValue(true);
|
|
|
|
|
m_showWarningButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_WARNING));
|
2014-06-23 13:47:08 +02:00
|
|
|
m_showWarningButtonAction->setToolTip(tr("Show warning messages."));
|
2012-10-04 14:54:59 +02:00
|
|
|
m_showWarningButtonAction->setCheckable(true);
|
2015-08-25 15:26:48 +02:00
|
|
|
m_showWarningButtonAction->setChecked(true);
|
2015-12-04 19:21:05 +01:00
|
|
|
m_showWarningButtonAction->setIcon(Core::Icons::WARNING_TOOLBAR.icon());
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_showWarningButtonAction, &Utils::SavedAction::toggled,
|
|
|
|
|
m_proxyModel, &QmlConsoleProxyModel::setShowWarnings);
|
2012-10-04 14:54:59 +02:00
|
|
|
m_showWarningButton->setDefaultAction(m_showWarningButtonAction);
|
|
|
|
|
|
|
|
|
|
m_showErrorButton = new QToolButton(m_consoleWidget);
|
|
|
|
|
m_showErrorButton->setAutoRaise(true);
|
|
|
|
|
|
|
|
|
|
m_showErrorButtonAction = new Utils::SavedAction(this);
|
|
|
|
|
m_showErrorButtonAction->setDefaultValue(true);
|
|
|
|
|
m_showErrorButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_ERROR));
|
2014-06-23 13:47:08 +02:00
|
|
|
m_showErrorButtonAction->setToolTip(tr("Show error messages."));
|
2012-10-04 14:54:59 +02:00
|
|
|
m_showErrorButtonAction->setCheckable(true);
|
2015-08-25 15:26:48 +02:00
|
|
|
m_showErrorButtonAction->setChecked(true);
|
2015-12-04 19:21:05 +01:00
|
|
|
m_showErrorButtonAction->setIcon(Core::Icons::ERROR_TOOLBAR.icon());
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_showErrorButtonAction, &Utils::SavedAction::toggled, m_proxyModel, &QmlConsoleProxyModel::setShowErrors);
|
2012-10-04 14:54:59 +02:00
|
|
|
m_showErrorButton->setDefaultAction(m_showErrorButtonAction);
|
|
|
|
|
|
|
|
|
|
m_spacer = new QWidget(m_consoleWidget);
|
|
|
|
|
m_spacer->setMinimumWidth(30);
|
|
|
|
|
|
|
|
|
|
m_statusLabel = new QLabel(m_consoleWidget);
|
|
|
|
|
|
|
|
|
|
readSettings();
|
|
|
|
|
connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlConsolePane::~QmlConsolePane()
|
|
|
|
|
{
|
|
|
|
|
writeSettings();
|
|
|
|
|
delete m_consoleWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *QmlConsolePane::outputWidget(QWidget *)
|
|
|
|
|
{
|
|
|
|
|
return m_consoleWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QWidget *> QmlConsolePane::toolBarWidgets() const
|
|
|
|
|
{
|
|
|
|
|
return QList<QWidget *>() << m_showDebugButton << m_showWarningButton << m_showErrorButton
|
|
|
|
|
<< m_spacer << m_statusLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int QmlConsolePane::priorityInStatusBar() const
|
|
|
|
|
{
|
|
|
|
|
return 20;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::clearContents()
|
|
|
|
|
{
|
|
|
|
|
QmlConsoleModel::qmlConsoleItemModel()->clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::visibilityChanged(bool /*visible*/)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlConsolePane::canFocus() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlConsolePane::hasFocus() const
|
|
|
|
|
{
|
2015-10-28 13:32:53 +01:00
|
|
|
for (QWidget *widget = m_consoleWidget->window()->focusWidget(); widget != 0;
|
|
|
|
|
widget = widget->parentWidget()) {
|
|
|
|
|
if (widget == m_consoleWidget)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2012-10-04 14:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::setFocus()
|
|
|
|
|
{
|
2015-10-28 13:32:53 +01:00
|
|
|
m_consoleView->setFocus();
|
2012-10-04 14:54:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlConsolePane::canNext() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlConsolePane::canPrevious() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::goToNext()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::goToPrev()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlConsolePane::canNavigate() const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::settings();
|
|
|
|
|
m_showDebugButtonAction->readSettings(settings);
|
|
|
|
|
m_showWarningButtonAction->readSettings(settings);
|
|
|
|
|
m_showErrorButtonAction->readSettings(settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::setContext(const QString &context)
|
|
|
|
|
{
|
|
|
|
|
m_statusLabel->setText(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlConsolePane::writeSettings() const
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::settings();
|
|
|
|
|
m_showDebugButtonAction->writeSettings(settings);
|
|
|
|
|
m_showWarningButtonAction->writeSettings(settings);
|
|
|
|
|
m_showErrorButtonAction->writeSettings(settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // QmlJSTools
|