MCPcopy Create free account
hub / github.com/GilesBathgate/RapCAD / getSaveFileName

Method getSaveFileName

src/ui/mainwindow.cpp:328–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328QString MainWindow::getSaveFileName(QWidget* parent,const QString& caption,const QString& dir,const QString& filter,const QString& suffix)
329{
330 QFileDialog dialog(parent,caption,dir,filter);
331 dialog.setDefaultSuffix(suffix);
332 dialog.setOption(QFileDialog::DontConfirmOverwrite,true);
333 dialog.setAcceptMode(QFileDialog::AcceptSave);
334 while (dialog.exec() == QDialog::Accepted) {
335 const auto& selected=dialog.selectedFiles();
336 QString fileName=selected.first();
337 QFileInfo info(fileName);
338 if(!info.exists())
339 return fileName;
340
341 auto result=QMessageBox::warning(parent,caption,
342 tr("A file named \"%1\" already exists. Do you want to replace it?").arg(info.fileName()),
343 QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,QMessageBox::No);
344 if(result==QMessageBox::Cancel) break;
345 if(result==QMessageBox::Yes) return fileName;
346 }
347 return QString();
348}
349
350void MainWindow::exportFile(const QString& type)
351{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected