json_edit_dialog.h 709 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <QDialog>
  3. #include <QJsonObject>
  4. #include <QPlainTextEdit>
  5. #include <QPushButton>
  6. namespace MapEditor {
  7. class JsonEditDialog : public QDialog {
  8. Q_OBJECT
  9. public:
  10. explicit JsonEditDialog(const QString &title, const QJsonObject &json,
  11. QWidget *parent = nullptr);
  12. [[nodiscard]] QJsonObject getJson() const;
  13. [[nodiscard]] bool isValid() const { return m_isValid; }
  14. private slots:
  15. void validateJson();
  16. void onAccepted();
  17. private:
  18. void setupUI(const QString &title, const QJsonObject &json);
  19. QPlainTextEdit *m_editor = nullptr;
  20. QPushButton *m_okButton = nullptr;
  21. QJsonObject m_result;
  22. bool m_isValid = false;
  23. };
  24. } // namespace MapEditor