aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlpreview
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2023-10-16 20:53:46 +0200
committerAlessandro Portale <alessandro.portale@qt.io>2023-10-18 08:21:13 +0000
commit5336fd83a004c1fe5265b9f9ba87320c031d2040 (patch)
tree62b195e9ea13fa8c90e39dde6cbff9fdb109bfed /src/plugins/qmlpreview
parent0e77cdcc2e45f484cd85fb06acc3e8439d66ac4d (diff)
QmlPreview: Tell users how to preview single files
In order to preview a specific (QML) file, a QML Preview process has to have been started, before. The "Preview File" context menu action was therefore disabled until at least one QML Preview was running. This precondition is neither documented nor evident to users. This change removes the disabling/enabling of the context menu action and shows an explanatory message box for the case that no running QML Preview is available. Fixes: QTCREATORBUG-29300 Change-Id: I643c57cab15ef4893a8efa6ac8839a3c00e956fb Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/qmlpreview')
-rw-r--r--src/plugins/qmlpreview/qmlpreviewplugin.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp
index 9d05d0ee398..2722ecb016e 100644
--- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp
+++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp
@@ -44,6 +44,7 @@
#include <android/androidconstants.h>
#include <QAction>
+#include <QMessageBox>
#include <QPointer>
#include <QTimer>
@@ -174,11 +175,6 @@ QmlPreviewPluginPrivate::QmlPreviewPluginPrivate(QmlPreviewPlugin *parent)
menu = Core::ActionManager::actionContainer(Constants::M_FILECONTEXT);
action = new QAction(Tr::tr("Preview File"), this);
- action->setEnabled(false);
- connect(q, &QmlPreviewPlugin::runningPreviewsChanged,
- action, [action](const QmlPreviewRunControlList &previews) {
- action->setEnabled(!previews.isEmpty());
- });
connect(action, &QAction::triggered, q, &QmlPreviewPlugin::previewCurrentFile);
menu->addAction(
Core::ActionManager::registerAction(action, "QmlPreview.PreviewFile", Core::Context(Constants::C_PROJECT_TREE)),
@@ -336,6 +332,11 @@ void QmlPreviewPlugin::previewCurrentFile()
|| currentNode->asFileNode()->fileType() != FileType::QML)
return;
+ if (runningPreviews().isEmpty())
+ QMessageBox::warning(Core::ICore::dialogParent(), Tr::tr("QML Preview not running"),
+ Tr::tr("Please start the QML Preview for the project before selecting "
+ "a specific file for preview."));
+
const QString file = currentNode->filePath().toString();
if (file != d->m_previewedFile)
setPreviewedFile(file);