src/mainwindow.cpp

changeset 183
97b591813c8b
parent 178
a23024fc98e0
child 191
d355d4c52d51
equal deleted inserted replaced
182:27fb1c3c9fbb 183:97b591813c8b
77 this, &MainWindow::actionSave); 77 this, &MainWindow::actionSave);
78 connect(this->ui->actionSaveAs, &QAction::triggered, 78 connect(this->ui->actionSaveAs, &QAction::triggered,
79 this, &MainWindow::actionSaveAs); 79 this, &MainWindow::actionSaveAs);
80 connect(this->ui->actionClose, &QAction::triggered, this, &MainWindow::actionClose); 80 connect(this->ui->actionClose, &QAction::triggered, this, &MainWindow::actionClose);
81 connect(this->ui->actionDelete, &QAction::triggered, this, &MainWindow::actionDelete); 81 connect(this->ui->actionDelete, &QAction::triggered, this, &MainWindow::actionDelete);
82 connect(this->ui->actionInvert, &QAction::triggered, this, &MainWindow::actionInvert);
82 connect(this->ui->tabs, &QTabWidget::tabCloseRequested, this, &MainWindow::handleTabCloseButton); 83 connect(this->ui->tabs, &QTabWidget::tabCloseRequested, this, &MainWindow::handleTabCloseButton);
83 for (auto data : ::renderStyleButtons) 84 for (auto data : ::renderStyleButtons)
84 { 85 {
85 QAction* action = data.memberInstance(this->ui.get()); 86 QAction* action = data.memberInstance(this->ui.get());
86 connect(action, &QAction::triggered, [this, data]() 87 connect(action, &QAction::triggered, [this, data]()
377 } 378 }
378 } 379 }
379 } 380 }
380 381
381 /** 382 /**
383 * @brief Handles the "Invert" action
384 */
385 void MainWindow::actionInvert()
386 {
387 Document* document = this->currentDocument();
388 if (document != nullptr)
389 {
390 // TODO: simplify
391 std::unique_ptr<ModelEditor> modelEditor = document->editModel();
392 const std::optional<ModelId> modelId = this->documents.findIdForModel(&modelEditor->model());
393 if (modelId.has_value())
394 {
395 ldraw::GetPolygonsContext context = {
396 .modelId = modelId.value(),
397 .documents = &this->documents,
398 };
399 for (const ldraw::id_t id : document->selectedObjects())
400 {
401 modelEditor->modifyObject(id, [&context](ldraw::Object* object)
402 {
403 object->invert(&context);
404 });
405 }
406 }
407 }
408 }
409
410 /**
382 * @brief Removes the document at the specified tab index 411 * @brief Removes the document at the specified tab index
383 * @param index 412 * @param index
384 */ 413 */
385 void MainWindow::handleTabCloseButton(int tabIndex) 414 void MainWindow::handleTabCloseButton(int tabIndex)
386 { 415 {

mercurial