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();
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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
|
||||
|
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>analyzer_category_small.png</file>
|
||||
<file>TimeDisplay.qml</file>
|
||||
<file>clean_pane_small.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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<QVariantList>();
|
||||
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(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)
|
||||
|
@@ -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<TracePlugin> m_plugin;
|
||||
QSize m_sizeHint;
|
||||
|
Reference in New Issue
Block a user