From 9baa4f51a105ccdb13cb8f9e25e94b5eac79f89e Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Fri, 24 Jun 2011 18:19:08 +0200 Subject: [PATCH] QmlProfiler: Clear button in toolbar Change-Id: Id9739b7828b080b016aa41b13b4f5313a2319172 Reviewed-on: http://codereview.qt.nokia.com/750 Reviewed-by: Qt Sanity Bot Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/MainView.qml | 128 +++++++++++++----- src/plugins/qmlprofiler/qml/RangeMover.qml | 3 +- .../qmlprofiler/qml/clean_pane_small.png | Bin 0 -> 713 bytes src/plugins/qmlprofiler/qml/qml.qrc | 1 + .../qmlprofiler/qmlprofilercalleeview.h | 1 + .../qmlprofiler/qmlprofilercallerview.h | 1 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 7 + src/plugins/qmlprofiler/qmlprofilertool.h | 4 +- src/plugins/qmlprofiler/timelineview.cpp | 1 + src/plugins/qmlprofiler/tracewindow.cpp | 4 + src/plugins/qmlprofiler/tracewindow.h | 3 + 11 files changed, 113 insertions(+), 40 deletions(-) create mode 100644 src/plugins/qmlprofiler/qml/clean_pane_small.png diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index eee32f17450..608b4974104 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -52,19 +52,32 @@ Rectangle { root.updateCursorPosition(); } - function clearAll() { + function clearData() { Plotter.reset(); view.clearData(); rangeMover.x = 2 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++ Connections { target: connection onEvent: { if (Plotter.valuesdone) { - root.clearAll(); + root.clearData(); } if (!Plotter.valuesdone && event === 0) //### only handle paint event @@ -73,7 +86,7 @@ Rectangle { onRange: { if (Plotter.valuesdone) { - root.clearAll(); + root.clearData(); } // todo: consider nestingLevel @@ -95,11 +108,6 @@ Rectangle { onClear: { 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); } + function hideRangeDetails() { + rangeDetails.visible = false + rangeDetails.duration = "" + rangeDetails.label = "" + rangeDetails.type = "" + rangeDetails.file = "" + rangeDetails.line = -1 + } + //our main interaction view Flickable { id: flick @@ -155,12 +172,11 @@ Rectangle { height: flick.contentHeight x: flick.contentX onClicked: { - rangeDetails.visible = false - rangeDetails.duration = "" - rangeDetails.label = "" - rangeDetails.type = "" - rangeDetails.file = "" - rangeDetails.line = -1 + root.hideRangeDetails(); + } + hoverEnabled: true + onExited: { + root.hideRangeDetails(); } } @@ -207,36 +223,63 @@ Rectangle { GradientStop { position: 1.0; color: myColor } } 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 { id: mouseArea anchors.fill: parent hoverEnabled: true onEntered: { - 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, 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 + root.mouseTracking = true; + root.selectedEventIndex = index; + enableSelected(mouseX, y); + root.mouseTracking = false; } onExited: { - myColor = baseColor + disableSelected(); } + onClicked: root.gotoSourceLocation(rangeDetails.file, rangeDetails.line); } } @@ -246,6 +289,18 @@ Rectangle { //popup showing the details for the hovered range 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 { @@ -324,5 +379,4 @@ Rectangle { opacity: 0 anchors.top: canvas.top } - } diff --git a/src/plugins/qmlprofiler/qml/RangeMover.qml b/src/plugins/qmlprofiler/qml/RangeMover.qml index 8617b3399ee..68c528074c7 100644 --- a/src/plugins/qmlprofiler/qml/RangeMover.qml +++ b/src/plugins/qmlprofiler/qml/RangeMover.qml @@ -43,7 +43,8 @@ Item { property real possibleValue: (canvas.canvasWindow.x + x) * Plotter.xScale(canvas) onPossibleValueChanged: { prevXStep = canvas.canvasWindow.x; - value = possibleValue + if (value != possibleValue) + value = possibleValue; } property real value diff --git a/src/plugins/qmlprofiler/qml/clean_pane_small.png b/src/plugins/qmlprofiler/qml/clean_pane_small.png new file mode 100644 index 0000000000000000000000000000000000000000..341e23861a1a88d031112e94a2e257dd4cb9a6f6 GIT binary patch literal 713 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7SkfJR9T^y|-MHc(VZ^|| zAX(xXQ4*Y=R#Ki=l*-_klAn~S;F+74o*I;zm{M7IGS!BGfhpS4#WAGfR!?xOM{uG< z-M+^+XXb6*`Er&_>9QH(yE&IMZGGA5y@zmb^4~&DpcYx6hsX_Vw(QEq)uB?_1tK|JmmK=e_SMIhTqYwRw5? zNLZDF{nYP&FBB+SzCLCbE^^zqNA>rb$2a1GAJ0{`-ac1U=1+Oaf~L4tUoRV~+a~L4 z->}{F^-sQ&`l^-Od{r!LRUD}^xxdbT(XCgt?`n|3_dlKYw|P_*sMc+rch4$8qWQC&kITBN8+HU##W~IEW~x)}ng994{(9!iftigDO&Yt_ih&ssil z?}bG+JDaX%2;F=sv&!mp!g8)vDw4-%w26JtnSMMWta*!HyUg{z&T2Le zru~wU(?l)&`Th%ixS|;HQI*A}hT)+z$9B$x6>aU?EW3qub2pfG3#|4vc;Ri%x+Fwu z<(Xa0u6%3n%;sowZ}jXu{#sP(#OYJVCn{Dj`IiW+eVVahW}?w6bJjF*8R$@nU)q28pVROvwmwHU@)+= WJ&=E1){23Ffx*+&&t;ucLK6V-jy=o( literal 0 HcmV?d00001 diff --git a/src/plugins/qmlprofiler/qml/qml.qrc b/src/plugins/qmlprofiler/qml/qml.qrc index 0befcb5b062..a735d65b704 100644 --- a/src/plugins/qmlprofiler/qml/qml.qrc +++ b/src/plugins/qmlprofiler/qml/qml.qrc @@ -12,5 +12,6 @@ ToolButton.qml analyzer_category_small.png TimeDisplay.qml + clean_pane_small.png diff --git a/src/plugins/qmlprofiler/qmlprofilercalleeview.h b/src/plugins/qmlprofiler/qmlprofilercalleeview.h index 8d436dab2d6..715a006eddd 100644 --- a/src/plugins/qmlprofiler/qmlprofilercalleeview.h +++ b/src/plugins/qmlprofiler/qmlprofilercalleeview.h @@ -52,6 +52,7 @@ signals: public slots: void clean(); + void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line); void complete(); diff --git a/src/plugins/qmlprofiler/qmlprofilercallerview.h b/src/plugins/qmlprofiler/qmlprofilercallerview.h index 71ceb69b061..7f9416fea98 100644 --- a/src/plugins/qmlprofiler/qmlprofilercallerview.h +++ b/src/plugins/qmlprofiler/qmlprofilercallerview.h @@ -52,6 +52,7 @@ signals: public slots: void clean(); + void addRangedEvent(int type, int nestingLevel, int nestingInType, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line); void complete(); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 321a35de0b0..49de24df466 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -101,6 +101,7 @@ public: bool m_isAttached; QAction *m_attachAction; QToolButton *m_recordButton; + QToolButton *m_clearButton; bool m_recordingEnabled; enum ConnectMode { @@ -300,6 +301,11 @@ QWidget *QmlProfilerTool::createControlWidget() d->m_recordButton->setChecked(true); 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")); QPalette palette = timeLabel->palette(); palette.setColor(QPalette::WindowText, Qt::white); @@ -308,6 +314,7 @@ QWidget *QmlProfilerTool::createControlWidget() connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString))); layout->addWidget(timeLabel); + toolbarWidget->setLayout(layout); return toolbarWidget; diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index fd590c3e1a4..375b82a714b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -64,8 +64,6 @@ public: bool canRunRemotely() const; bool needsOutputPane() const { return false; } - void clearDisplay(); - public slots: void connectClient(); void disconnectClient(); @@ -77,6 +75,8 @@ public slots: void gotoSourceLocation(const QString &fileUrl, int lineNumber); void updateTimer(qreal elapsedSeconds); + void clearDisplay(); + signals: void setTimeLabel(const QString &); void fetchingData(bool); diff --git a/src/plugins/qmlprofiler/timelineview.cpp b/src/plugins/qmlprofiler/timelineview.cpp index 9583fcf167d..265fe9464a4 100644 --- a/src/plugins/qmlprofiler/timelineview.cpp +++ b/src/plugins/qmlprofiler/timelineview.cpp @@ -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("fileName", m_ranges.property(i).property("fileName").toString()); ctxt->setContextProperty("line", m_ranges.property(i).property("line").toNumber()); + ctxt->setContextProperty("index", i); QString label; QVariantList list = m_ranges.property(i).property("label").toVariant().value(); for (int i = 0; i < list.size(); ++i) { diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index 71f11dfa802..842c4537e9a 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -312,6 +312,8 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn) connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition())); connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer())); + + connect(this, SIGNAL(internalClearDisplay()), m_view->rootObject(), SLOT(clearAll())); } void TraceWindow::updateCursorPosition() @@ -329,6 +331,8 @@ void TraceWindow::clearDisplay() { if (m_plugin) m_plugin.data()->clearView(); + else + emit internalClearDisplay(); } void TraceWindow::setRecording(bool recording) diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index eae46f5be4d..f234d52bfc7 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -63,6 +63,7 @@ public: void setRecording(bool recording); bool isRecording() const; + public slots: void updateCursorPosition(); void updateTimer(); @@ -74,6 +75,8 @@ signals: 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 internalClearDisplay(); + private: QWeakPointer m_plugin; QSize m_sizeHint;