comparison widgets/InteractiveFileFinder.cpp @ 760:d0fd7630d32f tonioni

Make session file extension parameterisable, use .ton for Tony
author Chris Cannam
date Wed, 02 Apr 2014 18:22:41 +0100
parents 52e5f6fe31ad
children 6d95d87f1654
comparison
equal deleted inserted replaced
759:30bc7b2155dc 760:d0fd7630d32f
31 31
32 InteractiveFileFinder 32 InteractiveFileFinder
33 InteractiveFileFinder::m_instance; 33 InteractiveFileFinder::m_instance;
34 34
35 InteractiveFileFinder::InteractiveFileFinder() : 35 InteractiveFileFinder::InteractiveFileFinder() :
36 m_sessionExtension("sv"),
36 m_lastLocatedLocation("") 37 m_lastLocatedLocation("")
37 { 38 {
38 SVDEBUG << "Registering interactive file finder" << endl; 39 SVDEBUG << "Registering interactive file finder" << endl;
39 FileFinder::registerFileFinder(this); 40 FileFinder::registerFileFinder(this);
40 } 41 }
41 42
42 InteractiveFileFinder::~InteractiveFileFinder() 43 InteractiveFileFinder::~InteractiveFileFinder()
43 { 44 {
45 }
46
47 void
48 InteractiveFileFinder::setApplicationSessionExtension(QString extension)
49 {
50 m_sessionExtension = extension;
44 } 51 }
45 52
46 QString 53 QString
47 InteractiveFileFinder::getOpenFileName(FileType type, QString fallbackLocation) 54 InteractiveFileFinder::getOpenFileName(FileType type, QString fallbackLocation)
48 { 55 {
55 switch (type) { 62 switch (type) {
56 63
57 case SessionFile: 64 case SessionFile:
58 settingsKey = "sessionpath"; 65 settingsKey = "sessionpath";
59 title = tr("Select a session file"); 66 title = tr("Select a session file");
60 filter = tr("Sonic Visualiser session files (*.sv)\nRDF files (%1)\nAll files (*.*)").arg(RDFImporter::getKnownExtensions()); 67 filter = tr("%1 session files (*.%1)\nRDF files (%3)\nAll files (*.*)")
68 .arg(QApplication::applicationName())
69 .arg(m_sessionExtension)
70 .arg(RDFImporter::getKnownExtensions());
61 break; 71 break;
62 72
63 case AudioFile: 73 case AudioFile:
64 settingsKey = "audiopath"; 74 settingsKey = "audiopath";
65 title = "Select an audio file"; 75 title = "Select an audio file";
95 .arg(RDFImporter::getKnownExtensions()); 105 .arg(RDFImporter::getKnownExtensions());
96 break; 106 break;
97 107
98 case SessionOrAudioFile: 108 case SessionOrAudioFile:
99 settingsKey = "lastpath"; 109 settingsKey = "lastpath";
100 filter = tr("All supported files (*.sv %1 %2)\nSonic Visualiser session files (*.sv)\nAudio files (%2)\nRDF files (%1)\nAll files (*.*)") 110 filter = tr("All supported files (*.sv %1 %2)\n%3 session files (*.%4)\nAudio files (%2)\nRDF files (%1)\nAll files (*.*)")
101 .arg(RDFImporter::getKnownExtensions()) 111 .arg(RDFImporter::getKnownExtensions())
102 .arg(AudioFileReaderFactory::getKnownExtensions()); 112 .arg(AudioFileReaderFactory::getKnownExtensions())
113 .arg(QApplication::applicationName())
114 .arg(m_sessionExtension);
103 break; 115 break;
104 116
105 case ImageFile: 117 case ImageFile:
106 settingsKey = "imagepath"; 118 settingsKey = "imagepath";
107 { 119 {
121 filter = tr("Comma-separated data files (*.csv)\nSpace-separated .lab files (*.lab)\nText files (*.txt)\nAll files (*.*)"); 133 filter = tr("Comma-separated data files (*.csv)\nSpace-separated .lab files (*.lab)\nText files (*.txt)\nAll files (*.*)");
122 break; 134 break;
123 135
124 case AnyFile: 136 case AnyFile:
125 settingsKey = "lastpath"; 137 settingsKey = "lastpath";
126 filter = tr("All supported files (*.sv %1 %2 %3)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nLayer files (%2)\nRDF files (%3)\nAll files (*.*)") 138 filter = tr("All supported files (*.sv %1 %2 %3)\n%4 session files (*.%5)\nAudio files (%1)\nLayer files (%2)\nRDF files (%3)\nAll files (*.*)")
127 .arg(AudioFileReaderFactory::getKnownExtensions()) 139 .arg(AudioFileReaderFactory::getKnownExtensions())
128 .arg(DataFileReaderFactory::getKnownExtensions()) 140 .arg(DataFileReaderFactory::getKnownExtensions())
129 .arg(RDFImporter::getKnownExtensions()); 141 .arg(RDFImporter::getKnownExtensions())
142 .arg(QApplication::applicationName())
143 .arg(m_sessionExtension);
130 break; 144 break;
131 }; 145 };
132 146
133 if (lastPath == "") { 147 if (lastPath == "") {
134 char *home = getenv("HOME"); 148 char *home = getenv("HOME");
214 switch (type) { 228 switch (type) {
215 229
216 case SessionFile: 230 case SessionFile:
217 settingsKey = "savesessionpath"; 231 settingsKey = "savesessionpath";
218 title = tr("Select a session file"); 232 title = tr("Select a session file");
219 filter = tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)"); 233 filter = tr("%1 session files (*.%2)\nAll files (*.*)")
234 .arg(QApplication::applicationName()).arg(m_sessionExtension);
220 break; 235 break;
221 236
222 case AudioFile: 237 case AudioFile:
223 settingsKey = "saveaudiopath"; 238 settingsKey = "saveaudiopath";
224 title = "Select an audio file"; 239 title = "Select an audio file";
298 dialog.setAcceptMode(QFileDialog::AcceptSave); 313 dialog.setAcceptMode(QFileDialog::AcceptSave);
299 dialog.setFileMode(QFileDialog::AnyFile); 314 dialog.setFileMode(QFileDialog::AnyFile);
300 dialog.setConfirmOverwrite(false); // we'll do that 315 dialog.setConfirmOverwrite(false); // we'll do that
301 316
302 if (type == SessionFile) { 317 if (type == SessionFile) {
303 dialog.setDefaultSuffix("sv"); 318 dialog.setDefaultSuffix(m_sessionExtension);
304 } else if (type == AudioFile) { 319 } else if (type == AudioFile) {
305 dialog.setDefaultSuffix("wav"); 320 dialog.setDefaultSuffix("wav");
306 } else if (type == ImageFile) { 321 } else if (type == ImageFile) {
307 dialog.setDefaultSuffix("png"); 322 dialog.setDefaultSuffix("png");
308 } else if (type == CSVFile) { 323 } else if (type == CSVFile) {