| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** Copyright (C) 2016 The Qt Company Ltd. | 
					
						
							|  |  |  | ** Contact: https://www.qt.io/licensing/
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Commercial License Usage | 
					
						
							|  |  |  | ** Licensees holding valid commercial Qt licenses may use this file in | 
					
						
							|  |  |  | ** accordance with the commercial license agreement provided with the | 
					
						
							|  |  |  | ** Software or, alternatively, in accordance with the terms contained in | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** a written agreement between you and The Qt Company. For licensing terms | 
					
						
							|  |  |  | ** and conditions see https://www.qt.io/terms-conditions. For further
 | 
					
						
							|  |  |  | ** information use the contact form at https://www.qt.io/contact-us.
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2016-01-15 14:57:40 +01:00
										 |  |  | ** GNU General Public License Usage | 
					
						
							|  |  |  | ** Alternatively, this file may be used under the terms of the GNU | 
					
						
							|  |  |  | ** General Public License version 3 as published by the Free Software | 
					
						
							|  |  |  | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT | 
					
						
							|  |  |  | ** included in the packaging of this file. Please review the following | 
					
						
							|  |  |  | ** information to ensure the GNU General Public License requirements will | 
					
						
							|  |  |  | ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-03-25 09:25:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include "qmlprofilertool.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerstatemanager.h"
 | 
					
						
							| 
									
										
										
										
											2015-07-01 18:11:54 +02:00
										 |  |  | #include "qmlprofilerruncontrol.h"
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include "qmlprofilerconstants.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerattachdialog.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerviewmanager.h"
 | 
					
						
							|  |  |  | #include "qmlprofilerclientmanager.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  | #include "qmlprofilermodelmanager.h"
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | #include "qmlprofilerdetailsrewriter.h"
 | 
					
						
							| 
									
										
										
										
											2014-10-27 17:41:22 +01:00
										 |  |  | #include "qmlprofilernotesmodel.h"
 | 
					
						
							| 
									
										
										
										
											2015-08-28 12:50:46 +02:00
										 |  |  | #include "qmlprofilerrunconfigurationaspect.h"
 | 
					
						
							|  |  |  | #include "qmlprofilersettings.h"
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  | #include "qmlprofilerplugin.h"
 | 
					
						
							| 
									
										
										
										
											2016-12-19 18:47:06 +01:00
										 |  |  | #include "qmlprofilertextmark.h"
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  | #include <app/app_version.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-08 18:19:25 +02:00
										 |  |  | #include <debugger/debuggericons.h>
 | 
					
						
							| 
									
										
										
										
											2018-08-01 17:33:41 +02:00
										 |  |  | #include <debugger/debuggermainwindow.h>
 | 
					
						
							| 
									
										
										
										
											2016-02-24 14:42:52 +01:00
										 |  |  | #include <debugger/analyzer/analyzermanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-20 12:43:29 +02:00
										 |  |  | #include <utils/fancymainwindow.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <utils/fileinprojectfinder.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-14 17:19:28 +02:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-09 13:07:57 +01:00
										 |  |  | #include <utils/url.h>
 | 
					
						
							| 
									
										
										
										
											2016-05-23 14:15:06 +02:00
										 |  |  | #include <utils/utilsicons.h>
 | 
					
						
							| 
									
										
										
										
											2013-01-29 18:00:30 +01:00
										 |  |  | #include <projectexplorer/environmentaspect.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <projectexplorer/projectexplorer.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/project.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-01 13:48:10 +02:00
										 |  |  | #include <projectexplorer/target.h>
 | 
					
						
							| 
									
										
										
										
											2011-10-28 16:32:34 +02:00
										 |  |  | #include <projectexplorer/session.h>
 | 
					
						
							| 
									
										
										
										
											2013-04-17 11:10:45 +02:00
										 |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2017-04-12 10:06:41 +02:00
										 |  |  | #include <projectexplorer/taskhub.h>
 | 
					
						
							| 
									
										
										
										
											2014-09-26 09:14:03 +02:00
										 |  |  | #include <texteditor/texteditor.h>
 | 
					
						
							| 
									
										
										
										
											2011-12-27 22:41:31 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-28 16:21:03 +02:00
										 |  |  | #include <coreplugin/actionmanager/command.h>
 | 
					
						
							|  |  |  | #include <coreplugin/actionmanager/actionmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include <coreplugin/coreconstants.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | #include <coreplugin/editormanager/editormanager.h>
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  | #include <coreplugin/find/findplugin.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | #include <coreplugin/messagemanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | #include <coreplugin/helpmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | #include <coreplugin/modemanager.h>
 | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  | #include <coreplugin/progressmanager/progressmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | #include <coreplugin/imode.h>
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | #include <qtsupport/qtkitinformation.h>
 | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QApplication>
 | 
					
						
							| 
									
										
										
										
											2016-12-20 13:00:18 +01:00
										 |  |  | #include <QDockWidget>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QFileDialog>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QHBoxLayout>
 | 
					
						
							|  |  |  | #include <QLabel>
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | #include <QLineEdit>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QMenu>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QMessageBox>
 | 
					
						
							| 
									
										
										
										
											2013-04-17 17:58:27 +02:00
										 |  |  | #include <QTcpServer>
 | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  | #include <QTime>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QToolButton>
 | 
					
						
							| 
									
										
										
										
											2011-04-08 13:05:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | using namespace Core; | 
					
						
							|  |  |  | using namespace Core::Constants; | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  | using namespace Debugger; | 
					
						
							|  |  |  | using namespace Debugger::Constants; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | using namespace QmlProfiler::Constants; | 
					
						
							| 
									
										
										
										
											2011-09-14 13:12:25 +02:00
										 |  |  | using namespace ProjectExplorer; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | namespace QmlProfiler { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | class QmlProfilerTool::QmlProfilerToolPrivate | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QmlProfilerStateManager *m_profilerState = nullptr; | 
					
						
							|  |  |  |     QmlProfilerClientManager *m_profilerConnections = nullptr; | 
					
						
							|  |  |  |     QmlProfilerModelManager *m_profilerModelManager = nullptr; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QmlProfilerViewManager *m_viewContainer = nullptr; | 
					
						
							|  |  |  |     QToolButton *m_recordButton = nullptr; | 
					
						
							|  |  |  |     QMenu *m_recordFeaturesMenu = nullptr; | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QAction *m_startAction = nullptr; | 
					
						
							|  |  |  |     QAction *m_stopAction = nullptr; | 
					
						
							|  |  |  |     QToolButton *m_clearButton = nullptr; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     // open search
 | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QToolButton *m_searchButton = nullptr; | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     // hide and show categories
 | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QToolButton *m_displayFeaturesButton = nullptr; | 
					
						
							|  |  |  |     QMenu *m_displayFeaturesMenu = nullptr; | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-21 13:23:26 +01:00
										 |  |  |     // elapsed time display
 | 
					
						
							| 
									
										
										
										
											2018-04-12 10:04:55 +02:00
										 |  |  |     QLabel *m_timeLabel = nullptr; | 
					
						
							| 
									
										
										
										
											2017-11-21 13:23:26 +01:00
										 |  |  |     QTimer m_recordingTimer; | 
					
						
							|  |  |  |     QTime m_recordingElapsedTime; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     bool m_toolBusy = false; | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-15 14:40:18 +01:00
										 |  |  | QmlProfilerTool::QmlProfilerTool() | 
					
						
							|  |  |  |     : d(new QmlProfilerToolPrivate) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-26 21:18:13 +02:00
										 |  |  |     setObjectName(QLatin1String("QmlProfilerTool")); | 
					
						
							| 
									
										
										
										
											2011-05-20 13:36:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_profilerState = new QmlProfilerStateManager(this); | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::profilerStateChanged); | 
					
						
							|  |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::serverRecordingChanged); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     d->m_profilerConnections = new QmlProfilerClientManager(this); | 
					
						
							| 
									
										
										
										
											2016-06-10 11:15:53 +02:00
										 |  |  |     d->m_profilerConnections->setProfilerStateManager(d->m_profilerState); | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_profilerConnections, &QmlProfilerClientManager::connectionClosed, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::clientsDisconnected); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-28 16:45:43 +01:00
										 |  |  |     d->m_profilerModelManager = new QmlProfilerModelManager(this); | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |     d->m_profilerModelManager->registerFeatures(0, QmlProfilerModelManager::QmlEventLoader(), | 
					
						
							|  |  |  |                                                 std::bind(&QmlProfilerTool::initialize, this), | 
					
						
							|  |  |  |                                                 std::bind(&QmlProfilerTool::finalize, this), | 
					
						
							|  |  |  |                                                 std::bind(&QmlProfilerTool::clear, this)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::error, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::showErrorDialog); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::availableFeaturesChanged, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::setAvailableFeatures); | 
					
						
							| 
									
										
										
										
											2015-02-10 20:29:54 +01:00
										 |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::saveFinished, | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  |             this, &QmlProfilerTool::onLoadSaveFinished); | 
					
						
							|  |  |  |     connect(d->m_profilerModelManager, &QmlProfilerModelManager::loadFinished, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::onLoadSaveFinished); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |     d->m_profilerConnections->setModelManager(d->m_profilerModelManager); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     d->m_recordingTimer.setInterval(100); | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(&d->m_recordingTimer, &QTimer::timeout, this, &QmlProfilerTool::updateTimeDisplay); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_viewContainer = new QmlProfilerViewManager(this, | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |                                                     d->m_profilerModelManager, | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |                                                     d->m_profilerState); | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_viewContainer, &QmlProfilerViewManager::gotoSourceLocation, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::gotoSourceLocation); | 
					
						
							| 
									
										
										
										
											2011-07-06 14:13:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-06 16:52:14 +02:00
										 |  |  |     //
 | 
					
						
							|  |  |  |     // Toolbar
 | 
					
						
							|  |  |  |     //
 | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     d->m_recordButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     d->m_recordButton->setCheckable(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_recordButton,&QAbstractButton::clicked, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::recordingButtonChanged); | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  |     d->m_recordButton->setChecked(true); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_recordFeaturesMenu = new QMenu(d->m_recordButton); | 
					
						
							|  |  |  |     d->m_recordButton->setMenu(d->m_recordFeaturesMenu); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     d->m_recordButton->setPopupMode(QToolButton::MenuButtonPopup); | 
					
						
							| 
									
										
										
										
											2015-10-30 12:35:17 +01:00
										 |  |  |     connect(d->m_recordFeaturesMenu, &QMenu::triggered, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::toggleRequestedFeature); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     d->m_clearButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2016-08-03 17:55:54 +02:00
										 |  |  |     d->m_clearButton->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon()); | 
					
						
							| 
									
										
										
										
											2011-07-05 16:40:26 +02:00
										 |  |  |     d->m_clearButton->setToolTip(tr("Discard data")); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     connect(d->m_clearButton, &QAbstractButton::clicked, [this](){ | 
					
						
							|  |  |  |         if (checkForUnsavedNotes()) | 
					
						
							|  |  |  |             clearData(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  |     d->m_searchButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2016-05-23 14:15:06 +02:00
										 |  |  |     d->m_searchButton->setIcon(Utils::Icons::ZOOM_TOOLBAR.icon()); | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     d->m_searchButton->setToolTip(tr("Search timeline event notes.")); | 
					
						
							| 
									
										
										
										
											2019-01-28 09:10:46 +01:00
										 |  |  |     d->m_searchButton->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  |     connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch); | 
					
						
							| 
									
										
										
										
											2019-01-28 09:10:46 +01:00
										 |  |  |     connect(d->m_viewContainer, &QmlProfilerViewManager::viewsCreated, this, [this]() { | 
					
						
							|  |  |  |         d->m_searchButton->setEnabled(d->m_viewContainer->traceView()->isUsable()); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesButton = new QToolButton; | 
					
						
							| 
									
										
										
										
											2016-08-03 17:55:54 +02:00
										 |  |  |     d->m_displayFeaturesButton->setIcon(Utils::Icons::FILTER.icon()); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesButton->setToolTip(tr("Hide or show event categories.")); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setPopupMode(QToolButton::InstantPopup); | 
					
						
							| 
									
										
										
										
											2015-09-28 19:14:46 +02:00
										 |  |  |     d->m_displayFeaturesButton->setProperty("noArrow", true); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     d->m_displayFeaturesMenu = new QMenu(d->m_displayFeaturesButton); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setMenu(d->m_displayFeaturesMenu); | 
					
						
							|  |  |  |     connect(d->m_displayFeaturesMenu, &QMenu::triggered, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::toggleVisibleFeature); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 18:05:03 +02:00
										 |  |  |     d->m_timeLabel = new QLabel(); | 
					
						
							| 
									
										
										
										
											2019-02-11 12:24:27 +01:00
										 |  |  |     d->m_timeLabel->setProperty("panelwidget", true); | 
					
						
							| 
									
										
										
										
											2015-06-30 18:05:03 +02:00
										 |  |  |     d->m_timeLabel->setIndent(10); | 
					
						
							|  |  |  |     updateTimeDisplay(); | 
					
						
							| 
									
										
										
										
											2017-08-10 11:07:38 +02:00
										 |  |  |     connect(d->m_timeLabel, &QObject::destroyed, &d->m_recordingTimer, &QTimer::stop); | 
					
						
							| 
									
										
										
										
											2015-06-30 18:05:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     setAvailableFeatures(d->m_profilerModelManager->availableFeatures()); | 
					
						
							|  |  |  |     setRecordedFeatures(0); | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  |     // When the widgets are requested we assume that the session data
 | 
					
						
							|  |  |  |     // is available, then we can populate the file finder
 | 
					
						
							| 
									
										
										
										
											2016-12-29 14:26:29 +01:00
										 |  |  |     d->m_profilerModelManager->populateFileFinder(); | 
					
						
							| 
									
										
										
										
											2012-05-10 11:46:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     d->m_startAction = Debugger::createStartAction(); | 
					
						
							|  |  |  |     d->m_stopAction = Debugger::createStopAction(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-28 16:21:03 +02:00
										 |  |  |     QObject::connect(d->m_startAction, &QAction::triggered, this, &QmlProfilerTool::profileStartupProject); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-01 17:33:41 +02:00
										 |  |  |     Utils::Perspective *perspective = d->m_viewContainer->perspective(); | 
					
						
							| 
									
										
											  
											
												Debugger: Make most views per-engine instead of singletons
This is a step towards properly supporting multiple debugger
sessions side-by-side.
The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.
Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.
Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.
The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.
There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.
The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.
There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.
Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
											
										 
											2018-07-31 12:30:48 +02:00
										 |  |  |     perspective->addToolBarAction(d->m_startAction); | 
					
						
							|  |  |  |     perspective->addToolBarAction(d->m_stopAction); | 
					
						
							|  |  |  |     perspective->addToolBarWidget(d->m_recordButton); | 
					
						
							|  |  |  |     perspective->addToolBarWidget(d->m_clearButton); | 
					
						
							|  |  |  |     perspective->addToolBarWidget(d->m_searchButton); | 
					
						
							|  |  |  |     perspective->addToolBarWidget(d->m_displayFeaturesButton); | 
					
						
							|  |  |  |     perspective->addToolBarWidget(d->m_timeLabel); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, | 
					
						
							|  |  |  |             this, &QmlProfilerTool::updateRunActions); | 
					
						
							| 
									
										
										
										
											2016-12-19 18:47:06 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel(); | 
					
						
							|  |  |  |     if (EditorManager *editorManager = EditorManager::instance()) { | 
					
						
							|  |  |  |         connect(editorManager, &EditorManager::editorCreated, | 
					
						
							|  |  |  |                 model, [this, model](Core::IEditor *editor, const QString &fileName) { | 
					
						
							|  |  |  |             Q_UNUSED(editor); | 
					
						
							| 
									
										
										
										
											2017-08-15 18:44:18 +02:00
										 |  |  |             model->createMarks(d->m_viewContainer, fileName); | 
					
						
							| 
									
										
										
										
											2016-12-19 18:47:06 +01:00
										 |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-08-10 16:00:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     auto updateRecordButton = [this]() { | 
					
						
							|  |  |  |         const bool recording = | 
					
						
							|  |  |  |                 d->m_profilerState->currentState() != QmlProfilerStateManager::AppRunning | 
					
						
							|  |  |  |                 ? d->m_profilerState->clientRecording() : d->m_profilerState->serverRecording(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const static QIcon recordOn = Debugger::Icons::RECORD_ON.icon(); | 
					
						
							|  |  |  |         const static QIcon recordOff = Debugger::Icons::RECORD_OFF.icon(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // update display
 | 
					
						
							|  |  |  |         d->m_recordButton->setToolTip(recording ? tr("Disable Profiling") : tr("Enable Profiling")); | 
					
						
							|  |  |  |         d->m_recordButton->setIcon(recording ? recordOn : recordOff); | 
					
						
							|  |  |  |         d->m_recordButton->setChecked(recording); | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::stateChanged, | 
					
						
							|  |  |  |             d->m_recordButton, updateRecordButton); | 
					
						
							|  |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::serverRecordingChanged, | 
					
						
							|  |  |  |             d->m_recordButton, updateRecordButton); | 
					
						
							|  |  |  |     connect(d->m_profilerState, &QmlProfilerStateManager::clientRecordingChanged, | 
					
						
							|  |  |  |             d->m_recordButton, updateRecordButton); | 
					
						
							|  |  |  |     updateRecordButton(); | 
					
						
							| 
									
										
										
										
											2016-03-03 10:47:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QmlProfilerTool::~QmlProfilerTool() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-28 14:15:51 +02:00
										 |  |  |     d->m_profilerModelManager->clearAll(); | 
					
						
							| 
									
										
										
										
											2016-03-03 10:47:02 +01:00
										 |  |  |     delete d; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  | void QmlProfilerTool::updateRunActions() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (d->m_toolBusy) { | 
					
						
							|  |  |  |         d->m_startAction->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2016-04-05 10:55:27 +02:00
										 |  |  |         d->m_startAction->setToolTip(tr("A QML Profiler analysis is still in progress.")); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |         d->m_stopAction->setEnabled(true); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2016-04-05 10:55:27 +02:00
										 |  |  |         QString whyNot = tr("Start QML Profiler analysis."); | 
					
						
							| 
									
										
										
										
											2016-03-10 13:30:15 +01:00
										 |  |  |         bool canRun = ProjectExplorerPlugin::canRunStartupProject | 
					
						
							|  |  |  |                 (ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, &whyNot); | 
					
						
							|  |  |  |         d->m_startAction->setToolTip(whyNot); | 
					
						
							|  |  |  |         d->m_startAction->setEnabled(canRun); | 
					
						
							|  |  |  |         d->m_stopAction->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-29 16:04:31 +02:00
										 |  |  | void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) | 
					
						
							| 
									
										
										
										
											2016-03-03 10:47:02 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     d->m_toolBusy = true; | 
					
						
							| 
									
										
										
										
											2017-05-29 16:04:31 +02:00
										 |  |  |     auto runControl = runWorker->runControl(); | 
					
						
							|  |  |  |     auto runConfiguration = runControl->runConfiguration(); | 
					
						
							| 
									
										
										
										
											2016-03-03 16:10:04 +01:00
										 |  |  |     if (runConfiguration) { | 
					
						
							| 
									
										
										
										
											2017-05-29 16:04:31 +02:00
										 |  |  |         auto aspect = static_cast<QmlProfilerRunConfigurationAspect *>( | 
					
						
							| 
									
										
										
										
											2018-09-07 13:29:45 +02:00
										 |  |  |                     runConfiguration->aspect(Constants::SETTINGS)); | 
					
						
							| 
									
										
										
										
											2016-03-03 16:10:04 +01:00
										 |  |  |         if (aspect) { | 
					
						
							| 
									
										
										
										
											2018-11-24 12:14:44 +01:00
										 |  |  |             if (auto settings = static_cast<const QmlProfilerSettings *>(aspect->currentSettings())) { | 
					
						
							| 
									
										
										
										
											2016-03-03 16:10:04 +01:00
										 |  |  |                 d->m_profilerConnections->setFlushInterval(settings->flushEnabled() ? | 
					
						
							|  |  |  |                                                                settings->flushInterval() : 0); | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |                 d->m_profilerModelManager->setAggregateTraces(settings->aggregateTraces()); | 
					
						
							| 
									
										
										
										
											2016-03-03 16:10:04 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-03 10:47:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-15 10:35:17 +01:00
										 |  |  |     auto handleStop = [this, runControl]() { | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |         d->m_toolBusy = false; | 
					
						
							|  |  |  |         updateRunActions(); | 
					
						
							| 
									
										
										
										
											2017-06-26 18:40:11 +02:00
										 |  |  |         disconnect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop); | 
					
						
							| 
									
										
										
										
											2018-05-31 14:11:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // If we're still trying to connect, stop now.
 | 
					
						
							|  |  |  |         if (d->m_profilerConnections->isConnecting()) { | 
					
						
							|  |  |  |             showNonmodalWarning(tr("The application finished before a connection could be " | 
					
						
							|  |  |  |                                    "established. No data was loaded.")); | 
					
						
							|  |  |  |             d->m_profilerConnections->disconnectFromServer(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-01-15 10:35:17 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(runControl, &RunControl::stopped, this, handleStop); | 
					
						
							| 
									
										
										
										
											2018-03-05 17:07:13 +01:00
										 |  |  |     connect(runControl, &RunControl::finished, this, [this, handleStop] { | 
					
						
							| 
									
										
										
										
											2018-01-15 10:35:17 +01:00
										 |  |  |         if (d->m_toolBusy) | 
					
						
							|  |  |  |             handleStop(); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-26 18:40:11 +02:00
										 |  |  |     connect(d->m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     updateRunActions(); | 
					
						
							| 
									
										
										
										
											2017-05-29 13:14:16 +02:00
										 |  |  |     runWorker->registerProfilerStateManager(d->m_profilerState); | 
					
						
							| 
									
										
										
										
											2016-03-03 10:47:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  |     // Initialize m_projectFinder
 | 
					
						
							|  |  |  |     //
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 14:56:00 +02:00
										 |  |  |     d->m_profilerModelManager->populateFileFinder(runConfiguration ? runConfiguration->target() | 
					
						
							|  |  |  |                                                                    : nullptr); | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(d->m_profilerConnections, &QmlProfilerClientManager::connectionFailed, | 
					
						
							|  |  |  |             runWorker, [this, runWorker]() { | 
					
						
							| 
									
										
										
										
											2018-11-24 12:14:44 +01:00
										 |  |  |         auto infoBox = new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |         infoBox->setIcon(QMessageBox::Critical); | 
					
						
							|  |  |  |         infoBox->setWindowTitle(Core::Constants::IDE_DISPLAY_NAME); | 
					
						
							| 
									
										
										
										
											2018-05-31 12:52:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const int interval = d->m_profilerConnections->retryInterval(); | 
					
						
							|  |  |  |         const int retries = d->m_profilerConnections->maximumRetries(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         infoBox->setText(QmlProfilerTool::tr("Could not connect to the in-process QML profiler " | 
					
						
							|  |  |  |                                              "within %1 s.\n" | 
					
						
							|  |  |  |                                              "Do you want to retry and wait %2 s?") | 
					
						
							|  |  |  |                          .arg(interval * retries / 1000.0) | 
					
						
							|  |  |  |                          .arg(interval * 2 * retries / 1000.0)); | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |         infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help); | 
					
						
							|  |  |  |         infoBox->setDefaultButton(QMessageBox::Retry); | 
					
						
							|  |  |  |         infoBox->setModal(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-31 12:52:24 +02:00
										 |  |  |         connect(infoBox, &QDialog::finished, runWorker, [this, runWorker, interval](int result) { | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |             switch (result) { | 
					
						
							|  |  |  |             case QMessageBox::Retry: | 
					
						
							| 
									
										
										
										
											2018-05-31 12:52:24 +02:00
										 |  |  |                 d->m_profilerConnections->setRetryInterval(interval * 2); | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |                 d->m_profilerConnections->retryConnect(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             case QMessageBox::Help: | 
					
						
							| 
									
										
										
										
											2019-01-24 10:42:24 +01:00
										 |  |  |                 HelpManager::showHelpUrl( | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |                             "qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"); | 
					
						
							|  |  |  |                 Q_FALLTHROUGH(); | 
					
						
							|  |  |  |             case QMessageBox::Cancel: | 
					
						
							|  |  |  |                 // The actual error message has already been logged.
 | 
					
						
							|  |  |  |                 QmlProfilerTool::logState(QmlProfilerTool::tr("Failed to connect.")); | 
					
						
							|  |  |  |                 runWorker->cancelProcess(); | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         infoBox->show(); | 
					
						
							|  |  |  |     }, Qt::QueuedConnection); // Queue any connection failures after reportStarted()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     d->m_profilerConnections->connectToServer(runWorker->serverUrl()); | 
					
						
							|  |  |  |     d->m_profilerState->setCurrentState(QmlProfilerStateManager::AppRunning); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | void QmlProfilerTool::recordingButtonChanged(bool recording) | 
					
						
							| 
									
										
										
										
											2011-04-06 12:26:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |     // clientRecording is our intention for new sessions. That may differ from the state of the
 | 
					
						
							|  |  |  |     // current session, as indicated by the button. To synchronize it, toggle once.
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     if (recording && d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) { | 
					
						
							|  |  |  |         if (checkForUnsavedNotes()) { | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |             if (!d->m_profilerModelManager->aggregateTraces()) | 
					
						
							| 
									
										
										
										
											2018-01-03 13:40:48 +01:00
										 |  |  |                 clearEvents(); // clear before the recording starts, unless we aggregate recordings
 | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |             if (d->m_profilerState->clientRecording()) | 
					
						
							|  |  |  |                 d->m_profilerState->setClientRecording(false); | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |             d->m_profilerState->setClientRecording(true); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             d->m_recordButton->setChecked(false); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2014-11-17 17:32:52 +01:00
										 |  |  |         if (d->m_profilerState->clientRecording() == recording) | 
					
						
							|  |  |  |             d->m_profilerState->setClientRecording(!recording); | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |         d->m_profilerState->setClientRecording(recording); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-12 16:36:40 +01:00
										 |  |  | void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-04-01 13:57:49 +02:00
										 |  |  |     if (lineNumber < 0 || fileUrl.isEmpty()) | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 14:26:29 +01:00
										 |  |  |     const QString projectFileName = d->m_profilerModelManager->findLocalFile(fileUrl); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-09 11:01:03 +01:00
										 |  |  |     QFileInfo fileInfo(projectFileName); | 
					
						
							|  |  |  |     if (!fileInfo.exists() || !fileInfo.isReadable()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-17 19:12:44 +01:00
										 |  |  |     // The text editors count columns starting with 0, but the ASTs store the
 | 
					
						
							|  |  |  |     // location starting with 1, therefore the -1.
 | 
					
						
							| 
									
										
										
										
											2016-12-21 12:41:55 +01:00
										 |  |  |     EditorManager::openEditorAt( | 
					
						
							|  |  |  |                 projectFileName, lineNumber == 0 ? 1 : lineNumber, columnNumber - 1, Id(), | 
					
						
							|  |  |  |                 EditorManager::DoNotSwitchToDesignMode | EditorManager::DoNotSwitchToEditMode); | 
					
						
							| 
									
										
										
										
											2011-03-11 12:22:57 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::updateTimeDisplay() | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     double seconds = 0; | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |     switch (d->m_profilerState->currentState()) { | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppStopRequested: | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppDying: | 
					
						
							|  |  |  |         return; // Transitional state: don't update the display.
 | 
					
						
							|  |  |  |     case QmlProfilerStateManager::AppRunning: | 
					
						
							|  |  |  |         if (d->m_profilerState->serverRecording()) { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |             seconds = d->m_recordingElapsedTime.elapsed() / 1000.0; | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |             break; | 
					
						
							| 
									
										
										
										
											2017-11-21 13:23:26 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         Q_FALLTHROUGH(); | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |     case QmlProfilerStateManager::Idle: | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |         if (d->m_profilerModelManager->traceDuration() > 0) | 
					
						
							| 
									
										
										
										
											2018-03-28 08:57:46 +02:00
										 |  |  |             seconds = d->m_profilerModelManager->traceDuration() / 1.0e9; | 
					
						
							| 
									
										
										
										
											2015-10-20 13:04:44 +02:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  |     QString timeString = QString::number(seconds,'f',1); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     QString profilerTimeStr = QmlProfilerTool::tr("%1 s").arg(timeString, 6); | 
					
						
							|  |  |  |     d->m_timeLabel->setText(tr("Elapsed: %1").arg(profilerTimeStr)); | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-08 14:30:30 +02:00
										 |  |  | void QmlProfilerTool::showTimeLineSearch() | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2016-12-20 13:00:18 +01:00
										 |  |  |     QmlProfilerTraceView *traceView = d->m_viewContainer->traceView(); | 
					
						
							| 
									
										
										
										
											2019-01-28 09:10:46 +01:00
										 |  |  |     QTC_ASSERT(traceView, return); | 
					
						
							| 
									
										
										
										
											2016-12-20 13:00:18 +01:00
										 |  |  |     QTC_ASSERT(qobject_cast<QDockWidget *>(traceView->parentWidget()), return); | 
					
						
							|  |  |  |     traceView->parentWidget()->raise(); | 
					
						
							|  |  |  |     traceView->setFocus(); | 
					
						
							| 
									
										
										
										
											2016-03-11 19:12:07 +01:00
										 |  |  |     Core::Find::openFindToolBar(Core::Find::FindForwardDirection); | 
					
						
							| 
									
										
										
										
											2015-01-30 16:52:11 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 13:40:48 +01:00
										 |  |  | void QmlProfilerTool::clearEvents() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |     d->m_profilerModelManager->clear(); | 
					
						
							| 
									
										
										
										
											2018-01-03 13:40:48 +01:00
										 |  |  |     d->m_profilerConnections->clearEvents(); | 
					
						
							|  |  |  |     setRecordedFeatures(0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::clearData() | 
					
						
							| 
									
										
										
										
											2011-11-28 16:30:30 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |     d->m_profilerModelManager->clearAll(); | 
					
						
							| 
									
										
										
										
											2016-05-23 16:14:25 +02:00
										 |  |  |     d->m_profilerConnections->clearBufferedData(); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     setRecordedFeatures(0); | 
					
						
							| 
									
										
										
										
											2011-03-24 12:42:15 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-04-01 13:48:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-06 16:04:18 +02:00
										 |  |  | void QmlProfilerTool::clearDisplay() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     d->m_profilerConnections->clearBufferedData(); | 
					
						
							|  |  |  |     d->m_viewContainer->clear(); | 
					
						
							|  |  |  |     updateTimeDisplay(); | 
					
						
							| 
									
										
										
										
											2011-04-06 16:04:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  | void QmlProfilerTool::setButtonsEnabled(bool enable) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     d->m_clearButton->setEnabled(enable); | 
					
						
							|  |  |  |     d->m_displayFeaturesButton->setEnabled(enable); | 
					
						
							| 
									
										
										
										
											2019-01-28 09:10:46 +01:00
										 |  |  |     const QmlProfilerTraceView *traceView = d->m_viewContainer->traceView(); | 
					
						
							|  |  |  |     d->m_searchButton->setEnabled(traceView && traceView->isUsable() && enable); | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |     d->m_recordFeaturesMenu->setEnabled(enable); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-29 18:04:07 +02:00
										 |  |  | void QmlProfilerTool::createInitialTextMarks() | 
					
						
							| 
									
										
										
										
											2016-12-19 18:47:06 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel(); | 
					
						
							|  |  |  |     foreach (IDocument *document, DocumentModel::openedDocuments()) | 
					
						
							| 
									
										
										
										
											2017-08-15 18:44:18 +02:00
										 |  |  |         model->createMarks(d->m_viewContainer, document->filePath().toString()); | 
					
						
							| 
									
										
										
										
											2016-12-19 18:47:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  | bool QmlProfilerTool::prepareTool() | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-08-10 16:00:37 +02:00
										 |  |  |     if (d->m_profilerState->clientRecording()) { | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  |         if (checkForUnsavedNotes()) { | 
					
						
							|  |  |  |             clearData(); // clear right away to suppress second warning on server recording change
 | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-06-18 16:26:58 +02:00
										 |  |  |     return true; | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  | ProjectExplorer::RunControl *QmlProfilerTool::attachToWaitingApplication() | 
					
						
							| 
									
										
										
										
											2015-02-18 18:51:29 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-04-12 10:06:41 +02:00
										 |  |  |     if (!prepareTool()) | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  |         return nullptr; | 
					
						
							| 
									
										
										
										
											2017-04-12 10:06:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |     Id kitId; | 
					
						
							| 
									
										
										
										
											2017-11-21 13:23:26 +01:00
										 |  |  |     int port; | 
					
						
							| 
									
										
										
										
											2018-11-24 12:14:44 +01:00
										 |  |  |     Kit *kit = nullptr; | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |         QSettings *settings = ICore::settings(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         kitId = Id::fromSetting(settings->value(QLatin1String("AnalyzerQmlAttachDialog/kitId"))); | 
					
						
							| 
									
										
										
										
											2017-11-21 13:23:26 +01:00
										 |  |  |         port = settings->value(QLatin1String("AnalyzerQmlAttachDialog/port"), 3768).toInt(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         QmlProfilerAttachDialog dialog; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         dialog.setKitId(kitId); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         dialog.setPort(port); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (dialog.exec() != QDialog::Accepted) | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  |             return nullptr; | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         kit = dialog.kit(); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         port = dialog.port(); | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  |         QTC_ASSERT(port >= 0, return nullptr); | 
					
						
							|  |  |  |         QTC_ASSERT(port <= std::numeric_limits<quint16>::max(), return nullptr); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  |         settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/kitId"), kit->id().toSetting()); | 
					
						
							| 
									
										
										
										
											2011-10-15 11:52:03 +02:00
										 |  |  |         settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/port"), port); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-13 11:43:04 +02:00
										 |  |  |     QUrl serverUrl; | 
					
						
							| 
									
										
										
										
											2013-04-26 10:23:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-06 12:50:51 +01:00
										 |  |  |     IDevice::ConstPtr device = DeviceKitAspect::device(kit); | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  |     QTC_ASSERT(device, return nullptr); | 
					
						
							| 
									
										
										
										
											2017-06-29 18:32:01 +02:00
										 |  |  |     QUrl toolControl = device->toolControlChannel(IDevice::QmlControlChannel); | 
					
						
							| 
									
										
										
										
											2018-01-09 13:07:57 +01:00
										 |  |  |     serverUrl.setScheme(Utils::urlTcpScheme()); | 
					
						
							| 
									
										
										
										
											2017-06-29 18:32:01 +02:00
										 |  |  |     serverUrl.setHost(toolControl.host()); | 
					
						
							| 
									
										
										
										
											2017-06-13 11:43:04 +02:00
										 |  |  |     serverUrl.setPort(port); | 
					
						
							| 
									
										
										
										
											2016-01-19 17:25:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 10:53:34 +02:00
										 |  |  |     d->m_viewContainer->perspective()->select(); | 
					
						
							| 
									
										
										
										
											2017-04-12 10:06:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-30 08:41:08 +02:00
										 |  |  |     auto runConfig = RunConfiguration::startupRunConfiguration(); | 
					
						
							|  |  |  |     auto runControl = new RunControl(runConfig, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); | 
					
						
							| 
									
										
										
										
											2017-06-19 14:10:24 +02:00
										 |  |  |     auto profiler = new QmlProfilerRunner(runControl); | 
					
						
							|  |  |  |     profiler->setServerUrl(serverUrl); | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |     connect(profiler, &QmlProfilerRunner::starting, this, &QmlProfilerTool::finalizeRunControl); | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 12:42:09 +01:00
										 |  |  |     connect(d->m_profilerConnections, &QmlProfilerClientManager::connectionClosed, | 
					
						
							|  |  |  |             runControl, &RunControl::initiateStop); | 
					
						
							| 
									
										
										
										
											2017-04-11 14:36:03 +02:00
										 |  |  |     ProjectExplorerPlugin::startRunControl(runControl); | 
					
						
							| 
									
										
										
										
											2018-01-09 11:14:39 +01:00
										 |  |  |     return runControl; | 
					
						
							| 
									
										
										
										
											2011-04-04 15:03:31 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-04-04 15:56:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-06 15:44:34 +02:00
										 |  |  | void QmlProfilerTool::logState(const QString &msg) | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-07-23 01:19:42 +02:00
										 |  |  |     MessageManager::write(msg, MessageManager::Flash); | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::logError(const QString &msg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-09-05 01:52:17 +02:00
										 |  |  |     MessageManager::write(msg); | 
					
						
							| 
									
										
										
										
											2011-07-27 11:49:39 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::showErrorDialog(const QString &error) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-24 12:14:44 +01:00
										 |  |  |     auto errorDialog = new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     errorDialog->setIcon(QMessageBox::Warning); | 
					
						
							|  |  |  |     errorDialog->setWindowTitle(tr("QML Profiler")); | 
					
						
							|  |  |  |     errorDialog->setText(error); | 
					
						
							|  |  |  |     errorDialog->setStandardButtons(QMessageBox::Ok); | 
					
						
							|  |  |  |     errorDialog->setDefaultButton(QMessageBox::Ok); | 
					
						
							|  |  |  |     errorDialog->setModal(false); | 
					
						
							|  |  |  |     errorDialog->show(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  | void saveLastTraceFile(const QString &filename) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings(); | 
					
						
							|  |  |  |     if (filename != settings->lastTraceFile()) { | 
					
						
							|  |  |  |         settings->setLastTraceFile(filename); | 
					
						
							|  |  |  |         settings->writeGlobalSettings(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | void QmlProfilerTool::showSaveDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2016-05-10 13:27:48 +02:00
										 |  |  |     QLatin1String tFile(QtdFileExtension); | 
					
						
							|  |  |  |     QLatin1String zFile(QztFileExtension); | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |     QString filename = QFileDialog::getSaveFileName( | 
					
						
							|  |  |  |                 ICore::mainWindow(), tr("Save QML Trace"), | 
					
						
							|  |  |  |                 QmlProfilerPlugin::globalSettings()->lastTraceFile(), | 
					
						
							| 
									
										
										
										
											2016-05-10 13:27:48 +02:00
										 |  |  |                 tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile)); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     if (!filename.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2016-05-10 13:27:48 +02:00
										 |  |  |         if (!filename.endsWith(zFile) && !filename.endsWith(tFile)) | 
					
						
							|  |  |  |             filename += zFile; | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |         saveLastTraceFile(filename); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |         Debugger::enableMainWindow(false); | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |         Core::ProgressManager::addTask(d->m_profilerModelManager->save(filename), | 
					
						
							|  |  |  |                                        tr("Saving Trace Data"), TASK_SAVE, | 
					
						
							|  |  |  |                                        Core::ProgressManager::ShowInApplicationIcon); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::showLoadDialog() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |     if (!checkForUnsavedNotes()) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-22 10:53:34 +02:00
										 |  |  |     d->m_viewContainer->perspective()->select(); | 
					
						
							| 
									
										
										
										
											2011-11-16 17:06:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-10 13:27:48 +02:00
										 |  |  |     QLatin1String tFile(QtdFileExtension); | 
					
						
							|  |  |  |     QLatin1String zFile(QztFileExtension); | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |     QString filename = QFileDialog::getOpenFileName( | 
					
						
							|  |  |  |                 ICore::mainWindow(), tr("Load QML Trace"), | 
					
						
							|  |  |  |                 QmlProfilerPlugin::globalSettings()->lastTraceFile(), | 
					
						
							| 
									
										
										
										
											2016-05-10 13:27:48 +02:00
										 |  |  |                 tr("QML traces (*%1 *%2)").arg(zFile).arg(tFile)); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!filename.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2015-09-11 16:55:46 +02:00
										 |  |  |         saveLastTraceFile(filename); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |         Debugger::enableMainWindow(false); | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |                 this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2016-12-29 14:26:29 +01:00
										 |  |  |         d->m_profilerModelManager->populateFileFinder(); | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |         Core::ProgressManager::addTask(d->m_profilerModelManager->load(filename), | 
					
						
							|  |  |  |                                        tr("Loading Trace Data"), TASK_LOAD); | 
					
						
							| 
									
										
										
										
											2011-07-26 13:56:14 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-08-18 16:10:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-28 16:21:03 +02:00
										 |  |  | void QmlProfilerTool::profileStartupProject() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!prepareTool()) | 
					
						
							|  |  |  |         return; | 
					
						
							| 
									
										
										
										
											2018-08-22 10:53:34 +02:00
										 |  |  |     d->m_viewContainer->perspective()->select(); | 
					
						
							|  |  |  |     ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); | 
					
						
							| 
									
										
										
										
											2018-05-28 16:21:03 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QAction *QmlProfilerTool::startAction() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_startAction; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QAction *QmlProfilerTool::stopAction() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_stopAction; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  | void QmlProfilerTool::onLoadSaveFinished() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     disconnect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged, | 
					
						
							|  |  |  |                this, &QmlProfilerTool::setRecordedFeatures); | 
					
						
							| 
									
										
										
										
											2016-03-02 13:57:37 +01:00
										 |  |  |     Debugger::enableMainWindow(true); | 
					
						
							| 
									
										
										
										
											2015-02-17 14:25:24 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  | /*!
 | 
					
						
							|  |  |  |     Checks if we have unsaved notes. If so, shows a warning dialog. Returns true if we can continue | 
					
						
							|  |  |  |     with a potentially destructive operation and discard the warnings, or false if not. We don't | 
					
						
							|  |  |  |     want to show a save/discard dialog here because that will often result in a confusing series of | 
					
						
							|  |  |  |     different dialogs: first "save" and then immediately "load" or "connect". | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | bool QmlProfilerTool::checkForUnsavedNotes() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!d->m_profilerModelManager->notesModel()->isModified()) | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     return QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), | 
					
						
							|  |  |  |                                 tr("You are about to discard the profiling data, including unsaved " | 
					
						
							|  |  |  |                                    "notes. Do you want to continue?"), | 
					
						
							|  |  |  |                                 QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  | void QmlProfilerTool::clientsDisconnected() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |     if (d->m_toolBusy) { | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |         if (d->m_profilerModelManager->aggregateTraces()) { | 
					
						
							| 
									
										
										
										
											2018-03-27 15:58:43 +02:00
										 |  |  |             d->m_profilerModelManager->finalize(); | 
					
						
							| 
									
										
										
										
											2018-05-31 12:28:03 +02:00
										 |  |  |         } else if (d->m_profilerState->serverRecording()) { | 
					
						
							| 
									
										
										
										
											2016-01-22 17:43:09 +01:00
										 |  |  |             // If the application stopped by itself, check if we have all the data
 | 
					
						
							|  |  |  |             if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying || | 
					
						
							|  |  |  |                     d->m_profilerState->currentState() == QmlProfilerStateManager::Idle) { | 
					
						
							| 
									
										
										
										
											2015-11-18 12:34:52 +01:00
										 |  |  |                 showNonmodalWarning(tr("Application finished before loading profiled data.\n" | 
					
						
							|  |  |  |                                        "Please use the stop button instead.")); | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |                 d->m_profilerModelManager->clearAll(); | 
					
						
							| 
									
										
										
										
											2015-11-18 12:34:52 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2015-09-11 16:10:58 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-01-22 17:43:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // ... and return to the "base" state
 | 
					
						
							| 
									
										
										
										
											2018-01-16 17:58:23 +01:00
										 |  |  |     if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppDying) { | 
					
						
							|  |  |  |         QTimer::singleShot(0, d->m_profilerState, [this]() { | 
					
						
							|  |  |  |             d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-05-08 15:14:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void addFeatureToMenu(QMenu *menu, ProfileFeature feature, quint64 enabledFeatures) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QAction *action = | 
					
						
							|  |  |  |             menu->addAction(QmlProfilerTool::tr(QmlProfilerModelManager::featureName(feature))); | 
					
						
							|  |  |  |     action->setCheckable(true); | 
					
						
							|  |  |  |     action->setData(static_cast<uint>(feature)); | 
					
						
							|  |  |  |     action->setChecked(enabledFeatures & (1ULL << (feature))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-03 23:48:57 +02:00
										 |  |  | template<ProfileFeature feature> | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::updateFeatures(quint64 features) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-24 07:59:13 +03:00
										 |  |  |     if (features & (1ULL << (feature))) { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         addFeatureToMenu(d->m_recordFeaturesMenu, feature, | 
					
						
							|  |  |  |                          d->m_profilerState->requestedFeatures()); | 
					
						
							|  |  |  |         addFeatureToMenu(d->m_displayFeaturesMenu, feature, | 
					
						
							|  |  |  |                          d->m_profilerModelManager->visibleFeatures()); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     updateFeatures<static_cast<ProfileFeature>(feature + 1)>(features); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::updateFeatures<MaximumProfileFeature>(quint64 features) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     Q_UNUSED(features); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::setAvailableFeatures(quint64 features) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |     if (features != d->m_profilerState->requestedFeatures()) | 
					
						
							|  |  |  |         d->m_profilerState->setRequestedFeatures(features); // by default, enable them all.
 | 
					
						
							|  |  |  |     if (d->m_recordFeaturesMenu && d->m_displayFeaturesMenu) { | 
					
						
							|  |  |  |         d->m_recordFeaturesMenu->clear(); | 
					
						
							|  |  |  |         d->m_displayFeaturesMenu->clear(); | 
					
						
							|  |  |  |         updateFeatures<static_cast<ProfileFeature>(0)>(features); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::setRecordedFeatures(quint64 features) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     foreach (QAction *action, d->m_displayFeaturesMenu->actions()) | 
					
						
							|  |  |  |         action->setEnabled(features & (1ULL << action->data().toUInt())); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  | void QmlProfilerTool::initialize() | 
					
						
							| 
									
										
										
										
											2011-08-18 16:10:33 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |     setButtonsEnabled(false);            // Other buttons disabled
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::finalize() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     updateTimeDisplay(); | 
					
						
							| 
									
										
										
										
											2018-05-29 18:04:07 +02:00
										 |  |  |     createInitialTextMarks(); | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |     setButtonsEnabled(true); | 
					
						
							|  |  |  |     d->m_recordButton->setEnabled(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::clear() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     clearDisplay(); | 
					
						
							|  |  |  |     setButtonsEnabled(true); | 
					
						
							|  |  |  |     d->m_recordButton->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-04 17:20:13 +01:00
										 |  |  | QList <QAction *> QmlProfilerTool::profilerContextMenuActions() | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QList <QAction *> commonActions; | 
					
						
							| 
									
										
										
										
											2018-02-01 12:06:22 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (Command *command = ActionManager::command(Constants::QmlProfilerLoadActionId)) | 
					
						
							|  |  |  |         commonActions << command->action(); | 
					
						
							|  |  |  |     if (Command *command = ActionManager::command(Constants::QmlProfilerSaveActionId)) | 
					
						
							|  |  |  |         commonActions << command->action(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     return commonActions; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::showNonmodalWarning(const QString &warningMsg) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-11-24 12:14:44 +01:00
										 |  |  |     auto noExecWarning = new QMessageBox(ICore::mainWindow()); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     noExecWarning->setIcon(QMessageBox::Warning); | 
					
						
							|  |  |  |     noExecWarning->setWindowTitle(tr("QML Profiler")); | 
					
						
							|  |  |  |     noExecWarning->setText(warningMsg); | 
					
						
							|  |  |  |     noExecWarning->setStandardButtons(QMessageBox::Ok); | 
					
						
							|  |  |  |     noExecWarning->setDefaultButton(QMessageBox::Ok); | 
					
						
							|  |  |  |     noExecWarning->setModal(false); | 
					
						
							|  |  |  |     noExecWarning->show(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-29 16:04:31 +02:00
										 |  |  | QmlProfilerClientManager *QmlProfilerTool::clientManager() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-01-09 14:50:12 +01:00
										 |  |  |     return d->m_profilerConnections; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QmlProfilerModelManager *QmlProfilerTool::modelManager() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_profilerModelManager; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QmlProfilerStateManager *QmlProfilerTool::stateManager() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return d->m_profilerState; | 
					
						
							| 
									
										
										
										
											2017-05-29 16:04:31 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | void QmlProfilerTool::profilerStateChanged() | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     switch (d->m_profilerState->currentState()) { | 
					
						
							| 
									
										
										
										
											2012-05-11 17:19:15 +02:00
										 |  |  |     case QmlProfilerStateManager::AppDying : { | 
					
						
							|  |  |  |         // If already disconnected when dying, check again that all data was read
 | 
					
						
							|  |  |  |         if (!d->m_profilerConnections->isConnected()) | 
					
						
							| 
									
										
										
										
											2016-07-04 16:34:25 +02:00
										 |  |  |             clientsDisconnected(); | 
					
						
							| 
									
										
										
										
											2012-05-11 17:19:15 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     case QmlProfilerStateManager::Idle : | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |     case QmlProfilerStateManager::AppStopRequested: | 
					
						
							|  |  |  |         // Don't allow toggling the recording while data is loaded when application quits
 | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |         if (d->m_profilerState->serverRecording()) { | 
					
						
							|  |  |  |             // Turn off recording and wait for remaining data
 | 
					
						
							|  |  |  |             d->m_profilerConnections->stopRecording(); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // Directly transition to idle
 | 
					
						
							| 
									
										
										
										
											2018-01-16 17:58:23 +01:00
										 |  |  |             QTimer::singleShot(0, d->m_profilerState, [this]() { | 
					
						
							|  |  |  |                 d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-10-20 12:48:26 +02:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     default: | 
					
						
							|  |  |  |         // no special action needed for other states
 | 
					
						
							| 
									
										
										
										
											2011-09-14 13:26:19 +02:00
										 |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void QmlProfilerTool::serverRecordingChanged() | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |     if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppRunning) { | 
					
						
							|  |  |  |         // clear the old data each time we start a new profiling session
 | 
					
						
							|  |  |  |         if (d->m_profilerState->serverRecording()) { | 
					
						
							| 
									
										
										
										
											2014-11-03 14:19:26 +01:00
										 |  |  |             // We cannot stop it here, so we cannot give the usual yes/no dialog. Show a dialog
 | 
					
						
							|  |  |  |             // offering to immediately save the data instead.
 | 
					
						
							|  |  |  |             if (d->m_profilerModelManager->notesModel()->isModified() && | 
					
						
							|  |  |  |                     QMessageBox::warning(QApplication::activeWindow(), tr("QML Profiler"), | 
					
						
							|  |  |  |                                          tr("Starting a new profiling session will discard the " | 
					
						
							|  |  |  |                                             "previous data, including unsaved notes.\nDo you want " | 
					
						
							|  |  |  |                                             "to save the data first?"), | 
					
						
							|  |  |  |                                          QMessageBox::Save, QMessageBox::Discard) == | 
					
						
							|  |  |  |                     QMessageBox::Save) | 
					
						
							|  |  |  |                 showSaveDialog(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-10 16:00:37 +02:00
										 |  |  |             d->m_recordingTimer.start(); | 
					
						
							|  |  |  |             d->m_recordingElapsedTime.start(); | 
					
						
							| 
									
										
										
										
											2018-04-20 18:06:38 +02:00
										 |  |  |             if (!d->m_profilerModelManager->aggregateTraces()) | 
					
						
							| 
									
										
										
										
											2018-01-03 13:40:48 +01:00
										 |  |  |                 clearEvents(); | 
					
						
							| 
									
										
										
										
											2018-04-05 09:47:33 +02:00
										 |  |  |             d->m_profilerModelManager->initialize(); | 
					
						
							| 
									
										
										
										
											2013-08-08 13:28:08 +02:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2017-08-10 16:00:37 +02:00
										 |  |  |             d->m_recordingTimer.stop(); | 
					
						
							|  |  |  |             if (!d->m_profilerModelManager->aggregateTraces()) | 
					
						
							| 
									
										
										
										
											2018-03-27 15:58:43 +02:00
										 |  |  |                 d->m_profilerModelManager->finalize(); | 
					
						
							| 
									
										
										
										
											2012-02-24 10:47:17 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |     } else if (d->m_profilerState->currentState() == QmlProfilerStateManager::AppStopRequested) { | 
					
						
							| 
									
										
										
										
											2018-03-27 15:58:43 +02:00
										 |  |  |         d->m_profilerModelManager->finalize(); | 
					
						
							| 
									
										
										
										
											2016-08-04 17:29:05 +02:00
										 |  |  |         d->m_profilerState->setCurrentState(QmlProfilerStateManager::Idle); | 
					
						
							| 
									
										
										
										
											2012-02-13 15:26:57 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::toggleRequestedFeature(QAction *action) | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     uint feature = action->data().toUInt(); | 
					
						
							|  |  |  |     if (action->isChecked()) | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         d->m_profilerState->setRequestedFeatures( | 
					
						
							|  |  |  |                     d->m_profilerState->requestedFeatures() | (1ULL << feature)); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  |         d->m_profilerState->setRequestedFeatures( | 
					
						
							|  |  |  |                     d->m_profilerState->requestedFeatures() & (~(1ULL << feature))); | 
					
						
							| 
									
										
										
										
											2014-09-09 18:22:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-30 15:55:33 +02:00
										 |  |  | void QmlProfilerTool::toggleVisibleFeature(QAction *action) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint feature = action->data().toUInt(); | 
					
						
							|  |  |  |     if (action->isChecked()) | 
					
						
							|  |  |  |         d->m_profilerModelManager->setVisibleFeatures( | 
					
						
							|  |  |  |                     d->m_profilerModelManager->visibleFeatures() | (1ULL << feature)); | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         d->m_profilerModelManager->setVisibleFeatures( | 
					
						
							|  |  |  |                     d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature))); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 16:02:54 +02:00
										 |  |  | } // namespace Internal
 | 
					
						
							|  |  |  | } // namespace QmlProfiler
 |