diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:04:59 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:04:59 +0200 |
commit | f570e2f2685aa43aa518c2f8578391c1847cddbe (patch) | |
tree | b9376b3a7e807c5e0c4cf3d5615c14034d9675d6 /ui | |
parent | 3.2 (diff) | |
download | FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.gz FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.tar.bz2 FreeFileSync-f570e2f2685aa43aa518c2f8578391c1847cddbe.zip |
3.3
Diffstat (limited to 'ui')
-rw-r--r-- | ui/MainDialog.cpp | 239 | ||||
-rw-r--r-- | ui/MainDialog.h | 6 | ||||
-rw-r--r-- | ui/SmallDialogs.cpp | 96 | ||||
-rw-r--r-- | ui/batchStatusHandler.cpp | 16 | ||||
-rw-r--r-- | ui/checkVersion.cpp | 19 | ||||
-rw-r--r-- | ui/folderPair.h | 12 | ||||
-rw-r--r-- | ui/gridView.cpp | 29 | ||||
-rw-r--r-- | ui/gridView.h | 4 | ||||
-rw-r--r-- | ui/guiGenerated.cpp | 50 | ||||
-rw-r--r-- | ui/guiGenerated.h | 16 | ||||
-rw-r--r-- | ui/settingsDialog.cpp | 154 | ||||
-rw-r--r-- | ui/settingsDialog.h | 2 | ||||
-rw-r--r-- | ui/sorting.h | 27 | ||||
-rw-r--r-- | ui/trayIcon.cpp | 87 | ||||
-rw-r--r-- | ui/trayIcon.h | 2 |
15 files changed, 431 insertions, 328 deletions
diff --git a/ui/MainDialog.cpp b/ui/MainDialog.cpp index 0d203453..4d255950 100644 --- a/ui/MainDialog.cpp +++ b/ui/MainDialog.cpp @@ -228,6 +228,16 @@ private: }; +struct DirNotFound +{ + bool operator()(const FolderPairEnh& fp) const + { + return !dirExists(FreeFileSync::getFormattedDirectoryName(fp.leftDirectory)) || + !dirExists(FreeFileSync::getFormattedDirectoryName(fp.rightDirectory)); + } +}; + + //################################################################################################################################## MainDialog::MainDialog(wxFrame* frame, const wxString& cfgFileName, @@ -256,42 +266,43 @@ MainDialog::MainDialog(wxFrame* frame, //initialize and load configuration readGlobalSettings(); + bool loadCfgSuccess = false; if (cfgFileName.empty()) - readConfigurationFromXml(lastConfigFileName(), true); + loadCfgSuccess = readConfigurationFromXml(lastConfigFileName(), true); else - readConfigurationFromXml(cfgFileName, true); + loadCfgSuccess = readConfigurationFromXml(cfgFileName, true); //set icons for this dialog - m_bpButton10->SetBitmapLabel(*GlobalResources::getInstance().bitmapExit); - m_buttonCompare->setBitmapFront(*GlobalResources::getInstance().bitmapCompare); - m_bpButtonSyncConfig->SetBitmapLabel(*GlobalResources::getInstance().bitmapSyncCfg); - m_bpButtonCmpConfig->SetBitmapLabel(*GlobalResources::getInstance().bitmapCmpCfg); - m_bpButtonSave->SetBitmapLabel(*GlobalResources::getInstance().bitmapSave); - m_bpButtonLoad->SetBitmapLabel(*GlobalResources::getInstance().bitmapLoad); - m_bpButtonAddPair->SetBitmapLabel(*GlobalResources::getInstance().bitmapAddFolderPair); - m_bitmap15->SetBitmap(*GlobalResources::getInstance().bitmapStatusEdge); - - m_bitmapCreate->SetBitmap(*GlobalResources::getInstance().bitmapCreate); - m_bitmapUpdate->SetBitmap(*GlobalResources::getInstance().bitmapUpdate); - m_bitmapDelete->SetBitmap(*GlobalResources::getInstance().bitmapDelete); - m_bitmapData->SetBitmap(*GlobalResources::getInstance().bitmapData); + m_bpButton10->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("exit"))); + m_buttonCompare->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("compare"))); + m_bpButtonSyncConfig->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("syncConfig"))); + m_bpButtonCmpConfig->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("cmpConfig"))); + m_bpButtonSave->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("save"))); + m_bpButtonLoad->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("load"))); + m_bpButtonAddPair->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("addFolderPair"))); + m_bitmap15->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusEdge"))); + + m_bitmapCreate->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("create"))); + m_bitmapUpdate->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("update"))); + m_bitmapDelete->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("delete"))); + m_bitmapData->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("data"))); bSizer6->Layout(); //wxButtonWithImage size might have changed //menu icons: workaround for wxWidgets: small hack to update menu items: actually this is a wxWidgets bug (affects Windows- and Linux-build) MenuItemUpdater updateMenuFile(m_menuFile); - updateMenuFile.addForUpdate(m_menuItem10, *GlobalResources::getInstance().bitmapCompareSmall); - updateMenuFile.addForUpdate(m_menuItem11, *GlobalResources::getInstance().bitmapSyncSmall); - updateMenuFile.addForUpdate(m_menuItemNew, *GlobalResources::getInstance().bitmapNewSmall); - updateMenuFile.addForUpdate(m_menuItemSave, *GlobalResources::getInstance().bitmapSaveSmall); - updateMenuFile.addForUpdate(m_menuItemLoad, *GlobalResources::getInstance().bitmapLoadSmall); + updateMenuFile.addForUpdate(m_menuItem10, GlobalResources::getInstance().getImageByName(wxT("compareSmall"))); + updateMenuFile.addForUpdate(m_menuItem11, GlobalResources::getInstance().getImageByName(wxT("syncSmall"))); + updateMenuFile.addForUpdate(m_menuItemNew, GlobalResources::getInstance().getImageByName(wxT("newSmall"))); + updateMenuFile.addForUpdate(m_menuItemSave, GlobalResources::getInstance().getImageByName(wxT("saveSmall"))); + updateMenuFile.addForUpdate(m_menuItemLoad, GlobalResources::getInstance().getImageByName(wxT("loadSmall"))); MenuItemUpdater updateMenuAdv(m_menuAdvanced); - updateMenuAdv.addForUpdate(m_menuItemGlobSett, *GlobalResources::getInstance().bitmapSettingsSmall); - updateMenuAdv.addForUpdate(m_menuItem7, *GlobalResources::getInstance().bitmapBatchSmall); + updateMenuAdv.addForUpdate(m_menuItemGlobSett, GlobalResources::getInstance().getImageByName(wxT("settingsSmall"))); + updateMenuAdv.addForUpdate(m_menuItem7, GlobalResources::getInstance().getImageByName(wxT("batchSmall"))); MenuItemUpdater updateMenuHelp(m_menuHelp); - updateMenuHelp.addForUpdate(m_menuItemAbout, *GlobalResources::getInstance().bitmapAboutSmall); + updateMenuHelp.addForUpdate(m_menuItemAbout, GlobalResources::getInstance().getImageByName(wxT("aboutSmall"))); //create language selection menu @@ -353,6 +364,22 @@ MainDialog::MainDialog(wxFrame* frame, //asynchronous call to wxWindow::Layout(): fix superfluous frame on right and bottom when FFS is started in fullscreen mode Connect(wxEVT_IDLE, wxIdleEventHandler(MainDialog::OnLayoutWindowAsync), NULL, this); + +//---------------------------------------------------------------------------------------------------------------------------------------------------------------- + //some convenience: if FFS is started with a *.ffs_gui file as commandline parameter AND all directories contained exist, comparison shall be started right off + if (!cfgFileName.empty() && loadCfgSuccess) + { + const FreeFileSync::MainConfiguration currMainCfg = getCurrentConfiguration().mainCfg; + const bool allFoldersExist = !DirNotFound()(currMainCfg.firstPair) && + std::find_if(currMainCfg.additionalPairs.begin(), currMainCfg.additionalPairs.end(), + DirNotFound()) == currMainCfg.additionalPairs.end(); + if (allFoldersExist) + { + wxCommandEvent dummy2(wxEVT_COMMAND_BUTTON_CLICKED); + m_buttonCompare->AddPendingEvent(dummy2); //simulate button click on "compare" + } + } +//---------------------------------------------------------------------------------------------------------------------------------------------------------------- } @@ -735,20 +762,15 @@ void exstractNames(const FileSystemObject& fsObj, wxString& name, wxString& dir) { if (!fsObj.isEmpty<side>()) { - const FileMapping* fileObj = dynamic_cast<const FileMapping*>(&fsObj); - if (fileObj != NULL) + if (isDirectoryMapping(fsObj)) { name = zToWx(fsObj.getFullName<side>()); - dir = zToWx(fsObj.getFullName<side>().BeforeLast(globalFunctions::FILE_NAME_SEPARATOR)); + dir = name; } else { - const DirMapping* dirObj = dynamic_cast<const DirMapping*>(&fsObj); - if (dirObj != NULL) - { - name = zToWx(fsObj.getFullName<side>()); - dir = name; - } + name = zToWx(fsObj.getFullName<side>()); + dir = zToWx(fsObj.getFullName<side>().BeforeLast(globalFunctions::FILE_NAME_SEPARATOR)); } } else @@ -1190,9 +1212,10 @@ void MainDialog::OnContextRim(wxGridEvent& event) //re-create context menu contextMenu.reset(new wxMenu); - if (syncPreview.previewIsEnabled()) + if (syncPreview.previewIsEnabled() && + fsObj && fsObj->getSyncOperation() != SO_EQUAL) { - if (fsObj && (selectionLeft.size() + selectionRight.size() > 0)) + if (selectionLeft.size() + selectionRight.size() > 0) { //CONTEXT_SYNC_DIR_LEFT wxMenuItem* menuItemSyncDirLeft = new wxMenuItem(contextMenu.get(), CONTEXT_SYNC_DIR_LEFT, wxString(_("Change direction")) + wxT("\tALT + LEFT")); @@ -1220,13 +1243,13 @@ void MainDialog::OnContextRim(wxGridEvent& event) if (fsObj->isActive()) { wxMenuItem* menuItemExclTemp = new wxMenuItem(contextMenu.get(), CONTEXT_FILTER_TEMP, wxString(_("Exclude temporarily")) + wxT("\tSPACE")); - menuItemExclTemp->SetBitmap(*GlobalResources::getInstance().bitmapCheckBoxFalse); + menuItemExclTemp->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("checkboxFalse"))); contextMenu->Append(menuItemExclTemp); } else { wxMenuItem* menuItemInclTemp = new wxMenuItem(contextMenu.get(), CONTEXT_FILTER_TEMP, wxString(_("Include temporarily")) + wxT("\tSPACE")); - menuItemInclTemp->SetBitmap(*GlobalResources::getInstance().bitmapCheckBoxTrue); + menuItemInclTemp->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("checkboxTrue"))); contextMenu->Append(menuItemInclTemp); } } @@ -1244,16 +1267,14 @@ void MainDialog::OnContextRim(wxGridEvent& event) const FileSystemObject* currObj = gridDataView->getObject(*i); if (currObj && !currObj->isEmpty<LEFT_SIDE>()) exFilterCandidateObj.push_back( - FilterObject(currObj->getRelativeName<LEFT_SIDE>(), - dynamic_cast<const DirMapping*>(currObj) != NULL)); + FilterObject(currObj->getRelativeName<LEFT_SIDE>(), isDirectoryMapping(*currObj))); } for (std::set<unsigned int>::const_iterator i = selectionRight.begin(); i != selectionRight.end(); ++i) { const FileSystemObject* currObj = gridDataView->getObject(*i); if (currObj && !currObj->isEmpty<RIGHT_SIDE>()) exFilterCandidateObj.push_back( - FilterObject(currObj->getRelativeName<RIGHT_SIDE>(), - dynamic_cast<const DirMapping*>(currObj) != NULL)); + FilterObject(currObj->getRelativeName<RIGHT_SIDE>(), isDirectoryMapping(*currObj))); } //############################################################################################### @@ -1267,7 +1288,7 @@ void MainDialog::OnContextRim(wxGridEvent& event) //add context menu item wxMenuItem* menuItemExclExt = new wxMenuItem(contextMenu.get(), CONTEXT_EXCLUDE_EXT, wxString(_("Exclude via filter:")) + wxT(" ") + wxT("*.") + zToWx(extension)); - menuItemExclExt->SetBitmap(*GlobalResources::getInstance().bitmapFilterSmall); + menuItemExclExt->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("filterSmall"))); contextMenu->Append(menuItemExclExt); //connect event @@ -1289,7 +1310,7 @@ void MainDialog::OnContextRim(wxGridEvent& event) if (menuItemExclObj != NULL) { - menuItemExclObj->SetBitmap(*GlobalResources::getInstance().bitmapFilterSmall); + menuItemExclObj->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("filterSmall"))); contextMenu->Append(menuItemExclObj); //connect event @@ -1603,9 +1624,9 @@ void MainDialog::OnContextMiddleLabel(wxGridEvent& event) wxMenuItem* itemCmpResult = new wxMenuItem(contextMenu.get(), CONTEXT_COMPARISON_RESULT, _("Comparison Result")); if (syncPreview.previewIsEnabled()) - itemSyncPreview->SetBitmap(*GlobalResources::getInstance().bitmapSyncViewSmall); + itemSyncPreview->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("syncViewSmall"))); else - itemCmpResult->SetBitmap(*GlobalResources::getInstance().bitmapCmpViewSmall); + itemCmpResult->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("cmpViewSmall"))); contextMenu->Append(itemCmpResult); contextMenu->Append(itemSyncPreview); @@ -1667,44 +1688,19 @@ wxString getFormattedHistoryElement(const wxString& filename) } -wxString getFullFilename(const wxString& name) -{ - //resolve relative names to avoid problems after working directory is changed - wxFileName filename(name); - if (!filename.Normalize()) - return name; //fallback - - return filename.GetFullPath(); -} - - -//tests if the same filenames are specified, even if they are relative to the current working directory -inline -bool sameFileSpecified(const wxString& file1, const wxString& file2) -{ - const wxString file1Full = getFullFilename(file1); - const wxString file2Full = getFullFilename(file2); - -#ifdef FFS_WIN //don't respect case in windows build - return file1Full.CmpNoCase(file2Full) == 0; -#elif defined FFS_LINUX - return file1Full == file2Full; -#endif -} - - +//tests if the same filenames are specified, even if they are relative to the current working directory/include symlinks or \\?\ prefix class FindDuplicates { public: - FindDuplicates(const wxString& name) : m_name(name) {} + FindDuplicates(const Zstring& name) : m_name(name) {} bool operator()(const wxString& other) const { - return sameFileSpecified(m_name, other); + return Utility::sameFileSpecified(m_name, wxToZ(other)); } private: - const wxString& m_name; + const Zstring& m_name; }; @@ -1714,7 +1710,7 @@ void MainDialog::addFileToCfgHistory(const wxString& filename) if (!wxFileExists(filename)) return; - std::vector<wxString>::const_iterator i = find_if(cfgFileNames.begin(), cfgFileNames.end(), FindDuplicates(filename)); + std::vector<wxString>::const_iterator i = find_if(cfgFileNames.begin(), cfgFileNames.end(), FindDuplicates(wxToZ(filename))); if (i != cfgFileNames.end()) { //if entry is in the list, then jump to element @@ -1725,7 +1721,7 @@ void MainDialog::addFileToCfgHistory(const wxString& filename) cfgFileNames.insert(cfgFileNames.begin(), filename); //the default config file should receive another name on GUI - if (sameFileSpecified(lastConfigFileName(), filename)) + if (Utility::sameFileSpecified(wxToZ(lastConfigFileName()), wxToZ(filename))) m_choiceHistory->Insert(_("<Last session>"), 0); //insert at beginning of list else m_choiceHistory->Insert(getFormattedHistoryElement(filename), 0); //insert at beginning of list @@ -1763,7 +1759,11 @@ void MainDialog::OnSaveConfig(wxCommandEvent& event) bool MainDialog::trySaveConfig() //return true if saved successfully { - const wxString defaultFileName = currentConfigFileName.empty() ? wxT("SyncSettings.ffs_gui") : currentConfigFileName; + wxString defaultFileName = currentConfigFileName.empty() ? wxT("SyncSettings.ffs_gui") : currentConfigFileName; + //attention: currentConfigFileName may be an imported *.ffs_batch file! We don't want to overwrite it with a GUI config! + if (defaultFileName.EndsWith(wxT(".ffs_batch"))) + defaultFileName.Replace(wxT(".ffs_batch"), wxT(".ffs_gui"), false); + wxFileDialog* filePicker = new wxFileDialog(this, wxEmptyString, wxEmptyString, defaultFileName, wxString(_("FreeFileSync configuration")) + wxT(" (*.ffs_gui)|*.ffs_gui"), wxFD_SAVE); if (filePicker->ShowModal() == wxID_OK) @@ -1937,7 +1937,7 @@ void MainDialog::OnSetSyncDirection(FFSSyncDirectionEvent& event) if (fsObj) { setSyncDirectionRec(event.direction, *fsObj); //set new direction (recursively) - FreeFileSync::setActiveStatus(true, *fsObj); //works recursively for directories + FreeFileSync::setActiveStatus(true, *fsObj); //works recursively for directories } } @@ -2291,75 +2291,75 @@ void MainDialog::OnSyncDirNone(wxCommandEvent& event) void MainDialog::initViewFilterButtons() { //compare result buttons - m_bpButtonLeftOnly->init(*GlobalResources::getInstance().bitmapLeftOnlyAct, + m_bpButtonLeftOnly->init(GlobalResources::getInstance().getImageByName(wxT("leftOnlyAct")), _("Hide files that exist on left side only"), - *GlobalResources::getInstance().bitmapLeftOnlyDeact, + GlobalResources::getInstance().getImageByName(wxT("leftOnlyDeact")), _("Show files that exist on left side only")); - m_bpButtonRightOnly->init(*GlobalResources::getInstance().bitmapRightOnlyAct, + m_bpButtonRightOnly->init(GlobalResources::getInstance().getImageByName(wxT("rightOnlyAct")), _("Hide files that exist on right side only"), - *GlobalResources::getInstance().bitmapRightOnlyDeact, + GlobalResources::getInstance().getImageByName(wxT("rightOnlyDeact")), _("Show files that exist on right side only")); - m_bpButtonLeftNewer->init(*GlobalResources::getInstance().bitmapLeftNewerAct, + m_bpButtonLeftNewer->init(GlobalResources::getInstance().getImageByName(wxT("leftNewerAct")), _("Hide files that are newer on left"), - *GlobalResources::getInstance().bitmapLeftNewerDeact, + GlobalResources::getInstance().getImageByName(wxT("leftNewerDeact")), _("Show files that are newer on left")); - m_bpButtonRightNewer->init(*GlobalResources::getInstance().bitmapRightNewerAct, + m_bpButtonRightNewer->init(GlobalResources::getInstance().getImageByName(wxT("rightNewerAct")), _("Hide files that are newer on right"), - *GlobalResources::getInstance().bitmapRightNewerDeact, + GlobalResources::getInstance().getImageByName(wxT("rightNewerDeact")), _("Show files that are newer on right")); - m_bpButtonEqual->init(*GlobalResources::getInstance().bitmapEqualAct, + m_bpButtonEqual->init(GlobalResources::getInstance().getImageByName(wxT("equalAct")), _("Hide files that are equal"), - *GlobalResources::getInstance().bitmapEqualDeact, + GlobalResources::getInstance().getImageByName(wxT("equalDeact")), _("Show files that are equal")); - m_bpButtonDifferent->init(*GlobalResources::getInstance().bitmapDifferentAct, + m_bpButtonDifferent->init(GlobalResources::getInstance().getImageByName(wxT("differentAct")), _("Hide files that are different"), - *GlobalResources::getInstance().bitmapDifferentDeact, + GlobalResources::getInstance().getImageByName(wxT("differentDeact")), _("Show files that are different")); - m_bpButtonConflict->init(*GlobalResources::getInstance().bitmapConflictAct, + m_bpButtonConflict->init(GlobalResources::getInstance().getImageByName(wxT("conflictAct")), _("Hide conflicts"), - *GlobalResources::getInstance().bitmapConflictDeact, + GlobalResources::getInstance().getImageByName(wxT("conflictDeact")), _("Show conflicts")); //sync preview buttons - m_bpButtonSyncCreateLeft->init(*GlobalResources::getInstance().bitmapSyncCreateLeftAct, + m_bpButtonSyncCreateLeft->init(GlobalResources::getInstance().getImageByName(wxT("syncCreateLeftAct")), _("Hide files that will be created on the left side"), - *GlobalResources::getInstance().bitmapSyncCreateLeftDeact, + GlobalResources::getInstance().getImageByName(wxT("syncCreateLeftDeact")), _("Show files that will be created on the left side")); - m_bpButtonSyncCreateRight->init(*GlobalResources::getInstance().bitmapSyncCreateRightAct, + m_bpButtonSyncCreateRight->init(GlobalResources::getInstance().getImageByName(wxT("syncCreateRightAct")), _("Hide files that will be created on the right side"), - *GlobalResources::getInstance().bitmapSyncCreateRightDeact, + GlobalResources::getInstance().getImageByName(wxT("syncCreateRightDeact")), _("Show files that will be created on the right side")); - m_bpButtonSyncDeleteLeft->init(*GlobalResources::getInstance().bitmapSyncDeleteLeftAct, + m_bpButtonSyncDeleteLeft->init(GlobalResources::getInstance().getImageByName(wxT("syncDeleteLeftAct")), _("Hide files that will be deleted on the left side"), - *GlobalResources::getInstance().bitmapSyncDeleteLeftDeact, + GlobalResources::getInstance().getImageByName(wxT("syncDeleteLeftDeact")), _("Show files that will be deleted on the left side")); - m_bpButtonSyncDeleteRight->init(*GlobalResources::getInstance().bitmapSyncDeleteRightAct, + m_bpButtonSyncDeleteRight->init(GlobalResources::getInstance().getImageByName(wxT("syncDeleteRightAct")), _("Hide files that will be deleted on the right side"), - *GlobalResources::getInstance().bitmapSyncDeleteRightDeact, + GlobalResources::getInstance().getImageByName(wxT("syncDeleteRightDeact")), _("Show files that will be deleted on the right side")); - m_bpButtonSyncDirOverwLeft->init(*GlobalResources::getInstance().bitmapSyncDirLeftAct, + m_bpButtonSyncDirOverwLeft->init(GlobalResources::getInstance().getImageByName(wxT("syncDirLeftAct")), _("Hide files that will be overwritten on left side"), - *GlobalResources::getInstance().bitmapSyncDirLeftDeact, + GlobalResources::getInstance().getImageByName(wxT("syncDirLeftDeact")), _("Show files that will be overwritten on left side")); - m_bpButtonSyncDirOverwRight->init(*GlobalResources::getInstance().bitmapSyncDirRightAct, + m_bpButtonSyncDirOverwRight->init(GlobalResources::getInstance().getImageByName(wxT("syncDirRightAct")), _("Hide files that will be overwritten on right side"), - *GlobalResources::getInstance().bitmapSyncDirRightDeact, + GlobalResources::getInstance().getImageByName(wxT("syncDirRightDeact")), _("Show files that will be overwritten on right side")); - m_bpButtonSyncDirNone->init(*GlobalResources::getInstance().bitmapSyncDirNoneAct, + m_bpButtonSyncDirNone->init(GlobalResources::getInstance().getImageByName(wxT("syncDirNoneAct")), _("Hide files that won't be copied"), - *GlobalResources::getInstance().bitmapSyncDirNoneDeact, + GlobalResources::getInstance().getImageByName(wxT("syncDirNoneDeact")), _("Show files that won't be copied")); //compare result buttons @@ -2388,8 +2388,8 @@ void MainDialog::updateFilterButtons() if (m_notebookBottomLeft->GetImageList() == NULL) { wxImageList* panelIcons = new wxImageList(16, 16); - panelIcons->Add(wxBitmap(*GlobalResources::getInstance().bitmapFilterSmall)); - panelIcons->Add(wxBitmap(*GlobalResources::getInstance().bitmapFilterSmallGrey)); + panelIcons->Add(wxBitmap(GlobalResources::getInstance().getImageByName(wxT("filterSmall")))); + panelIcons->Add(wxBitmap(GlobalResources::getInstance().getImageByName(wxT("filterSmallGrey")))); m_notebookBottomLeft->AssignImageList(panelIcons); //pass ownership } @@ -2400,7 +2400,7 @@ void MainDialog::updateFilterButtons() const bool isNullFilter = NameFilter(currentCfg.mainCfg.includeFilter, currentCfg.mainCfg.excludeFilter).isNull(); if (isNullFilter) { - m_bpButtonFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterOff); + m_bpButtonFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterOff"))); m_bpButtonFilter->SetToolTip(_("No filter selected")); //additional filter icon @@ -2408,7 +2408,7 @@ void MainDialog::updateFilterButtons() } else { - m_bpButtonFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterOn); + m_bpButtonFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterOn"))); m_bpButtonFilter->SetToolTip(_("Filter has been selected")); //show filter icon @@ -2417,7 +2417,7 @@ void MainDialog::updateFilterButtons() } else { - m_bpButtonFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterOff); + m_bpButtonFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterOff"))); m_bpButtonFilter->SetToolTip(_("Filtering is deactivated")); //additional filter icon @@ -2457,6 +2457,7 @@ void MainDialog::OnCompare(wxCommandEvent &event) FreeFileSync::CompareProcess comparison(currentCfg.mainCfg.hidden.traverseDirectorySymlinks, currentCfg.mainCfg.hidden.fileTimeTolerance, globalSettings.ignoreOneHourDiff, + globalSettings.detectRenameThreshold, globalSettings.optDialogs, &statusHandler); @@ -2469,6 +2470,11 @@ void MainDialog::OnCompare(wxCommandEvent &event) newCompareData); gridDataView->setData(newCompareData); //newCompareData is invalidated after this call + + //play (optional) sound notification after sync has completed (GUI and batch mode) + const wxString soundFile = FreeFileSync::getInstallationDir() + wxT("Compare_Complete.wav"); + if (fileExists(wxToZ(soundFile))) + wxSound::Play(soundFile, wxSOUND_ASYNC); } catch (AbortThisProcess&) { @@ -2932,6 +2938,7 @@ void MainDialog::updateGridViewData() m_bpButtonSyncDirOverwLeft-> isActive(), m_bpButtonSyncDirOverwRight->isActive(), m_bpButtonSyncDirNone-> isActive(), + m_bpButtonEqual-> isActive(), m_bpButtonConflict-> isActive()); filesOnLeftView = result.filesOnLeftView; @@ -2950,6 +2957,7 @@ void MainDialog::updateGridViewData() m_bpButtonSyncDirOverwLeft-> Show(result.existsSyncDirLeft); m_bpButtonSyncDirOverwRight->Show(result.existsSyncDirRight); m_bpButtonSyncDirNone-> Show(result.existsSyncDirNone); + m_bpButtonEqual-> Show(result.existsSyncEqual); m_bpButtonConflict-> Show(result.existsConflict); if ( m_bpButtonSyncCreateLeft-> IsShown() || @@ -2959,6 +2967,7 @@ void MainDialog::updateGridViewData() m_bpButtonSyncDirOverwLeft-> IsShown() || m_bpButtonSyncDirOverwRight->IsShown() || m_bpButtonSyncDirNone-> IsShown() || + m_bpButtonEqual-> IsShown() || m_bpButtonConflict-> IsShown()) { m_panel112->Show(); @@ -3269,14 +3278,14 @@ void MainDialog::updateGuiForFolderPair() m_bpButtonLocalFilter->Hide(); m_bpButtonAltSyncCfg->Hide(); - m_bpButtonSwapSides->SetBitmapLabel(*GlobalResources::getInstance().bitmapSwap); + m_bpButtonSwapSides->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("swap"))); } else { m_bpButtonLocalFilter->Show(); m_bpButtonAltSyncCfg->Show(); - m_bpButtonSwapSides->SetBitmapLabel(*GlobalResources::getInstance().bitmapSwapSlim); + m_bpButtonSwapSides->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("swapSlim"))); } m_panelTopMiddle->Layout(); @@ -3427,6 +3436,7 @@ void MainDialog::OnMenuExportFileList(wxCommandEvent& event) exportString += wxString(wxT("\"")) + getDescription(SO_OVERWRITE_LEFT) + wxT("\";") + getSymbol(SO_OVERWRITE_LEFT) + wxT('\n'); exportString += wxString(wxT("\"")) + getDescription(SO_OVERWRITE_RIGHT) + wxT("\";") + getSymbol(SO_OVERWRITE_RIGHT) + wxT('\n'); exportString += wxString(wxT("\"")) + getDescription(SO_DO_NOTHING) + wxT("\";") + getSymbol(SO_DO_NOTHING) + wxT('\n'); + exportString += wxString(wxT("\"")) + getDescription(SO_DO_NOTHING) + wxT("\";") + getSymbol(SO_EQUAL) + wxT('\n'); exportString += wxString(wxT("\"")) + getDescription(SO_UNRESOLVED_CONFLICT) + wxT("\";") + getSymbol(SO_UNRESOLVED_CONFLICT) + wxT('\n'); } else @@ -3644,13 +3654,13 @@ void MainDialog::SyncPreview::enableSynchronization(bool value) { synchronizationEnabled = true; mainDlg_->m_buttonStartSync->SetForegroundColour(*wxBLACK); - mainDlg_->m_buttonStartSync->setBitmapFront(*GlobalResources::getInstance().bitmapSync); + mainDlg_->m_buttonStartSync->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("sync"))); } else { synchronizationEnabled = false; mainDlg_->m_buttonStartSync->SetForegroundColour(wxColor(128, 128, 128)); //Some colors seem to have problems with 16Bit color depth, well this one hasn't! - mainDlg_->m_buttonStartSync->setBitmapFront(*GlobalResources::getInstance().bitmapSyncDisabled); + mainDlg_->m_buttonStartSync->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("syncDisabled"))); } } @@ -3663,3 +3673,4 @@ bool MainDialog::SyncPreview::synchronizationIsEnabled() const + diff --git a/ui/MainDialog.h b/ui/MainDialog.h index 61f1537f..ff9fee09 100644 --- a/ui/MainDialog.h +++ b/ui/MainDialog.h @@ -82,7 +82,7 @@ public: MainDialog(wxFrame* frame, const wxString& cfgFileName, xmlAccess::XmlGlobalSettings& settings, - wxHelpController& helpController); + wxHelpController& helpController); ~MainDialog(); @@ -116,7 +116,7 @@ private: void removeAddFolderPair(const unsigned int pos); void clearAddFolderPairs(); -void updateGuiForFolderPair(); //helper method: add usability by showing/hiding buttons related to folder pairs + void updateGuiForFolderPair(); //helper method: add usability by showing/hiding buttons related to folder pairs //main method for putting gridDataView on UI: updates data respecting current view settings void updateGuiGrid(); @@ -267,7 +267,7 @@ void updateGuiForFolderPair(); //helper method: add usability by showing/hiding xmlAccess::XmlGuiConfig currentCfg; //folder pairs: - std::auto_ptr<FirstFolderPairCfg> firstFolderPair; //always bound!!! + std::auto_ptr<FirstFolderPairCfg> firstFolderPair; //always bound!!! std::vector<FolderPairPanel*> additionalFolderPairs; //additional pairs to the first pair //gui settings diff --git a/ui/SmallDialogs.cpp b/ui/SmallDialogs.cpp index 74678244..cab26472 100644 --- a/ui/SmallDialogs.cpp +++ b/ui/SmallDialogs.cpp @@ -14,16 +14,18 @@ #include <wx/wupdlock.h> #include "../shared/globalFunctions.h" #include "trayIcon.h" +#include "../shared/staticAssert.h" +#include "../shared/buildInfo.h" using namespace FreeFileSync; AboutDlg::AboutDlg(wxWindow* window) : AboutDlgGenerated(window) { - m_bitmap9->SetBitmap(*GlobalResources::getInstance().bitmapWebsite); - m_bitmap10->SetBitmap(*GlobalResources::getInstance().bitmapEmail); - m_bitmap11->SetBitmap(*GlobalResources::getInstance().bitmapLogo); - m_bitmap13->SetBitmap(*GlobalResources::getInstance().bitmapGPL); + m_bitmap9->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("website"))); + m_bitmap10->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("email"))); + m_bitmap11->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("logo"))); + m_bitmap13->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("gpl"))); //create language credits for (std::vector<LocInfoLine>::const_iterator i = LocalizationInfo::getMapping().begin(); i != LocalizationInfo::getMapping().end(); ++i) @@ -49,10 +51,19 @@ AboutDlg::AboutDlg(wxWindow* window) : AboutDlgGenerated(window) //build information wxString build = wxString(wxT("(")) + _("Build:") + wxT(" ") + __TDATE__; #if wxUSE_UNICODE - build += wxT(" - Unicode)"); + build += wxT(" - Unicode"); #else - build += wxT(" - ANSI)"); + build += wxT(" - ANSI"); #endif //wxUSE_UNICODE + + //compile time info about 32/64-bit build + if (Utility::is64BitBuild) + build += wxT(" x64)"); + else + build += wxT(" x86)"); + assert_static(Utility::is32BitBuild || Utility::is64BitBuild); + + m_build->SetLabel(build); m_animationControl1->SetAnimation(*GlobalResources::getInstance().animationMoney); @@ -80,7 +91,7 @@ HelpDlg::HelpDlg(wxWindow* window) : HelpDlgGenerated(window) { m_notebook1->SetFocus(); - m_bitmap25->SetBitmap(*GlobalResources::getInstance().bitmapHelp); + m_bitmap25->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("help"))); //populate decision trees: "compare by date" wxTreeItemId treeRoot = m_treeCtrl1->AddRoot(_("DECISION TREE")); @@ -137,10 +148,10 @@ FilterDlg::FilterDlg(wxWindow* window, includeFilter(filterIncl), excludeFilter(filterExcl) { - m_bitmap8->SetBitmap(*GlobalResources::getInstance().bitmapInclude); - m_bitmap9->SetBitmap(*GlobalResources::getInstance().bitmapExclude); - m_bitmap26->SetBitmap(*GlobalResources::getInstance().bitmapFilterOn); - m_bpButtonHelp->SetBitmapLabel(*GlobalResources::getInstance().bitmapHelp); + m_bitmap8->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("include"))); + m_bitmap9->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("exclude"))); + m_bitmap26->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("filterOn"))); + m_bpButtonHelp->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("help"))); m_textCtrlInclude->SetValue(zToWx(includeFilter)); m_textCtrlExclude->SetValue(zToWx(excludeFilter)); @@ -243,12 +254,12 @@ void DeleteDialog::updateTexts() if (m_checkBoxUseRecycler->GetValue()) { m_staticTextHeader->SetLabel(_("Do you really want to move the following objects(s) to the Recycle Bin?")); - m_bitmap12->SetBitmap(*GlobalResources::getInstance().bitmapRecycler); + m_bitmap12->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("recycler"))); } else { m_staticTextHeader->SetLabel(_("Do you really want to delete the following objects(s)?")); - m_bitmap12->SetBitmap(*GlobalResources::getInstance().bitmapDeleteFile); + m_bitmap12->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("deleteFile"))); } const std::pair<wxString, int> delInfo = FreeFileSync::deleteFromGridAndHDPreview( @@ -292,7 +303,7 @@ void DeleteDialog::OnUseRecycler(wxCommandEvent& event) { if (!FreeFileSync::recycleBinExists()) { - wxMessageBox(_("It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR); + wxMessageBox(_("Unable to initialize Recycle Bin!"), _("Error") , wxOK | wxICON_ERROR); m_checkBoxUseRecycler->SetValue(false); } } @@ -307,7 +318,7 @@ ErrorDlg::ErrorDlg(wxWindow* parentWindow, const int activeButtons, const wxStri ErrorDlgGenerated(parentWindow), ignoreErrors(ignoreNextErrors) { - m_bitmap10->SetBitmap(*GlobalResources::getInstance().bitmapError); + m_bitmap10->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("error"))); m_textCtrl8->SetValue(messageText); m_checkBoxIgnoreErrors->SetValue(ignoreNextErrors); @@ -368,7 +379,7 @@ WarningDlg::WarningDlg(wxWindow* parentWindow, int activeButtons, const wxStrin WarningDlgGenerated(parentWindow), dontShowAgain(dontShowDlgAgain) { - m_bitmap10->SetBitmap(*GlobalResources::getInstance().bitmapWarning); + m_bitmap10->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("warning"))); m_textCtrl8->SetValue(messageText); m_checkBoxDontShowAgain->SetValue(dontShowAgain); @@ -418,7 +429,7 @@ QuestionDlg::QuestionDlg(wxWindow* parentWindow, int activeButtons, const wxStri QuestionDlgGenerated(parentWindow), dontShowAgain(dontShowDlgAgain) { - m_bitmap10->SetBitmap(*GlobalResources::getInstance().bitmapQuestion); + m_bitmap10->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("question"))); m_textCtrl8->SetValue(messageText); if (dontShowAgain) m_checkBoxDontAskAgain->SetValue(*dontShowAgain); @@ -485,8 +496,8 @@ CustomizeColsDlg::CustomizeColsDlg(wxWindow* window, xmlAccess::ColumnAttributes output(attr), m_showFileIcons(showFileIcons) { - m_bpButton29->SetBitmapLabel(*GlobalResources::getInstance().bitmapMoveUp); - m_bpButton30->SetBitmapLabel(*GlobalResources::getInstance().bitmapMoveDown); + m_bpButton29->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("moveUp"))); + m_bpButton30->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("moveDown"))); xmlAccess::ColumnAttributes columnSettings = attr; @@ -604,12 +615,11 @@ SyncPreviewDlg::SyncPreviewDlg(wxWindow* parentWindow, using FreeFileSync::includeNumberSeparator; using globalFunctions::numberToWxString; - //m_bitmapPreview->SetBitmap(*GlobalResources::getInstance().bitmapSync); - m_buttonStartSync->setBitmapFront(*GlobalResources::getInstance().bitmapStartSync); - m_bitmapCreate->SetBitmap(*GlobalResources::getInstance().bitmapCreate); - m_bitmapUpdate->SetBitmap(*GlobalResources::getInstance().bitmapUpdate); - m_bitmapDelete->SetBitmap(*GlobalResources::getInstance().bitmapDelete); - m_bitmapData->SetBitmap(*GlobalResources::getInstance().bitmapData); + m_buttonStartSync->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("startSync"))); + m_bitmapCreate->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("create"))); + m_bitmapUpdate->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("update"))); + m_bitmapDelete->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("delete"))); + m_bitmapData->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("data"))); m_staticTextVariant->SetLabel(variantName); m_textCtrlData->SetValue(FreeFileSync::formatFilesizeToShortString(statistics.getDataToProcess())); @@ -657,9 +667,9 @@ CompareCfgDialog::CompareCfgDialog(wxWindow* parentWindow, const wxPoint& positi //move dialog up so that compare-config button and first config-variant are on same level Move(wxPoint(position.x, std::max(0, position.y - (m_buttonTimeSize->GetScreenPosition() - GetScreenPosition()).y))); - m_bpButtonHelp->SetBitmapLabel(*GlobalResources::getInstance().bitmapHelp); - m_bitmapByTime->SetBitmap(*GlobalResources::getInstance().bitmapCmpByTime); - m_bitmapByContent->SetBitmap(*GlobalResources::getInstance().bitmapCmpByContent); + m_bpButtonHelp->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("help"))); + m_bitmapByTime->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("cmpByTime"))); + m_bitmapByContent->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("cmpByContent"))); switch (cmpVar) { @@ -714,17 +724,17 @@ GlobalSettingsDlg::GlobalSettingsDlg(wxWindow* window, xmlAccess::XmlGlobalSetti GlobalSettingsDlgGenerated(window), settings(globalSettings) { - m_bitmapSettings->SetBitmap(*GlobalResources::getInstance().bitmapSettings); - m_buttonResetDialogs->setBitmapFront(*GlobalResources::getInstance().bitmapWarningSmall, 5); - m_bpButtonAddRow->SetBitmapLabel(*GlobalResources::getInstance().bitmapAddFolderPair); - m_bpButtonRemoveRow->SetBitmapLabel(*GlobalResources::getInstance().bitmapRemoveFolderPair); + m_bitmapSettings->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("settings"))); + m_buttonResetDialogs->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("warningSmall")), 5); + m_bpButtonAddRow->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("addFolderPair"))); + m_bpButtonRemoveRow->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("removeFolderPair"))); m_checkBoxIgnoreOneHour->SetValue(globalSettings.ignoreOneHourDiff); m_checkBoxCopyLocked->SetValue(globalSettings.copyLockedFiles); #ifndef FFS_WIN -m_staticTextCopyLocked->Hide(); -m_checkBoxCopyLocked->Hide(); + m_staticTextCopyLocked->Hide(); + m_checkBoxCopyLocked->Hide(); #endif set(globalSettings.gui.externelApplications); @@ -1130,11 +1140,11 @@ void SyncStatus::updateStatusDialogNow() break; case COMPARING_CONTENT: minimizedToSysTray->setToolTip(wxString(wxT("FreeFileSync - ")) + wxString(_("Comparing content...")) + wxT(" ") + - fromatPercentage(currentData, totalData)); + fromatPercentage(currentData, totalData), currentData.ToDouble() * 100 / totalData.ToDouble()); break; case SYNCHRONIZING: minimizedToSysTray->setToolTip(wxString(wxT("FreeFileSync - ")) + wxString(_("Synchronizing...")) + wxT(" ") + - fromatPercentage(currentData, totalData)); + fromatPercentage(currentData, totalData), currentData.ToDouble() * 100 / totalData.ToDouble()); break; case ABORTED: case FINISHED_WITH_SUCCESS: @@ -1230,37 +1240,37 @@ void SyncStatus::setCurrentStatus(SyncStatusID id) switch (id) { case ABORTED: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusError); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusError"))); m_staticTextStatus->SetLabel(_("Aborted")); break; case FINISHED_WITH_SUCCESS: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusSuccess); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusSuccess"))); m_staticTextStatus->SetLabel(_("Completed")); break; case FINISHED_WITH_ERROR: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusWarning); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusWarning"))); m_staticTextStatus->SetLabel(_("Completed")); break; case PAUSE: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusPause); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusPause"))); m_staticTextStatus->SetLabel(_("Paused")); break; case SCANNING: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusScanning); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusScanning"))); m_staticTextStatus->SetLabel(_("Scanning...")); break; case COMPARING_CONTENT: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusBinCompare); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusBinaryCompare"))); m_staticTextStatus->SetLabel(_("Comparing content...")); break; case SYNCHRONIZING: - m_bitmapStatus->SetBitmap(*GlobalResources::getInstance().bitmapStatusSyncing); + m_bitmapStatus->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("statusSyncing"))); m_staticTextStatus->SetLabel(_("Synchronizing...")); break; } diff --git a/ui/batchStatusHandler.cpp b/ui/batchStatusHandler.cpp index 43e818ee..793f18fd 100644 --- a/ui/batchStatusHandler.cpp +++ b/ui/batchStatusHandler.cpp @@ -63,14 +63,18 @@ private: using namespace globalFunctions; //create logfile directory - const wxString logfileDir = logfileDirectory.empty() ? FreeFileSync::getDefaultLogDirectory() : logfileDirectory; - if (!FreeFileSync::dirExists(wxToZ(logfileDir))) - FreeFileSync::createDirectory(wxToZ(logfileDir)); //create recursively if necessary: may throw (FileError&) + Zstring logfileDir = logfileDirectory.empty() ? + wxToZ(FreeFileSync::getDefaultLogDirectory()) : + FreeFileSync::getFormattedDirectoryName(wxToZ(logfileDirectory)); + + if (!FreeFileSync::dirExists(logfileDir)) + FreeFileSync::createDirectory(logfileDir); //create recursively if necessary: may throw (FileError&) //assemble logfile name - wxString logfileName = logfileDir; - if (!logfileName.empty() && logfileName.Last() != FILE_NAME_SEPARATOR) - logfileName += FILE_NAME_SEPARATOR; + if (!logfileDir.EndsWith(FILE_NAME_SEPARATOR)) + logfileDir += FILE_NAME_SEPARATOR; + + wxString logfileName = zToWx(logfileDir); wxString timeNow = wxDateTime::Now().FormatISOTime(); timeNow.Replace(wxT(":"), wxT("-")); diff --git a/ui/checkVersion.cpp b/ui/checkVersion.cpp index 2fb57ec6..9ecb8876 100644 --- a/ui/checkVersion.cpp +++ b/ui/checkVersion.cpp @@ -1,12 +1,12 @@ #include "checkVersion.h" - +#include <wx/msgdlg.h> #include <wx/protocol/http.h> #include <wx/sstream.h> #include "../version/version.h" -#include <wx/msgdlg.h> #include <wx/utils.h> #include <wx/timer.h> #include "../shared/globalFunctions.h" +#include "smallDialogs.h" class CloseConnectionOnExit @@ -112,9 +112,15 @@ void FreeFileSync::checkForUpdatePeriodically(long& lastUpdateCheck) { if (lastUpdateCheck == 0) { - const int rv = wxMessageBox(_("Do you want FreeFileSync to automatically check for updates every week?"), _("Information"), wxYES_NO | wxICON_QUESTION); - if (rv == wxYES) - { + QuestionDlg* const messageDlg = new QuestionDlg(NULL, + QuestionDlg::BUTTON_YES | QuestionDlg::BUTTON_CANCEL, + wxString(_("Do you want FreeFileSync to automatically check for updates every week?")) + wxT("\n") + + _("(Requires an Internet connection!)")); + + const bool checkRegularly = messageDlg->ShowModal() == QuestionDlg::BUTTON_YES; + messageDlg->Destroy(); + if (checkRegularly) + { lastUpdateCheck = 123; //some old date (few seconds after 1970) checkForUpdatePeriodically(lastUpdateCheck); //check for updates now @@ -140,6 +146,3 @@ void FreeFileSync::checkForUpdatePeriodically(long& lastUpdateCheck) } } - - - diff --git a/ui/folderPair.h b/ui/folderPair.h index 557f3cc6..a67e5078 100644 --- a/ui/folderPair.h +++ b/ui/folderPair.h @@ -60,13 +60,13 @@ public: { if (altSyncConfig.get()) { - basicPanel_.m_bpButtonAltSyncCfg->SetBitmapLabel(*GlobalResources::getInstance().bitmapSyncCfgSmall); + basicPanel_.m_bpButtonAltSyncCfg->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("syncConfigSmall"))); basicPanel_.m_bpButtonAltSyncCfg->SetToolTip(wxString(_("Select alternate synchronization settings")) + wxT(" ") + globalFunctions::LINE_BREAK + wxT("(") + altSyncConfig->syncConfiguration.getVariantName() + wxT(")")); } else { - basicPanel_.m_bpButtonAltSyncCfg->SetBitmapLabel(*GlobalResources::getInstance().bitmapSyncCfgSmallGrey); + basicPanel_.m_bpButtonAltSyncCfg->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("syncConfigSmallGrey"))); basicPanel_.m_bpButtonAltSyncCfg->SetToolTip(_("Select alternate synchronization settings")); } @@ -77,18 +77,18 @@ public: const bool isNullFilter = NameFilter(localFilter.includeFilter, localFilter.excludeFilter).isNull(); if (isNullFilter) { - basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterSmallGrey); + basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterSmallGrey"))); basicPanel_.m_bpButtonLocalFilter->SetToolTip(_("No filter selected")); } else { - basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterSmall); + basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterSmall"))); basicPanel_.m_bpButtonLocalFilter->SetToolTip(_("Filter has been selected")); } } else { - basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(*GlobalResources::getInstance().bitmapFilterSmallGrey); + basicPanel_.m_bpButtonLocalFilter->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("filterSmallGrey"))); basicPanel_.m_bpButtonLocalFilter->SetToolTip(_("Filtering is deactivated")); } } @@ -104,7 +104,7 @@ protected: basicPanel_.m_bpButtonAltSyncCfg-> Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnAltSyncCfg), NULL, this); basicPanel_.m_bpButtonLocalFilter->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(FolderPairPanelBasic::OnLocalFilterCfg), NULL, this); - basicPanel_.m_bpButtonRemovePair->SetBitmapLabel(*GlobalResources::getInstance().bitmapRemoveFolderPair); + basicPanel_.m_bpButtonRemovePair->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("removeFolderPair"))); } virtual void OnLocalFilterCfgRemoveConfirm(wxCommandEvent& event) diff --git a/ui/gridView.cpp b/ui/gridView.cpp index 8a3929fb..9b841e56 100644 --- a/ui/gridView.cpp +++ b/ui/gridView.cpp @@ -92,15 +92,11 @@ GridView::StatusCmpResult GridView::updateCmpResult(bool hideFiltered, //maps so } else { - const DirMapping* dirObj = dynamic_cast<const DirMapping*>(fsObj); - if (dirObj) - { - if (!dirObj->isEmpty<LEFT_SIDE>()) + if (!fsObj->isEmpty<LEFT_SIDE>()) ++output.foldersOnLeftView; - if (!dirObj->isEmpty<RIGHT_SIDE>()) + if (!fsObj->isEmpty<RIGHT_SIDE>()) ++output.foldersOnRightView; - } } viewRef.push_back(*j); @@ -119,6 +115,7 @@ GridView::StatusSyncPreview::StatusSyncPreview() : existsSyncDirLeft(false), existsSyncDirRight(false), existsSyncDirNone(false), + existsSyncEqual(false), existsConflict(false), filesOnLeftView(0), @@ -135,6 +132,7 @@ GridView::StatusSyncPreview GridView::updateSyncPreview(bool hideFiltered, //map bool syncDirOverwLeftActive, bool syncDirOverwRightActive, bool syncDirNoneActive, + bool syncEqualActive, bool conflictFilesActive) { StatusSyncPreview output; @@ -146,13 +144,6 @@ GridView::StatusSyncPreview GridView::updateSyncPreview(bool hideFiltered, //map const FileSystemObject* fsObj = getReferencedRow(*j); if (fsObj) { - //synchronization preview - - //exclude result "==" -//#warning na dann consider mal! - if (fsObj->getCategory() == FILE_EQUAL) //note: consider "objectsTotal" - continue; - //hide filtered row, if corresponding option is set if (hideFiltered && !fsObj->isActive()) continue; @@ -188,6 +179,10 @@ GridView::StatusSyncPreview GridView::updateSyncPreview(bool hideFiltered, //map output.existsSyncDirNone = true; if (!syncDirNoneActive) continue; break; + case SO_EQUAL: + output.existsSyncEqual = true; + if (!syncEqualActive) continue; + break; case SO_UNRESOLVED_CONFLICT: output.existsConflict = true; if (!conflictFilesActive) continue; @@ -211,15 +206,11 @@ GridView::StatusSyncPreview GridView::updateSyncPreview(bool hideFiltered, //map } else { - const DirMapping* dirObj = dynamic_cast<const DirMapping*>(fsObj); - if (dirObj) - { - if (!dirObj->isEmpty<LEFT_SIDE>()) + if (!fsObj->isEmpty<LEFT_SIDE>()) ++output.foldersOnLeftView; - if (!dirObj->isEmpty<RIGHT_SIDE>()) + if (!fsObj->isEmpty<RIGHT_SIDE>()) ++output.foldersOnRightView; - } } viewRef.push_back(*j); diff --git a/ui/gridView.h b/ui/gridView.h index 5ab28a44..eaa8ad8c 100644 --- a/ui/gridView.h +++ b/ui/gridView.h @@ -61,6 +61,7 @@ public: bool existsSyncDirLeft; bool existsSyncDirRight; bool existsSyncDirNone; + bool existsSyncEqual; bool existsConflict; unsigned int filesOnLeftView; @@ -81,6 +82,7 @@ public: bool syncDirOverwLeftActive, bool syncDirOverwRightActive, bool syncDirNoneActive, + bool syncEqualActive, bool conflictFilesActive); @@ -125,7 +127,7 @@ private: // | // | (update...) // \|/ - std::vector<RefIndex> sortedRef; //equivalent to folerCmp, but may be sorted + std::vector<RefIndex> sortedRef; //equivalent to folderCmp, but may be sorted // | // | (setData) // \|/ diff --git a/ui/guiGenerated.cpp b/ui/guiGenerated.cpp index 9670c775..c522ccff 100644 --- a/ui/guiGenerated.cpp +++ b/ui/guiGenerated.cpp @@ -492,6 +492,15 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const sbSizer31->Add( 0, 0, 1, wxEXPAND, 5 ); + m_bpButtonSyncCreateLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + sbSizer31->Add( m_bpButtonSyncCreateLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButtonSyncDirOverwLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + sbSizer31->Add( m_bpButtonSyncDirOverwLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButtonSyncDeleteLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + sbSizer31->Add( m_bpButtonSyncDeleteLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_bpButtonLeftOnly = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); sbSizer31->Add( m_bpButtonLeftOnly, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -504,24 +513,15 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const m_bpButtonDifferent = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); sbSizer31->Add( m_bpButtonDifferent, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_bpButtonSyncDirNone = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + sbSizer31->Add( m_bpButtonSyncDirNone, 0, wxALIGN_CENTER_VERTICAL, 5 ); + m_bpButtonRightNewer = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); sbSizer31->Add( m_bpButtonRightNewer, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_bpButtonRightOnly = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); sbSizer31->Add( m_bpButtonRightOnly, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_bpButtonSyncCreateLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); - sbSizer31->Add( m_bpButtonSyncCreateLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButtonSyncDirOverwLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); - sbSizer31->Add( m_bpButtonSyncDirOverwLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButtonSyncDeleteLeft = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); - sbSizer31->Add( m_bpButtonSyncDeleteLeft, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButtonSyncDirNone = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); - sbSizer31->Add( m_bpButtonSyncDirNone, 0, wxALIGN_CENTER_VERTICAL, 5 ); - m_bpButtonSyncDeleteRight = new ToggleButton( m_panel112, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); sbSizer31->Add( m_bpButtonSyncDeleteRight, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -756,16 +756,16 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const m_bpButtonFilter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnConfigureFilter ), NULL, this ); m_checkBoxActivateFilter->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnFilterButton ), NULL, this ); m_checkBoxHideFilt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnHideFilteredButton ), NULL, this ); + m_bpButtonSyncCreateLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateLeft ), NULL, this ); + m_bpButtonSyncDirOverwLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirLeft ), NULL, this ); + m_bpButtonSyncDeleteLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteLeft ), NULL, this ); m_bpButtonLeftOnly->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnLeftOnlyFiles ), NULL, this ); m_bpButtonLeftNewer->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnLeftNewerFiles ), NULL, this ); m_bpButtonEqual->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnEqualFiles ), NULL, this ); m_bpButtonDifferent->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnDifferentFiles ), NULL, this ); + m_bpButtonSyncDirNone->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirNone ), NULL, this ); m_bpButtonRightNewer->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnRightNewerFiles ), NULL, this ); m_bpButtonRightOnly->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnRightOnlyFiles ), NULL, this ); - m_bpButtonSyncCreateLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateLeft ), NULL, this ); - m_bpButtonSyncDirOverwLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirLeft ), NULL, this ); - m_bpButtonSyncDeleteLeft->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteLeft ), NULL, this ); - m_bpButtonSyncDirNone->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirNone ), NULL, this ); m_bpButtonSyncDeleteRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteRight ), NULL, this ); m_bpButtonSyncDirOverwRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirRight ), NULL, this ); m_bpButtonSyncCreateRight->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateRight ), NULL, this ); @@ -817,16 +817,16 @@ MainDialogGenerated::~MainDialogGenerated() m_bpButtonFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnConfigureFilter ), NULL, this ); m_checkBoxActivateFilter->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnFilterButton ), NULL, this ); m_checkBoxHideFilt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnHideFilteredButton ), NULL, this ); + m_bpButtonSyncCreateLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateLeft ), NULL, this ); + m_bpButtonSyncDirOverwLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirLeft ), NULL, this ); + m_bpButtonSyncDeleteLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteLeft ), NULL, this ); m_bpButtonLeftOnly->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnLeftOnlyFiles ), NULL, this ); m_bpButtonLeftNewer->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnLeftNewerFiles ), NULL, this ); m_bpButtonEqual->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnEqualFiles ), NULL, this ); m_bpButtonDifferent->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnDifferentFiles ), NULL, this ); + m_bpButtonSyncDirNone->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirNone ), NULL, this ); m_bpButtonRightNewer->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnRightNewerFiles ), NULL, this ); m_bpButtonRightOnly->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnRightOnlyFiles ), NULL, this ); - m_bpButtonSyncCreateLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateLeft ), NULL, this ); - m_bpButtonSyncDirOverwLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirLeft ), NULL, this ); - m_bpButtonSyncDeleteLeft->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteLeft ), NULL, this ); - m_bpButtonSyncDirNone->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirNone ), NULL, this ); m_bpButtonSyncDeleteRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDeleteRight ), NULL, this ); m_bpButtonSyncDirOverwRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncDirRight ), NULL, this ); m_bpButtonSyncCreateRight->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainDialogGenerated::OnSyncCreateRight ), NULL, this ); @@ -1309,7 +1309,7 @@ BatchDlgGenerated::BatchDlgGenerated( wxWindow* parent, wxWindowID id, const wxS wxBoxSizer* bSizer1151; bSizer1151 = new wxBoxSizer( wxHORIZONTAL ); - m_textCtrlCustomDelFolder = new wxTextCtrl( m_panelCustomDeletionDir, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_RIGHT ); + m_textCtrlCustomDelFolder = new wxTextCtrl( m_panelCustomDeletionDir, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textCtrlCustomDelFolder->SetMinSize( wxSize( 160,-1 ) ); bSizer1151->Add( m_textCtrlCustomDelFolder, 1, wxALIGN_CENTER_VERTICAL, 5 ); @@ -3322,7 +3322,7 @@ FilterDlgGenerated::FilterDlgGenerated( wxWindow* parent, wxWindowID id, const w wxBoxSizer* bSizer66; bSizer66 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText181 = new wxStaticText( m_panel13, wxID_ANY, _("Include: *.doc;*.zip;*.exe\nExclude: temp\\*"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText181 = new wxStaticText( m_panel13, wxID_ANY, _("Include: *.doc;*.zip;*.exe\nExclude: \\stuff\\temp\\*"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText181->Wrap( -1 ); bSizer66->Add( m_staticText181, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); @@ -3600,7 +3600,7 @@ GlobalSettingsDlgGenerated::GlobalSettingsDlgGenerated( wxWindow* parent, wxWind m_staticTextCopyLocked = new wxStaticText( this, wxID_ANY, _("Copy locked files"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextCopyLocked->Wrap( -1 ); - m_staticTextCopyLocked->SetToolTip( _("Use Volume Shadow Copy Service to copy locked or shared files.") ); + m_staticTextCopyLocked->SetToolTip( _("Copy shared or locked files using Volume Shadow Copy Service.") ); bSizer1201->Add( m_staticTextCopyLocked, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); @@ -3609,7 +3609,7 @@ GlobalSettingsDlgGenerated::GlobalSettingsDlgGenerated( wxWindow* parent, wxWind m_checkBoxCopyLocked = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - m_checkBoxCopyLocked->SetToolTip( _("Use Volume Shadow Copy Service to copy locked or shared files.") ); + m_checkBoxCopyLocked->SetToolTip( _("Copy shared or locked files using Volume Shadow Copy Service.") ); bSizer1201->Add( m_checkBoxCopyLocked, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); @@ -3663,7 +3663,7 @@ GlobalSettingsDlgGenerated::GlobalSettingsDlgGenerated( wxWindow* parent, wxWind m_gridCustomCommand->EnableDragColSize( true ); m_gridCustomCommand->SetColLabelSize( 20 ); m_gridCustomCommand->SetColLabelValue( 0, _("Description") ); - m_gridCustomCommand->SetColLabelValue( 1, _("Commandline") ); + m_gridCustomCommand->SetColLabelValue( 1, _("Command line") ); m_gridCustomCommand->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows diff --git a/ui/guiGenerated.h b/ui/guiGenerated.h index 70cce976..ab4d3c12 100644 --- a/ui/guiGenerated.h +++ b/ui/guiGenerated.h @@ -118,16 +118,16 @@ class MainDialogGenerated : public wxFrame wxCheckBox* m_checkBoxHideFilt; wxPanel* m_panel112; + ToggleButton* m_bpButtonSyncCreateLeft; + ToggleButton* m_bpButtonSyncDirOverwLeft; + ToggleButton* m_bpButtonSyncDeleteLeft; ToggleButton* m_bpButtonLeftOnly; ToggleButton* m_bpButtonLeftNewer; ToggleButton* m_bpButtonEqual; ToggleButton* m_bpButtonDifferent; + ToggleButton* m_bpButtonSyncDirNone; ToggleButton* m_bpButtonRightNewer; ToggleButton* m_bpButtonRightOnly; - ToggleButton* m_bpButtonSyncCreateLeft; - ToggleButton* m_bpButtonSyncDirOverwLeft; - ToggleButton* m_bpButtonSyncDeleteLeft; - ToggleButton* m_bpButtonSyncDirNone; ToggleButton* m_bpButtonSyncDeleteRight; ToggleButton* m_bpButtonSyncDirOverwRight; ToggleButton* m_bpButtonSyncCreateRight; @@ -195,16 +195,16 @@ class MainDialogGenerated : public wxFrame virtual void OnConfigureFilter( wxCommandEvent& event ){ event.Skip(); } virtual void OnFilterButton( wxCommandEvent& event ){ event.Skip(); } virtual void OnHideFilteredButton( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSyncCreateLeft( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSyncDirLeft( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSyncDeleteLeft( wxCommandEvent& event ){ event.Skip(); } virtual void OnLeftOnlyFiles( wxCommandEvent& event ){ event.Skip(); } virtual void OnLeftNewerFiles( wxCommandEvent& event ){ event.Skip(); } virtual void OnEqualFiles( wxCommandEvent& event ){ event.Skip(); } virtual void OnDifferentFiles( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSyncDirNone( wxCommandEvent& event ){ event.Skip(); } virtual void OnRightNewerFiles( wxCommandEvent& event ){ event.Skip(); } virtual void OnRightOnlyFiles( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSyncCreateLeft( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSyncDirLeft( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSyncDeleteLeft( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSyncDirNone( wxCommandEvent& event ){ event.Skip(); } virtual void OnSyncDeleteRight( wxCommandEvent& event ){ event.Skip(); } virtual void OnSyncDirRight( wxCommandEvent& event ){ event.Skip(); } virtual void OnSyncCreateRight( wxCommandEvent& event ){ event.Skip(); } diff --git a/ui/settingsDialog.cpp b/ui/settingsDialog.cpp index 230d187d..fe037322 100644 --- a/ui/settingsDialog.cpp +++ b/ui/settingsDialog.cpp @@ -48,12 +48,12 @@ SyncCfgDialog::SyncCfgDialog(wxWindow* window, updateConfigIcons(cmpVariant, localSyncConfiguration); //set icons for this dialog - m_bitmapLeftOnly->SetBitmap(*GlobalResources::getInstance().bitmapLeftOnly); - m_bitmapRightOnly->SetBitmap(*GlobalResources::getInstance().bitmapRightOnly); - m_bitmapLeftNewer->SetBitmap(*GlobalResources::getInstance().bitmapLeftNewer); - m_bitmapRightNewer->SetBitmap(*GlobalResources::getInstance().bitmapRightNewer); - m_bitmapDifferent->SetBitmap(*GlobalResources::getInstance().bitmapDifferent); - m_bitmapConflict->SetBitmap(*GlobalResources::getInstance().bitmapConflictGrey); + m_bitmapLeftOnly->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("leftOnly"))); + m_bitmapRightOnly->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("rightOnly"))); + m_bitmapLeftNewer->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("leftNewer"))); + m_bitmapRightNewer->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("rightNewer"))); + m_bitmapDifferent->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("different"))); + m_bitmapConflict->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("conflictGrey"))); bSizer201->Layout(); //wxButtonWithImage size might have changed @@ -175,15 +175,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.exLeftSideOnly) { case SYNC_DIR_RIGHT: - buttonLeftOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowRightCr); + buttonLeftOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowRightCr"))); buttonLeftOnly->SetToolTip(getDescription(SO_CREATE_NEW_RIGHT)); break; case SYNC_DIR_LEFT: - buttonLeftOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapDeleteLeft); + buttonLeftOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("deleteLeft"))); buttonLeftOnly->SetToolTip(getDescription(SO_DELETE_LEFT)); break; case SYNC_DIR_NONE: - buttonLeftOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowNone); + buttonLeftOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowNone"))); buttonLeftOnly->SetToolTip(getDescription(SO_DO_NOTHING)); break; } @@ -191,15 +191,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.exRightSideOnly) { case SYNC_DIR_RIGHT: - buttonRightOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapDeleteRight); + buttonRightOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("deleteRight"))); buttonRightOnly->SetToolTip(getDescription(SO_DELETE_RIGHT)); break; case SYNC_DIR_LEFT: - buttonRightOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowLeftCr); + buttonRightOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowLeftCr"))); buttonRightOnly->SetToolTip(getDescription(SO_CREATE_NEW_LEFT)); break; case SYNC_DIR_NONE: - buttonRightOnly->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowNone); + buttonRightOnly->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowNone"))); buttonRightOnly->SetToolTip(getDescription(SO_DO_NOTHING)); break; } @@ -207,15 +207,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.leftNewer) { case SYNC_DIR_RIGHT: - buttonLeftNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowRight); + buttonLeftNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowRight"))); buttonLeftNewer->SetToolTip(getDescription(SO_OVERWRITE_RIGHT)); break; case SYNC_DIR_LEFT: - buttonLeftNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowLeft); + buttonLeftNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowLeft"))); buttonLeftNewer->SetToolTip(getDescription(SO_OVERWRITE_LEFT)); break; case SYNC_DIR_NONE: - buttonLeftNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowNone); + buttonLeftNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowNone"))); buttonLeftNewer->SetToolTip(getDescription(SO_DO_NOTHING)); break; } @@ -223,15 +223,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.rightNewer) { case SYNC_DIR_RIGHT: - buttonRightNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowRight); + buttonRightNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowRight"))); buttonRightNewer->SetToolTip(getDescription(SO_OVERWRITE_RIGHT)); break; case SYNC_DIR_LEFT: - buttonRightNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowLeft); + buttonRightNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowLeft"))); buttonRightNewer->SetToolTip(getDescription(SO_OVERWRITE_LEFT)); break; case SYNC_DIR_NONE: - buttonRightNewer->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowNone); + buttonRightNewer->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowNone"))); buttonRightNewer->SetToolTip(getDescription(SO_DO_NOTHING)); break; } @@ -239,15 +239,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.different) { case SYNC_DIR_RIGHT: - buttonDifferent->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowRight); + buttonDifferent->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowRight"))); buttonDifferent->SetToolTip(getDescription(SO_OVERWRITE_RIGHT)); break; case SYNC_DIR_LEFT: - buttonDifferent->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowLeft); + buttonDifferent->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowLeft"))); buttonDifferent->SetToolTip(getDescription(SO_OVERWRITE_LEFT)); break; case SYNC_DIR_NONE: - buttonDifferent->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowNone); + buttonDifferent->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowNone"))); buttonDifferent->SetToolTip(getDescription(SO_DO_NOTHING)); break; } @@ -255,15 +255,15 @@ void SyncCfgDialog::updateConfigIcons(const CompareVariant compareVar, switch (syncConfig.conflict) { case SYNC_DIR_RIGHT: - buttonConflict->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowRight); + buttonConflict->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowRight"))); buttonConflict->SetToolTip(getDescription(SO_OVERWRITE_RIGHT)); break; case SYNC_DIR_LEFT: - buttonConflict->SetBitmapLabel(*GlobalResources::getInstance().bitmapArrowLeft); + buttonConflict->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("arrowLeft"))); buttonConflict->SetToolTip(getDescription(SO_OVERWRITE_LEFT)); break; case SYNC_DIR_NONE: - buttonConflict->SetBitmapLabel(*GlobalResources::getInstance().bitmapConflict); + buttonConflict->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("conflict"))); buttonConflict->SetToolTip(_("Leave as unresolved conflict")); break; } @@ -350,7 +350,7 @@ void updateToolTipDeletionHandling(wxChoice* choiceHandleError, wxPanel* customD break; case FreeFileSync::MOVE_TO_CUSTOM_DIRECTORY: - choiceHandleError->SetToolTip(_("Move files to a user-defined directory.")); + choiceHandleError->SetToolTip(_("Move files into a time-stamped subdirectory.")); customDir->Enable(); break; } @@ -637,16 +637,16 @@ void BatchDialog::init() //set icons for this dialog - m_bpButtonAddPair->SetBitmapLabel(*GlobalResources::getInstance().bitmapAddFolderPair); - m_bitmapLeftOnly->SetBitmap(*GlobalResources::getInstance().bitmapLeftOnly); - m_bitmapRightOnly->SetBitmap(*GlobalResources::getInstance().bitmapRightOnly); - m_bitmapLeftNewer->SetBitmap(*GlobalResources::getInstance().bitmapLeftNewer); - m_bitmapRightNewer->SetBitmap(*GlobalResources::getInstance().bitmapRightNewer); - m_bitmapDifferent->SetBitmap(*GlobalResources::getInstance().bitmapDifferent); - m_bitmapConflict->SetBitmap(*GlobalResources::getInstance().bitmapConflictGrey); - m_bitmap8->SetBitmap(*GlobalResources::getInstance().bitmapInclude); - m_bitmap9->SetBitmap(*GlobalResources::getInstance().bitmapExclude); - m_bitmap27->SetBitmap(*GlobalResources::getInstance().bitmapBatch); + m_bpButtonAddPair->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("addFolderPair"))); + m_bitmapLeftOnly->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("leftOnly"))); + m_bitmapRightOnly->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("rightOnly"))); + m_bitmapLeftNewer->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("leftNewer"))); + m_bitmapRightNewer->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("rightNewer"))); + m_bitmapDifferent->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("different"))); + m_bitmapConflict->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("conflictGrey"))); + m_bitmap8->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("include"))); + m_bitmap9->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("exclude"))); + m_bitmap27->SetBitmap(GlobalResources::getInstance().getImageByName(wxT("batch"))); m_buttonSave->SetFocus(); } @@ -1143,11 +1143,11 @@ void BatchDialog::OnAddFolderPair(wxCommandEvent& event) addFolderPair(newPairs, true); //add pair in front of additonal pairs //clear first pair - const FolderPairEnh cfgEmpty; - firstFolderPair->setValues(cfgEmpty.leftDirectory, - cfgEmpty.rightDirectory, - cfgEmpty.altSyncConfig, - cfgEmpty.localFilter); + const FolderPairEnh cfgEmpty; + firstFolderPair->setValues(cfgEmpty.leftDirectory, + cfgEmpty.rightDirectory, + cfgEmpty.altSyncConfig, + cfgEmpty.localFilter); } @@ -1220,48 +1220,48 @@ void BatchDialog::addFolderPair(const std::vector<FreeFileSync::FolderPairEnh>& wxWindowUpdateLocker dummy(m_panelOverview); //avoid display distortion if (!newPairs.empty()) -{ - //add folder pairs - int pairHeight = 0; - for (std::vector<FreeFileSync::FolderPairEnh>::const_iterator i = newPairs.begin(); i != newPairs.end(); ++i) { - BatchFolderPairPanel* newPair = new BatchFolderPairPanel(m_scrolledWindow6, *this); - - if (addFront) + //add folder pairs + int pairHeight = 0; + for (std::vector<FreeFileSync::FolderPairEnh>::const_iterator i = newPairs.begin(); i != newPairs.end(); ++i) { - bSizerAddFolderPairs->Insert(0, newPair, 0, wxEXPAND, 5); - additionalFolderPairs.insert(additionalFolderPairs.begin(), newPair); - } - else - { - bSizerAddFolderPairs->Add(newPair, 0, wxEXPAND, 5); - additionalFolderPairs.push_back(newPair); - } + BatchFolderPairPanel* newPair = new BatchFolderPairPanel(m_scrolledWindow6, *this); - //get size of scrolled window - pairHeight = newPair->GetSize().GetHeight(); + if (addFront) + { + bSizerAddFolderPairs->Insert(0, newPair, 0, wxEXPAND, 5); + additionalFolderPairs.insert(additionalFolderPairs.begin(), newPair); + } + else + { + bSizerAddFolderPairs->Add(newPair, 0, wxEXPAND, 5); + additionalFolderPairs.push_back(newPair); + } - //register events - newPair->m_bpButtonRemovePair->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BatchDialog::OnRemoveFolderPair), NULL, this ); + //get size of scrolled window + pairHeight = newPair->GetSize().GetHeight(); - //set alternate configuration - newPair->setValues(i->leftDirectory, - i->rightDirectory, - i->altSyncConfig, - i->localFilter); - } - //set size of scrolled window - const int visiblePairs = std::min(additionalFolderPairs.size() + 1, MAX_FOLDER_PAIRS); //up to MAX_FOLDER_PAIRS pairs shall be shown - m_scrolledWindow6->SetMinSize(wxSize( -1, pairHeight * visiblePairs)); + //register events + newPair->m_bpButtonRemovePair->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(BatchDialog::OnRemoveFolderPair), NULL, this ); - //update controls - m_scrolledWindow6->Fit(); //adjust scrolled window size - m_panelOverview->Layout(); //adjust stuff inside scrolled window - Fit(); //adapt dialog size + //set alternate configuration + newPair->setValues(i->leftDirectory, + i->rightDirectory, + i->altSyncConfig, + i->localFilter); + } + //set size of scrolled window + const int visiblePairs = std::min(additionalFolderPairs.size() + 1, MAX_FOLDER_PAIRS); //up to MAX_FOLDER_PAIRS pairs shall be shown + m_scrolledWindow6->SetMinSize(wxSize( -1, pairHeight * visiblePairs)); - //after changing folder pairs window focus is lost: results in scrolled window scrolling to top each time window is shown: we don't want this - m_bpButtonLeftOnly->SetFocus(); -} + //update controls + m_scrolledWindow6->Fit(); //adjust scrolled window size + m_panelOverview->Layout(); //adjust stuff inside scrolled window + Fit(); //adapt dialog size + + //after changing folder pairs window focus is lost: results in scrolled window scrolling to top each time window is shown: we don't want this + m_bpButtonLeftOnly->SetFocus(); + } updateGuiForFolderPair(); } @@ -1269,7 +1269,7 @@ void BatchDialog::addFolderPair(const std::vector<FreeFileSync::FolderPairEnh>& void BatchDialog::removeAddFolderPair(const int pos) { - wxWindowUpdateLocker dummy(m_panelOverview); //avoid display distortion + wxWindowUpdateLocker dummy(m_panelOverview); //avoid display distortion if (0 <= pos && pos < static_cast<int>(additionalFolderPairs.size())) { @@ -1296,7 +1296,7 @@ void BatchDialog::removeAddFolderPair(const int pos) m_bpButtonLeftOnly->SetFocus(); } - updateGuiForFolderPair(); + updateGuiForFolderPair(); } diff --git a/ui/settingsDialog.h b/ui/settingsDialog.h index 0864cf92..15d880f4 100644 --- a/ui/settingsDialog.h +++ b/ui/settingsDialog.h @@ -137,7 +137,7 @@ private: void removeAddFolderPair(const int pos); void clearAddFolderPairs(); -void updateGuiForFolderPair(); + void updateGuiForFolderPair(); FreeFileSync::CompareVariant getCurrentCompareVar() const; diff --git a/ui/sorting.h b/ui/sorting.h index 04ecc171..5771d7db 100644 --- a/ui/sorting.h +++ b/ui/sorting.h @@ -60,16 +60,16 @@ bool sortByFileName(const FileSystemObject& a, const FileSystemObject& b) return true; //empty rows always last - if (dynamic_cast<const DirMapping*>(&a)) //sort directories by relative name + if (isDirectoryMapping(a)) //sort directories by relative name { - if (dynamic_cast<const DirMapping*>(&b)) + if (isDirectoryMapping(b)) return stringSmallerThan(a.getRelativeName<side>(), b.getRelativeName<side>()); else return false; } else { - if (dynamic_cast<const DirMapping*>(&b)) + if (isDirectoryMapping(b)) return true; else return Compare<ascending>().isSmallerThan( @@ -86,15 +86,16 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) else if (b.isEmpty<side>()) return true; //empty rows always last - const FileMapping* fileObjA = dynamic_cast<const FileMapping*>(&a); - const Zstring relDirNameA = fileObjA != NULL ? - a.getParentRelativeName() : //file - a.getRelativeName<side>(); //directory + const bool isDirectoryA = isDirectoryMapping(a); + const Zstring relDirNameA = isDirectoryA ? + a.getRelativeName<side>() : //directory + a.getParentRelativeName(); //file + + const bool isDirectoryB = isDirectoryMapping(b); + const Zstring relDirNameB = isDirectoryB ? + b.getRelativeName<side>() : //directory + b.getParentRelativeName(); //file - const FileMapping* fileObjB = dynamic_cast<const FileMapping*>(&b); - const Zstring relDirNameB = fileObjB != NULL ? - b.getParentRelativeName() : //file - b.getRelativeName<side>(); //directory //compare relative names without filenames first const int rv = compareString(relDirNameA, relDirNameB); @@ -102,9 +103,9 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) return Compare<ascending>().isSmallerThan(rv, 0); else //compare the filenames { - if (fileObjB == NULL) //directories shall appear before files + if (isDirectoryB) //directories shall appear before files return false; - else if (fileObjA == NULL) + else if (isDirectoryA) return true; return stringSmallerThan(a.getShortName<side>(), b.getShortName<side>()); diff --git a/ui/trayIcon.cpp b/ui/trayIcon.cpp index 478d135a..921fe79f 100644 --- a/ui/trayIcon.cpp +++ b/ui/trayIcon.cpp @@ -1,8 +1,8 @@ #include "trayIcon.h" #include "../library/resources.h" #include "smallDialogs.h" -//#include "../library/statusHandler.h" #include <wx/taskbar.h> +#include <cmath> enum Selection @@ -89,10 +89,90 @@ void MinimizeToTray::resumeFromTray() //remove trayIcon and restore windows: Mi } -void MinimizeToTray::setToolTip(const wxString& toolTipText) +namespace +{ +inline +int roundNum(double d) //little rounding function +{ + return static_cast<int>(d < 0 ? d - .5 : d + .5); +} + + +wxIcon generateIcon(size_t percent) //generate icon with progress indicator +{ + percent = std::min(percent, static_cast<size_t>(100u)); //handle invalid input + +#ifdef FFS_WIN + static const wxBitmap trayIcon = GlobalResources::getInstance().getImageByName(wxT("FFS_tray_win.png")); +#elif defined FFS_LINUX + static const wxBitmap trayIcon = GlobalResources::getInstance().getImageByName(wxT("FFS_tray_linux.png")); +#endif + + const int indicatorHeight = roundNum((trayIcon.GetHeight() * percent) / 100.0); + + //minor optimization + static std::pair<int, wxIcon> buffer = std::make_pair(-1, wxNullIcon); + if (buffer.first == indicatorHeight) + return buffer.second; + + if ( trayIcon.GetWidth() > 0 && + trayIcon.GetHeight() > 0) + { + static const int indicatorWidth = trayIcon.GetWidth() * .25; + const int indicatorXBegin = ceil((trayIcon.GetWidth() - indicatorWidth) / 2.0); + const int indicatorYBegin = trayIcon.GetHeight() - indicatorHeight; + + wxImage genImage(trayIcon.ConvertToImage()); + + //draw progress indicator: do NOT use wxDC::DrawRectangle! Doesn't respect alpha in Windows, but does in Linux! + //We need a simple, working solution: + unsigned char* const data = genImage.GetData(); + for (int row = indicatorYBegin; row < genImage.GetHeight(); ++row) + { + for (int col = indicatorXBegin; col < indicatorXBegin + indicatorWidth; ++col) + { + unsigned char* const pixelBegin = data + (row * genImage.GetWidth() + col) * 3; + pixelBegin[0] = 255; //red + pixelBegin[1] = 255; //green + pixelBegin[2] = 0; //blue + } + } + + if (genImage.HasAlpha()) + { + unsigned char* const alpha = genImage.GetAlpha(); + //make progress indicator fully opaque: + for (int row = indicatorYBegin; row < genImage.GetHeight(); ++row) + ::memset(alpha + row * genImage.GetWidth() + indicatorXBegin, wxIMAGE_ALPHA_OPAQUE, indicatorWidth); + } + + wxIcon genIcon; + genIcon.CopyFromBitmap(wxBitmap(genImage)); + + //fill buffer + buffer.first = indicatorHeight; + buffer.second = genIcon; + + return genIcon; + } + + //fallback + wxIcon defaultIcon; + defaultIcon.CopyFromBitmap(trayIcon); + + //fill buffer + buffer.first = indicatorHeight; + buffer.second = defaultIcon; + + return defaultIcon; +} +} + + +void MinimizeToTray::setToolTip(const wxString& toolTipText, size_t percent) { if (trayIcon) - trayIcon->SetIcon(*GlobalResources::getInstance().programIcon, toolTipText); + trayIcon->SetIcon(generateIcon(percent), toolTipText); } @@ -125,3 +205,4 @@ void MinimizeToTray::OnDoubleClick(wxCommandEvent& event) { resumeFromTray(); } + diff --git a/ui/trayIcon.h b/ui/trayIcon.h index 94e75518..8c8797d4 100644 --- a/ui/trayIcon.h +++ b/ui/trayIcon.h @@ -11,7 +11,7 @@ public: MinimizeToTray(wxTopLevelWindow* callerWnd, wxWindow* secondWnd = NULL); //ensure callerWind has longer lifetime! ~MinimizeToTray(); //show windows again - void setToolTip(const wxString& toolTipText); + void setToolTip(const wxString& toolTipText, size_t percent = 0); //percent (optional), number between [0, 100], for small progress indicator void keepHidden(); //do not show windows again: avoid window flashing shortly before it is destroyed private: |