comparison main/MainWindow.cpp @ 103:99d44871334b

* better recollection of last opened remote location; remember to offer to save session if modified when opening a new remote location
author Chris Cannam
date Fri, 16 Feb 2007 16:57:15 +0000
parents 32b386dac447
children efc8b5da414a
comparison
equal deleted inserted replaced
102:00309c07f7a9 103:99d44871334b
2568 } 2568 }
2569 2569
2570 void 2570 void
2571 MainWindow::openLocation() 2571 MainWindow::openLocation()
2572 { 2572 {
2573 QSettings settings;
2574 settings.beginGroup("MainWindow");
2575 QString lastLocation = settings.value("lastremote", "").toString();
2576
2573 bool ok = false; 2577 bool ok = false;
2574 QString text = QInputDialog::getText 2578 QString text = QInputDialog::getText
2575 (this, tr("Open Location"), 2579 (this, tr("Open Location"),
2576 tr("Please enter the URL of the location to open:"), 2580 tr("Please enter the URL of the location to open:"),
2577 QLineEdit::Normal, "", &ok); 2581 QLineEdit::Normal, lastLocation, &ok);
2578 if (!ok || text.isEmpty()) return; 2582
2583 if (!ok) return;
2584
2585 settings.setValue("lastremote", text);
2586
2587 if (text.isEmpty()) return;
2579 2588
2580 if (openURL(QUrl(text)) == FileOpenFailed) { 2589 if (openURL(QUrl(text)) == FileOpenFailed) {
2581 QMessageBox::critical(this, tr("Failed to open location"), 2590 QMessageBox::critical(this, tr("Failed to open location"),
2582 tr("URL \"%1\" could not be opened").arg(text)); 2591 tr("URL \"%1\" could not be opened").arg(text));
2583 } 2592 }
2604 return; 2613 return;
2605 } 2614 }
2606 2615
2607 if (path.endsWith("sv")) { 2616 if (path.endsWith("sv")) {
2608 2617
2609 if (!checkSaveModified()) return ; 2618 if (!checkSaveModified()) return;
2610 2619
2611 if (openSessionFile(path) == FileOpenFailed) { 2620 if (openSessionFile(path) == FileOpenFailed) {
2612 QMessageBox::critical(this, tr("Failed to open file"), 2621 QMessageBox::critical(this, tr("Failed to open file"),
2613 tr("Session file \"%1\" could not be opened").arg(path)); 2622 tr("Session file \"%1\" could not be opened").arg(path));
2614 } 2623 }
2700 if (!bzFile.open(QIODevice::ReadOnly)) { 2709 if (!bzFile.open(QIODevice::ReadOnly)) {
2701 std::cerr << "Failed to open session file \"" << location.toStdString() 2710 std::cerr << "Failed to open session file \"" << location.toStdString()
2702 << "\": " << bzFile.errorString().toStdString() << std::endl; 2711 << "\": " << bzFile.errorString().toStdString() << std::endl;
2703 return FileOpenFailed; 2712 return FileOpenFailed;
2704 } 2713 }
2714
2715 if (!checkSaveModified()) return FileOpenCancelled;
2705 2716
2706 QString error; 2717 QString error;
2707 closeSession(); 2718 closeSession();
2708 createDocument(); 2719 createDocument();
2709 2720