Extending Project Settings Panel

Panel Introduction

Project Settings holds the configuration related to the project operation, which is stored in the settings folder under the project directory and needs to be included in the version management, so that multiple people can share the configuration, otherwise it may lead to inconsistent operation on different machines.

The Projects -> Projects Settings menu can be found in the top menu bar, as shown below:

project-settings-menu

Click on it to open the settings panel, as shown in the following figure:s

project-settings-panel

On the left side of the project settings panel is the function module tab, and on the right side is the configuration modification interface for the corresponding function.

We can add custom configurations to the project by customizing the display data in this panel, and visualize and manage the project configuration with the help of the project settings panel.

If you want to take effect for all projects, you need to customize the editor-related configuration, please refer to the document Extending the Preferences Panel.

The Custom Item Settings function allows a we to register multiple tabs, so there will be a small line on the left tab indicating which function the tab belongs to.

Data Configuration and Display

Custom project settings need to rely on data configuration, you need to define the relevant data fields in contributions.profile.project first.

Note: The configuration data in the project settings should be stored in the profile.project field.

Once the data fields are defined, you also need to define the data to be displayed and the UI components to be used to display it in the contributions.project field. This is shown below.

  1. // package.json
  2. {
  3. "name": "project-test",
  4. "contributions": {
  5. "profile": {
  6. "project": {
  7. "foo": {
  8. "default": 1
  9. },
  10. "foo1": {
  11. "default": 0.4
  12. },
  13. "foo2": {
  14. "default": false
  15. },
  16. "foo3": {
  17. "default": 0
  18. },
  19. "foo4": {
  20. "default": "label"
  21. }
  22. }
  23. },
  24. "project": {
  25. "tab1": {
  26. "label": "test",
  27. "content": {
  28. "foo": {
  29. "ui": "ui-num-input"
  30. },
  31. "foo1": {
  32. "ui": "ui-slider",
  33. "attributes": {
  34. "min": 0,
  35. "max": 1,
  36. "step": 0.1
  37. }
  38. },
  39. "foo2": {
  40. "ui": "ui-checkbox"
  41. },
  42. "foo3": {
  43. "ui": "ui-select",
  44. "items": [
  45. {
  46. "value": 0,
  47. "label": "ITEM 0"
  48. },
  49. {
  50. "value": 1,
  51. "label": "ITEM 1"
  52. },
  53. {
  54. "value": 2,
  55. "label": "ITEM 2"
  56. }
  57. ]
  58. }
  59. }
  60. },
  61. "tab2": {
  62. "label": "test2",
  63. "content": {
  64. "foo4": {
  65. "ui": "ui-input"
  66. }
  67. },
  68. "foo2": {
  69. "ui": "ui-checkbox"
  70. },
  71. "foo3": {
  72. "ui": "ui-select",
  73. "items": [
  74. {
  75. "value": 0,
  76. "label": "ITEM 0"
  77. },
  78. {
  79. "value": 1,
  80. "label": "ITEM 1"
  81. },
  82. {
  83. "value": 2,
  84. "label": "ITEM 2"
  85. }
  86. ]
  87. }
  88. },
  89. "tab1": {
  90. "label": "test"
  91. }
  92. }
  93. }
  94. }

In the above example, 4 data items are defined in the contributions.profile.project field: foo, foo1, foo2, foo3.

For more information on how to define profile related configuration, please refer to Configuration System.

There are 2 tabs defined in the contributions.project field: test, tes2.

In the test tab, each of the 4 data items is configured, see UI Component Configuration later for the specific configuration properties.

After refreshing the extension in the Extension Manager list, open the Project Settings Panel again via the Project -> Project Settings menu to see the following screen.

project-settings-panel-custom

UI Component Configuration

This example shows the usage of 4 common UI components in customizing the project settings panel, in theory all UI components with value attribute can be used in customizing the project settings panel, please refer to the documentation UI Components.