blob: b97badf8069a95d14199bd23226ea57833c29a4a (
plain)
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
|
#include "syncDialog.h"
#include "../library/globalFunctions.h"
SyncDialog::SyncDialog(MainDialog* window)
: SyncDialogGenerated(window), mainDialog(window)
{
//make working copy of mainDialog->syncConfiguration and recycler setting
localSyncConfiguration = mainDialog->syncConfiguration;
m_checkBoxUseRecycler->SetValue(mainDialog->useRecycleBin);
m_checkBoxHideErrors->SetValue(mainDialog->hideErrorMessages);
//set icons for this dialog
m_bpButton18->SetBitmapLabel(*GlobalResources::bitmapStartSync);
m_bitmap13->SetBitmap(*GlobalResources::bitmapLeftOnlyDeact);
m_bitmap14->SetBitmap(*GlobalResources::bitmapRightOnlyDeact);
m_bitmap15->SetBitmap(*GlobalResources::bitmapLeftNewerDeact);
m_bitmap16->SetBitmap(*GlobalResources::bitmapRightNewerDeact);
m_bitmap17->SetBitmap(*GlobalResources::bitmapDifferentDeact);
//set sync config icons
updateConfigIcons();
//set radiobutton
if (localSyncConfiguration.exLeftSideOnly == syncDirRight &&
localSyncConfiguration.exRightSideOnly == syncDirRight &&
localSyncConfiguration.leftNewer == syncDirRight &&
localSyncConfiguration.rightNewer == syncDirRight &&
localSyncConfiguration.different == syncDirRight)
m_radioBtn1->SetValue(true); //one way ->
else if (localSyncConfiguration.exLeftSideOnly == syncDirRight &&
localSyncConfiguration.exRightSideOnly == syncDirLeft &&
localSyncConfiguration.leftNewer == syncDirRight &&
localSyncConfiguration.rightNewer == syncDirLeft &&
localSyncConfiguration.different == syncDirNone)
m_radioBtn2->SetValue(true); //two way <->
else
m_radioBtn3->SetValue(true); //other
m_bpButton18->SetLabel(_("&Start"));
}
//#################################################################################################################
SyncDialog::~SyncDialog() {}
void SyncDialog::updateConfigIcons()
{
if (localSyncConfiguration.exLeftSideOnly == syncDirRight)
{
m_bpButton5->SetBitmapLabel(*GlobalResources::bitmapRightArrow);
m_bpButton5->SetToolTip(_("Copy from left to right"));
}
else if (localSyncConfiguration.exLeftSideOnly == syncDirLeft)
{
m_bpButton5->SetBitmapLabel(*GlobalResources::bitmapDelete);
m_bpButton5->SetToolTip(_("Delete files existing on left side only"));
}
else if (localSyncConfiguration.exLeftSideOnly == syncDirNone)
{
m_bpButton5->SetBitmapLabel(wxNullBitmap);
m_bpButton5->SetToolTip(_("Do nothing"));
}
if (localSyncConfiguration.exRightSideOnly == syncDirRight)
{
m_bpButton6->SetBitmapLabel(*GlobalResources::bitmapDelete);
m_bpButton6->SetToolTip(_("Delete files existing on right side only"));
}
else if (localSyncConfiguration.exRightSideOnly == syncDirLeft)
{
m_bpButton6->SetBitmapLabel(*GlobalResources::bitmapLeftArrow);
m_bpButton6->SetToolTip(_("Copy from right to left"));
}
else if (localSyncConfiguration.exRightSideOnly == syncDirNone)
{
m_bpButton6->SetBitmapLabel(wxNullBitmap);
m_bpButton6->SetToolTip(_("Do nothing"));
}
if (localSyncConfiguration.leftNewer == syncDirRight)
{
m_bpButton7->SetBitmapLabel(*GlobalResources::bitmapRightArrow);
m_bpButton7->SetToolTip(_("Copy from left to right overwriting"));
}
else if (localSyncConfiguration.leftNewer == syncDirLeft)
{
m_bpButton7->SetBitmapLabel(*GlobalResources::bitmapLeftArrow);
m_bpButton7->SetToolTip(_("Copy from right to left overwriting"));
}
else if (localSyncConfiguration.leftNewer == syncDirNone)
{
m_bpButton7->SetBitmapLabel(wxNullBitmap);
m_bpButton7->SetToolTip(_("Do nothing"));
}
if (localSyncConfiguration.rightNewer == syncDirRight)
{
m_bpButton8->SetBitmapLabel(*GlobalResources::bitmapRightArrow);
m_bpButton8->SetToolTip(_("Copy from left to right overwriting"));
}
else if (localSyncConfiguration.rightNewer == syncDirLeft)
{
m_bpButton8->SetBitmapLabel(*GlobalResources::bitmapLeftArrow);
m_bpButton8->SetToolTip(_("Copy from right to left overwriting"));
}
else if (localSyncConfiguration.rightNewer == syncDirNone)
{
m_bpButton8->SetBitmapLabel(wxNullBitmap);
m_bpButton8->SetToolTip(_("Do nothing"));
}
if (localSyncConfiguration.different == syncDirRight)
{
m_bpButton9->SetBitmapLabel(*GlobalResources::bitmapRightArrow);
m_bpButton9->SetToolTip(_("Copy from left to right overwriting"));
}
else if (localSyncConfiguration.different == syncDirLeft)
{
m_bpButton9->SetBitmapLabel(*GlobalResources::bitmapLeftArrow);
m_bpButton9->SetToolTip(_("Copy from right to left overwriting"));
}
else if (localSyncConfiguration.different == syncDirNone)
{
m_bpButton9->SetBitmapLabel(wxNullBitmap);
m_bpButton9->SetToolTip(_("Do nothing"));
}
//update preview of bytes to be transferred:
int objectsTotal = 0;
double dataTotal = 0;
FreeFileSync::calcTotalBytesToSync(objectsTotal, dataTotal, mainDialog->currentGridData, localSyncConfiguration);
wxString objects = globalFunctions::numberToWxString(objectsTotal);
globalFunctions::includeNumberSeparator(objects);
wxString data = FreeFileSync::formatFilesizeToShortString(dataTotal);
m_textCtrl12->SetValue(objects);
m_textCtrl5->SetValue(data);
}
void SyncDialog::OnClose(wxCloseEvent& event)
{
EndModal(0);
}
void SyncDialog::OnCancel(wxCommandEvent& event)
{
EndModal(0);
}
void SyncDialog::OnBack(wxCommandEvent& event)
{
//write configuration to main dialog
mainDialog->syncConfiguration = localSyncConfiguration;
mainDialog->useRecycleBin = m_checkBoxUseRecycler->GetValue();
mainDialog->hideErrorMessages = m_checkBoxHideErrors->GetValue();
EndModal(0);
}
void SyncDialog::OnStartSync(wxCommandEvent& event)
{
//write configuration to main dialog
mainDialog->syncConfiguration = localSyncConfiguration;
mainDialog->useRecycleBin = m_checkBoxUseRecycler->GetValue();
mainDialog->hideErrorMessages = m_checkBoxHideErrors->GetValue();
EndModal(StartSynchronizationProcess);
}
void SyncDialog::OnSelectRecycleBin(wxCommandEvent& event)
{
if (event.IsChecked())
{
if (!FreeFileSync::recycleBinExists())
{
wxMessageBox(_("It was not possible to gain access to Recycle Bin!\n\nIt's likely that you are not using Windows XP. (Probably Vista)\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR);
m_checkBoxUseRecycler->SetValue(false);
}
}
}
void SyncDialog::OnSyncLeftToRight( wxCommandEvent& event )
{
localSyncConfiguration.exLeftSideOnly = syncDirRight;
localSyncConfiguration.exRightSideOnly = syncDirRight;
localSyncConfiguration.leftNewer = syncDirRight;
localSyncConfiguration.rightNewer = syncDirRight;
localSyncConfiguration.different = syncDirRight;
updateConfigIcons();
//if event is triggered by button
m_radioBtn1->SetValue(true);
}
void SyncDialog::OnSyncBothSides( wxCommandEvent& event )
{
localSyncConfiguration.exLeftSideOnly = syncDirRight;
localSyncConfiguration.exRightSideOnly = syncDirLeft;
localSyncConfiguration.leftNewer = syncDirRight;
localSyncConfiguration.rightNewer = syncDirLeft;
localSyncConfiguration.different = syncDirNone;
updateConfigIcons();
//if event is triggered by button
m_radioBtn2->SetValue(true);
}
void toggleSyncDirection(SyncDirection& current)
{
if (current == syncDirRight)
current = syncDirLeft;
else if (current == syncDirLeft)
current = syncDirNone;
else if (current== syncDirNone)
current = syncDirRight;
else
assert (false);
}
void SyncDialog::OnExLeftSideOnly( wxCommandEvent& event )
{
toggleSyncDirection(localSyncConfiguration.exLeftSideOnly);
updateConfigIcons();
//set custom config button
m_radioBtn3->SetValue(true);
}
void SyncDialog::OnExRightSideOnly( wxCommandEvent& event )
{
toggleSyncDirection(localSyncConfiguration.exRightSideOnly);
updateConfigIcons();
//set custom config button
m_radioBtn3->SetValue(true);
}
void SyncDialog::OnLeftNewer( wxCommandEvent& event )
{
toggleSyncDirection(localSyncConfiguration.leftNewer);
updateConfigIcons();
//set custom config button
m_radioBtn3->SetValue(true);
}
void SyncDialog::OnRightNewer( wxCommandEvent& event )
{
toggleSyncDirection(localSyncConfiguration.rightNewer);
updateConfigIcons();
//set custom config button
m_radioBtn3->SetValue(true);
}
void SyncDialog::OnDifferent( wxCommandEvent& event )
{
toggleSyncDirection(localSyncConfiguration.different);
updateConfigIcons();
//set custom config button
m_radioBtn3->SetValue(true);
}
|