void ImportExportGadgetWidget::on_exportButton_clicked() { QString file = filename; QString filter = tr("GCS Settings file (*.xml)"); file = QFileDialog::getSaveFileName(this, tr("Save GCS Settings too file .."), QFileInfo(file).absoluteFilePath(), filter).trimmed(); if (file.isEmpty()) { return; } // Add a "XML" extension to the file in case it does not exist: if (!file.toLower().endsWith(".xml")) file.append(".xml"); filename = file; qDebug() << "Export pressed! Write to file " << QFileInfo(file).absoluteFilePath(); QMessageBox msgBox; QDir dir = QFileInfo(file).absoluteDir(); if (! dir.exists()) { msgBox.setText(tr("Can't write file ") + QFileInfo(file).absoluteFilePath() + " since directory "+ dir.absolutePath() + " doesn't exist!"); msgBox.exec(); return; } exportConfiguration(file); msgBox.setText(tr("The settings have been exported to ") + QFileInfo(file).absoluteFilePath()); msgBox.exec(); emit done(); }
void World::menuChoice(int n) { BuildingBlock *bb = getSelectedBuildingBlock(); switch (n) { case 1 : { OUTPUT << "ADD block link to : " << bb->blockId << " num Face : " << numSelectedFace << endl; vector<Cell3DPosition> nCells = lattice->getRelativeConnectivity(bb->position); Cell3DPosition nPos = bb->position + nCells[numSelectedFace]; addBlock(0, bb->buildNewBlockCode, nPos, bb->color); linkBlock(nPos); linkNeighbors(nPos); } break; case 2 : { OUTPUT << "DEL num block : " << tabGlBlocks[numSelectedGlBlock]->blockId << endl; deleteBlock(bb); } break; case 3 : { tapBlock(getScheduler()->now(), bb->blockId, numSelectedFace); } break; case 4: // Save current configuration exportConfiguration(); break; } }