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:
Henning Gruendl
2023-09-15 10:40:18 +02:00
committed by Henning Gründl
parent 5ed667c554
commit 6d5ceadccf
5 changed files with 51 additions and 20 deletions

View File

@@ -57,14 +57,38 @@ Column {
onIndexFromBackendChanged: action.currentIndex = action.indexFromBackend onIndexFromBackendChanged: action.currentIndex = action.indexFromBackend
onActivated: backend.changeActionType(action.currentValue) onActivated: backend.changeActionType(action.currentValue)
model: [ model: ListModel {
{ value: ConnectionModelStatementDelegate.CallFunction, text: qsTr("Call Function") }, ListElement {
{ value: ConnectionModelStatementDelegate.Assign, text: qsTr("Assign") }, value: ConnectionModelStatementDelegate.CallFunction
{ value: ConnectionModelStatementDelegate.ChangeState, text: qsTr("Change State") }, text: qsTr("Call Function")
{ value: ConnectionModelStatementDelegate.SetProperty, text: qsTr("Set Property") }, enabled: true
{ value: ConnectionModelStatementDelegate.PrintMessage, text: qsTr("Print Message") }, }
{ value: ConnectionModelStatementDelegate.Custom, text: qsTr("Unknown") } 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
}
}
} }
} }

View File

@@ -155,6 +155,7 @@ T.ComboBox {
width: control.width width: control.width
height: control.style.controlSize.height height: control.style.controlSize.height
padding: 0 padding: 0
enabled: model.enabled === undefined ? true : model.enabled
contentItem: Text { contentItem: Text {
leftPadding: itemDelegateIconArea.width leftPadding: itemDelegateIconArea.width
@@ -182,8 +183,13 @@ T.ComboBox {
T.Label { T.Label {
id: itemDelegateIcon id: itemDelegateIcon
text: StudioTheme.Constants.tickIcon text: StudioTheme.Constants.tickIcon
color: itemDelegate.hovered ? control.style.text.selectedText color: {
: control.style.text.idle 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.family: StudioTheme.Constants.iconFont.family
font.pixelSize: control.style.smallIconFontSize font.pixelSize: control.style.smallIconFontSize
visible: control.currentIndex === index visible: control.currentIndex === index
@@ -200,7 +206,8 @@ T.ComboBox {
y: 0 y: 0
width: itemDelegate.width - 2 * control.style.borderWidth width: itemDelegate.width - 2 * control.style.borderWidth
height: itemDelegate.height height: itemDelegate.height
color: itemDelegate.hovered ? control.style.interaction : "transparent" color: itemDelegate.hovered && itemDelegate.enabled ? control.style.interaction
: "transparent"
} }
} }
} }

View File

@@ -760,14 +760,14 @@ QString ConnectionEditorEvaluator::getDisplayStringForType(const QString &statem
newDoc->parseJavaScript(); newDoc->parseJavaScript();
if (!newDoc->isParsedCorrectly()) if (!newDoc->isParsedCorrectly())
return ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME; return ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
newDoc->ast()->accept(&evaluator); newDoc->ast()->accept(&evaluator);
const bool valid = evaluator.status() == ConnectionEditorEvaluator::Succeeded; const bool valid = evaluator.status() == ConnectionEditorEvaluator::Succeeded;
if (!valid) if (!valid)
return ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME; return ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
auto result = evaluator.resultNode(); auto result = evaluator.resultNode();

View File

@@ -21,8 +21,8 @@ inline constexpr char LOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
"QmlDesigner::ConnectionEditorStatements", "Print"); "QmlDesigner::ConnectionEditorStatements", "Print");
inline constexpr char EMPTY_DISPLAY_NAME[] = QT_TRANSLATE_NOOP( inline constexpr char EMPTY_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
"QmlDesigner::ConnectionEditorStatements", "Empty"); "QmlDesigner::ConnectionEditorStatements", "Empty");
inline constexpr char UNKNOWN_DISPLAY_NAME[] = QT_TRANSLATE_NOOP( inline constexpr char CUSTOM_DISPLAY_NAME[] = QT_TRANSLATE_NOOP(
"QmlDesigner::ConnectionEditorStatements", "Unknown"); "QmlDesigner::ConnectionEditorStatements", "Custom");
struct Variable; struct Variable;
struct MatchedFunction; struct MatchedFunction;

View File

@@ -105,10 +105,10 @@ void tst_ConnectionEditor::invalidSyntax()
= "{someItem.complexCall(blah)}"; //valid QML bit not valid for ConnectionEditor = "{someItem.complexCall(blah)}"; //valid QML bit not valid for ConnectionEditor
QString result = ConnectionEditorEvaluator::getDisplayStringForType(statement1); QString result = ConnectionEditorEvaluator::getDisplayStringForType(statement1);
QCOMPARE(result, ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME); QCOMPARE(result, ConnectionEditorStatements::CUSTOM_DISPLAY_NAME);
result = ConnectionEditorEvaluator::getDisplayStringForType(statement2); result = ConnectionEditorEvaluator::getDisplayStringForType(statement2);
QCOMPARE(result, ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME); QCOMPARE(result, ConnectionEditorStatements::CUSTOM_DISPLAY_NAME);
auto resultHandler = ConnectionEditorEvaluator::parseStatement(statement1); auto resultHandler = ConnectionEditorEvaluator::parseStatement(statement1);
auto parsedStatement = ConnectionEditorStatements::okStatement(resultHandler); auto parsedStatement = ConnectionEditorStatements::okStatement(resultHandler);
@@ -169,14 +169,14 @@ void tst_ConnectionEditor::displayStrings_data()
QTest::newRow("Custom function call assignment") QTest::newRow("Custom function call assignment")
<< "{someItem.color = item.functionCall()}" << "{someItem.color = item.functionCall()}"
<< ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME; << ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
QTest::newRow("Custom function call with argument") QTest::newRow("Custom function call with argument")
<< "{someItem.color = item.functionCall(\"test\")}" << "{someItem.color = item.functionCall(\"test\")}"
<< ConnectionEditorStatements::UNKNOWN_DISPLAY_NAME; << ConnectionEditorStatements::CUSTOM_DISPLAY_NAME;
QTest::newRow("Custom function call with argument 2") 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() void tst_ConnectionEditor::parseAssignment()