Skip to content

Commit

Permalink
feat: Add the text option for QJsonSchemaString to handle multipl…
Browse files Browse the repository at this point in the history
…e lines of text
  • Loading branch information
zmoth committed Sep 18, 2023
1 parent fa99887 commit 23f76a7
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 146 deletions.
18 changes: 17 additions & 1 deletion examples/Simple/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ const std::string jsonText = R"(
{
"type": "object",
"title": "Json Example",
"ui:order": ["str", "enum", "file", "dir", "num", "range", "arr", "obj"],
"ui:order": [
"str",
"text",
"enum",
"file",
"dir",
"num",
"range",
"arr",
"obj"
],
"properties": {
"invisible": {
"ui:visible": false,
Expand All @@ -27,6 +37,12 @@ const std::string jsonText = R"(
"default": "hello world",
"description": "This is a tooltip"
},
"text": {
"type": "string",
"ui:widget": "text",
"default": "hello world",
"description": "This is a tooltip"
},
"enum": {
"type": "string",
"default": "hello world",
Expand Down
12 changes: 2 additions & 10 deletions include/QJsonSchemaForm/QJsonSchemaWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
QT_BEGIN_NAMESPACE

class QComboBox;
class QLineEdit;
class QPushButton;
class QCheckBox;
class QAbstractButton;
class QDateEdit;
class QFormLayout;
class QToolButton;
class QListWidget;
Expand Down Expand Up @@ -129,12 +125,8 @@ class QJsonSchemaString : public QJsonSchemaWidget
[[nodiscard]] QJsonValue getValue() const override;
void setValue(const QString &) const;

QComboBox *combo = nullptr;
QLineEdit *widget = nullptr;
QPushButton *fileButton = nullptr;
QPushButton *dirButton = nullptr;
QPushButton *colorButton = nullptr;
QDateEdit *dateEdit = nullptr;
private:
QWidget *_widget{nullptr};
};

/// @brief 布尔
Expand Down
6 changes: 6 additions & 0 deletions json/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"default": "dragonborn",
"description": "String choice with default value"
},
"text": {
"type": "string",
"ui:widget": "text",
"default": "{\n文本\n}",
"description": "文本编辑器"
},
"string_color": {
"title": "Color",
"type": "string",
Expand Down
18 changes: 17 additions & 1 deletion json/test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"type": "object",
"title": "Json Example",
"ui:order": ["str", "enum", "file", "dir", "num", "range", "arr", "obj"],
"ui:order": [
"str",
"text",
"enum",
"file",
"dir",
"num",
"range",
"arr",
"obj"
],
"properties": {
"invisible": {
"ui:visible": false,
Expand All @@ -13,6 +23,12 @@
"default": "hello world",
"description": "This is a tooltip"
},
"text": {
"type": "string",
"ui:widget": "text",
"default": "hello world",
"description": "This is a tooltip"
},
"enum": {
"type": "string",
"default": "hello world",
Expand Down
Loading

0 comments on commit 23f76a7

Please sign in to comment.