forked from qt-creator/qt-creator
Added settings class to QML Inspector
For starters, we only remember whether the initial warning about dangers of Live Preview was shown.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "qmljslivetextpreview.h"
|
||||
#include "qmljsprivateapi.h"
|
||||
#include "qmljscontextcrumblepath.h"
|
||||
#include "qmljsinspectorsettings.h"
|
||||
|
||||
#include <qmljseditor/qmljseditorconstants.h>
|
||||
|
||||
@@ -112,7 +113,6 @@ enum {
|
||||
ConnectionAttemptSimultaneousInterval = 500
|
||||
};
|
||||
|
||||
bool Inspector::m_showExperimentalWarning = true;
|
||||
Inspector *Inspector::m_instance = 0;
|
||||
|
||||
Inspector::Inspector(QObject *parent)
|
||||
@@ -120,6 +120,7 @@ Inspector::Inspector(QObject *parent)
|
||||
m_connectionTimer(new QTimer(this)),
|
||||
m_connectionAttempts(0),
|
||||
m_listeningToEditorManager(false),
|
||||
m_settings(new InspectorSettings(this)),
|
||||
m_debugProject(0)
|
||||
{
|
||||
m_clientProxy = ClientProxy::instance();
|
||||
@@ -143,6 +144,17 @@ Inspector::Inspector(QObject *parent)
|
||||
|
||||
Inspector::~Inspector()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Inspector::saveSettings() const
|
||||
{
|
||||
m_settings->saveSettings(Core::ICore::instance()->settings());
|
||||
}
|
||||
|
||||
void Inspector::restoreSettings()
|
||||
{
|
||||
m_settings->restoreSettings(Core::ICore::instance()->settings());
|
||||
}
|
||||
|
||||
void Inspector::disconnected()
|
||||
@@ -409,12 +421,12 @@ void Inspector::crumblePathElementClicked(int pathIndex)
|
||||
|
||||
bool Inspector::showExperimentalWarning()
|
||||
{
|
||||
return m_showExperimentalWarning;
|
||||
return m_settings->showLivePreviewWarning();
|
||||
}
|
||||
|
||||
void Inspector::setShowExperimentalWarning(bool value)
|
||||
{
|
||||
m_showExperimentalWarning = value;
|
||||
m_settings->setShowLivePreviewWarning(value);
|
||||
}
|
||||
|
||||
Inspector *Inspector::instance()
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace Internal {
|
||||
|
||||
class ClientProxy;
|
||||
class InspectorContext;
|
||||
class InspectorSettings;
|
||||
class ContextCrumblePath;
|
||||
class QmlJSLiveTextPreview;
|
||||
|
||||
@@ -94,14 +95,19 @@ public:
|
||||
QDeclarativeDebugExpressionQuery *setBindingForObject(int objectDebugId, const QString &objectId,
|
||||
const QString &propertyName, const QVariant &value,
|
||||
bool isLiteralValue);
|
||||
static bool showExperimentalWarning();
|
||||
static void setShowExperimentalWarning(bool value);
|
||||
void saveSettings() const;
|
||||
void restoreSettings();
|
||||
|
||||
bool showExperimentalWarning();
|
||||
void setShowExperimentalWarning(bool value);
|
||||
|
||||
static Inspector *instance();
|
||||
|
||||
// returns the project being currently debugged, or 0 if not debugging anything
|
||||
ProjectExplorer::Project *debugProject() const;
|
||||
void createDockWidgets();
|
||||
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &text);
|
||||
void livePreviewActivated(bool isActivated);
|
||||
@@ -150,12 +156,13 @@ private:
|
||||
int m_connectionAttempts;
|
||||
ClientProxy *m_clientProxy;
|
||||
|
||||
static bool m_showExperimentalWarning;
|
||||
bool m_listeningToEditorManager;
|
||||
|
||||
ContextCrumblePath *m_crumblePath;
|
||||
QDockWidget *m_crumblePathDock;
|
||||
|
||||
InspectorSettings *m_settings;
|
||||
|
||||
// Qml/JS integration
|
||||
QHash<QString, QmlJSLiveTextPreview *> m_textPreviews;
|
||||
QmlJS::Snapshot m_loadedSnapshot; //the snapshot loaded by the viewer
|
||||
|
||||
@@ -19,7 +19,8 @@ qmlinspectortoolbar.h \
|
||||
qmljslivetextpreview.h \
|
||||
qmljstoolbarcolorbox.h \
|
||||
qmljsdesigndebugclient.h \
|
||||
qmljscontextcrumblepath.h
|
||||
qmljscontextcrumblepath.h \
|
||||
qmljsinspectorsettings.h
|
||||
|
||||
SOURCES += \
|
||||
qmljsdebuggerclient.cpp \
|
||||
@@ -31,7 +32,8 @@ qmlinspectortoolbar.cpp \
|
||||
qmljslivetextpreview.cpp \
|
||||
qmljstoolbarcolorbox.cpp \
|
||||
qmljsdesigndebugclient.cpp \
|
||||
qmljscontextcrumblepath.cpp
|
||||
qmljscontextcrumblepath.cpp \
|
||||
qmljsinspectorsettings.cpp
|
||||
|
||||
include(../../libs/qmljsdebugclient/qmljsdebugclient-lib.pri)
|
||||
|
||||
|
||||
@@ -58,12 +58,7 @@ const char * const FROM_QML_ACTION = "QmlInspector.FromQml";
|
||||
|
||||
// settings
|
||||
const char * const S_QML_INSPECTOR = "QML.Inspector";
|
||||
const char * const S_EXTERNALPORT_KEY = "ExternalPort";
|
||||
const char * const S_EXTERNALURL_KEY = "ExternalUrl";
|
||||
const char * const S_SHOW_UNINSPECTABLE_ITEMS = "ShowUninspectableProperties";
|
||||
const char * const S_SHOW_UNWATCHABLE_PROPERTIES = "ShowUninspectableItem";
|
||||
const char * const S_GROUP_PROPERTIES_BY_ITEM_TYPE = "GroupPropertiesByItemType";
|
||||
|
||||
const char * const S_LIVE_PREVIEW_WARNING_KEY = "ShowLivePreview";
|
||||
const char * const ARG_DESIGNMODE = "-designmode";
|
||||
|
||||
enum DesignTool {
|
||||
|
||||
@@ -116,6 +116,7 @@ Inspector *InspectorPlugin::inspector() const
|
||||
|
||||
ExtensionSystem::IPlugin::ShutdownFlag InspectorPlugin::aboutToShutdown()
|
||||
{
|
||||
m_inspector->saveSettings();
|
||||
return SynchronousShutdown;
|
||||
}
|
||||
|
||||
@@ -172,7 +173,7 @@ void InspectorPlugin::extensionsInitialized()
|
||||
|
||||
connect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(qreal)));
|
||||
|
||||
|
||||
m_inspector->restoreSettings();
|
||||
}
|
||||
|
||||
void InspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *project, const QString &runMode)
|
||||
|
||||
46
src/plugins/qmljsinspector/qmljsinspectorsettings.cpp
Normal file
46
src/plugins/qmljsinspector/qmljsinspectorsettings.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "qmljsinspectorsettings.h"
|
||||
#include "qmljsinspectorconstants.h"
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
namespace QmlJSInspector {
|
||||
namespace Internal {
|
||||
|
||||
InspectorSettings::InspectorSettings(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_showLivePreviewWarning(true)
|
||||
{
|
||||
}
|
||||
|
||||
InspectorSettings::~InspectorSettings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InspectorSettings::restoreSettings(QSettings *settings)
|
||||
{
|
||||
|
||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
||||
m_showLivePreviewWarning = settings->value(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), true).toBool();
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void InspectorSettings::saveSettings(QSettings *settings) const
|
||||
{
|
||||
settings->beginGroup(QLatin1String(QmlJSInspector::Constants::S_QML_INSPECTOR));
|
||||
settings->setValue(QLatin1String(QmlJSInspector::Constants::S_LIVE_PREVIEW_WARNING_KEY), m_showLivePreviewWarning);
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
|
||||
bool InspectorSettings::showLivePreviewWarning() const
|
||||
{
|
||||
return m_showLivePreviewWarning;
|
||||
}
|
||||
|
||||
void InspectorSettings::setShowLivePreviewWarning(bool value)
|
||||
{
|
||||
m_showLivePreviewWarning = value;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlJSInspector
|
||||
29
src/plugins/qmljsinspector/qmljsinspectorsettings.h
Normal file
29
src/plugins/qmljsinspector/qmljsinspectorsettings.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef INSPECTORSETTINGS_H
|
||||
#define INSPECTORSETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QSettings)
|
||||
|
||||
namespace QmlJSInspector {
|
||||
namespace Internal {
|
||||
|
||||
class InspectorSettings : public QObject
|
||||
{
|
||||
public:
|
||||
InspectorSettings(QObject *parent = 0);
|
||||
~InspectorSettings();
|
||||
void restoreSettings(QSettings *settings);
|
||||
void saveSettings(QSettings *settings) const;
|
||||
|
||||
bool showLivePreviewWarning() const;
|
||||
void setShowLivePreviewWarning(bool value);
|
||||
|
||||
private:
|
||||
bool m_showLivePreviewWarning;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlJSInspector
|
||||
|
||||
#endif // INSPECTORSETTINGS_H
|
||||
@@ -554,10 +554,10 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
||||
if (delta.referenceRefreshRequired)
|
||||
ClientProxy::instance()->refreshObjectTree();
|
||||
|
||||
if (Inspector::showExperimentalWarning() && delta.appliedChangesToViewer) {
|
||||
if (Inspector::instance()->showExperimentalWarning() && delta.appliedChangesToViewer) {
|
||||
showExperimentalWarning();
|
||||
experimentalWarningShown = true;
|
||||
Inspector::setShowExperimentalWarning(false);
|
||||
Inspector::instance()->setShowExperimentalWarning(false);
|
||||
}
|
||||
|
||||
if (delta.unsyncronizableChanges != NoUnsyncronizableChanges && !experimentalWarningShown)
|
||||
|
||||
Reference in New Issue
Block a user