forked from qt-creator/qt-creator
QmlDesigner: Fix Connections status in ContextMenu
Task-number: QDS-8521 Change-Id: Id0b835fb14b18563d4ecc0c1b2039b9bb181c32c Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QScopeGuard>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
@@ -610,31 +611,29 @@ public:
|
|||||||
{
|
{
|
||||||
menu()->clear();
|
menu()->clear();
|
||||||
|
|
||||||
menu()->setEnabled(true);
|
|
||||||
|
|
||||||
const auto selection = selectionContext();
|
const auto selection = selectionContext();
|
||||||
|
|
||||||
|
bool showMenu = false;
|
||||||
|
auto cleanup = qScopeGuard([&]{ menu()->setEnabled(showMenu); });
|
||||||
|
|
||||||
if (!selection.isValid())
|
if (!selection.isValid())
|
||||||
return;
|
return;
|
||||||
if (!selection.singleNodeIsSelected())
|
if (!selection.singleNodeIsSelected())
|
||||||
return;
|
return;
|
||||||
if (!action()->isEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ModelNode currentNode = selection.currentSingleSelectedNode();
|
ModelNode currentNode = selection.currentSingleSelectedNode();
|
||||||
|
|
||||||
if (!currentNode.isValid())
|
if (!currentNode.isValid())
|
||||||
return;
|
return;
|
||||||
|
if (!currentNode.hasId())
|
||||||
|
return;
|
||||||
|
showMenu = true;
|
||||||
|
|
||||||
QmlObjectNode currentObjectNode(currentNode);
|
QmlObjectNode currentObjectNode(currentNode);
|
||||||
|
|
||||||
QStringList signalsList = getSignalsList(currentNode);
|
QStringList signalsList = getSignalsList(currentNode);
|
||||||
QList<SlotList> slotsLists = getSlotsLists(currentNode);
|
QList<SlotList> slotsLists = getSlotsLists(currentNode);
|
||||||
|
|
||||||
if (!currentNode.hasId()) {
|
|
||||||
menu()->setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const ModelNode &connectionNode : currentObjectNode.getAllConnections()) {
|
for (const ModelNode &connectionNode : currentObjectNode.getAllConnections()) {
|
||||||
for (const AbstractProperty &property : connectionNode.properties()) {
|
for (const AbstractProperty &property : connectionNode.properties()) {
|
||||||
if (property.isSignalHandlerProperty() && property.name() != "target") {
|
if (property.isSignalHandlerProperty() && property.name() != "target") {
|
||||||
|
Reference in New Issue
Block a user