forked from qt-creator/qt-creator
QmlProfiler: Persist the last trace file loaded or saved
This is quite handy if you keep all your traces in one directory. Change-Id: I09842404493c02fb0ca9c4a328950f7b6dcb5be0 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
@@ -40,6 +40,7 @@ const char TASK_LOAD[] = "QmlProfiler.TaskLoad";
|
||||
const char TASK_SAVE[] = "QmlProfiler.TaskSave";
|
||||
const char FLUSH_ENABLED[] = "Analyzer.QmlProfiler.FlushEnabled";
|
||||
const char FLUSH_INTERVAL[] = "Analyzer.QmlProfiler.FlushInterval";
|
||||
const char LAST_TRACE_FILE[] = "Analyzer.QmlProfiler.LastTraceFile";
|
||||
const char SETTINGS[] = "Analyzer.QmlProfiler.Settings";
|
||||
const char ANALYZER[] = "Analyzer";
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ QmlProfilerSettings::QmlProfilerSettings()
|
||||
QVariantMap defaults;
|
||||
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
|
||||
defaults.insert(QLatin1String(Constants::FLUSH_ENABLED), false);
|
||||
defaults.insert(QLatin1String(Constants::LAST_TRACE_FILE), QString());
|
||||
|
||||
// Read stored values
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
@@ -92,6 +93,19 @@ void QmlProfilerSettings::setFlushInterval(quint32 flushInterval)
|
||||
}
|
||||
}
|
||||
|
||||
QString QmlProfilerSettings::lastTraceFile() const
|
||||
{
|
||||
return m_lastTraceFile;
|
||||
}
|
||||
|
||||
void QmlProfilerSettings::setLastTraceFile(const QString &lastTracePath)
|
||||
{
|
||||
if (m_lastTraceFile != lastTracePath) {
|
||||
m_lastTraceFile = lastTracePath;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerSettings::writeGlobalSettings() const
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
@@ -107,12 +121,14 @@ void QmlProfilerSettings::toMap(QVariantMap &map) const
|
||||
{
|
||||
map[QLatin1String(Constants::FLUSH_INTERVAL)] = m_flushInterval;
|
||||
map[QLatin1String(Constants::FLUSH_ENABLED)] = m_flushEnabled;
|
||||
map[QLatin1String(Constants::LAST_TRACE_FILE)] = m_lastTraceFile;
|
||||
}
|
||||
|
||||
void QmlProfilerSettings::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_flushEnabled = map.value(QLatin1String(Constants::FLUSH_ENABLED)).toBool();
|
||||
m_flushInterval = map.value(QLatin1String(Constants::FLUSH_INTERVAL)).toUInt();
|
||||
m_lastTraceFile = map.value(QLatin1String(Constants::LAST_TRACE_FILE)).toString();
|
||||
emit changed();
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
quint32 flushInterval() const;
|
||||
void setFlushInterval(quint32 flushInterval);
|
||||
|
||||
QString lastTraceFile() const;
|
||||
void setLastTraceFile(const QString &lastTraceFile);
|
||||
|
||||
void writeGlobalSettings() const;
|
||||
|
||||
signals:
|
||||
@@ -62,6 +65,7 @@ protected:
|
||||
private:
|
||||
bool m_flushEnabled;
|
||||
quint32 m_flushInterval;
|
||||
QString m_lastTraceFile;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
#include "qmlprofilerrunconfigurationaspect.h"
|
||||
#include "qmlprofilersettings.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzerruncontrol.h>
|
||||
@@ -537,13 +538,25 @@ void QmlProfilerTool::showSaveOption()
|
||||
d->m_saveQmlTrace->setEnabled(!d->m_profilerModelManager->isEmpty());
|
||||
}
|
||||
|
||||
void saveLastTraceFile(const QString &filename)
|
||||
{
|
||||
QmlProfilerSettings *settings = QmlProfilerPlugin::globalSettings();
|
||||
if (filename != settings->lastTraceFile()) {
|
||||
settings->setLastTraceFile(filename);
|
||||
settings->writeGlobalSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerTool::showSaveDialog()
|
||||
{
|
||||
QString filename = QFileDialog::getSaveFileName(ICore::mainWindow(), tr("Save QML Trace"), QString(),
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
ICore::mainWindow(), tr("Save QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
|
||||
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
|
||||
if (!filename.isEmpty()) {
|
||||
if (!filename.endsWith(QLatin1String(TraceFileExtension)))
|
||||
filename += QLatin1String(TraceFileExtension);
|
||||
saveLastTraceFile(filename);
|
||||
AnalyzerManager::mainWindow()->setEnabled(false);
|
||||
d->m_profilerModelManager->save(filename);
|
||||
}
|
||||
@@ -559,10 +572,13 @@ void QmlProfilerTool::showLoadDialog()
|
||||
|
||||
AnalyzerManager::selectAction(QmlProfilerRemoteActionId);
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(ICore::mainWindow(), tr("Load QML Trace"), QString(),
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
ICore::mainWindow(), tr("Load QML Trace"),
|
||||
QmlProfilerPlugin::globalSettings()->lastTraceFile(),
|
||||
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
|
||||
|
||||
if (!filename.isEmpty()) {
|
||||
saveLastTraceFile(filename);
|
||||
AnalyzerManager::mainWindow()->setEnabled(false);
|
||||
connect(d->m_profilerModelManager, &QmlProfilerModelManager::recordedFeaturesChanged,
|
||||
this, &QmlProfilerTool::setRecordedFeatures);
|
||||
|
||||
Reference in New Issue
Block a user