Audacity 3.2.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ProgressDialog Class Reference

ProgressDialog Class. More...

#include <ProgressDialog.h>

Inheritance diagram for ProgressDialog:
[legend]
Collaboration diagram for ProgressDialog:
[legend]

Public Types

using MessageColumn = std::vector< TranslatableString >
 
using MessageTable = std::vector< MessageColumn >
 

Public Member Functions

 ProgressDialog ()
 Methods for ProgressDialog. More...
 
 ProgressDialog (const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
virtual ~ProgressDialog ()
 
bool Create (const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
void Reinit () override
 Reset the dialog state. More...
 
void SetDialogTitle (const TranslatableString &title) override
 Change the dialog's title. More...
 
ProgressResult Update (int value, const TranslatableString &message={})
 
ProgressResult Update (double current, const TranslatableString &message={})
 
ProgressResult Update (double current, double total, const TranslatableString &message={})
 
ProgressResult Update (wxULongLong_t current, wxULongLong_t total, const TranslatableString &message={})
 
ProgressResult Update (wxLongLong current, wxLongLong total, const TranslatableString &message={})
 
ProgressResult Update (wxLongLong_t current, wxLongLong_t total, const TranslatableString &message={})
 
ProgressResult Update (int current, int total, const TranslatableString &message={})
 
ProgressResult Poll (unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={}) override
 Update the bar and poll for clicks. Call only on the main thread. More...
 
void SetMessage (const TranslatableString &message) override
 Change an existing dialog's message. More...
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
virtual ~ProgressDialog ()
 
virtual ProgressResult Poll (unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={})=0
 Update the bar and poll for clicks. Call only on the main thread. More...
 
virtual void SetMessage (const TranslatableString &message)=0
 Change an existing dialog's message. More...
 
virtual void SetDialogTitle (const TranslatableString &title)=0
 Change the dialog's title. More...
 
virtual void Reinit ()=0
 Reset the dialog state. More...
 

Protected Member Functions

 ProgressDialog (const TranslatableString &title, const MessageTable &columns, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
bool Create (const TranslatableString &title, const MessageTable &columns, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 

Protected Attributes

wxWindowRef mHadFocus
 
wxStaticText * mElapsed
 
wxStaticText * mRemaining
 
wxGauge * mGauge
 
wxLongLong_t mStartTime
 
wxLongLong_t mLastUpdate
 
wxLongLong_t mYieldTimer
 
int mLastValue
 
bool mCancel
 
bool mStop
 
bool mIsTransparent
 
bool m_bShowElapsedTime = true
 
bool m_bConfirmAction = false
 

Private Member Functions

void Init ()
 
bool SearchForWindow (const wxWindowList &list, const wxWindow *searchfor) const
 
void OnCancel (wxCommandEvent &e)
 
void OnStop (wxCommandEvent &e)
 
void OnCloseWindow (wxCloseEvent &e)
 
void Beep () const
 
bool ConfirmAction (const TranslatableString &sPrompt, const TranslatableString &sTitle, int iButtonID=-1)
 
void AddMessageAsColumn (wxBoxSizer *pSizer, const MessageColumn &column, bool bFirstColumn)
 

Private Attributes

wxEventLoopGuarantor mLoop
 
std::unique_ptr< wxWindowDisabler > mDisable
 
wxStaticText * mMessage {}
 
int mLastW { 0 }
 
int mLastH { 0 }
 

Detailed Description

ProgressDialog Class.

Custom progress dialog with Audacity specific semantics.

Definition at line 50 of file ProgressDialog.h.

Member Typedef Documentation

◆ MessageColumn

Definition at line 63 of file ProgressDialog.h.

◆ MessageTable

Definition at line 64 of file ProgressDialog.h.

Constructor & Destructor Documentation

◆ ProgressDialog() [1/3]

ProgressDialog::ProgressDialog ( )

Methods for ProgressDialog.

Definition at line 996 of file ProgressDialog.cpp.

998{
999}

◆ ProgressDialog() [2/3]

ProgressDialog::ProgressDialog ( const TranslatableString title,
const TranslatableString message = {},
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)

Definition at line 1001 of file ProgressDialog.cpp.

1006{
1007 Create(title, message, flags, sRemainingLabelText);
1008}
static const auto title
bool Create(const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})

References Create(), and title.

Here is the call graph for this function:

◆ ProgressDialog() [3/3]

ProgressDialog::ProgressDialog ( const TranslatableString title,
const MessageTable columns,
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)
protected

Definition at line 1010 of file ProgressDialog.cpp.

1015{
1016 Create(title, columns, flags, sRemainingLabelText);
1017}

References Create(), and title.

Here is the call graph for this function:

◆ ~ProgressDialog()

ProgressDialog::~ProgressDialog ( )
virtual

Reimplemented from BasicUI::ProgressDialog.

Definition at line 1022 of file ProgressDialog.cpp.

1023{
1024 // Delete the window disabler before hiding the dialog to allow
1025 // focus to return to the original window.
1026 mDisable.reset();
1027
1028 if (IsShown())
1029 {
1030 Show(false);
1031
1032 Beep();
1033 }
1034
1035#if defined(__WXGTK__)
1036 // Under GTK, when applying any effect that prompts the user, it's more than
1037 // like that FindFocus() will return NULL. So, make sure something has focus.
1038 if (GetParent()) {
1039 GetParent()->SetFocus();
1040 }
1041#endif
1042
1043 // Restore saved focus, but only if the window still exists.
1044 //
1045 // PRL: I'm conservatively preserving the old existence test, but I think
1046 // it's redundant now that we use wxWindowRef to avoid a dangling pointer
1047 if (mHadFocus && SearchForWindow(wxTopLevelWindows, mHadFocus)) {
1048 mHadFocus->SetFocus();
1049 }
1050}
std::unique_ptr< wxWindowDisabler > mDisable
void Beep() const
bool SearchForWindow(const wxWindowList &list, const wxWindow *searchfor) const
wxWindowRef mHadFocus

References Beep(), mDisable, mHadFocus, and SearchForWindow().

Here is the call graph for this function:

Member Function Documentation

◆ AddMessageAsColumn()

void ProgressDialog::AddMessageAsColumn ( wxBoxSizer *  pSizer,
const MessageColumn column,
bool  bFirstColumn 
)
private

Definition at line 1107 of file ProgressDialog.cpp.

1109 {
1110
1111 // Assuming that we don't want empty columns, bail out if there is no text.
1112 if (column.empty())
1113 return;
1114
1115 // Join strings
1116 auto sText = column[0];
1117 std::for_each( column.begin() + 1, column.end(),
1118 [&](const TranslatableString &text)
1119 { sText.Join( text, wxT("\n") ); });
1120
1121 // Create a statictext object and add to the sizer
1122 wxStaticText* oText = safenew wxStaticText(this,
1123 wxID_ANY,
1124 sText.Translation(),
1125 wxDefaultPosition,
1126 wxDefaultSize,
1127 wxALIGN_LEFT);
1128 oText->SetName(sText.Translation()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1129
1130 // If this is the first column then set the mMessage pointer so non-TimerRecord usages
1131 // will still work correctly in SetMessage()
1132 if (bFirstColumn) {
1133 mMessage = oText;
1134 }
1135
1136 pSizer->Add(oText, 1, wxEXPAND | wxALL, 5);
1137}
#define safenew
Definition: MemoryX.h:10
wxStaticText * mMessage
Holds a msgid for the translation catalog; may also bind format arguments.
wxWeakRef< wxTextCtrl > sText
Definition: LogWindow.cpp:44

References mMessage, safenew, and anonymous_namespace{LogWindow.cpp}::sText.

Referenced by Create().

Here is the caller graph for this function:

◆ Beep()

void ProgressDialog::Beep ( ) const
private

Definition at line 1615 of file ProgressDialog.cpp.

1616{
1617 int after;
1618 bool should;
1619 wxString name;
1620
1621 gPrefs->Read(wxT("/GUI/BeepOnCompletion"), &should, false);
1622 gPrefs->Read(wxT("/GUI/BeepAfterDuration"), &after, 60);
1623 gPrefs->Read(wxT("/GUI/BeepFileName"), &name, wxEmptyString);
1624
1625 if (should && wxGetUTCTimeMillis().GetValue() - mStartTime > after * 1000)
1626 {
1627 wxBusyCursor busy;
1628 wxSound s;
1629
1630 if (name.empty())
1631 {
1632 s.Create(sizeof(beep), beep);
1633 }
1634 else
1635 {
1636 s.Create(name);
1637 }
1638
1639 if (s.IsOk())
1640 {
1641 s.Play(wxSOUND_SYNC);
1642 }
1643 }
1644}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:82
FileConfig * gPrefs
Definition: Prefs.cpp:71
static const unsigned char beep[]
wxLongLong_t mStartTime

References beep, TranslatableString::empty(), gPrefs, mStartTime, name, and wxT().

Referenced by ~ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConfirmAction()

bool ProgressDialog::ConfirmAction ( const TranslatableString sPrompt,
const TranslatableString sTitle,
int  iButtonID = -1 
)
private

Definition at line 1648 of file ProgressDialog.cpp.

1650 {
1651
1652 // Check if confirmations are enabled?
1653 // If not then return TRUE
1654 if (m_bConfirmAction == false) {
1655 return true;
1656 }
1657
1658 AudacityMessageDialog dlgMessage(
1659 this,
1660 sPrompt,
1661 sTitle,
1662 wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP );
1663 int iAction = dlgMessage.ShowModal();
1664
1665 bool bReturn = (iAction == wxID_YES);
1666 if ((bReturn == false) && (iButtonID > -1)) {
1667 // Set the focus back to the relevant button
1668 FindWindowById(iButtonID, this)->SetFocus();
1669 }
1670
1671 return bReturn;
1672}
Wrap wxMessageDialog so that caption IS translatable.

References m_bConfirmAction.

Referenced by OnCancel(), OnCloseWindow(), and OnStop().

Here is the caller graph for this function:

◆ Create() [1/2]

bool ProgressDialog::Create ( const TranslatableString title,
const MessageTable columns,
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)
protected

Definition at line 1158 of file ProgressDialog.cpp.

1162{
1163 Init();
1164
1165 wxWindow *parent =
1166#if defined(__WXMAC__)
1167 // Bug 2703: In release builds, the progress dialog will fall behind
1168 // the top level dialog (like effects dialogs). This does not happen
1169 // in debug builds and I was not able to track down the reason. So,
1170 // this is a workaround and should be reviewed as some point, like
1171 // when upgrading to the next WX version.
1172 GetParentForModalDialog(mHadFocus, 0);
1173#else
1174 GetParentForModalDialog(nullptr, 0);
1175#endif
1176
1177 // Set this boolean to indicate if we are using the "Elapsed" labels
1179 // Set this boolean to indicate if we confirm the Cancel/Stop actions
1181
1182 bool success = wxDialogWrapper::Create(parent,
1183 wxID_ANY,
1184 title,
1185 wxDefaultPosition,
1186 wxDefaultSize,
1187 wxDEFAULT_DIALOG_STYLE |
1188 wxFRAME_FLOAT_ON_PARENT);
1189 if (!success)
1190 {
1191 return false;
1192 }
1193
1194 SetName(); // This was added for NVDA screen reader and may now be redundant.
1195 SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); // Ancient code. Is it still required?
1196
1197 {
1198 wxWindow *window;
1199
1200 // There may be more than one column, so create a BoxSizer container
1201 auto uColSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1202 auto colSizer = uColSizer.get();
1203
1204 // TODO: this setting-up of a grid of text in a sizer might be worth
1205 // extracting as a utility for building other dialogs.
1206 {
1207 bool bFirstCol = true;
1208 for (const auto &column : columns) {
1209 AddMessageAsColumn(colSizer, column, bFirstCol);
1210 bFirstCol = false;
1211 }
1212 }
1213
1214 // and put message column(s) into a main vertical sizer.
1215 auto vertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1216 vertSizer->Add(uColSizer.release(), 1, wxEXPAND | wxALL, 10);
1217
1218 mGauge = safenew wxGauge(this,
1219 wxID_ANY,
1220 1000,
1221 wxDefaultPosition,
1222 wxDefaultSize,
1223 wxGA_HORIZONTAL);
1224 vertSizer->Add(mGauge, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
1225
1226 {
1227 auto uGridSizer = std::make_unique<wxFlexGridSizer>(2, 2, 10, 10);
1228 // Only one row if we are not going to show the elapsed time
1229 if (m_bShowElapsedTime == false) {
1230 uGridSizer = std::make_unique<wxFlexGridSizer>(1, 2, 10, 10);
1231 }
1232 auto gridSizer = uGridSizer.get();
1233
1234 if (m_bShowElapsedTime) {
1235 window = safenew wxStaticText(this,
1236 wxID_ANY,
1237 _("Elapsed Time:"),
1238 wxDefaultPosition,
1239 wxDefaultSize,
1240 wxALIGN_RIGHT);
1241
1242 window->SetName(window->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1243 gridSizer->Add(window, 0, wxALIGN_RIGHT);
1244
1245 mElapsed = safenew wxStaticText(this,
1246 wxID_ANY,
1247 wxT("00:00:00"),
1248 wxDefaultPosition,
1249 wxDefaultSize,
1250 wxALIGN_LEFT);
1251
1252 mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1253 gridSizer->Add(mElapsed, 0, wxALIGN_LEFT);
1254 }
1255
1256 // Customised "Remaining" label text
1257 auto sRemainingText = sRemainingLabelText;
1258 if (sRemainingText.empty()) {
1259 sRemainingText = XO("Remaining Time:");
1260 }
1261
1262 window = safenew wxStaticText(this,
1263 wxID_ANY,
1264 sRemainingText.Translation(),
1265 wxDefaultPosition,
1266 wxDefaultSize,
1267 wxALIGN_RIGHT);
1268 window->SetName(window->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1269 gridSizer->Add(window, 0, wxALIGN_RIGHT);
1270
1271 mRemaining = safenew wxStaticText(this,
1272 wxID_ANY,
1273 wxT("00:00:00"),
1274 wxDefaultPosition,
1275 wxDefaultSize,
1276 wxALIGN_LEFT);
1277 mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1278 gridSizer->Add(mRemaining, 0, wxALIGN_LEFT);
1279
1280 vertSizer->Add(uGridSizer.release(), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
1281 }
1282
1283 {
1284 auto uButtonBar = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1285 auto buttonBarSizer = uButtonBar.get();
1286
1287 if (!(flags & pdlgHideStopButton)) {
1288 window = safenew wxButton(this, wxID_OK, _("Stop"));
1289 buttonBarSizer->Add(window, 0, wxRIGHT, 10);
1290 }
1291 if (!(flags & pdlgHideCancelButton)) {
1292 window = safenew wxButton(this, wxID_CANCEL, _("Cancel"));
1293 buttonBarSizer->Add(window, 0, wxRIGHT, 10);
1294 }
1295 vertSizer->Add(uButtonBar.release(), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
1296 }
1297
1298 SetSizerAndFit(vertSizer.release());
1299 }
1300 Layout();
1301
1302 // Center progress bar on Parent if it is nice and wide, otherwise Center on screen.
1303 int parentWidth = -1, parentHeight=-1;
1304 if( GetParent() ) GetParent()->GetSize( &parentWidth, &parentHeight );
1305 if (parentWidth > 400)
1306 CenterOnParent();
1307 else
1308 CenterOnScreen();
1309
1310 Reinit();
1311
1312 // Even though we won't necessarily show the dialog due to the 500ms
1313 // delay, we MUST disable other windows/menus anyway since we run the risk
1314 // of allowing other tasks to run before this one is complete.
1315 //
1316 // Reviewed this code per Proposed Features #1, at
1317 // http://wiki.audacityteam.org/wiki/Proposal_Timer_Record_Improvements.
1318 // Note that this causes a problem for Timer Record wait dialog
1319 // (see TimerRecordDialog::RunWaitDialog()), because it makes it
1320 // impossible to do any editing, even in other open projects,
1321 // while waiting for Timer Record to start -- and then also
1322 // while it's recording, it has a ProgressDialog, so really,
1323 // no editing in any project until Timer Record finishes.
1324 mDisable = std::make_unique<wxWindowDisabler>(this);
1325
1326 return true;
1327}
#define XO(s)
Definition: Internat.h:31
#define _(s)
Definition: Internat.h:75
@ pdlgConfirmStopCancel
@ pdlgHideStopButton
@ pdlgHideElapsedTime
@ pdlgHideCancelButton
wxStaticText * mElapsed
wxGauge * mGauge
void AddMessageAsColumn(wxBoxSizer *pSizer, const MessageColumn &column, bool bFirstColumn)
void Reinit() override
Reset the dialog state.
wxStaticText * mRemaining
bool Create(wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))

References _, AddMessageAsColumn(), wxDialogWrapper::Create(), Init(), m_bConfirmAction, m_bShowElapsedTime, mDisable, mElapsed, mGauge, mHadFocus, mRemaining, pdlgConfirmStopCancel, pdlgHideCancelButton, pdlgHideElapsedTime, pdlgHideStopButton, Reinit(), safenew, wxDialogWrapper::SetName(), title, wxT(), and XO.

Here is the call graph for this function:

◆ Create() [2/2]

bool ProgressDialog::Create ( const TranslatableString title,
const TranslatableString message = {},
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)

Definition at line 1139 of file ProgressDialog.cpp.

1143{
1144 MessageTable columns(1);
1145 columns.back().push_back(message);
1146 auto result = Create(title, columns, flags, sRemainingLabelText);
1147
1148 if (result) {
1149 // Record some values used in case of change of message
1150 // TODO: make the following work in case of message tables
1151 wxClientDC dc(this);
1152 dc.GetMultiLineTextExtent(message.Translation(), &mLastW, &mLastH);
1153 }
1154
1155 return result;
1156}
std::vector< MessageColumn > MessageTable
wxString Translation() const

References Create(), mLastH, mLastW, title, and TranslatableString::Translation().

Referenced by Create(), and ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void ProgressDialog::Init ( )
private

Definition at line 1052 of file ProgressDialog.cpp.

1053{
1054 // There's a problem where the focus is not returned to the window that had
1055 // it before creating this object. The reason is because the focus events
1056 // that are sent to the parent window after the wxWindowDisabler are created
1057 // are tossed and focus will not get restored to the parent once the disabler
1058 // is deleted. (See bug #1173 for more info)
1059 //
1060 // So, we capture and restore the focus ourselves.
1061 mHadFocus = wxWindow::FindFocus();
1062
1063#if defined(__WXGTK__)
1064 // Under GTK, when applying any effect that prompts the user, it's more than
1065 // likely that FindFocus() will return NULL. So, make sure something has focus.
1066 if (GetParent())
1067 {
1068 GetParent()->SetFocus();
1069 }
1070#endif
1071}

References mHadFocus.

Referenced by Create().

Here is the caller graph for this function:

◆ OnCancel()

void ProgressDialog::OnCancel ( wxCommandEvent &  e)
private

Definition at line 1583 of file ProgressDialog.cpp.

1584{
1585 if (!ConfirmAction(
1586 XO("Are you sure you wish to cancel?"),
1587 XO("Confirm Cancel"), wxID_CANCEL)) {
1588 return;
1589 }
1590 FindWindowById(wxID_CANCEL, this)->Disable();
1591 mCancel = true;
1592}
bool ConfirmAction(const TranslatableString &sPrompt, const TranslatableString &sTitle, int iButtonID=-1)

References ConfirmAction(), mCancel, and XO.

Here is the call graph for this function:

◆ OnCloseWindow()

void ProgressDialog::OnCloseWindow ( wxCloseEvent &  e)
private

Definition at line 1606 of file ProgressDialog.cpp.

1607{
1608 if (!ConfirmAction(
1609 XO("Are you sure you wish to close?"), XO("Confirm Close"))) {
1610 return;
1611 }
1612 mCancel = true;
1613}

References ConfirmAction(), mCancel, and XO.

Here is the call graph for this function:

◆ OnStop()

void ProgressDialog::OnStop ( wxCommandEvent &  e)
private

Definition at line 1594 of file ProgressDialog.cpp.

1595{
1596 if (!ConfirmAction(
1597 XO("Are you sure you wish to stop?"),
1598 XO("Confirm Stop"), wxID_OK)) {
1599 return;
1600 }
1601 FindWindowById(wxID_OK, this)->Disable();
1602 mCancel = false;
1603 mStop = true;
1604}

References ConfirmAction(), mCancel, mStop, and XO.

Here is the call graph for this function:

◆ Poll()

ProgressResult ProgressDialog::Poll ( unsigned long long  numerator,
unsigned long long  denominator,
const TranslatableString message = {} 
)
overridevirtual

Update the bar and poll for clicks. Call only on the main thread.

Implements BasicUI::ProgressDialog.

Definition at line 1496 of file ProgressDialog.cpp.

1499{
1500 return Update(numerator, denominator, message);
1501}
ProgressResult Update(int value, const TranslatableString &message={})

References Update().

Here is the call graph for this function:

◆ Reinit()

void ProgressDialog::Reinit ( )
overridevirtual

Reset the dialog state.

Implements BasicUI::ProgressDialog.

Definition at line 1073 of file ProgressDialog.cpp.

1074{
1075 mLastValue = 0;
1076
1077 mStartTime = wxGetUTCTimeMillis().GetValue();
1080 mCancel = false;
1081 mStop = false;
1082
1083 // Because wxGTK is very sensitive about maintaining focus when
1084 // this window is not shown, we always show it. But, since we
1085 // want a 500ms delay before it's actually visible for those
1086 // quick tasks, we show it as transparent. If the initial
1087 // delay is exceeded, then we reset the dialog to full opacity.
1088 SetTransparent(0);
1089 mIsTransparent = true;
1090
1091 auto button = FindWindowById(wxID_CANCEL, this);
1092 if (button)
1093 button->Enable();
1094 button = FindWindowById(wxID_OK, this);
1095 if (button)
1096 button->Enable();
1097
1098 wxDialogWrapper::Show(true);
1099}
wxLongLong_t mLastUpdate
wxLongLong_t mYieldTimer

References mCancel, mIsTransparent, mLastUpdate, mLastValue, mStartTime, mStop, and mYieldTimer.

Referenced by Create().

Here is the caller graph for this function:

◆ SearchForWindow()

bool ProgressDialog::SearchForWindow ( const wxWindowList &  list,
const wxWindow *  searchfor 
) const
private

Definition at line 1570 of file ProgressDialog.cpp.

1571{
1572 for (auto win : list)
1573 {
1574 if (win == searchfor || SearchForWindow(win->GetChildren(), searchfor))
1575 {
1576 return true;
1577 }
1578 }
1579
1580 return false;
1581}

References SearchForWindow().

Referenced by SearchForWindow(), and ~ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDialogTitle()

void ProgressDialog::SetDialogTitle ( const TranslatableString title)
overridevirtual

Change the dialog's title.

Implements BasicUI::ProgressDialog.

Definition at line 1101 of file ProgressDialog.cpp.

1102{
1103 SetTitle(title);
1104}
void SetTitle(const TranslatableString &title)

References wxDialogWrapper::SetTitle(), and title.

Here is the call graph for this function:

◆ SetMessage()

void ProgressDialog::SetMessage ( const TranslatableString message)
overridevirtual

Change an existing dialog's message.

Implements BasicUI::ProgressDialog.

Definition at line 1522 of file ProgressDialog.cpp.

1523{
1524 if (!message.empty())
1525 {
1526 mMessage->SetLabel(message.Translation());
1527
1528 int w, h;
1529 wxClientDC dc(mMessage);
1530 dc.GetMultiLineTextExtent(message.Translation(), &w, &h);
1531
1532 auto sizeUpdated = false;
1533 const auto currentSize = GetClientSize();
1534 auto ds = currentSize;
1535
1536 // TODO: make the following work in case of message tables
1537 if (w > mLastW)
1538 {
1539 ds.x += (w - mLastW);
1540 sizeUpdated = true;
1541 mLastW = w;
1542 }
1543
1544 if (h > mLastH)
1545 {
1546 ds.y += (h - mLastH);
1547 sizeUpdated = true;
1548 mLastH = h;
1549 }
1550
1551 if (sizeUpdated)
1552 {
1553#if defined(__WXMAC__)
1554 wxSize sz = mMessage->GetSize();
1555 mMessage->SetMinSize(wxSize(wxMax(sz.x, mLastW), wxMax(sz.y, mLastH)));
1556#endif
1557 // No need to adjust for the margin here since we only add
1558 // to the existing dimensions.
1559 ds.x = wxMax(wxMax(ds.x, mLastW), wxMax(ds.y, mLastH));
1560 SetClientSize(ds);
1561 SetPosition(GetPosition() - (ds - currentSize) / 2);
1562 wxDialogWrapper::Update();
1563 }
1564 }
1565}

References TranslatableString::empty(), mLastH, mLastW, mMessage, and TranslatableString::Translation().

Referenced by Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update() [1/7]

ProgressResult ProgressDialog::Update ( double  current,
const TranslatableString message = {} 
)

Definition at line 1426 of file ProgressDialog.cpp.

1428{
1429 return Update((int)(current * 1000), message);
1430}

References Update().

Here is the call graph for this function:

◆ Update() [2/7]

ProgressResult ProgressDialog::Update ( double  current,
double  total,
const TranslatableString message = {} 
)

Definition at line 1506 of file ProgressDialog.cpp.

1508{
1509 if (total != 0)
1510 {
1511 return Update((int)(current * 1000.0 / total), message);
1512 }
1513 else
1514 {
1515 return Update(1000, message);
1516 }
1517}

References Update().

Here is the call graph for this function:

◆ Update() [3/7]

ProgressResult ProgressDialog::Update ( int  current,
int  total,
const TranslatableString message = {} 
)

Definition at line 1483 of file ProgressDialog.cpp.

1485{
1486 if (total != 0)
1487 {
1488 return Update((int)(current * ((double)(1000.0 / total))), message);
1489 }
1490 else
1491 {
1492 return Update(1000, message);
1493 }
1494}

References Update().

Here is the call graph for this function:

◆ Update() [4/7]

ProgressResult ProgressDialog::Update ( int  value,
const TranslatableString message = {} 
)

Definition at line 1332 of file ProgressDialog.cpp.

1334{
1335 if (mCancel)
1336 {
1337 // for compatibility with old Update, that returned false on cancel
1339 }
1340 else if (mStop)
1341 {
1342 return ProgressResult::Stopped;
1343 }
1344
1345 wxLongLong_t now = wxGetUTCTimeMillis().GetValue();
1346 wxLongLong_t elapsed = now - mStartTime;
1347
1348 if (elapsed < 500)
1349 {
1351 }
1352
1353 if (mIsTransparent)
1354 {
1355 SetTransparent(255);
1356 mIsTransparent = false;
1357 }
1358
1359 if (value <= 0)
1360 {
1361 value = 1;
1362 }
1363
1364 if (value > 1000)
1365 {
1366 value = 1000;
1367 }
1368
1369 wxLongLong_t estimate = elapsed * 1000ll / value;
1370 wxLongLong_t remains = (estimate + mStartTime) - now;
1371
1372 SetMessage(message);
1373
1374 if (value != mLastValue)
1375 {
1376 mGauge->SetValue(value);
1377 mGauge->Update();
1378 mLastValue = value;
1379 }
1380
1381 // Only update if a full second has passed or track progress is complete
1382 if ((now - mLastUpdate > 1000) || (value == 1000))
1383 {
1384 if (m_bShowElapsedTime) {
1385 wxTimeSpan tsElapsed(0, 0, 0, elapsed);
1386 mElapsed->SetLabel(tsElapsed.Format(wxT("%H:%M:%S")));
1387 mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1388 mElapsed->Update();
1389 }
1390
1391 wxTimeSpan tsRemains(0, 0, 0, remains);
1392 mRemaining->SetLabel(tsRemains.Format(wxT("%H:%M:%S")));
1393 mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1394 mRemaining->Update();
1395
1396 mLastUpdate = now;
1397 }
1398
1399 wxDialogWrapper::Update();
1400
1401 // Copied from wx 3.0.2 generic progress dialog
1402 //
1403 // we have to yield because not only we want to update the display but
1404 // also to process the clicks on the cancel and skip buttons
1405 // NOTE: using YieldFor() this call shouldn't give re-entrancy problems
1406 // for event handlers not interested to UI/user-input events.
1407 //
1408 // LL: Added timer category to prevent extreme delays when processing effects
1409 // (and probably other things). I do not yet know why this happens and
1410 // I'm not too keen on having timer events processed here, but you do
1411 // what you have to do.
1412
1413 // Nyquist effects call Update on every callback, but YieldFor is
1414 // quite slow on Linux / Mac, so don't call too frequently. (bug 1575)
1415 if ((now - mYieldTimer > 50) || (value == 1000)) {
1416 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT | wxEVT_CATEGORY_TIMER);
1417 mYieldTimer = now;
1418 }
1419
1421}
void SetMessage(const TranslatableString &message) override
Change an existing dialog's message.

References RefreshCode::Cancelled, m_bShowElapsedTime, mCancel, mElapsed, mGauge, mIsTransparent, mLastUpdate, mLastValue, mRemaining, mStartTime, mStop, mYieldTimer, SetMessage(), BasicUI::Success, and wxT().

Referenced by ProjectFileIO::CopyTo(), ImportRaw(), TransportUtilities::PlayCurrentRegionAndWait(), TransportUtilities::PlayPlayRegionAndWait(), Poll(), TransportUtilities::RecordAndWait(), RemoveDependencies(), and Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update() [5/7]

ProgressResult ProgressDialog::Update ( wxLongLong  current,
wxLongLong  total,
const TranslatableString message = {} 
)

Definition at line 1451 of file ProgressDialog.cpp.

1453{
1454 if (total.GetValue() != 0)
1455 {
1456 return Update((int)(current.GetValue() * 1000ll / total.GetValue()), message);
1457 }
1458 else
1459 {
1460 return Update(1000, message);
1461 }
1462}

References Update().

Here is the call graph for this function:

◆ Update() [6/7]

ProgressResult ProgressDialog::Update ( wxLongLong_t  current,
wxLongLong_t  total,
const TranslatableString message = {} 
)

Definition at line 1467 of file ProgressDialog.cpp.

1469{
1470 if (total != 0)
1471 {
1472 return Update((int)(current * 1000ll / total), message);
1473 }
1474 else
1475 {
1476 return Update(1000, message);
1477 }
1478}

References Update().

Here is the call graph for this function:

◆ Update() [7/7]

ProgressResult ProgressDialog::Update ( wxULongLong_t  current,
wxULongLong_t  total,
const TranslatableString message = {} 
)

Definition at line 1435 of file ProgressDialog.cpp.

1437{
1438 if (total != 0)
1439 {
1440 return Update((int)(current * 1000 / total), message);
1441 }
1442 else
1443 {
1444 return Update(1000, message);
1445 }
1446}

References Update().

Here is the call graph for this function:

Member Data Documentation

◆ m_bConfirmAction

bool ProgressDialog::m_bConfirmAction = false
protected

Definition at line 129 of file ProgressDialog.h.

Referenced by ConfirmAction(), and Create().

◆ m_bShowElapsedTime

bool ProgressDialog::m_bShowElapsedTime = true
protected

Definition at line 128 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mCancel

bool ProgressDialog::mCancel
protected

◆ mDisable

std::unique_ptr<wxWindowDisabler> ProgressDialog::mDisable
private

Definition at line 150 of file ProgressDialog.h.

Referenced by Create(), and ~ProgressDialog().

◆ mElapsed

wxStaticText* ProgressDialog::mElapsed
protected

Definition at line 113 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mGauge

wxGauge* ProgressDialog::mGauge
protected

Definition at line 115 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mHadFocus

wxWindowRef ProgressDialog::mHadFocus
protected

Definition at line 111 of file ProgressDialog.h.

Referenced by Create(), Init(), and ~ProgressDialog().

◆ mIsTransparent

bool ProgressDialog::mIsTransparent
protected

Definition at line 125 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastH

int ProgressDialog::mLastH { 0 }
private

Definition at line 154 of file ProgressDialog.h.

Referenced by Create(), and SetMessage().

◆ mLastUpdate

wxLongLong_t ProgressDialog::mLastUpdate
protected

Definition at line 118 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastValue

int ProgressDialog::mLastValue
protected

Definition at line 120 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastW

int ProgressDialog::mLastW { 0 }
private

Definition at line 153 of file ProgressDialog.h.

Referenced by Create(), and SetMessage().

◆ mLoop

wxEventLoopGuarantor ProgressDialog::mLoop
private

Definition at line 148 of file ProgressDialog.h.

◆ mMessage

wxStaticText* ProgressDialog::mMessage {}
private

Definition at line 152 of file ProgressDialog.h.

Referenced by AddMessageAsColumn(), and SetMessage().

◆ mRemaining

wxStaticText* ProgressDialog::mRemaining
protected

Definition at line 114 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mStartTime

wxLongLong_t ProgressDialog::mStartTime
protected

Definition at line 117 of file ProgressDialog.h.

Referenced by Beep(), Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mStop

bool ProgressDialog::mStop
protected

Definition at line 123 of file ProgressDialog.h.

Referenced by OnStop(), Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mYieldTimer

wxLongLong_t ProgressDialog::mYieldTimer
protected

Definition at line 119 of file ProgressDialog.h.

Referenced by Reinit(), and Update().


The documentation for this class was generated from the following files: