void MainWindow::deleteSelectedInstructions() { if (!project()) { return; } if (decompileAutomatically()) { project()->cancelAll(); } project()->deleteInstructions(instructionsView_->selectedInstructions()); if (decompileAutomatically()) { project()->decompile(); } }
void MainWindow::disassembleSelectedSectionRange() { if (!project()) { return; } if (decompileAutomatically()) { project()->cancelAll(); } project()->disassemble(disassemblyDialog_->selectedSection(), *disassemblyDialog_->startAddress(), *disassemblyDialog_->endAddress()); if (decompileAutomatically()) { project()->decompile(); } }
void MainWindow::saveSettings() { if (parent() == nullptr) { settings_->setValue("geometry", saveGeometry()); } settings_->setValue("windowState", saveState()); settings_->setValue("decompileAutomatically", decompileAutomatically()); foreach (QObject *child, children()) { if (auto textView = qobject_cast<TextView *>(child)) { if (!textView->objectName().isEmpty()) { settings_->setValue(textView->objectName() + ".font", textView->documentFont()); } } else if (auto treeView = qobject_cast<TreeView *>(child)) { if (!treeView->objectName().isEmpty()) { settings_->setValue(treeView->objectName() + ".font", treeView->documentFont()); } } } }
void MainWindow::open(const QStringList &filenames) { if (filenames.empty()) { return; } auto context = std::make_shared<core::Context>(); context->setLogToken(logToken_); foreach (const QString &filename, filenames) { try { core::Driver::parse(*context, filename); } catch (const nc::Exception &e) { QMessageBox::critical(this, tr("Error"), e.unicodeWhat()); return; } catch (const std::exception &e) { QMessageBox::critical(this, tr("Error"), e.what()); return; } } auto project = std::make_unique<gui::Project>(); project->setName(QFileInfo(filenames.front()).fileName()); project->setContext(context); project->setImage(context->image()); project->setInstructions(context->instructions()); open(std::move(project)); if (project_->instructions()->empty()) { project_->disassemble(); } if (decompileAutomatically()) { project_->decompile(); } }