Mercurial > hg > svgui
comparison widgets/InteractiveFileFinder.cpp @ 1324:13d9b422f7fe zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:31 +0100 |
parents | 34b941921ac8 |
children | c8a6fd3f9dff |
comparison
equal
deleted
inserted
replaced
1183:57d192e26331 | 1324:13d9b422f7fe |
---|---|
17 #include "data/fileio/FileSource.h" | 17 #include "data/fileio/FileSource.h" |
18 #include "data/fileio/AudioFileReaderFactory.h" | 18 #include "data/fileio/AudioFileReaderFactory.h" |
19 #include "data/fileio/DataFileReaderFactory.h" | 19 #include "data/fileio/DataFileReaderFactory.h" |
20 #include "rdf/RDFImporter.h" | 20 #include "rdf/RDFImporter.h" |
21 #include "rdf/RDFExporter.h" | 21 #include "rdf/RDFExporter.h" |
22 #include "system/System.h" | |
22 | 23 |
23 #include <QFileInfo> | 24 #include <QFileInfo> |
24 #include <QMessageBox> | 25 #include <QMessageBox> |
25 #include <QFileDialog> | 26 #include <QFileDialog> |
26 #include <QInputDialog> | 27 #include <QInputDialog> |
132 } | 133 } |
133 filter = tr("Image files (%1)\nAll files (*.*)").arg(fmts.join(" ")); | 134 filter = tr("Image files (%1)\nAll files (*.*)").arg(fmts.join(" ")); |
134 } | 135 } |
135 break; | 136 break; |
136 | 137 |
138 case SVGFile: | |
139 settingsKeyStub = "svg"; | |
140 filter = tr("Scalable Vector Graphics files (*.svg)\nAll files (*.*)"); | |
141 break; | |
142 | |
137 case CSVFile: | 143 case CSVFile: |
138 settingsKeyStub = "layer"; | 144 settingsKeyStub = "layer"; |
139 filter = tr("Comma-separated data files (*.csv)\nSpace-separated .lab files (*.lab)\nText files (*.txt)\nAll files (*.*)"); | 145 filter = tr("Comma-separated data files (*.csv)\nSpace-separated .lab files (*.lab)\nText files (*.txt)\nAll files (*.*)"); |
140 break; | 146 break; |
141 | 147 |
149 .arg(m_sessionExtension); | 155 .arg(m_sessionExtension); |
150 break; | 156 break; |
151 }; | 157 }; |
152 | 158 |
153 if (lastPath == "") { | 159 if (lastPath == "") { |
154 char *home = getenv("HOME"); | 160 std::string home; |
155 if (home) lastPath = home; | 161 if (getEnvUtf8("HOME", home)) { |
156 else lastPath = "."; | 162 lastPath = QString::fromStdString(home); |
163 } else { | |
164 lastPath = "."; | |
165 } | |
157 } else if (QFileInfo(lastPath).isDir()) { | 166 } else if (QFileInfo(lastPath).isDir()) { |
158 lastPath = QFileInfo(lastPath).canonicalPath(); | 167 lastPath = QFileInfo(lastPath).canonicalPath(); |
159 } else { | 168 } else { |
160 lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath(); | 169 lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath(); |
161 } | 170 } |
280 settingsKeyStub = "saveimage"; | 289 settingsKeyStub = "saveimage"; |
281 title = tr("Select a file to export to"); | 290 title = tr("Select a file to export to"); |
282 filter = tr("Portable Network Graphics files (*.png)\nAll files (*.*)"); | 291 filter = tr("Portable Network Graphics files (*.png)\nAll files (*.*)"); |
283 break; | 292 break; |
284 | 293 |
294 case SVGFile: | |
295 settingsKeyStub = "savesvg"; | |
296 title = tr("Select a file to export to"); | |
297 filter = tr("Scalable Vector Graphics files (*.svg)\nAll files (*.*)"); | |
298 break; | |
299 | |
285 case CSVFile: | 300 case CSVFile: |
286 settingsKeyStub = "savelayer"; | 301 settingsKeyStub = "savelayer"; |
287 title = tr("Select a file to export to"); | 302 title = tr("Select a file to export to"); |
288 filter = tr("Comma-separated data files (*.csv)\nText files (*.txt)\nAll files (*.*)"); | 303 filter = tr("Comma-separated data files (*.csv)\nText files (*.txt)\nAll files (*.*)"); |
289 break; | 304 break; |
292 cerr << "ERROR: Internal error: InteractiveFileFinder::getSaveFileName: AnyFile cannot be used here" << endl; | 307 cerr << "ERROR: Internal error: InteractiveFileFinder::getSaveFileName: AnyFile cannot be used here" << endl; |
293 abort(); | 308 abort(); |
294 }; | 309 }; |
295 | 310 |
296 if (lastPath == "") { | 311 if (lastPath == "") { |
297 char *home = getenv("HOME"); | 312 std::string home; |
298 if (home) lastPath = home; | 313 if (getEnvUtf8("HOME", home)) { |
299 else lastPath = "."; | 314 lastPath = QString::fromStdString(home); |
315 } else { | |
316 lastPath = "."; | |
317 } | |
300 } else if (QFileInfo(lastPath).isDir()) { | 318 } else if (QFileInfo(lastPath).isDir()) { |
301 lastPath = QFileInfo(lastPath).canonicalPath(); | 319 lastPath = QFileInfo(lastPath).canonicalPath(); |
302 } else { | 320 } else { |
303 lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath(); | 321 lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath(); |
304 } | 322 } |
328 defaultSuffix = m_sessionExtension; | 346 defaultSuffix = m_sessionExtension; |
329 } else if (type == AudioFile) { | 347 } else if (type == AudioFile) { |
330 defaultSuffix = "wav"; | 348 defaultSuffix = "wav"; |
331 } else if (type == ImageFile) { | 349 } else if (type == ImageFile) { |
332 defaultSuffix = "png"; | 350 defaultSuffix = "png"; |
351 } else if (type == SVGFile) { | |
352 defaultSuffix = "svg"; | |
333 } else if (type == CSVFile) { | 353 } else if (type == CSVFile) { |
334 defaultSuffix = "csv"; | 354 defaultSuffix = "csv"; |
335 } | 355 } |
336 | 356 |
337 defaultSuffix = | 357 defaultSuffix = |
448 | 468 |
449 case ImageFile: | 469 case ImageFile: |
450 settingsKeyStub = "image"; | 470 settingsKeyStub = "image"; |
451 break; | 471 break; |
452 | 472 |
473 case SVGFile: | |
474 settingsKeyStub = "svg"; | |
475 break; | |
476 | |
453 case CSVFile: | 477 case CSVFile: |
454 settingsKeyStub = "layer"; | 478 settingsKeyStub = "layer"; |
455 break; | 479 break; |
456 | 480 |
457 case AnyFile: | 481 case AnyFile: |