diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:47:21 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 16:47:21 +0200 |
commit | ca64896d49b70fc0ffec711a079167c972fe635e (patch) | |
tree | 0059c36336378c886b750860aa5343b847c3609a /ui/SmallDialogs.cpp | |
parent | 1.3 (diff) | |
download | FreeFileSync-ca64896d49b70fc0ffec711a079167c972fe635e.tar.gz FreeFileSync-ca64896d49b70fc0ffec711a079167c972fe635e.tar.bz2 FreeFileSync-ca64896d49b70fc0ffec711a079167c972fe635e.zip |
1.4
Diffstat (limited to 'ui/SmallDialogs.cpp')
-rw-r--r-- | ui/SmallDialogs.cpp | 152 |
1 files changed, 122 insertions, 30 deletions
diff --git a/ui/SmallDialogs.cpp b/ui/SmallDialogs.cpp index cf21bc22..77fc8a59 100644 --- a/ui/SmallDialogs.cpp +++ b/ui/SmallDialogs.cpp @@ -1,10 +1,13 @@ #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(); @@ -79,7 +82,7 @@ void FilterDlg::OnOK(wxCommandEvent& event) mainDialog->excludeFilter = m_textCtrlExclude->GetValue(); //when leaving dialog: filter and redraw grid, if filter is active - EndModal(OkayButtonPressed); + EndModal(okayButtonPressed); } @@ -104,6 +107,7 @@ DeleteDialog::DeleteDialog(const wxString& headerText, const wxString& messageTe { m_staticTextHeader->SetLabel(headerText); m_textCtrlMessage->SetValue(messageText); + m_bitmap12->SetBitmap(*GlobalResources::bitmapDeleteFile); m_buttonOK->SetFocus(); } @@ -113,17 +117,17 @@ DeleteDialog::~DeleteDialog() {} void DeleteDialog::OnOK(wxCommandEvent& event) { - EndModal(OkayButtonPressed); + EndModal(okayButtonPressed); } void DeleteDialog::OnCancel(wxCommandEvent& event) { - EndModal(CancelButtonPressed); + EndModal(cancelButtonPressed); } void DeleteDialog::OnClose(wxCloseEvent& event) { - EndModal(CancelButtonPressed); + EndModal(cancelButtonPressed); } //######################################################################################## @@ -140,49 +144,58 @@ ErrorDlg::ErrorDlg(const wxString messageText, bool& suppressErrormessages) : ErrorDlg::~ErrorDlg() {} + void ErrorDlg::OnClose(wxCloseEvent& event) { //suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here - EndModal(AbortButtonPressed); + EndModal(abortButtonPressed); } + void ErrorDlg::OnContinue(wxCommandEvent& event) { suppressErrors = m_checkBoxSuppress->GetValue(); - EndModal(ContinueButtonPressed); + EndModal(continueButtonPressed); } + void ErrorDlg::OnRetry(wxCommandEvent& event) { //suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here - EndModal(RetryButtonPressed); + EndModal(retryButtonPressed); } + void ErrorDlg::OnAbort(wxCommandEvent& event) { //suppressErrors = m_checkBoxSuppress->GetValue(); -> not needed here - EndModal(AbortButtonPressed); + EndModal(abortButtonPressed); } //######################################################################################## -SyncStatus::SyncStatus(StatusUpdater* updater, double gaugeTotalElements, wxWindow* parentWindow) : +SyncStatus::SyncStatus(StatusUpdater* updater, wxWindow* parentWindow) : SyncStatusGenerated(parentWindow), currentStatusUpdater(updater), windowToDis(parentWindow), currentProcessIsRunning(true), - numberOfProcessedObjects(0) + 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); - resetGauge(gaugeTotalElements); - m_buttonAbort->SetFocus(); if (windowToDis) //disable (main) window while this status dialog is shown - windowToDis->Enable(false); + windowToDis->Disable(); } @@ -190,28 +203,31 @@ SyncStatus::~SyncStatus() { if (windowToDis) { - windowToDis->Enable(true); + windowToDis->Enable(); windowToDis->Raise(); } } -void SyncStatus::resetGauge(double totalNrOfElements) +void SyncStatus::resetGauge(int totalObjectsToProcess, double totalDataToProcess) { - currentElements = 0; - totalElements = totalNrOfElements; + currentData = 0; + totalData = totalDataToProcess; + + currentObjects = 0; + totalObjects = totalObjectsToProcess; - if (totalElements != 0) - scalingFactor = 50000 / totalElements; //let's normalize to 50000 + if (totalData != 0) + scalingFactor = 50000 / totalData; //let's normalize to 50000 else scalingFactor = 0; } -void SyncStatus::incProgressIndicator_NoUpdate(double number) +void SyncStatus::incProgressIndicator_NoUpdate(int objectsProcessed, double dataProcessed) { - currentElements+= number; - numberOfProcessedObjects++; + currentData+= dataProcessed; + currentObjects+= objectsProcessed; } @@ -224,19 +240,17 @@ void SyncStatus::setStatusText_NoUpdate(const wxString& text) void SyncStatus::updateStatusDialogNow() { //progress indicator - m_gauge1->SetValue(int(currentElements * scalingFactor)); + m_gauge1->SetValue(int(currentData * scalingFactor)); //status text m_textCtrlInfo->SetValue(currentStatusText); - //processed objects - m_staticTextProcessedObj->SetLabel(GlobalFunctions::numberToWxString(numberOfProcessedObjects)); + //remaining objects + m_staticTextRemainingObj->SetLabel(numberToWxString(totalObjects - currentObjects)); //remaining bytes left for copy - const wxString remainingBytes = - FreeFileSync::formatFilesizeToShortString(mpz_class(currentElements)) + "/" + - FreeFileSync::formatFilesizeToShortString(mpz_class(totalElements)); - m_staticTextBytesCopied->SetLabel(remainingBytes); + const wxString remainingBytes = FreeFileSync::formatFilesizeToShortString(mpz_class(totalData - currentData)); + m_staticTextDataRemaining->SetLabel(remainingBytes); //do the ui update updateUI_Now(); @@ -252,6 +266,8 @@ void SyncStatus::processHasFinished(const wxString& finalStatusText) //essential 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(); // } @@ -271,6 +287,82 @@ void SyncStatus::OnAbort(wxCommandEvent& event) void SyncStatus::OnClose(wxCloseEvent& event) { - if (!currentProcessIsRunning) Destroy(); + 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(); +} |