| 11 | int const ImagePreviewHeight = 600; |
| 12 | |
| 13 | JsonEditor::JsonEditor(JsonPath::PathPtr const& path, Options const& options, List<String> const& files) |
| 14 | : QMainWindow(), m_path(path), m_editFormat(options.editFormat), m_options(options), m_files(files), m_fileIndex(0) { |
| 15 | auto* w = new QWidget(this); |
| 16 | w->setObjectName("background"); |
| 17 | setCentralWidget(w); |
| 18 | setWindowTitle("Json Editor"); |
| 19 | resize(1280, 720); |
| 20 | |
| 21 | auto* layout = new QGridLayout(centralWidget()); |
| 22 | |
| 23 | QFont font("Monospace"); |
| 24 | font.setStyleHint(QFont::StyleHint::Monospace); |
| 25 | |
| 26 | m_jsonDocument = new QTextDocument("Hello world"); |
| 27 | m_jsonDocument->setDefaultFont(font); |
| 28 | |
| 29 | m_statusLabel = new QLabel(centralWidget()); |
| 30 | layout->addWidget(m_statusLabel, 0, 0, 1, 5); |
| 31 | |
| 32 | m_jsonPreview = new QTextEdit(this); |
| 33 | m_jsonPreview->setReadOnly(true); |
| 34 | m_jsonPreview->setDocument(m_jsonDocument); |
| 35 | layout->addWidget(m_jsonPreview, 1, 0, 1, 5); |
| 36 | |
| 37 | m_backButton = new QPushButton(centralWidget()); |
| 38 | m_backButton->setText("« Back"); |
| 39 | layout->addWidget(m_backButton, 2, 0); |
| 40 | connect(m_backButton, SIGNAL(pressed()), this, SLOT(back())); |
| 41 | |
| 42 | m_pathLabel = new QLabel(centralWidget()); |
| 43 | layout->addWidget(m_pathLabel, 2, 1); |
| 44 | |
| 45 | m_imageLabel = new QLabel(centralWidget()); |
| 46 | m_imageLabel->setMaximumSize(ImagePreviewWidth, ImagePreviewHeight); |
| 47 | m_imageLabel->setMinimumSize(ImagePreviewWidth, ImagePreviewHeight); |
| 48 | m_imageLabel->setAlignment(Qt::AlignCenter); |
| 49 | if (!m_options.editorImages.empty()) |
| 50 | layout->addWidget(m_imageLabel, 1, 5); |
| 51 | |
| 52 | m_valueEditor = new QLineEdit(centralWidget()); |
| 53 | m_valueEditor->setFont(font); |
| 54 | layout->addWidget(m_valueEditor, 2, 2); |
| 55 | connect(m_valueEditor, SIGNAL(returnPressed()), this, SLOT(next())); |
| 56 | connect(m_valueEditor, SIGNAL(textChanged(QString const&)), this, SLOT(updatePreview(QString const&))); |
| 57 | |
| 58 | m_nextButton = new QPushButton(centralWidget()); |
| 59 | m_nextButton->setText("Next »"); |
| 60 | m_nextButton->setDefault(true); |
| 61 | layout->addWidget(m_nextButton, 2, 3); |
| 62 | connect(m_nextButton, SIGNAL(pressed()), this, SLOT(next())); |
| 63 | |
| 64 | m_errorDialog = new QErrorMessage(this); |
| 65 | m_errorDialog->setModal(true); |
| 66 | |
| 67 | displayCurrentFile(); |
| 68 | } |
| 69 | |
| 70 | void JsonEditor::next() { |
nothing calls this directly
no test coverage detected