src/main.cpp

changeset 329
6d75fa09cc0c
parent 328
3ea38fd469ca
child 330
edb6c09cdd3c
equal deleted inserted replaced
328:3ea38fd469ca 329:6d75fa09cc0c
331 ui->toolWidgetStack->setCurrentIndex(i); 331 ui->toolWidgetStack->setCurrentIndex(i);
332 }); 332 });
333 } 333 }
334 } 334 }
335 335
336 static QFont monospace()
337 {
338 QFont font{"Monospace"};
339 font.setStyleHint(QFont::TypeWriter);
340 font.setPointSize(10);
341 font.setFixedPitch(true);
342 return font;
343 }
344
336 constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b) 345 constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b)
337 { 346 {
338 return a.row() < b.row(); 347 return a.row() < b.row();
339 } 348 }
340 349
427 ColorTable colorTable; 436 ColorTable colorTable;
428 gl::RenderPreferences renderPreferences; 437 gl::RenderPreferences renderPreferences;
429 MessageLog messageLog; 438 MessageLog messageLog;
430 Signal settingsChanged; 439 Signal settingsChanged;
431 ui.setupUi(&mainWindow); 440 ui.setupUi(&mainWindow);
432 QFont monospace{"Monospace"};
433 monospace.setStyleHint(QFont::TypeWriter);
434 monospace.setPointSize(10);
435 monospace.setFixedPitch(true);
436 ui.modelEdit->setFont(monospace);
437 ToolWidgets toolWidgets{ 441 ToolWidgets toolWidgets{
438 .circleToolOptions = new CircleToolOptionsWidget{&mainWindow}, 442 .circleToolOptions = new CircleToolOptionsWidget{&mainWindow},
439 .objectEditor = new ObjectEditor{&mainWindow}, 443 .objectEditor = new ObjectEditor{&mainWindow},
440 }; 444 };
441 const auto updateTitle = [&ui, &mainWindow]{ 445 const auto updateTitle = [&ui, &mainWindow]{
524 QString modeltext; 528 QString modeltext;
525 QTextStream stream{&modeltext}; 529 QTextStream stream{&modeltext};
526 ::save(*model, &stream); 530 ::save(*model, &stream);
527 data->textbuffer = std::make_unique<QTextDocument>(); 531 data->textbuffer = std::make_unique<QTextDocument>();
528 data->textbuffer->setPlainText(modeltext); 532 data->textbuffer->setPlainText(modeltext);
533 data->textbuffer->setDefaultFont(monospace());
529 data->textbuffer->setDocumentLayout(new QPlainTextDocumentLayout(data->textbuffer.get())); 534 data->textbuffer->setDocumentLayout(new QPlainTextDocumentLayout(data->textbuffer.get()));
530 data->textcursor = std::make_unique<QTextCursor>(data->textbuffer.get()); 535 data->textcursor = std::make_unique<QTextCursor>(data->textbuffer.get());
531 documents.setModelPayload(modelId, data); 536 documents.setModelPayload(modelId, data);
532 QObject::connect( 537 QObject::connect(
533 data->tools.get(), 538 data->tools.get(),
774 model->clear(); 779 model->clear();
775 QString text = ui.modelEdit->toPlainText(); 780 QString text = ui.modelEdit->toPlainText();
776 QTextStream stream{&text}; 781 QTextStream stream{&text};
777 Parser parser(stream); 782 Parser parser(stream);
778 parser.parseBody(*data->model); 783 parser.parseBody(*data->model);
784 documents.loadDependenciesForAllModels(libraries);
779 data->canvas->update(); 785 data->canvas->update();
780 } 786 }
781 }); 787 });
782 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock); 788 mainWindow.tabifyDockWidget(ui.messageLogDock, ui.toolOptionsDock);
783 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); 789 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>());

mercurial