diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index f998309ac172fb3dd971b8039cbaeb6c89599ac7..e9d792618296909bc459feeb9f3c47a1dfb00115 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -133,7 +133,9 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e Core::Command *cmd = addToolAction(m_actionPreview, am, toolsMenuContext, QLatin1String("QtQuick.Preview"), menuQtQuick, tr("Ctrl+Alt+R")); connect(cmd->action(), SIGNAL(triggered()), SLOT(openPreview())); + m_previewRunner = new QmlJSPreviewRunner(this); + m_actionPreview->setEnabled(m_previewRunner->isReady()); QAction *followSymbolUnderCursorAction = new QAction(tr("Follow Symbol Under Cursor"), this); cmd = am->registerAction(followSymbolUnderCursorAction, Constants::FOLLOW_SYMBOL_UNDER_CURSOR, context); diff --git a/src/plugins/qmljseditor/qmljspreviewrunner.cpp b/src/plugins/qmljseditor/qmljspreviewrunner.cpp index 61003606143a2ac063f417509593b05c03084ece..7611cecc2b0e8c44272000456095526cc63840b9 100644 --- a/src/plugins/qmljseditor/qmljspreviewrunner.cpp +++ b/src/plugins/qmljseditor/qmljspreviewrunner.cpp @@ -24,6 +24,10 @@ QmlJSPreviewRunner::QmlJSPreviewRunner(QObject *parent) : m_applicationLauncher.setEnvironment(environment.toStringList()); } +bool QmlJSPreviewRunner::isReady() const +{ + return !m_qmlViewerDefaultPath.isEmpty(); +} void QmlJSPreviewRunner::run(const QString &filename) { diff --git a/src/plugins/qmljseditor/qmljspreviewrunner.h b/src/plugins/qmljseditor/qmljspreviewrunner.h index 869327b10cc356e6726400fd25082174543d2d8f..1a3c26370fadf12e817143eccdc2d40a23d3d76a 100644 --- a/src/plugins/qmljseditor/qmljspreviewrunner.h +++ b/src/plugins/qmljseditor/qmljspreviewrunner.h @@ -13,6 +13,8 @@ class QmlJSPreviewRunner : public QObject Q_OBJECT public: explicit QmlJSPreviewRunner(QObject *parent = 0); + + bool isReady() const; void run(const QString &filename); signals: