From 380dcb660daf6692a907985d99d1404af94e314f Mon Sep 17 00:00:00 2001 From: Jonas Kalinka Date: Fri, 16 Feb 2024 15:08:30 +0100 Subject: [PATCH 1/3] added qmlformating --- 029_tool.qml_code_formatting.md | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 029_tool.qml_code_formatting.md diff --git a/029_tool.qml_code_formatting.md b/029_tool.qml_code_formatting.md new file mode 100644 index 0000000..21722fa --- /dev/null +++ b/029_tool.qml_code_formatting.md @@ -0,0 +1,36 @@ +# Tool QML code formatting + +## Goals +Keep code readable/consistent + +## Description +Apply an (semi)automated mechanism to keep your QML code readable/consistent. This tool is about formatting, not structure of your code. Qt provides the [`qmlfomat`](https://doc.qt.io/qt-6/qtquick-tools-and-utilities.html#qmlformat) tool as a cli-utility or directly integrated in QtCreator to streamline QML development. + +## Environment +QML + +## Platform +All + +## Implementation effort +Minimal + +## Applicability +Applicable to code that has just been written by yourself. Don't blindly reformat code! Reformatting code without careful consideration makes tracking changes more difficult, and disrupt the work of others who may be using the same code. + +## Caveats +\- + +## Limitations + - QtCreators `Tools > QML/JS > Reformat file` doesn't allow to reformat only selected text + +## See also + +## Implementation hints +At project start decide which code formatting to use. We ask the customer if there are in-house styles which should be implemented. If the customer doesn't care, we will use the official Qt QML code style. + +Use IDE to apply code formatting while writing (in QtCreator: `Options > Qt Quick > Code Style`). + +If a custom format shall be used, put a custom .qmlformat.ini in your repository, so every developer has the same settings applied. The default settings can be exported using `qmlformat --write-defaults` to start from there. + +To reformat whole QML files hit `Tools > QML/JS > Reformat file`, which isn't recommended because it can potentially lead to commits containing changes that are unrelated to the actual change. \ No newline at end of file From d1a3e3542fb0ee5b52866a3ad196de2fea0160f6 Mon Sep 17 00:00:00 2001 From: Jonas Kalinka Date: Mon, 19 Feb 2024 11:31:05 +0100 Subject: [PATCH 2/3] add link to c++ code formatting --- 029_tool.qml_code_formatting.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/029_tool.qml_code_formatting.md b/029_tool.qml_code_formatting.md index 21722fa..1190f9d 100644 --- a/029_tool.qml_code_formatting.md +++ b/029_tool.qml_code_formatting.md @@ -26,6 +26,8 @@ Applicable to code that has just been written by yourself. Don't blindly reforma ## See also +- [C/C++ code formatting](https://toobox.basyskom.com/26) + ## Implementation hints At project start decide which code formatting to use. We ask the customer if there are in-house styles which should be implemented. If the customer doesn't care, we will use the official Qt QML code style. From 0922d9a5a8c424644aff986aa030c2dc7804ede9 Mon Sep 17 00:00:00 2001 From: Jonas Kalinka Date: Mon, 19 Feb 2024 18:01:14 +0100 Subject: [PATCH 3/3] removed 'tool' from title --- 029_tool.qml_code_formatting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/029_tool.qml_code_formatting.md b/029_tool.qml_code_formatting.md index 1190f9d..1b0deb9 100644 --- a/029_tool.qml_code_formatting.md +++ b/029_tool.qml_code_formatting.md @@ -1,4 +1,4 @@ -# Tool QML code formatting +# QML code formatting ## Goals Keep code readable/consistent