forked from qt-creator/qt-creator
QmlProfiler: Clear button in toolbar
Change-Id: Id9739b7828b080b016aa41b13b4f5313a2319172 Reviewed-on: http://codereview.qt.nokia.com/750 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -52,19 +52,32 @@ Rectangle {
|
|||||||
root.updateCursorPosition();
|
root.updateCursorPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAll() {
|
function clearData() {
|
||||||
Plotter.reset();
|
Plotter.reset();
|
||||||
view.clearData();
|
view.clearData();
|
||||||
rangeMover.x = 2
|
rangeMover.x = 2
|
||||||
rangeMover.opacity = 0
|
rangeMover.opacity = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearAll() {
|
||||||
|
clearData();
|
||||||
|
selectedEventIndex = -1;
|
||||||
|
Plotter.valuesdone = false;
|
||||||
|
canvas.requestPaint();
|
||||||
|
view.visible = false;
|
||||||
|
root.elapsedTime = 0;
|
||||||
|
root.updateTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
property int selectedEventIndex : -1;
|
||||||
|
property bool mouseTracking: false;
|
||||||
|
|
||||||
//handle debug data coming from C++
|
//handle debug data coming from C++
|
||||||
Connections {
|
Connections {
|
||||||
target: connection
|
target: connection
|
||||||
onEvent: {
|
onEvent: {
|
||||||
if (Plotter.valuesdone) {
|
if (Plotter.valuesdone) {
|
||||||
root.clearAll();
|
root.clearData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Plotter.valuesdone && event === 0) //### only handle paint event
|
if (!Plotter.valuesdone && event === 0) //### only handle paint event
|
||||||
@@ -73,7 +86,7 @@ Rectangle {
|
|||||||
|
|
||||||
onRange: {
|
onRange: {
|
||||||
if (Plotter.valuesdone) {
|
if (Plotter.valuesdone) {
|
||||||
root.clearAll();
|
root.clearData();
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: consider nestingLevel
|
// todo: consider nestingLevel
|
||||||
@@ -95,11 +108,6 @@ Rectangle {
|
|||||||
|
|
||||||
onClear: {
|
onClear: {
|
||||||
root.clearAll();
|
root.clearAll();
|
||||||
Plotter.valuesdone = false;
|
|
||||||
canvas.requestPaint();
|
|
||||||
view.visible = false;
|
|
||||||
root.elapsedTime = 0;
|
|
||||||
root.updateTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -136,6 +144,15 @@ Rectangle {
|
|||||||
endTime: (rangeMover.x + rangeMover.width) * Plotter.xScale(canvas);
|
endTime: (rangeMover.x + rangeMover.width) * Plotter.xScale(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideRangeDetails() {
|
||||||
|
rangeDetails.visible = false
|
||||||
|
rangeDetails.duration = ""
|
||||||
|
rangeDetails.label = ""
|
||||||
|
rangeDetails.type = ""
|
||||||
|
rangeDetails.file = ""
|
||||||
|
rangeDetails.line = -1
|
||||||
|
}
|
||||||
|
|
||||||
//our main interaction view
|
//our main interaction view
|
||||||
Flickable {
|
Flickable {
|
||||||
id: flick
|
id: flick
|
||||||
@@ -155,12 +172,11 @@ Rectangle {
|
|||||||
height: flick.contentHeight
|
height: flick.contentHeight
|
||||||
x: flick.contentX
|
x: flick.contentX
|
||||||
onClicked: {
|
onClicked: {
|
||||||
rangeDetails.visible = false
|
root.hideRangeDetails();
|
||||||
rangeDetails.duration = ""
|
}
|
||||||
rangeDetails.label = ""
|
hoverEnabled: true
|
||||||
rangeDetails.type = ""
|
onExited: {
|
||||||
rangeDetails.file = ""
|
root.hideRangeDetails();
|
||||||
rangeDetails.line = -1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,36 +223,63 @@ Rectangle {
|
|||||||
GradientStop { position: 1.0; color: myColor }
|
GradientStop { position: 1.0; color: myColor }
|
||||||
}
|
}
|
||||||
smooth: true
|
smooth: true
|
||||||
|
|
||||||
|
property bool componentIsCompleted: false
|
||||||
|
Component.onCompleted: componentIsCompleted = true;
|
||||||
|
|
||||||
|
property bool isSelected: root.selectedEventIndex == index;
|
||||||
|
onIsSelectedChanged: {
|
||||||
|
if (!root.mouseTracking && componentIsCompleted) {
|
||||||
|
if (isSelected) {
|
||||||
|
enableSelected(0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
disableSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableSelected(x,y) {
|
||||||
|
currentItem = obj
|
||||||
|
myColor = Qt.darker(baseColor, 1.2)
|
||||||
|
rangeDetails.duration = duration
|
||||||
|
rangeDetails.label = label
|
||||||
|
rangeDetails.file = fileName
|
||||||
|
rangeDetails.line = line
|
||||||
|
rangeDetails.type = Plotter.names[type]
|
||||||
|
|
||||||
|
var pos = mapToItem(rangeDetails.parent, x, y+height)
|
||||||
|
var preferredX = Math.max(10, pos.x - rangeDetails.width/2)
|
||||||
|
if (preferredX + rangeDetails.width > rangeDetails.parent.width)
|
||||||
|
preferredX = rangeDetails.parent.width - rangeDetails.width
|
||||||
|
rangeDetails.x = preferredX
|
||||||
|
|
||||||
|
var preferredY = pos.y - rangeDetails.height/2;
|
||||||
|
if (preferredY + rangeDetails.height > root.height - 10)
|
||||||
|
preferredY = root.height - 10 - rangeDetails.height;
|
||||||
|
if (preferredY < 10)
|
||||||
|
preferredY=10;
|
||||||
|
rangeDetails.y = preferredY;
|
||||||
|
rangeDetails.visible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableSelected() {
|
||||||
|
myColor = baseColor
|
||||||
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: {
|
onEntered: {
|
||||||
currentItem = obj
|
root.mouseTracking = true;
|
||||||
myColor = Qt.darker(baseColor, 1.2)
|
root.selectedEventIndex = index;
|
||||||
rangeDetails.duration = duration
|
enableSelected(mouseX, y);
|
||||||
rangeDetails.label = label
|
root.mouseTracking = false;
|
||||||
rangeDetails.file = fileName
|
|
||||||
rangeDetails.line = line
|
|
||||||
rangeDetails.type = Plotter.names[type]
|
|
||||||
|
|
||||||
var pos = mapToItem(rangeDetails.parent, mouseX, y+height)
|
|
||||||
var preferredX = Math.max(10, pos.x - rangeDetails.width/2)
|
|
||||||
if (preferredX + rangeDetails.width > rangeDetails.parent.width)
|
|
||||||
preferredX = rangeDetails.parent.width - rangeDetails.width
|
|
||||||
rangeDetails.x = preferredX
|
|
||||||
|
|
||||||
var preferredY = pos.y - rangeDetails.height/2;
|
|
||||||
if (preferredY + rangeDetails.height > root.height - 10)
|
|
||||||
preferredY = root.height - 10 - rangeDetails.height;
|
|
||||||
if (preferredY < 10)
|
|
||||||
preferredY=10;
|
|
||||||
rangeDetails.y = preferredY;
|
|
||||||
rangeDetails.visible = true
|
|
||||||
}
|
}
|
||||||
onExited: {
|
onExited: {
|
||||||
myColor = baseColor
|
disableSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: root.gotoSourceLocation(rangeDetails.file, rangeDetails.line);
|
onClicked: root.gotoSourceLocation(rangeDetails.file, rangeDetails.line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,6 +289,18 @@ Rectangle {
|
|||||||
//popup showing the details for the hovered range
|
//popup showing the details for the hovered range
|
||||||
RangeDetails {
|
RangeDetails {
|
||||||
id: rangeDetails
|
id: rangeDetails
|
||||||
|
|
||||||
|
// follow the flickable
|
||||||
|
property int flickableX: flick.contentX;
|
||||||
|
property int lastFlickableX;
|
||||||
|
onXChanged: lastFlickableX = flickableX;
|
||||||
|
onFlickableXChanged: {
|
||||||
|
x = x - flickableX + lastFlickableX;
|
||||||
|
if (visible && (x + width <= 0 || x > root.width)) {
|
||||||
|
root.hideRangeDetails();
|
||||||
|
visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -324,5 +379,4 @@ Rectangle {
|
|||||||
opacity: 0
|
opacity: 0
|
||||||
anchors.top: canvas.top
|
anchors.top: canvas.top
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,8 @@ Item {
|
|||||||
property real possibleValue: (canvas.canvasWindow.x + x) * Plotter.xScale(canvas)
|
property real possibleValue: (canvas.canvasWindow.x + x) * Plotter.xScale(canvas)
|
||||||
onPossibleValueChanged: {
|
onPossibleValueChanged: {
|
||||||
prevXStep = canvas.canvasWindow.x;
|
prevXStep = canvas.canvasWindow.x;
|
||||||
value = possibleValue
|
if (value != possibleValue)
|
||||||
|
value = possibleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
property real value
|
property real value
|
||||||
|
BIN
src/plugins/qmlprofiler/qml/clean_pane_small.png
Normal file
BIN
src/plugins/qmlprofiler/qml/clean_pane_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 713 B |
@@ -12,5 +12,6 @@
|
|||||||
<file>ToolButton.qml</file>
|
<file>ToolButton.qml</file>
|
||||||
<file>analyzer_category_small.png</file>
|
<file>analyzer_category_small.png</file>
|
||||||
<file>TimeDisplay.qml</file>
|
<file>TimeDisplay.qml</file>
|
||||||
|
<file>clean_pane_small.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@@ -52,6 +52,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clean();
|
void clean();
|
||||||
|
|
||||||
void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
|
void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
|
||||||
const QStringList &data, const QString &fileName, int line);
|
const QStringList &data, const QString &fileName, int line);
|
||||||
void complete();
|
void complete();
|
||||||
|
@@ -52,6 +52,7 @@ signals:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clean();
|
void clean();
|
||||||
|
|
||||||
void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
|
void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length,
|
||||||
const QStringList &data, const QString &fileName, int line);
|
const QStringList &data, const QString &fileName, int line);
|
||||||
void complete();
|
void complete();
|
||||||
|
@@ -101,6 +101,7 @@ public:
|
|||||||
bool m_isAttached;
|
bool m_isAttached;
|
||||||
QAction *m_attachAction;
|
QAction *m_attachAction;
|
||||||
QToolButton *m_recordButton;
|
QToolButton *m_recordButton;
|
||||||
|
QToolButton *m_clearButton;
|
||||||
bool m_recordingEnabled;
|
bool m_recordingEnabled;
|
||||||
|
|
||||||
enum ConnectMode {
|
enum ConnectMode {
|
||||||
@@ -300,6 +301,11 @@ QWidget *QmlProfilerTool::createControlWidget()
|
|||||||
d->m_recordButton->setChecked(true);
|
d->m_recordButton->setChecked(true);
|
||||||
layout->addWidget(d->m_recordButton);
|
layout->addWidget(d->m_recordButton);
|
||||||
|
|
||||||
|
d->m_clearButton = new QToolButton(toolbarWidget);
|
||||||
|
d->m_clearButton->setIcon(QIcon(QLatin1String(":/qmlprofiler/clean_pane_small.png")));
|
||||||
|
connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay()));
|
||||||
|
layout->addWidget(d->m_clearButton);
|
||||||
|
|
||||||
QLabel *timeLabel = new QLabel(tr("Elapsed: 0 s"));
|
QLabel *timeLabel = new QLabel(tr("Elapsed: 0 s"));
|
||||||
QPalette palette = timeLabel->palette();
|
QPalette palette = timeLabel->palette();
|
||||||
palette.setColor(QPalette::WindowText, Qt::white);
|
palette.setColor(QPalette::WindowText, Qt::white);
|
||||||
@@ -308,6 +314,7 @@ QWidget *QmlProfilerTool::createControlWidget()
|
|||||||
|
|
||||||
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
||||||
layout->addWidget(timeLabel);
|
layout->addWidget(timeLabel);
|
||||||
|
|
||||||
toolbarWidget->setLayout(layout);
|
toolbarWidget->setLayout(layout);
|
||||||
|
|
||||||
return toolbarWidget;
|
return toolbarWidget;
|
||||||
|
@@ -64,8 +64,6 @@ public:
|
|||||||
bool canRunRemotely() const;
|
bool canRunRemotely() const;
|
||||||
bool needsOutputPane() const { return false; }
|
bool needsOutputPane() const { return false; }
|
||||||
|
|
||||||
void clearDisplay();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void connectClient();
|
void connectClient();
|
||||||
void disconnectClient();
|
void disconnectClient();
|
||||||
@@ -77,6 +75,8 @@ public slots:
|
|||||||
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
||||||
void updateTimer(qreal elapsedSeconds);
|
void updateTimer(qreal elapsedSeconds);
|
||||||
|
|
||||||
|
void clearDisplay();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setTimeLabel(const QString &);
|
void setTimeLabel(const QString &);
|
||||||
void fetchingData(bool);
|
void fetchingData(bool);
|
||||||
|
@@ -201,6 +201,7 @@ void TimelineView::updateTimeline(bool updateStartX)
|
|||||||
ctxt->setContextProperty("duration", qMax(qRound(m_ranges.property(i).property("duration").toNumber()/qreal(1000)),1));
|
ctxt->setContextProperty("duration", qMax(qRound(m_ranges.property(i).property("duration").toNumber()/qreal(1000)),1));
|
||||||
ctxt->setContextProperty("fileName", m_ranges.property(i).property("fileName").toString());
|
ctxt->setContextProperty("fileName", m_ranges.property(i).property("fileName").toString());
|
||||||
ctxt->setContextProperty("line", m_ranges.property(i).property("line").toNumber());
|
ctxt->setContextProperty("line", m_ranges.property(i).property("line").toNumber());
|
||||||
|
ctxt->setContextProperty("index", i);
|
||||||
QString label;
|
QString label;
|
||||||
QVariantList list = m_ranges.property(i).property("label").toVariant().value<QVariantList>();
|
QVariantList list = m_ranges.property(i).property("label").toVariant().value<QVariantList>();
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
@@ -312,6 +312,8 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
|||||||
|
|
||||||
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
||||||
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
|
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
|
||||||
|
|
||||||
|
connect(this, SIGNAL(internalClearDisplay()), m_view->rootObject(), SLOT(clearAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWindow::updateCursorPosition()
|
void TraceWindow::updateCursorPosition()
|
||||||
@@ -329,6 +331,8 @@ void TraceWindow::clearDisplay()
|
|||||||
{
|
{
|
||||||
if (m_plugin)
|
if (m_plugin)
|
||||||
m_plugin.data()->clearView();
|
m_plugin.data()->clearView();
|
||||||
|
else
|
||||||
|
emit internalClearDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWindow::setRecording(bool recording)
|
void TraceWindow::setRecording(bool recording)
|
||||||
|
@@ -63,6 +63,7 @@ public:
|
|||||||
void setRecording(bool recording);
|
void setRecording(bool recording);
|
||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCursorPosition();
|
void updateCursorPosition();
|
||||||
void updateTimer();
|
void updateTimer();
|
||||||
@@ -74,6 +75,8 @@ signals:
|
|||||||
void timeChanged(qreal newTime);
|
void timeChanged(qreal newTime);
|
||||||
void range(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
|
void range(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
|
||||||
|
|
||||||
|
void internalClearDisplay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWeakPointer<TracePlugin> m_plugin;
|
QWeakPointer<TracePlugin> m_plugin;
|
||||||
QSize m_sizeHint;
|
QSize m_sizeHint;
|
||||||
|
Reference in New Issue
Block a user