forked from qt-creator/qt-creator
QmlDesigner: Improve type selection
* Disable custom item in Connection Editor type selection * Rename Unknown to Custom Change-Id: I9fa8c9ab6284503d5ccc61813454b9d10f291a06 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
5ed667c554
commit
6d5ceadccf
@@ -57,14 +57,38 @@ Column {
|
||||
onIndexFromBackendChanged: action.currentIndex = action.indexFromBackend
|
||||
onActivated: backend.changeActionType(action.currentValue)
|
||||
|
||||
model: [
|
||||
{ value: ConnectionModelStatementDelegate.CallFunction, text: qsTr("Call Function") },
|
||||
{ value: ConnectionModelStatementDelegate.Assign, text: qsTr("Assign") },
|
||||
{ value: ConnectionModelStatementDelegate.ChangeState, text: qsTr("Change State") },
|
||||
{ value: ConnectionModelStatementDelegate.SetProperty, text: qsTr("Set Property") },
|
||||
{ value: ConnectionModelStatementDelegate.PrintMessage, text: qsTr("Print Message") },
|
||||
{ value: ConnectionModelStatementDelegate.Custom, text: qsTr("Unknown") }
|
||||
]
|
||||
model: ListModel {
|
||||
ListElement {
|
||||
value: ConnectionModelStatementDelegate.CallFunction
|
||||
text: qsTr("Call Function")
|
||||
enabled: true
|
||||
}
|
||||
ListElement {
|
||||
value: ConnectionModelStatementDelegate.Assign
|
||||
text: qsTr("Assign")
|
||||
enabled: true
|
||||
}
|
||||
ListElement {
|
||||
value: ConnectionModelStatementDelegate.ChangeState
|
||||
text: qsTr("Change State")
|
||||
enabled: true
|
||||
}
|
||||
ListElement {
|
||||
value: ConnectionModelStatementDelegate.SetProperty
|
||||
text: qsTr("Set Property")
|
||||
enabled: true
|
||||
}
|
||||
ListElement {
|
||||
vvalue: ConnectionModelStatementDelegate.PrintMessage
|
||||
text: qsTr("Print Message")
|
||||
enabled: true
|
||||
}
|
||||
ListElement {
|
||||
value: ConnectionModelStatementDelegate.Custom
|
||||
text: qsTr("Custom")
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -155,6 +155,7 @@ T.ComboBox {
|
||||
width: control.width
|
||||
height: control.style.controlSize.height
|
||||
padding: 0
|
||||
enabled: model.enabled === undefined ? true : model.enabled
|
||||
|
||||
contentItem: Text {
|
||||
leftPadding: itemDelegateIconArea.width
|
||||
@@ -182,8 +183,13 @@ T.ComboBox {
|
||||
T.Label {
|
||||
id: itemDelegateIcon
|
||||
text: StudioTheme.Constants.tickIcon
|
||||
color: itemDelegate.hovered ? control.style.text.selectedText
|
||||
: control.style.text.idle
|
||||
color: {
|
||||
if (!itemDelegate.enabled)
|
||||
return control.style.text.disabled
|
||||
|
||||
return itemDelegate.hovered ? control.style.text.selectedText
|
||||
: control.style.text.idle
|
||||
}
|
||||
font.family: StudioTheme.Constants.iconFont.family
|
||||
font.pixelSize: control.style.smallIconFontSize
|
||||
visible: control.currentIndex === index
|
||||
@@ -200,7 +206,8 @@ T.ComboBox {
|
||||
y: 0
|
||||
width: itemDelegate.width - 2 * control.style.borderWidth
|
||||
height: itemDelegate.height
|
||||
color: itemDelegate.hovered ? control.style.interaction : "transparent"
|
||||
color: itemDelegate.hovered && itemDelegate.enabled ? control.style.interaction
|
||||
: "transparent"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -760,14 +760,14 @@ QString ConnectionEditorEvaluator::getDisplayStringForType(const QString &statem
|
||||
newDoc->parseJavaScript();
|
||||
|
||||
if (!newDoc->isParsedCorrectly())
|
||||
return ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME;
|
||||
return ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
|
||||
|
||||
newDoc->ast()->accept(&evaluator);
|
||||
|
||||
const bool valid = evaluator.status() == ConnectionEditorEvaluator::Succeeded;
|
||||
|
||||
if (!valid)
|
||||
return ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME;
|
||||
return ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
|
||||
|
||||
auto result = evaluator.resultNode();
|
||||
|
||||
|
@@ -21,8 +21,8 @@ inline constexpr char LOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
|
||||
"QmlDesigner::ConnectionEditorStatements", "Print");
|
||||
inline constexpr char EMPTY_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
|
||||
"QmlDesigner::ConnectionEditorStatements", "Empty");
|
||||
inline constexpr char UNKNOWN_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
|
||||
"QmlDesigner::ConnectionEditorStatements", "Unknown");
|
||||
inline constexpr char CUSTOM_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
|
||||
"QmlDesigner::ConnectionEditorStatements", "Custom");
|
||||
|
||||
struct Variable;
|
||||
struct MatchedFunction;
|
||||
|
@@ -105,10 +105,10 @@ void tst_ConnectionEditor::invalidSyntax()
|
||||
= "{someItem.complexCall(blah)}"; //valid QML bit not valid for ConnectionEditor
|
||||
|
||||
QString result = ConnectionEditorEvaluator::getDisplayStringForType(statement1);
|
||||
QCOMPARE(result, ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME);
|
||||
QCOMPARE(result, ConnectionEditorStatements::CUSTOM_DISPLAY_NAME);
|
||||
|
||||
result = ConnectionEditorEvaluator::getDisplayStringForType(statement2);
|
||||
QCOMPARE(result, ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME);
|
||||
QCOMPARE(result, ConnectionEditorStatements::CUSTOM_DISPLAY_NAME);
|
||||
|
||||
auto resultHandler = ConnectionEditorEvaluator::parseStatement(statement1);
|
||||
auto parsedStatement = ConnectionEditorStatements::okStatement(resultHandler);
|
||||
@@ -169,14 +169,14 @@ void tst_ConnectionEditor::displayStrings_data()
|
||||
|
||||
QTest::newRow("Custom function call assignment")
|
||||
<< "{someItem.color = item.functionCall()}"
|
||||
<< ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME;
|
||||
<< ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
|
||||
|
||||
QTest::newRow("Custom function call with argument")
|
||||
<< "{someItem.color = item.functionCall(\"test\")}"
|
||||
<< ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME;
|
||||
<< ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
|
||||
|
||||
QTest::newRow("Custom function call with argument 2")
|
||||
<< "{item.functionCall(\"test\")}" << ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME;
|
||||
<< "{item.functionCall(\"test\")}" << ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
|
||||
}
|
||||
|
||||
void tst_ConnectionEditor::parseAssignment()
|
||||
|
Reference in New Issue
Block a user