fix(cpn): Use correct file types/extensions on Save and Export (#3025)
This commit is contained in:
+24
-10
@@ -1250,12 +1250,20 @@ bool MdiChild::saveAs(bool isNew)
|
|||||||
{
|
{
|
||||||
forceNewFilename();
|
forceNewFilename();
|
||||||
QFileInfo fi(curFile);
|
QFileInfo fi(curFile);
|
||||||
QString filter(ETX_FILES_FILTER % YML_FILES_FILTER);
|
QString filter(ETX_FILES_FILTER);
|
||||||
|
QString fileName;
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" + fi.fileName(), filter);
|
do
|
||||||
if (fileName.isEmpty())
|
{
|
||||||
return false;
|
fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.eepromDir() + "/" + fi.fileName(), filter);
|
||||||
g.eepromDir( QFileInfo(fileName).dir().absolutePath() );
|
if (fileName.isEmpty())
|
||||||
|
return false;
|
||||||
|
if (QFileInfo(fileName).suffix().toLower() != "etx")
|
||||||
|
QMessageBox::critical(this, CPN_STR_TTL_ERROR, tr("Invalid file extension!"));
|
||||||
|
}
|
||||||
|
while (QFileInfo(fileName).suffix().toLower() != "etx");
|
||||||
|
|
||||||
|
g.eepromDir(QFileInfo(fileName).dir().absolutePath());
|
||||||
|
|
||||||
return saveFile(fileName, true);
|
return saveFile(fileName, true);
|
||||||
}
|
}
|
||||||
@@ -1707,13 +1715,19 @@ unsigned MdiChild::exportModels(const QVector<int> modelIndices)
|
|||||||
const QString path(QDir::toNativeSeparators(g.profile[g.id()].sdPath() + "/TEMPLATES/" + QString(radioData.models[idx].name) + ".yml"));
|
const QString path(QDir::toNativeSeparators(g.profile[g.id()].sdPath() + "/TEMPLATES/" + QString(radioData.models[idx].name) + ".yml"));
|
||||||
qDebug() << path;
|
qDebug() << path;
|
||||||
|
|
||||||
QString filename = QFileDialog::getSaveFileName(this, tr("Export model"), path, YML_FILES_FILTER);
|
QString filename;
|
||||||
|
|
||||||
if (filename.isEmpty())
|
do
|
||||||
return false;
|
{
|
||||||
|
filename = QFileDialog::getSaveFileName(this, tr("Export model"), path, YML_FILES_FILTER);
|
||||||
|
|
||||||
if (QFileInfo(filename).suffix() != "yml")
|
if (filename.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (QFileInfo(filename).suffix().toLower() != "yml")
|
||||||
|
QMessageBox::critical(this, CPN_STR_TTL_ERROR, tr("Invalid file extension!"));
|
||||||
|
}
|
||||||
|
while (QFileInfo(filename).suffix().toLower() != "yml");
|
||||||
|
|
||||||
Storage storage(filename);
|
Storage storage(filename);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user