| 705 | } |
| 706 | |
| 707 | bool LiveCapture::checkAllowClose(int totalUnsavedCaptures, bool &noToAll) |
| 708 | { |
| 709 | m_IgnoreThreadClosed = true; |
| 710 | |
| 711 | bool suppressRemoteWarning = false; |
| 712 | |
| 713 | QMessageBox::StandardButtons msgFlags = RDDialog::YesNoCancel; |
| 714 | |
| 715 | const int unsavedCaptures = unsavedCaptureCount(); |
| 716 | const bool multipleClosures = totalUnsavedCaptures > unsavedCaptures; |
| 717 | |
| 718 | if(unsavedCaptures > 1 || multipleClosures) |
| 719 | msgFlags |= QMessageBox::NoToAll; |
| 720 | |
| 721 | for(int i = 0; i < ui->captures->count(); i++) |
| 722 | { |
| 723 | QListWidgetItem *item = ui->captures->item(i); |
| 724 | Capture *cap = GetCapture(ui->captures->item(i)); |
| 725 | |
| 726 | if(cap->saved) |
| 727 | continue; |
| 728 | |
| 729 | ui->captures->clearSelection(); |
| 730 | ToolWindowManager::raiseToolWindow(this); |
| 731 | ui->captures->setFocus(); |
| 732 | item->setSelected(true); |
| 733 | |
| 734 | QMessageBox::StandardButton res = QMessageBox::No; |
| 735 | |
| 736 | if(!suppressRemoteWarning && !noToAll) |
| 737 | { |
| 738 | QString frameName = tr("Frame #%1").arg(cap->frameNumber); |
| 739 | if(cap->frameNumber == ~0U) |
| 740 | frameName = tr("User-defined Capture"); |
| 741 | |
| 742 | res = RDDialog::question(this, tr("Unsaved capture"), |
| 743 | tr("Save this capture '%1 %2' at %3?") |
| 744 | .arg(cap->name) |
| 745 | .arg(frameName) |
| 746 | .arg(cap->timestamp.toString(lit("HH:mm:ss"))), |
| 747 | msgFlags); |
| 748 | |
| 749 | if(res == QMessageBox::NoToAll) |
| 750 | { |
| 751 | // if we're closing multiple connections make sure the user is sure of what they're doing |
| 752 | if(multipleClosures) |
| 753 | { |
| 754 | QMessageBox::StandardButton res2 = RDDialog::question( |
| 755 | this, tr("Discarding all captures"), |
| 756 | tr("Multiple connections open have potentially unsaved captures, " |
| 757 | "this will discard all captures in all connections, are you sure?")); |
| 758 | |
| 759 | // if the user is sure, apply the no to all |
| 760 | if(res2 == QMessageBox::Yes) |
| 761 | { |
| 762 | noToAll = true; |
| 763 | } |
| 764 | else |
no test coverage detected