From a79596fb4e1396a6042e2dc87aa5c3fcd374330e Mon Sep 17 00:00:00 2001 From: David Bailes Date: Wed, 26 Oct 2016 13:11:07 +0100 Subject: [PATCH] Add a setting for whether labels can be created by typing Added a setting for whether labels can be created by typing in a label track. The setting can be changed in either the Tracks menu, or the Tracks category in Preferences. By default the setting is set to on. --- src/LabelTrack.cpp | 4 +++- src/Menus.cpp | 14 ++++++++++++++ src/Menus.h | 1 + src/prefs/TracksPrefs.cpp | 5 ++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index 29d7afce1..bfa486054 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -1687,7 +1687,9 @@ bool LabelTrack::CaptureKey(wxKeyEvent & event) } } else { - if (IsGoodLabelFirstKey(event)) { + bool typeToCreateLabel; + gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, true); + if (IsGoodLabelFirstKey(event) && typeToCreateLabel) { AudacityProject * pProj = GetActiveProject(); // If we're playing, don't capture if the selection is the same as the diff --git a/src/Menus.cpp b/src/Menus.cpp index 070e45aaa..e3397bac1 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -920,6 +920,9 @@ void AudacityProject::CreateMenusAndCommands() AudioIOBusyFlag); c->AddItem(wxT("EditLabels"), _("&Edit Labels..."), FN(OnEditLabels)); + c->AddCheck(wxT("TypeToCreateLabel"), _("&Type to Create a Label (on/off)"), + FN(OnToggleTypeToCreateLabel), 0, AlwaysEnabledFlag, AlwaysEnabledFlag); + c->AddSeparator(); ////////////////////////////////////////////////////////////////////////// @@ -1911,6 +1914,8 @@ void AudacityProject::ModifyToolbarMenus() gPrefs->Read(wxT("/GUI/SyncLockTracks"), &active, false); SetSyncLock(active); mCommandManager.Check(wxT("SyncLock"), active); + gPrefs->Read(wxT("/GUI/TypeToCreateLabel"),&active, true); + mCommandManager.Check(wxT("TypeToCreateLabel"), active); } // checkActive is a temporary hack that should be removed as soon as we @@ -6694,6 +6699,15 @@ void AudacityProject::OnEditLabels() DoEditLabels(); } +void AudacityProject::OnToggleTypeToCreateLabel() +{ + bool typeToCreateLabel; + gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, true); + gPrefs->Write(wxT("/GUI/TypeToCreateLabel"), !typeToCreateLabel); + gPrefs->Flush(); + ModifyAllProjectToolbarMenus(); +} + void AudacityProject::OnApplyChain() { BatchProcessDialog dlg(this); diff --git a/src/Menus.h b/src/Menus.h index 01e287032..008e4b03c 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -377,6 +377,7 @@ void OnAddLabel(); void OnAddLabelPlaying(); void DoEditLabels(LabelTrack *lt = nullptr, int index = -1); void OnEditLabels(); +void OnToggleTypeToCreateLabel(); // Effect Menu diff --git a/src/prefs/TracksPrefs.cpp b/src/prefs/TracksPrefs.cpp index c7ebb7bb1..917d5d8b3 100644 --- a/src/prefs/TracksPrefs.cpp +++ b/src/prefs/TracksPrefs.cpp @@ -144,7 +144,7 @@ void TracksPrefs::PopulateOrExchange(ShuttleGui & S) wxT("/GUI/SelectAllOnNone"), true); /* i18n-hint: cut-lines are a lines indicating where to cut.*/ - S.TieCheckBox(_("Enable cu&t lines"), + S.TieCheckBox(_("Enable c&ut lines"), wxT("/GUI/EnableCutLines"), false); S.TieCheckBox(_("Enable &dragging of left and right selection edges"), @@ -156,6 +156,9 @@ void TracksPrefs::PopulateOrExchange(ShuttleGui & S) S.TieCheckBox(_("Editing a clip can &move other clips"), wxT("/GUI/EditClipCanMove"), true); + S.TieCheckBox(_("&Type to create a label"), + wxT("/GUI/TypeToCreateLabel"), + true); #ifdef EXPERIMENTAL_SCROLLING_LIMITS S.TieCheckBox(_("Enable scrolling left of &zero"), ScrollingPreferenceKey(),