Commit cf5bd6de authored by Lasse Holmstedt's avatar Lasse Holmstedt
Browse files

Made qml inspector look nicer and clear its contents upon close

parent c7049d80
......@@ -29,12 +29,14 @@
#include "expressionquerywidget.h"
#include "qmlinspectorconstants.h"
#include <utils/fancylineedit.h>
#include <utils/styledbar.h>
#include <utils/filterlineedit.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
#include <qmljseditor/qmljshighlighter.h>
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
......@@ -44,7 +46,7 @@
#include <QtGui/QLabel>
#include <QtGui/QTextEdit>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QGroupBox>
#include <QtGui/QTextObject>
#include <QtGui/QLayout>
......@@ -74,16 +76,25 @@ ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QDeclarativeEngineDebug
m_highlighter->setParent(m_textEdit->document());
if (m_mode == SeparateEntryMode) {
m_lineEdit = new QLineEdit;
Utils::StyledBar *bar = new Utils::StyledBar;
m_lineEdit = new Utils::FilterLineEdit;
m_lineEdit->setPlaceholderText(tr("<Expression>"));
m_lineEdit->setToolTip(tr("Write and evaluate QtScript expressions."));
m_clearButton = new QToolButton();
m_clearButton->setIcon(QIcon(QLatin1String(":/utils/images/reset.png")));
m_clearButton->setToolTip(tr("Clear Output"));
m_clearButton->setIcon(QIcon(Core::Constants::ICON_CLEAN_PANE));
connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearTextEditor()));
connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression()));
QHBoxLayout *hbox = new QHBoxLayout;
QHBoxLayout *hbox = new QHBoxLayout(bar);
hbox->setMargin(1);
hbox->setSpacing(1);
//hbox->addWidget(new QLabel(tr("Expression:")));
hbox->addWidget(m_lineEdit);
layout->addLayout(hbox);
hbox->addWidget(m_clearButton);
layout->addWidget(bar);
m_textEdit->setReadOnly(true);
m_lineEdit->installEventFilter(this);
......@@ -92,6 +103,13 @@ ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QDeclarativeEngineDebug
appendPrompt();
}
setFontSettings();
clear();
}
void ExpressionQueryWidget::clearTextEditor()
{
m_textEdit->clear();
m_textEdit->appendPlainText(tr("Debug Console\n"));
}
void ExpressionQueryWidget::setFontSettings()
......@@ -147,7 +165,8 @@ void ExpressionQueryWidget::setEngineDebug(QDeclarativeEngineDebug *client)
void ExpressionQueryWidget::clear()
{
m_textEdit->clear();
clearTextEditor();
if (m_lineEdit)
m_lineEdit->clear();
if (m_mode == ShellMode)
......
......@@ -39,10 +39,14 @@ QT_BEGIN_NAMESPACE
class QGroupBox;
class QPlainTextEdit;
class QLineEdit;
class QPushButton;
class QToolButton;
QT_END_NAMESPACE
namespace Utils {
class FancyLineEdit;
}
namespace Core {
class IContext;
}
......@@ -73,6 +77,7 @@ public slots:
void setCurrentObject(const QDeclarativeDebugObjectReference &obj);
private slots:
void clearTextEditor();
void executeExpression();
void showResult();
void invokeCompletion();
......@@ -89,8 +94,9 @@ private:
QDeclarativeEngineDebug *m_client;
QDeclarativeDebugExpressionQuery *m_query;
QPlainTextEdit *m_textEdit;
QLineEdit *m_lineEdit;
QPushButton *m_button;
Utils::FancyLineEdit *m_lineEdit;
QToolButton *m_clearButton;
QString m_prompt;
QString m_expr;
QString m_lastExpr;
......
......@@ -234,6 +234,9 @@ void QmlInspector::connectionStateChanged()
m_engineQuery = 0;
delete m_contextQuery;
m_contextQuery = 0;
resetViews();
break;
}
case QAbstractSocket::HostLookupState:
......@@ -254,10 +257,7 @@ void QmlInspector::connectionStateChanged()
m_expressionWidget->setEngineDebug(m_client);
}
m_objectTreeWidget->clear();
m_propertiesWidget->clear();
m_expressionWidget->clear();
m_watchTableModel->removeAllWatches();
resetViews();
m_frameRateWidget->reset(m_conn);
reloadEngines();
......@@ -272,6 +272,14 @@ void QmlInspector::connectionStateChanged()
}
}
void QmlInspector::resetViews()
{
m_objectTreeWidget->clear();
m_propertiesWidget->clear();
m_expressionWidget->clear();
m_watchTableModel->removeAllWatches();
}
Core::IContext *QmlInspector::context() const
{
return m_context;
......
......@@ -95,7 +95,7 @@ private slots:
void treeObjectActivated(const QDeclarativeDebugObjectReference &obj);
private:
void resetViews();
void initWidgets();
QDeclarativeDebugConnection *m_conn;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment