// ==================================================================================================================== // autoSaveLayout(): Called automatically upon exiting, using a hardcoded file name // ==================================================================================================================== void MainWindow::autoSaveLayout() { QString fileName = "TinScript_Auto_Layout.cfg"; QFile file(fileName); if (!file.open(QFile::WriteOnly)) return; writeLayout(file); }
ObjectWidget::ObjectWidget(const SceneObject& object, QWidget* parent) : DockWidget(object, parent), objectRenderer(Document::document->getSimulation(), object.name.toAscii().constData()), objectGlWidget(0), showSensorsAct(0), showDrawingsAct(0) { connect(Document::document, SIGNAL(updatedSceneGraph()), this, SLOT(updateObject())); connect(Document::document, SIGNAL(restoreLayoutSignal()), this, SLOT(restoreLayout())); connect(Document::document, SIGNAL(writeLayoutSignal()), this, SLOT(writeLayout())); connect(Document::document, SIGNAL(updateViewsSignal()), this, SLOT(updateView())); updateObject(); }
// ==================================================================================================================== // menuSaveLayout(): The slot called by selecting the menu option to save the layout // ==================================================================================================================== void MainWindow::menuSaveLayout() { QString fileName = QFileDialog::getSaveFileName(this, tr("Save layout")); if (fileName.isEmpty()) return; QFile file(fileName); if (!file.open(QFile::WriteOnly)) { QString msg = tr("Failed to open %1\n%2") .arg(fileName) .arg(file.errorString()); QMessageBox::warning(this, tr("Error"), msg); return; } // -- write the layout to the opened file writeLayout(file); }