Audacity 3.2.0
AudioPasteDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file AudioPasteDialog.cpp
6
7 @author Vitaly Sverchinsky
8
9**********************************************************************/
10
11#include "AudioPasteDialog.h"
12
13#include <wx/sizer.h>
14#include <wx/checkbox.h>
15#include <wx/stattext.h>
16#include <wx/radiobut.h>
17
18#include "ShuttleGui.h"
20#include "WindowAccessible.h"
21
22BEGIN_EVENT_TABLE(AudioPasteDialog, wxDialogWrapper)
26
27namespace {
28
30 XO("Smart clip.\n"
31 "The entire source clip will be pasted into your project, allowing you to access\ntrimmed audio data anytime."),
32 XO("Selected audio only.\n"
33 "Only the selected portion of the source clip will be pasted.")
34};
35
36//Setting is different from TracksBehaviorsAudioTrackPastePolicy
37//This is to remember the last mode used in the dialog
39 wxT("/GUI/AudioPasteDialogDefaultMode"),
40 {
42 {{}, {}},
43 { wxT("Keep"), wxT("Discard") }
44 },
45 0, // "Keep"
46};
47
48};
49
50AudioPasteDialog::AudioPasteDialog(wxWindow* parent, wxULongLong nCopiedBytes, int winid)
51 : wxDialogWrapper(parent, winid, XO("Paste audio")), mCopiedBytesNum(nCopiedBytes)
52{
55
56 SetInitialSize({520, -1});
57
58 Layout();
59 Fit();
60 Center();
61}
62
64{
65 S.SetBorder(20);
66 S.AddFixedText(XO("How would you like to paste your audio?"));
67 S.AddSpace(10);
68 S.StartRadioButtonGroup(AudioPasteDialogDefaultModeSetting);
69 {
70 for(int i = 0, count =AudioPasteDialogDefaultModeSetting.GetSymbols().size();
71 i < count;
72 ++i)
73 {
74 S.StartHorizontalLay(wxALIGN_LEFT);
75 {
76 S.SetBorder(0);
77 S.AddSpace(20);
78 wxRadioButton* radioButton{};
79 S.StartVerticalLay(0);
80 {
81 radioButton =
82 S.Name(audioPasteModeText[i]).TieRadioButton();
83 S.AddSpace(0, 0, 1);
84 }
85 S.EndVerticalLay();
86
87 S.AddVariableText(audioPasteModeText[i])->Bind(
88 wxEVT_LEFT_UP, [=](auto)
89 {
90 radioButton->SetValue(true);
91 });
92 #if wxUSE_ACCESSIBILITY
93 safenew WindowAccessible(radioButton);
94 #endif
95 S.AddSpace(20, 0);
96 }
97 S.EndHorizontalLay();
98 if(i != count - 1)
99 S.AddSpace(0, 10);
100 }
101 }
102 S.EndRadioButtonGroup();
103
104 S.SetBorder(20);
105 S.AddFixedText(
106 /* i18n-hint: %s substitutes for a file size, e.g. "345 MB". A "smart clip" is an audio clip containing hidden trimmed data. */
107 XO("The full smart clip is %s. Larger sizes will take longer to paste.")
108 .Format(wxFileName::GetHumanReadableSize(mCopiedBytesNum))
109 );
110
111
112 S.SetBorder(0);
113 S.StartHorizontalLay(wxEXPAND);
114 {
115 S.AddSpace(20, 0);
117 .AddCheckBox(XO("Remember my choice and don't ask again"), false);
118 if(mDontShowAgain != nullptr)
119 mDontShowAgain->SetFont(wxFont(wxFontInfo().Bold()));
120 S.AddSpace(0, 0, 1);
121 S.Id(wxID_CANCEL).AddButton(XXO("Cancel"), wxALIGN_CENTER);
122 S.AddSpace(6, 0);
123 S.Id(wxID_OK).AddButton(XXO("Continue"), wxALIGN_CENTER, true);
124 S.AddSpace(20, 0);
125 }
126 S.EndHorizontalLay();
127
128 S.AddSpace(0, 10);
129}
130
131void AudioPasteDialog::OnContinue(wxCommandEvent&)
132{
135
136 auto pasteMode = AudioPasteDialogDefaultModeSetting.Read();
137 if(mDontShowAgain->IsChecked())
139
140 gPrefs->Flush();
141
142 EndModal(pasteMode == wxT("Discard") ? DISCARD : KEEP);
143}
144
145void AudioPasteDialog::OnCancel(wxCommandEvent&)
146{
147 EndModal(wxID_CANCEL);
148}
wxT("CloseDown"))
END_EVENT_TABLE()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
ByColumns_t ByColumns
Definition: Prefs.cpp:515
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
ChoiceSetting TracksBehaviorsAudioTrackPastePolicy
wxCheckBox * mDontShowAgain
wxULongLong mCopiedBytesNum
void PopulateOrExchange(ShuttleGui &S)
AudioPasteDialog(wxWindow *parent, wxULongLong nCopiedBytes, int winid=wxID_ANY)
void OnContinue(wxCommandEvent &)
void OnCancel(wxCommandEvent &)
bool Write(const wxString &value)
Definition: Prefs.cpp:424
wxString Read() const
Definition: Prefs.cpp:388
const EnumValueSymbols & GetSymbols() const
Definition: Prefs.h:441
Abstract base class used in importing a file.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
virtual bool Flush() noexcept=0
const TranslatableString audioPasteModeText[]