diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2010-08-13 12:31:15 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2010-08-13 13:36:39 +0200 |
commit | ceca9d9d7abba7a48b4388654a68b22073a050e2 (patch) | |
tree | e44f9d890a699d1159dca4687132f3f31c622469 | |
parent | e28e1f0c568dd91b0b534c1c0c968e8b3549a8bc (diff) | |
download | qt-creator-ceca9d9d7abba7a48b4388654a68b22073a050e2.tar.gz |
Disable "Qt Quick->Preview" action if no qmlviewer in the PATH
An error dialog would be more explicit, but too late because of string
freeze.
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljspreviewrunner.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljspreviewrunner.h | 2 |
3 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index f998309ac1..e9d7926182 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 6100360614..7611cecc2b 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 869327b10c..1a3c26370f 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: |