1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
#include "smallDialogs.h"
#include "../library/globalFunctions.h"
using namespace globalFunctions;
AboutDlg::AboutDlg(MainDialog* window) : AboutDlgGenerated(window)
{
m_bitmap9->SetBitmap(*GlobalResources::bitmapWebsite);
m_bitmap10->SetBitmap(*GlobalResources::bitmapEmail);
m_bitmap11->SetBitmap(*GlobalResources::bitmapFFS);
m_animationControl1->SetAnimation(*GlobalResources::animationMoney);
m_animationControl1->Play();
//build
wxString build = wxString(_("(Build: ")) + __TDATE__ + ")";
m_build->SetLabel(build);
m_button8->SetFocus();
}
AboutDlg::~AboutDlg() {}
void AboutDlg::OnClose(wxCloseEvent& event)
{
Destroy();
}
void AboutDlg::OnOK(wxCommandEvent& event)
{
Destroy();
}
//########################################################################################
HelpDlg::HelpDlg(MainDialog* window) : HelpDlgGenerated(window)
{
m_button8->SetFocus();
}
HelpDlg::~HelpDlg() {}
void HelpDlg::OnClose(wxCloseEvent& event)
{
Destroy();
}
void HelpDlg::OnOK(wxCommandEvent& event)
{
Destroy();
}
//########################################################################################
FilterDlg::FilterDlg(MainDialog* window) :
FilterDlgGenerated(window),
mainDialog(window)
{
m_bitmap8->SetBitmap(*GlobalResources::bitmapInclude);
m_bitmap9->SetBitmap(*GlobalResources::bitmapExclude);
m_textCtrlInclude->SetValue(mainDialog->includeFilter);
m_textCtrlExclude->SetValue(mainDialog->excludeFilter);
}
FilterDlg::~FilterDlg() {}
void FilterDlg::OnClose(wxCloseEvent& event)
{
EndModal(0);
}
void FilterDlg::OnOK(wxCommandEvent& event)
{
//only if user presses ApplyFilter, he wants the changes to be committed
mainDialog->includeFilter = m_textCtrlInclude->GetValue();
mainDialog->excludeFilter = m_textCtrlExclude->GetValue();
//when leaving dialog: filter and redraw grid, if filter is active
EndModal(okayButtonPressed);
}
void FilterDlg::OnCancel(wxCommandEvent& event)
{
EndModal(0);
}
void FilterDlg::OnDefault(wxCommandEvent& event)
{
m_textCtrlInclude->SetValue("*");
m_textCtrlExclude->SetValue("");
//changes to mainDialog are only committed when the OK button is pressed
event.Skip();
}
//########################################################################################
DeleteDialog::DeleteDialog(const wxString& headerText, const wxString& messageText, wxWindow* main) :
DeleteDialogGenerated(main)
{
m_staticTextHeader->SetLabel(headerText);
m_textCtrlMessage->SetValue(messageText);
m_bitmap12->SetBitmap(*GlobalResources::bitmapDeleteFile);
m_buttonOK->SetFocus();
}
DeleteDialog::~DeleteDialog() {}
void DeleteDialog::OnOK(wxCommandEvent& event)
{
EndModal(okayButtonPressed);
}
void DeleteDialog::OnCancel(wxCommandEvent& event)
{
EndModal(cancelButtonPressed);
}
void DeleteDialog::OnClose(wxCloseEvent& event)
{
EndModal(cancelButtonPressed);
}
//########################################################################################
ErrorDlg::ErrorDlg(const wxString messageText, bool& suppressErrormessages) :
ErrorDlgGenerated(0),
suppressErrors(suppressErrormessages)
{
m_bitmap10->SetBitmap(*GlobalResources::bitmapWarning);
m_textCtrl8->SetValue(messageText);
m_buttonContinue->SetFocus();
}
ErrorDlg::~ErrorDlg() {}
void ErrorDlg::OnClose(wxCloseEvent& event)
{
//suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here
EndModal(abortButtonPressed);
}
void ErrorDlg::OnContinue(wxCommandEvent& event)
{
suppressErrors = m_checkBoxSuppress->GetValue();
EndModal(continueButtonPressed);
}
void ErrorDlg::OnRetry(wxCommandEvent& event)
{
//suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here
EndModal(retryButtonPressed);
}
void ErrorDlg::OnAbort(wxCommandEvent& event)
{
//suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here
EndModal(abortButtonPressed);
}
//########################################################################################
SyncStatus::SyncStatus(StatusUpdater* updater, wxWindow* parentWindow) :
SyncStatusGenerated(parentWindow),
currentStatusUpdater(updater),
windowToDis(parentWindow),
currentProcessIsRunning(true),
totalData(0),
currentData(0),
scalingFactor(0),
currentObjects(0),
totalObjects(0)
{
m_animationControl1->SetAnimation(*GlobalResources::animationSync);
m_animationControl1->Play();
//initialize gauge
m_gauge1->SetRange(50000);
m_gauge1->SetValue(0);
m_buttonAbort->SetFocus();
if (windowToDis) //disable (main) window while this status dialog is shown
windowToDis->Disable();
}
SyncStatus::~SyncStatus()
{
if (windowToDis)
{
windowToDis->Enable();
windowToDis->Raise();
}
}
void SyncStatus::resetGauge(int totalObjectsToProcess, double totalDataToProcess)
{
currentData = 0;
totalData = totalDataToProcess;
currentObjects = 0;
totalObjects = totalObjectsToProcess;
if (totalData != 0)
scalingFactor = 50000 / totalData; //let's normalize to 50000
else
scalingFactor = 0;
}
void SyncStatus::incProgressIndicator_NoUpdate(int objectsProcessed, double dataProcessed)
{
currentData+= dataProcessed;
currentObjects+= objectsProcessed;
}
void SyncStatus::setStatusText_NoUpdate(const wxString& text)
{
currentStatusText = text;
}
void SyncStatus::updateStatusDialogNow()
{
//progress indicator
m_gauge1->SetValue(int(currentData * scalingFactor));
//status text
m_textCtrlInfo->SetValue(currentStatusText);
//remaining objects
m_staticTextRemainingObj->SetLabel(numberToWxString(totalObjects - currentObjects));
//remaining bytes left for copy
const wxString remainingBytes = FreeFileSync::formatFilesizeToShortString(mpz_class(totalData - currentData));
m_staticTextDataRemaining->SetLabel(remainingBytes);
//do the ui update
updateUI_Now();
}
void SyncStatus::processHasFinished(const wxString& finalStatusText) //essential to call this in StatusUpdater derived class destructor
{ //at the LATEST(!) to prevent access to currentStatusUpdater
currentProcessIsRunning = false; //enable okay and close events
m_staticTextStatus->SetLabel(finalStatusText);
m_buttonAbort->Hide();
m_buttonOK->Show();
m_buttonOK->SetFocus();
m_animationControl1->Stop();
updateStatusDialogNow(); //keep this sequence to avoid display distortion, if e.g. only 1 item is sync'ed
Layout(); //
}
void SyncStatus::OnOkay(wxCommandEvent& event)
{
if (!currentProcessIsRunning) Destroy();
}
void SyncStatus::OnAbort(wxCommandEvent& event)
{
if (currentProcessIsRunning) currentStatusUpdater->requestAbortion();
}
void SyncStatus::OnClose(wxCloseEvent& event)
{
if (currentProcessIsRunning) currentStatusUpdater->requestAbortion();
else
Destroy();
}
//########################################################################################
CompareStatus::CompareStatus(wxWindow* parentWindow) :
CompareStatusGenerated(parentWindow),
scannedFiles(0),
totalMD5Data(0),
currentMD5Data(0),
scalingFactorMD5(0),
currentMD5Objects(0),
totalMD5Objects(0)
{
//initialize gauge
m_gauge2->SetRange(50000);
m_gauge2->SetValue(0);
}
CompareStatus::~CompareStatus() {}
void CompareStatus::resetMD5Gauge(int totalMD5ObjectsToProcess, double totalMD5DataToProcess)
{
currentMD5Data = 0;
totalMD5Data = totalMD5DataToProcess;
currentMD5Objects = 0;
totalMD5Objects = totalMD5ObjectsToProcess;
if (totalMD5Data != 0)
scalingFactorMD5 = 50000 / totalMD5Data; //let's normalize to 50000
else
scalingFactorMD5 = 0;
}
void CompareStatus::incScannedFiles_NoUpdate(int number)
{
scannedFiles+= number;
}
void CompareStatus::incProcessedMD5Data_NoUpdate(int objectsProcessed, double dataProcessed)
{
currentMD5Data+= dataProcessed;
currentMD5Objects+= objectsProcessed;
}
void CompareStatus::setStatusText_NoUpdate(const wxString& text)
{
currentStatusText = text;
}
void CompareStatus::updateStatusPanelNow()
{
//status texts
m_textCtrlFilename->SetValue(currentStatusText);
m_staticTextScanned->SetLabel(numberToWxString(scannedFiles));
//progress indicator for MD5
m_gauge2->SetValue(int(currentMD5Data * scalingFactorMD5));
//remaining MD5 objects
m_staticTextFilesToCompare->SetLabel(numberToWxString(totalMD5Objects - currentMD5Objects));
//remaining bytes left for MD5 calculation
const wxString remainingBytes = FreeFileSync::formatFilesizeToShortString(mpz_class(totalMD5Data - currentMD5Data));
m_staticTextDataToCompare->SetLabel(remainingBytes);
//do the ui update
updateUI_Now();
}
|