From 3cb679ccd82203754bb32d3b756a202a2fd01f73 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Thu, 11 Oct 2012 01:45:33 +0000 Subject: [PATCH] David Bailes patch for bug 591 --- src/Menus.cpp | 14 ++++++-------- src/TimeDialog.cpp | 9 ++++++--- src/TimeDialog.h | 3 +++ src/effects/Silence.cpp | 12 ++++++------ 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 87f055781..d30df74a7 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -2659,11 +2659,10 @@ void AudacityProject::OnSetLeftSelection() } else { - TimeDialog dlg(this, _("Set Left Selection Boundary"), _("Position")); wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT("")); - dlg.SetFormatString(fmt); - dlg.SetSampleRate(mRate); - dlg.SetTimeValue(mViewInfo.sel0); + TimeDialog dlg(this, _("Set Left Selection Boundary"), + fmt, mRate, mViewInfo.sel0, _("Position")); + if (wxID_OK == dlg.ShowModal()) { //Get the value from the dialog @@ -2702,11 +2701,10 @@ void AudacityProject::OnSetRightSelection() } else { - TimeDialog dlg(this, _("Set Right Selection Boundary"), _("Position")); wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT("")); - dlg.SetFormatString(fmt); - dlg.SetSampleRate(mRate); - dlg.SetTimeValue(mViewInfo.sel1); + TimeDialog dlg(this, _("Set Right Selection Boundary"), + fmt, mRate, mViewInfo.sel1, _("Position")); + if (wxID_OK == dlg.ShowModal()) { //Get the value from the dialog diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index 936f61866..75b71b272 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -30,12 +30,15 @@ END_EVENT_TABLE() TimeDialog::TimeDialog(wxWindow *parent, const wxString &title, + const wxString &format, + double rate, + double time, const wxString &prompt) : wxDialog(parent, wxID_ANY, title), + mFormat(format), + mRate(rate), + mTime(time), mPrompt(prompt), - mFormat(wxT("seconds")), - mRate(44100), - mTime(0.0), mTimeCtrl(NULL) { ShuttleGui S(this, eIsCreating); diff --git a/src/TimeDialog.h b/src/TimeDialog.h index e33db57da..e9aa74130 100644 --- a/src/TimeDialog.h +++ b/src/TimeDialog.h @@ -26,6 +26,9 @@ class TimeDialog:public wxDialog TimeDialog(wxWindow *parent, const wxString &title, + const wxString &format, + double rate, + double time, const wxString &prompt = _("Duration")); void SetFormatString(wxString formatString); diff --git a/src/effects/Silence.cpp b/src/effects/Silence.cpp index 4c125581c..3dbf2a526 100644 --- a/src/effects/Silence.cpp +++ b/src/effects/Silence.cpp @@ -30,20 +30,20 @@ bool EffectSilence::PromptUser() { - TimeDialog dlog(mParent, _("Silence Generator")); - - dlog.SetSampleRate(mProjectRate); + wxString fmt; if (mT1 > mT0) { // there is a selection: let's fit in there... mDuration = mT1 - mT0; - dlog.SetFormatString(_("hh:mm:ss + samples")); + fmt = _("hh:mm:ss + samples"); } else { // Retrieve last used values gPrefs->Read(wxT("/Effects/SilenceGen/Duration"), &mDuration, 30L); - dlog.SetFormatString(_("hh:mm:ss + milliseconds")); + fmt = _("hh:mm:ss + milliseconds"); } - dlog.SetTimeValue(mDuration); + + TimeDialog dlog(mParent, _("Silence Generator"), fmt, mProjectRate, + mDuration ); if (dlog.ShowModal() == wxID_CANCEL) return false;