forked from qt-creator/qt-creator
Analyzer: Rework the dock widget layout generation
Decouple layout generation from widget generation and separate analyzer action description from menu action creation. Tool specific layouts are named "Perspective" now. Change-Id: I774efe77a07640c4cc26e4e566662c8a673c8831 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -40,7 +40,10 @@ const char SETTINGS[] = "Analyzer.QmlProfiler.Settings";
|
||||
const char ANALYZER[] = "Analyzer";
|
||||
|
||||
const char TraceFileExtension[] = ".qtd";
|
||||
const char QmlProfilerToolId[] = "QmlProfiler";
|
||||
|
||||
const char QmlProfilerTimelineDock[] = "QmlProfilerTimelineDock";
|
||||
|
||||
const char QmlProfilerPerspective[] = "QmlProfilerPerspective";
|
||||
const char QmlProfilerLocalActionId[] = "QmlProfiler.Local";
|
||||
const char QmlProfilerRemoteActionId[] = "QmlProfiler.Remote";
|
||||
|
||||
|
||||
@@ -58,38 +58,35 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
|
||||
return tool->createRunControl(runConfiguration);
|
||||
};
|
||||
|
||||
AnalyzerAction *action = 0;
|
||||
|
||||
QString description = QmlProfilerTool::tr(
|
||||
"The QML Profiler can be used to find performance bottlenecks in "
|
||||
"applications using QML.");
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setActionId(Constants::QmlProfilerLocalActionId);
|
||||
action->setToolId(Constants::QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
action->setText(tr("QML Profiler"));
|
||||
action->setToolTip(description);
|
||||
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
||||
AnalyzerManager::addAction(action);
|
||||
ActionDescription desc;
|
||||
desc.setText(tr("QML Profiler"));
|
||||
desc.setToolTip(description);
|
||||
desc.setActionId(Constants::QmlProfilerLocalActionId);
|
||||
desc.setPerspectiveId(Constants::QmlProfilerPerspective);
|
||||
desc.setWidgetCreator(widgetCreator);
|
||||
desc.setRunControlCreator(runControlCreator);
|
||||
desc.setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
||||
AnalyzerManager::addAction(desc);
|
||||
|
||||
action = new AnalyzerAction(this);
|
||||
action->setActionId(Constants::QmlProfilerRemoteActionId);
|
||||
action->setToolId(Constants::QmlProfilerToolId);
|
||||
action->setWidgetCreator(widgetCreator);
|
||||
action->setRunControlCreator(runControlCreator);
|
||||
action->setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
|
||||
desc.setText(tr("QML Profiler (External)"));
|
||||
desc.setToolTip(description);
|
||||
desc.setActionId(Constants::QmlProfilerRemoteActionId);
|
||||
desc.setPerspectiveId(Constants::QmlProfilerPerspective);
|
||||
desc.setWidgetCreator(widgetCreator);
|
||||
desc.setRunControlCreator(runControlCreator);
|
||||
desc.setCustomToolStarter([tool](ProjectExplorer::RunConfiguration *rc) {
|
||||
tool->startRemoteTool(rc);
|
||||
});
|
||||
action->setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
action->setText(tr("QML Profiler (External)"));
|
||||
action->setToolTip(description);
|
||||
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
AnalyzerManager::addAction(action);
|
||||
desc.setToolPreparer([tool] { return tool->prepareTool(); });
|
||||
desc.setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||
AnalyzerManager::addAction(desc);
|
||||
|
||||
addAutoReleasedObject(new QmlProfilerRunControlFactory());
|
||||
addAutoReleasedObject(new Internal::QmlProfilerOptionsPage());
|
||||
|
||||
@@ -28,11 +28,9 @@
|
||||
#include "qmlprofilerruncontrol.h"
|
||||
#include "qmlprofilerrunconfigurationaspect.h"
|
||||
|
||||
#include <debugger/analyzer/ianalyzertool.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <debugger/analyzer/analyzerruncontrol.h>
|
||||
#include <debugger/analyzer/analyzerstartparameters.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
|
||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||
|
||||
#include <projectexplorer/environmentaspect.h>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "qmlprofilereventsview.h"
|
||||
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <debugger/analyzer/ianalyzertool.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <utils/itemviews.h>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
@@ -583,7 +583,7 @@ void QmlProfilerTool::showSaveDialog()
|
||||
if (!filename.endsWith(QLatin1String(TraceFileExtension)))
|
||||
filename += QLatin1String(TraceFileExtension);
|
||||
saveLastTraceFile(filename);
|
||||
AnalyzerManager::mainWindow()->setEnabled(false);
|
||||
AnalyzerManager::enableMainWindow(false);
|
||||
d->m_profilerModelManager->save(filename);
|
||||
}
|
||||
}
|
||||
@@ -605,7 +605,7 @@ void QmlProfilerTool::showLoadDialog()
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
saveLastTraceFile(filename);
|
||||
AnalyzerManager::mainWindow()->setEnabled(false);
|
||||
AnalyzerManager::enableMainWindow(false);
|
||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
|
||||
this, &QmlProfilerTool::setRecordedFeatures);
|
||||
d->m_profilerModelManager->load(filename);
|
||||
@@ -616,7 +616,7 @@ void QmlProfilerTool::onLoadSaveFinished()
|
||||
{
|
||||
disconnect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
|
||||
this, &QmlProfilerTool::setRecordedFeatures);
|
||||
AnalyzerManager::mainWindow()->setEnabled(true);
|
||||
AnalyzerManager::enableMainWindow(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmldebug/qmlprofilereventtypes.h"
|
||||
|
||||
#include <debugger/analyzer/ianalyzertool.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <debugger/analyzer/analyzerruncontrol.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
// Needed for the load&save actions in the context menu
|
||||
#include <debugger/analyzer/ianalyzertool.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
|
||||
@@ -81,9 +81,9 @@ void QmlProfilerViewManager::createViews()
|
||||
QTC_ASSERT(d->profilerModelManager, return);
|
||||
QTC_ASSERT(d->profilerState, return);
|
||||
|
||||
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
|
||||
//Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
|
||||
|
||||
d->traceView = new QmlProfilerTraceView(mw, this, d->profilerModelManager);
|
||||
d->traceView = new QmlProfilerTraceView(0, this, d->profilerModelManager);
|
||||
d->traceView->setWindowTitle(tr("Timeline"));
|
||||
connect(d->traceView, &QmlProfilerTraceView::gotoSourceLocation,
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
@@ -91,22 +91,23 @@ void QmlProfilerViewManager::createViews()
|
||||
this, &QmlProfilerViewManager::typeSelected);
|
||||
connect(this, &QmlProfilerViewManager::typeSelected,
|
||||
d->traceView, &QmlProfilerTraceView::selectByTypeId);
|
||||
d->timelineDock = AnalyzerManager::createDockWidget(Constants::QmlProfilerToolId, d->traceView);
|
||||
d->timelineDock->show();
|
||||
mw->splitDockWidget(mw->toolBarDockWidget(), d->timelineDock, Qt::Vertical);
|
||||
d->timelineDock = AnalyzerManager::createDockWidget(d->traceView, Constants::QmlProfilerTimelineDock);
|
||||
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
|
||||
|
||||
d->eventsViews << new QmlProfilerStatisticsView(mw, d->profilerModelManager);
|
||||
Perspective perspective(Constants::QmlProfilerPerspective);
|
||||
perspective.addDock(Constants::QmlProfilerTimelineDock, Core::Id(), Perspective::SplitVertical);
|
||||
|
||||
d->eventsViews << new QmlProfilerStatisticsView(0, d->profilerModelManager);
|
||||
if (d->eventsViewFactory)
|
||||
d->eventsViews.append(d->eventsViewFactory->create(mw, d->profilerModelManager));
|
||||
d->eventsViews.append(d->eventsViewFactory->create(0, d->profilerModelManager));
|
||||
|
||||
// Clear settings if the new views aren't there yet. Otherwise we get glitches
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") +
|
||||
QLatin1String(QmlProfiler::Constants::QmlProfilerToolId));
|
||||
QLatin1String(QmlProfiler::Constants::QmlProfilerPerspective));
|
||||
|
||||
foreach (QmlProfilerEventsView *view, d->eventsViews) {
|
||||
view->setParent(mw);
|
||||
connect(view, &QmlProfilerEventsView::typeSelected,
|
||||
this, &QmlProfilerViewManager::typeSelected);
|
||||
connect(this, &QmlProfilerViewManager::typeSelected,
|
||||
@@ -117,15 +118,15 @@ void QmlProfilerViewManager::createViews()
|
||||
this, &QmlProfilerViewManager::gotoSourceLocation);
|
||||
connect(view, &QmlProfilerEventsView::showFullRange,
|
||||
this, [this](){restrictEventsToRange(-1, -1);});
|
||||
QDockWidget *eventsDock = AnalyzerManager::createDockWidget(Constants::QmlProfilerToolId,
|
||||
view);
|
||||
eventsDock->show();
|
||||
mw->tabifyDockWidget(d->timelineDock, eventsDock);
|
||||
Core::Id dockId = Core::Id::fromString(view->objectName());
|
||||
QDockWidget *eventsDock = AnalyzerManager::createDockWidget(view, dockId);
|
||||
perspective.addDock(dockId, Constants::QmlProfilerTimelineDock, Perspective::AddToTab);
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, view);
|
||||
|
||||
if (!settings->contains(eventsDock->objectName()))
|
||||
settings->remove(QString());
|
||||
}
|
||||
AnalyzerManager::addPerspective(perspective);
|
||||
|
||||
settings->endGroup();
|
||||
d->timelineDock->raise();
|
||||
|
||||
Reference in New Issue
Block a user