comparison main/MainWindow.cpp @ 294:975f6b6c414c sv-v1.4 sv-v1.4rc1

* Improvements to importer feedback dialogs and suchlike
author Chris Cannam
date Fri, 05 Dec 2008 18:45:49 +0000
parents f262f283a655
children 75c32cc2814a
comparison
equal deleted inserted replaced
293:c4bc499122ec 294:975f6b6c414c
2180 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path)); 2180 tr("<b>File open failed</b><p>Layer file %1 could not be opened.").arg(path));
2181 return; 2181 return;
2182 } else if (status == FileOpenWrongMode) { 2182 } else if (status == FileOpenWrongMode) {
2183 emit hideSplash(); 2183 emit hideSplash();
2184 QMessageBox::critical(this, tr("Failed to open file"), 2184 QMessageBox::critical(this, tr("Failed to open file"),
2185 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data")); 2185 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
2186 } 2186 }
2187 } 2187 }
2188 } 2188 }
2189 2189
2190 void 2190 void
2480 QMessageBox::critical(this, tr("Failed to open file"), 2480 QMessageBox::critical(this, tr("Failed to open file"),
2481 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path)); 2481 tr("<b>File open failed</b><p>File \"%1\" could not be opened").arg(path));
2482 } else if (status == FileOpenWrongMode) { 2482 } else if (status == FileOpenWrongMode) {
2483 emit hideSplash(); 2483 emit hideSplash();
2484 QMessageBox::critical(this, tr("Failed to open file"), 2484 QMessageBox::critical(this, tr("Failed to open file"),
2485 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data")); 2485 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
2486 } 2486 }
2487 } 2487 }
2488 2488
2489 void 2489 void
2490 MainWindow::openLocation() 2490 MainWindow::openLocation()
2512 QMessageBox::critical(this, tr("Failed to open location"), 2512 QMessageBox::critical(this, tr("Failed to open location"),
2513 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text)); 2513 tr("<b>Open failed</b><p>URL \"%1\" could not be opened").arg(text));
2514 } else if (status == FileOpenWrongMode) { 2514 } else if (status == FileOpenWrongMode) {
2515 emit hideSplash(); 2515 emit hideSplash();
2516 QMessageBox::critical(this, tr("Failed to open location"), 2516 QMessageBox::critical(this, tr("Failed to open location"),
2517 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data")); 2517 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(text));
2518 } 2518 }
2519 } 2519 }
2520 2520
2521 void 2521 void
2522 MainWindow::openRecentFile() 2522 MainWindow::openRecentFile()
2540 QMessageBox::critical(this, tr("Failed to open location"), 2540 QMessageBox::critical(this, tr("Failed to open location"),
2541 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path)); 2541 tr("<b>Open failed</b><p>File or URL \"%1\" could not be opened").arg(path));
2542 } else if (status == FileOpenWrongMode) { 2542 } else if (status == FileOpenWrongMode) {
2543 emit hideSplash(); 2543 emit hideSplash();
2544 QMessageBox::critical(this, tr("Failed to open location"), 2544 QMessageBox::critical(this, tr("Failed to open location"),
2545 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data")); 2545 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(path));
2546 } 2546 }
2547 } 2547 }
2548 2548
2549 void 2549 void
2550 MainWindow::paneAdded(Pane *pane) 2550 MainWindow::paneAdded(Pane *pane)
2578 QMessageBox::critical(this, tr("Failed to open dropped URL"), 2578 QMessageBox::critical(this, tr("Failed to open dropped URL"),
2579 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i)); 2579 tr("<b>Open failed</b><p>Dropped URL \"%1\" could not be opened").arg(*i));
2580 } else if (status == FileOpenWrongMode) { 2580 } else if (status == FileOpenWrongMode) {
2581 emit hideSplash(); 2581 emit hideSplash();
2582 QMessageBox::critical(this, tr("Failed to open dropped URL"), 2582 QMessageBox::critical(this, tr("Failed to open dropped URL"),
2583 tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data")); 2583 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(*i));
2584 } 2584 }
2585 } 2585 }
2586 } 2586 }
2587 2587
2588 void 2588 void
2726 // else cancel 2726 // else cancel
2727 return false; 2727 return false;
2728 } 2728 }
2729 2729
2730 bool 2730 bool
2731 MainWindow::shouldCreateNewSessionForRDFAudio() 2731 MainWindow::shouldCreateNewSessionForRDFAudio(bool *cancel)
2732 { 2732 {
2733 QMessageBox mb; 2733 //!!! This is very similar to part of MainWindowBase::openAudio --
2734 mb.setWindowTitle("Open as new session?"); 2734 //!!! make them a bit more uniform
2735 mb.setText("<b>RDF refers to audio files</b><p>This RDF document refers to one or more audio files.<br>Do you want to start a new session for it?"); 2735
2736 QPushButton *a = mb.addButton(tr("Create new session"), QMessageBox::AcceptRole); 2736 QSettings settings;
2737 QPushButton *b = mb.addButton(tr("Add to current session"), QMessageBox::RejectRole); 2737 settings.beginGroup("MainWindow");
2738 mb.setDefaultButton(a); 2738 bool prevNewSession = settings.value("newsessionforrdfaudio", true).toBool();
2739 mb.exec(); 2739 settings.endGroup();
2740 if (mb.clickedButton() == a) { 2740 bool newSession = true;
2741 return true; 2741
2742 } else { 2742 QStringList items;
2743 items << tr("Close the current session and create a new one")
2744 << tr("Add this data to the current session");
2745
2746 bool ok = false;
2747 QString item = ListInputDialog::getItem
2748 (this, tr("Select target for import"),
2749 tr("<b>Select a target for import</b><p>This RDF document refers to one or more audio files.<br>You already have an audio waveform loaded.<br>What would you like to do with the new data?"),
2750 items, prevNewSession ? 0 : 1, &ok);
2751
2752 if (!ok || item.isEmpty()) {
2753 *cancel = true;
2743 return false; 2754 return false;
2744 } 2755 }
2756
2757 newSession = (item == items[0]);
2758 settings.beginGroup("MainWindow");
2759 settings.setValue("newsessionforrdfaudio", newSession);
2760 settings.endGroup();
2761
2762 if (newSession) return true;
2763 else return false;
2745 } 2764 }
2746 2765
2747 void 2766 void
2748 MainWindow::saveSession() 2767 MainWindow::saveSession()
2749 { 2768 {
3729 MainWindow::keyReference() 3748 MainWindow::keyReference()
3730 { 3749 {
3731 m_keyReference->show(); 3750 m_keyReference->show();
3732 } 3751 }
3733 3752
3753