MCPcopy Create free account
hub / github.com/audacity/audacity / OnApply

Method OnApply

src/effects/EffectUI.cpp:546–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546void EffectUIHost::OnApply(wxCommandEvent & evt)
547{
548 auto &project = mProject;
549
550 // On wxGTK (wx2.8.12), the default action is still executed even if
551 // the button is disabled. This appears to affect all wxDialogs, not
552 // just our Effects dialogs. So, this is a only temporary workaround
553 // for legacy effects that disable the OK button. Hopefully this has
554 // been corrected in wx3.
555 if (!mApplyBtn->IsEnabled())
556 {
557 return;
558 }
559
560 // Honor the "select all if none" preference...a little hackish, but whatcha gonna do...
561 if (!mIsBatch &&
562 mEffectUIHost.GetDefinition().GetType() != EffectTypeGenerate &&
563 mEffectUIHost.GetDefinition().GetType() != EffectTypeTool &&
564 ViewInfo::Get( project ).selectedRegion.isPoint())
565 {
566 auto flags = AlwaysEnabledFlag;
567 bool allowed =
568 CommandManager::Get( project ).ReportIfActionNotAllowed(
569 mEffectUIHost.GetDefinition().GetName(),
570 flags,
571 WaveTracksSelectedFlag() | TimeSelectedFlag());
572 if (!allowed)
573 return;
574 }
575
576 if (!TransferDataFromWindow() ||
577 // This is the main place where there is a side-effect on the config
578 // file to remember the last-used settings of an effect, just before
579 // applying the effect destructively.
580 !mEffectUIHost.GetDefinition()
581 .SaveUserPreset(CurrentSettingsGroup(), mpAccess->Get()))
582 return;
583
584 if (IsModal())
585 {
586 mDismissed = true;
587
588 EndModal(evt.GetId());
589
590 Close();
591
592 return;
593 }
594
595 // Progress dialog no longer yields, so this "shouldn't" be necessary (yet to be proven
596 // for sure), but it is a nice visual cue that something is going on.
597 mApplyBtn->Disable();
598 auto cleanup = finally( [&] { mApplyBtn->Enable(); } );
599
600 CommandContext context( project );
601 // This is absolute hackage...but easy and I can't think of another way just now.
602 //
603 // It should callback to the EffectManager to kick off the processing

Callers

nothing calls this directly

Calls 12

GetFunction · 0.85
finallyFunction · 0.85
GetIDFunction · 0.85
GetIdMethod · 0.80
DisableMethod · 0.80
IsEnabledMethod · 0.45
GetTypeMethod · 0.45
GetNameMethod · 0.45
SaveUserPresetMethod · 0.45
GetMethod · 0.45
EnableMethod · 0.45

Tested by

no test coverage detected