forked from qt-creator/qt-creator
QmlProfiler: use QQuickWidget instead of window container
Using QQuickWidget removes the need for some work-arounds. Task-number: QTCREATORBUG-11822 Change-Id: I1e344f0a9c11b4aa8601e8e1056602d855fb3f4d Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
DEFINES += QMLPROFILER_LIBRARY
|
||||
|
||||
QT += network qml quick
|
||||
QT += network qml quick quickwidgets
|
||||
|
||||
include(../../qtcreatorplugin.pri)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import qbs 1.0
|
||||
QtcPlugin {
|
||||
name: "QmlProfiler"
|
||||
|
||||
Depends { name: "Qt"; submodules: ["widgets", "network", "quick"] }
|
||||
Depends { name: "Qt"; submodules: ["widgets", "network", "quick", "quickwidgets"] }
|
||||
Depends { name: "Aggregation" }
|
||||
Depends { name: "QmlJS" }
|
||||
Depends { name: "QmlDebug" }
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include <QSlider>
|
||||
#include <QMenu>
|
||||
#include <QQuickItem>
|
||||
#include <QQuickWidget>
|
||||
#include <QApplication>
|
||||
|
||||
#include <math.h>
|
||||
@@ -81,7 +82,7 @@ public:
|
||||
|
||||
QSize m_sizeHint;
|
||||
|
||||
QQuickView *m_mainView;
|
||||
QQuickWidget *m_mainView;
|
||||
QmlProfilerModelManager *m_modelManager;
|
||||
Timeline::TimelineModelAggregator *m_modelProxy;
|
||||
|
||||
@@ -109,12 +110,11 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
|
||||
qmlRegisterType<Timeline::TimelineModel>();
|
||||
qmlRegisterType<Timeline::TimelineNotesModel>();
|
||||
|
||||
d->m_mainView = new QmlProfilerQuickView(this);
|
||||
d->m_mainView->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView);
|
||||
mainViewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
d->m_mainView = new QQuickWidget(this);
|
||||
d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
d->m_mainView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
groupLayout->addWidget(mainViewContainer);
|
||||
groupLayout->addWidget(d->m_mainView);
|
||||
setLayout(groupLayout);
|
||||
|
||||
d->m_profilerTool = profilerTool;
|
||||
@@ -311,42 +311,5 @@ void QmlProfilerTraceView::profilerDataModelStateChanged()
|
||||
}
|
||||
}
|
||||
|
||||
bool QmlProfilerQuickView::event(QEvent *ev)
|
||||
{
|
||||
// We assume context menus can only be triggered by mouse press, mouse release, or
|
||||
// pre-synthesized events from the window system.
|
||||
|
||||
bool relayed = false;
|
||||
switch (ev->type()) {
|
||||
case QEvent::ContextMenu:
|
||||
// In the case of mouse clicks the active popup gets automatically closed before they show
|
||||
// up here. That's not necessarily the case with keyboard triggered context menu events, so
|
||||
// we just ignore them if there is a popup already. Also, the event's pos() and globalPos()
|
||||
// don't make much sense in this case, so we just put the menu in the upper left corner.
|
||||
if (QApplication::activePopupWidget() == 0) {
|
||||
ev->accept();
|
||||
parent->showContextMenu(parent->mapToGlobal(QPoint(0,0)));
|
||||
relayed = true;
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease: {
|
||||
QMouseEvent *orig = static_cast<QMouseEvent *>(ev);
|
||||
QCoreApplication::instance()->postEvent(parent->window()->windowHandle(),
|
||||
new QMouseEvent(orig->type(), parent->window()->mapFromGlobal(orig->globalPos()),
|
||||
orig->button(), orig->buttons(), orig->modifiers()));
|
||||
relayed = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// QQuickView will eat mouse events even if they're not accepted by any QML construct. So we
|
||||
// ignore the return value of event() above.
|
||||
return QQuickView::event(ev) || relayed;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#define QMLPROFILERTRACEVIEW_H
|
||||
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include <QQuickView>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
@@ -85,14 +84,6 @@ private:
|
||||
QmlProfilerTraceViewPrivate *d;
|
||||
};
|
||||
|
||||
class QmlProfilerQuickView : public QQuickView {
|
||||
public:
|
||||
QmlProfilerQuickView(QmlProfilerTraceView *parent) : parent(parent) {}
|
||||
protected:
|
||||
QmlProfilerTraceView *parent;
|
||||
bool event(QEvent *ev);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user