Beispiel #1
0
void PrefsDialog::OnOK(wxCommandEvent & event)
{
   // Validate all pages first
   for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
      PrefsPanel *panel = (PrefsPanel *) mCategories->GetPage(i);

      // The dialog doesn't end until all the input is valid
      if (!panel->Validate()) {
         mCategories->SetSelection(i);
         return;
      }
   }

   // Now apply the changes
   for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
      PrefsPanel *panel = (PrefsPanel *) mCategories->GetPage(i);

      panel->Apply();
   }

   gPrefs->Write(wxT("/Prefs/PrefsCategory"), (long)mCategories->GetSelection());

#if USE_PORTMIXER
   if (gAudioIO) {
      gAudioIO->HandleDeviceChange();
   }
#endif

   // LL:  wxMac can't handle recreating the menus when this dialog is still active,
   //      so AudacityProject::UpdatePrefs() or any of the routines it calls must
   //      not cause AudacityProject::RebuildMenuBar() to be executed.
   for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
      gAudacityProjects[i]->UpdatePrefs();
   }

   EndModal(true);
}
Beispiel #2
0
void PrefsDialog::OnOK(wxCommandEvent & WXUNUSED(event))
{
    RecordExpansionState();

    // Validate all pages first
    if (mCategories) {
        for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
            PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i);

            // The dialog doesn't end until all the input is valid
            if (!panel->Validate()) {
                mCategories->SetSelection(i);
                return;
            }
        }
    }
    else {
        if (!mUniquePage->Validate())
            return;
    }

    if (mCategories) {
        // Now apply the changes
        for (size_t i = 0; i < mCategories->GetPageCount(); i++) {
            PrefsPanel *panel = (PrefsPanel *)mCategories->GetPage(i);

            panel->Apply();
        }
    }
    else
        mUniquePage->Apply();

    gPrefs->Flush();

    SavePreferredPage();

#if USE_PORTMIXER
    if (gAudioIO) {
        // We cannot have opened this dialog if gAudioIO->IsAudioTokenActive(),
        // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in
        // AudacityProject::GetUpdateFlags().
        // However, we can have an invalid audio token (so IsAudioTokenActive()
        // is false), but be monitoring.
        // If monitoring, have to stop the stream, so HandleDeviceChange() can work.
        // We could disable the Preferences command while monitoring, i.e.,
        // set AudioIONotBusyFlag/AudioIOBusyFlag according to monitoring, as well.
        // Instead allow it because unlike recording, for example, monitoring
        // is not clearly something that should prohibit opening prefs.
        // TODO: We *could* be smarter in this method and call HandleDeviceChange()
        // only when the device choices actually changed. True of lots of prefs!
        // As is, we always stop monitoring before handling the device change.
        if (gAudioIO->IsMonitoring())
        {
            gAudioIO->StopStream();
            while (gAudioIO->IsBusy())
                wxMilliSleep(100);
        }
        gAudioIO->HandleDeviceChange();
    }
#endif

    // LL:  wxMac can't handle recreating the menus when this dialog is still active,
    //      so AudacityProject::UpdatePrefs() or any of the routines it calls must
    //      not cause AudacityProject::RebuildMenuBar() to be executed.
    for (size_t i = 0; i < gAudacityProjects.size(); i++) {
        gAudacityProjects[i]->UpdatePrefs();
    }

    WaveformSettings::defaults().LoadPrefs();

    EndModal(true);
}