diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:12:17 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:12:17 +0200 |
commit | b654dbfa5f3e4a4d02f72023f7c5895635aa6396 (patch) | |
tree | 8c1dfe7f638c0fc7afc1d08bc2fc0fd0f8646e5e /ui | |
parent | 3.17 (diff) | |
download | FreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.tar.gz FreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.tar.bz2 FreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.zip |
3.18
Diffstat (limited to 'ui')
-rw-r--r-- | ui/batch_config.cpp | 24 | ||||
-rw-r--r-- | ui/batch_status_handler.cpp | 6 | ||||
-rw-r--r-- | ui/batch_status_handler.h | 5 | ||||
-rw-r--r-- | ui/check_version.cpp | 3 | ||||
-rw-r--r-- | ui/folder_pair.h | 4 | ||||
-rw-r--r-- | ui/grid_view.cpp | 96 | ||||
-rw-r--r-- | ui/grid_view.h | 16 | ||||
-rw-r--r-- | ui/gui_generated.cpp | 111 | ||||
-rw-r--r-- | ui/gui_generated.h | 12 | ||||
-rw-r--r-- | ui/gui_status_handler.cpp | 6 | ||||
-rw-r--r-- | ui/gui_status_handler.h | 2 | ||||
-rw-r--r-- | ui/main_dlg.cpp | 221 | ||||
-rw-r--r-- | ui/main_dlg.h | 6 | ||||
-rw-r--r-- | ui/progress_indicator.cpp | 57 | ||||
-rw-r--r-- | ui/progress_indicator.h | 17 | ||||
-rw-r--r-- | ui/small_dlgs.cpp | 1 | ||||
-rw-r--r-- | ui/sorting.h | 16 | ||||
-rw-r--r-- | ui/sync_cfg.cpp | 78 |
18 files changed, 341 insertions, 340 deletions
diff --git a/ui/batch_config.cpp b/ui/batch_config.cpp index 18b8a555..557cb229 100644 --- a/ui/batch_config.cpp +++ b/ui/batch_config.cpp @@ -5,7 +5,6 @@ // ************************************************************************** // #include "batch_config.h" -#include "../shared/xml_base.h" #include "../shared/dir_picker_i18n.h" #include "folder_pair.h" #include <iterator> @@ -16,7 +15,8 @@ #include "gui_generated.h" #include <wx/dnd.h> #include <wx/msgdlg.h> -#include "../shared/util.h" +//#include "../shared/util.h" +#include "../shared/wx_choice_enum.h" #include "../shared/mouse_move_dlg.h" using namespace zen; @@ -79,7 +79,7 @@ private: xmlAccess::XmlBatchConfig getCurrentConfiguration() const; - boost::shared_ptr<DirectoryPairBatchFirst> firstFolderPair; //always bound!!! + std::shared_ptr<DirectoryPairBatchFirst> firstFolderPair; //always bound!!! std::vector<DirectoryPairBatch*> additionalFolderPairs; //used when saving batch file @@ -87,9 +87,9 @@ private: xmlAccess::XmlBatchConfig localBatchCfg; - std::auto_ptr<wxMenu> contextMenu; + std::unique_ptr<wxMenu> contextMenu; - std::auto_ptr<zen::DirectoryName> logfileDir; + std::unique_ptr<zen::DirectoryName> logfileDir; zen::EnumDescrList<xmlAccess::OnError> enumDescrMap; }; @@ -410,11 +410,11 @@ void BatchDialog::OnFilesDropped(FFSFileDropEvent& event) xmlAccess::XmlBatchConfig batchCfg; try { - convertConfig(fileList, batchCfg); //throw (xmlAccess::XmlError) + convertConfig(fileList, batchCfg); //throw (xmlAccess::FfsXmlError) } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { - if (error.getSeverity() == xmlAccess::XmlError::WARNING) + if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING) wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING); else { @@ -571,7 +571,7 @@ bool BatchDialog::saveBatchFile(const wxString& filename) { xmlAccess::writeConfig(batchCfg, filename); } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { wxMessageBox(error.msg().c_str(), _("Error"), wxOK | wxICON_ERROR); return false; @@ -594,13 +594,13 @@ void BatchDialog::loadBatchFile(const wxString& filename) std::vector<wxString> filenames; filenames.push_back(filename); - xmlAccess::convertConfig(filenames, batchCfg); //throw (xmlAccess::XmlError) + xmlAccess::convertConfig(filenames, batchCfg); //throw (xmlAccess::FfsXmlError) //xmlAccess::readConfig(filename, batchCfg); } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { - if (error.getSeverity() == xmlAccess::XmlError::WARNING) + if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING) wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING); else { diff --git a/ui/batch_status_handler.cpp b/ui/batch_status_handler.cpp index b9eff9fa..4b4740f9 100644 --- a/ui/batch_status_handler.cpp +++ b/ui/batch_status_handler.cpp @@ -182,7 +182,7 @@ BatchStatusHandler::BatchStatusHandler(bool runSilent, handleError_(handleError), currentProcess(StatusHandler::PROCESS_NONE), returnValue(returnVal), - syncStatusFrame(*this, NULL, runSilent, jobName) + syncStatusFrame(*this, NULL, SyncStatus::SCANNING, runSilent, jobName) { if (logfileDirectory && logFileMaxCount > 0) { @@ -195,7 +195,7 @@ BatchStatusHandler::BatchStatusHandler(bool runSilent, { wxMessageBox(error.msg(), _("Error"), wxOK | wxICON_ERROR); returnValue = -7; - throw zen::AbortThisProcess(); + throw BatchAbortProcess(); } } @@ -415,5 +415,5 @@ void BatchStatusHandler::forceUiRefresh() void BatchStatusHandler::abortThisProcess() { requestAbortion(); - throw zen::AbortThisProcess(); //abort can be triggered by syncStatusFrame + throw BatchAbortProcess(); //abort can be triggered by syncStatusFrame } diff --git a/ui/batch_status_handler.h b/ui/batch_status_handler.h index 0e03141e..a7c16488 100644 --- a/ui/batch_status_handler.h +++ b/ui/batch_status_handler.h @@ -16,6 +16,9 @@ class LogFile; class SyncStatus; +//Exception class used to abort the "compare" and "sync" process +class BatchAbortProcess {}; + class BatchStatusHandler : public StatusHandler { @@ -50,7 +53,7 @@ private: int& returnValue; SyncStatus syncStatusFrame; //the window managed by SyncStatus has longer lifetime than this handler! - boost::shared_ptr<LogFile> logFile; //optional! + std::shared_ptr<LogFile> logFile; //optional! }; diff --git a/ui/check_version.cpp b/ui/check_version.cpp index 2147d717..03f7e486 100644 --- a/ui/check_version.cpp +++ b/ui/check_version.cpp @@ -11,13 +11,12 @@ #include "../version/version.h" #include <wx/utils.h> #include <wx/timer.h> -#include "../shared/string_tools.h" +#include <string_tools.h> #include "msg_popup.h" #include "../shared/standard_paths.h" #include <wx/tokenzr.h> #include "../shared/i18n.h" - class CloseConnectionOnExit { public: diff --git a/ui/folder_pair.h b/ui/folder_pair.h index d72651c8..770aceb3 100644 --- a/ui/folder_pair.h +++ b/ui/folder_pair.h @@ -26,7 +26,7 @@ template <class GuiPanel> class FolderPairPanelBasic : private wxEvtHandler { public: - typedef boost::shared_ptr<const zen::AlternateSyncConfig> AltSyncCfgPtr; + typedef std::shared_ptr<const zen::AlternateSyncConfig> AltSyncCfgPtr; AltSyncCfgPtr getAltSyncConfig() const { @@ -177,7 +177,7 @@ private: AltSyncCfgPtr altSyncConfig; //optional: present if non-NULL FilterConfig localFilter; - std::auto_ptr<wxMenu> contextMenu; + std::unique_ptr<wxMenu> contextMenu; }; } diff --git a/ui/grid_view.cpp b/ui/grid_view.cpp index 4db921fa..59bfb767 100644 --- a/ui/grid_view.cpp +++ b/ui/grid_view.cpp @@ -326,7 +326,7 @@ void GridView::setData(FolderComparison& newData) //------------------------------------ SORTING TEMPLATES ------------------------------------------------ template <bool ascending> -class GridView::SortByDirectory : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessDirectoryPair : public std::binary_function<RefIndex, RefIndex, bool> { public: bool operator()(const RefIndex a, const RefIndex b) const @@ -339,10 +339,10 @@ public: template <bool ascending, zen::SelectedSide side> -class GridView::SortByRelName : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessRelativeName : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByRelName(const GridView& view) : m_view(view) {} + LessRelativeName(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -359,7 +359,7 @@ public: else if (fsObjB == NULL) return true; - return sortByRelativeName<ascending, side>(*fsObjA, *fsObjB); + return lessRelativeName<ascending, side>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -367,10 +367,10 @@ private: template <bool ascending, zen::SelectedSide side> -class GridView::SortByFileName : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessShortFileName : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByFileName(const GridView& view) : m_view(view) {} + LessShortFileName(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -381,7 +381,7 @@ public: else if (fsObjB == NULL) return true; - return sortByFileName<ascending, side>(*fsObjA, *fsObjB); + return lessShortFileName<ascending, side>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -389,10 +389,10 @@ private: template <bool ascending, zen::SelectedSide side> -class GridView::SortByFileSize : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessFilesize : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByFileSize(const GridView& view) : m_view(view) {} + LessFilesize(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -403,7 +403,7 @@ public: else if (fsObjB == NULL) return true; - return sortByFileSize<ascending, side>(*fsObjA, *fsObjB); + return lessFilesize<ascending, side>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -411,10 +411,10 @@ private: template <bool ascending, zen::SelectedSide side> -class GridView::SortByDate : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessFiletime : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByDate(const GridView& view) : m_view(view) {} + LessFiletime(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -425,7 +425,7 @@ public: else if (fsObjB == NULL) return true; - return sortByDate<ascending, side>(*fsObjA, *fsObjB); + return lessFiletime<ascending, side>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -433,10 +433,10 @@ private: template <bool ascending, zen::SelectedSide side> -class GridView::SortByExtension : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessExtension : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByExtension(const GridView& view) : m_view(view) {} + LessExtension(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -447,7 +447,7 @@ public: else if (fsObjB == NULL) return true; - return sortByExtension<ascending, side>(*fsObjA, *fsObjB); + return lessExtension<ascending, side>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -455,10 +455,10 @@ private: template <bool ascending> -class GridView::SortByCmpResult : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessCmpResult : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortByCmpResult(const GridView& view) : m_view(view) {} + LessCmpResult(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -469,7 +469,7 @@ public: else if (fsObjB == NULL) return true; - return sortByCmpResult<ascending>(*fsObjA, *fsObjB); + return lessCmpResult<ascending>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -477,10 +477,10 @@ private: template <bool ascending> -class GridView::SortBySyncDirection : public std::binary_function<RefIndex, RefIndex, bool> +class GridView::LessSyncDirection : public std::binary_function<RefIndex, RefIndex, bool> { public: - SortBySyncDirection(const GridView& view) : m_view(view) {} + LessSyncDirection(const GridView& view) : m_view(view) {} bool operator()(const RefIndex a, const RefIndex b) const { @@ -491,7 +491,7 @@ public: else if (fsObjB == NULL) return true; - return sortBySyncDirection<ascending>(*fsObjA, *fsObjB); + return lessSyncDirection<ascending>(*fsObjA, *fsObjB); } private: const GridView& m_view; @@ -526,46 +526,46 @@ void GridView::sortView(SortType type, bool onLeft, bool ascending) switch (type) { case SORT_BY_REL_NAME: - if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByRelName<true, LEFT_SIDE>(*this)); - else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByRelName<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByRelName<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByRelName<false, RIGHT_SIDE>(*this)); + if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<true, LEFT_SIDE>(*this)); + else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<true, RIGHT_SIDE>(*this)); + else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<false, LEFT_SIDE >(*this)); + else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessRelativeName<false, RIGHT_SIDE>(*this)); break; case SORT_BY_FILENAME: - if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileName<true, LEFT_SIDE >(*this)); - else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileName<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileName<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileName<false, RIGHT_SIDE>(*this)); + if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessShortFileName<true, LEFT_SIDE >(*this)); + else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessShortFileName<true, RIGHT_SIDE>(*this)); + else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessShortFileName<false, LEFT_SIDE >(*this)); + else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessShortFileName<false, RIGHT_SIDE>(*this)); break; case SORT_BY_FILESIZE: - if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileSize<true, LEFT_SIDE >(*this)); - else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileSize<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileSize<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByFileSize<false, RIGHT_SIDE>(*this)); + if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFilesize<true, LEFT_SIDE >(*this)); + else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFilesize<true, RIGHT_SIDE>(*this)); + else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFilesize<false, LEFT_SIDE >(*this)); + else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFilesize<false, RIGHT_SIDE>(*this)); break; case SORT_BY_DATE: - if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<true, LEFT_SIDE >(*this)); - else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), SortByDate<false, RIGHT_SIDE>(*this)); + if ( ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFiletime<true, LEFT_SIDE >(*this)); + else if ( ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFiletime<true, RIGHT_SIDE>(*this)); + else if (!ascending && onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFiletime<false, LEFT_SIDE >(*this)); + else if (!ascending && !onLeft) std::sort(sortedRef.begin(), sortedRef.end(), LessFiletime<false, RIGHT_SIDE>(*this)); break; case SORT_BY_EXTENSION: - if ( ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<true, LEFT_SIDE >(*this)); - else if ( ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<true, RIGHT_SIDE>(*this)); - else if (!ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<false, LEFT_SIDE >(*this)); - else if (!ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByExtension<false, RIGHT_SIDE>(*this)); + if ( ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessExtension<true, LEFT_SIDE >(*this)); + else if ( ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessExtension<true, RIGHT_SIDE>(*this)); + else if (!ascending && onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessExtension<false, LEFT_SIDE >(*this)); + else if (!ascending && !onLeft) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessExtension<false, RIGHT_SIDE>(*this)); break; case SORT_BY_CMP_RESULT: - if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByCmpResult<true >(*this)); - else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByCmpResult<false>(*this)); + if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessCmpResult<true >(*this)); + else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessCmpResult<false>(*this)); break; case SORT_BY_SYNC_DIRECTION: - if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortBySyncDirection<true >(*this)); - else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortBySyncDirection<false>(*this)); + if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessSyncDirection<true >(*this)); + else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessSyncDirection<false>(*this)); break; case SORT_BY_DIRECTORY: - if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByDirectory<true>()); - else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), SortByDirectory<false>()); + if ( ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessDirectoryPair<true>()); + else if (!ascending) std::stable_sort(sortedRef.begin(), sortedRef.end(), LessDirectoryPair<false>()); break; } } diff --git a/ui/grid_view.h b/ui/grid_view.h index b21bcde4..edb54ab7 100644 --- a/ui/grid_view.h +++ b/ui/grid_view.h @@ -145,28 +145,28 @@ private: //sorting classes template <bool ascending> - class SortByDirectory; + class LessDirectoryPair; template <bool ascending, SelectedSide side> - class SortByRelName; + class LessRelativeName; template <bool ascending, SelectedSide side> - class SortByFileName; + class LessShortFileName; template <bool ascending, SelectedSide side> - class SortByFileSize; + class LessFilesize; template <bool ascending, SelectedSide side> - class SortByDate; + class LessFiletime; template <bool ascending, SelectedSide side> - class SortByExtension; + class LessExtension; template <bool ascending> - class SortByCmpResult; + class LessCmpResult; template <bool ascending> - class SortBySyncDirection; + class LessSyncDirection; }; diff --git a/ui/gui_generated.cpp b/ui/gui_generated.cpp index d3d7488f..c268957e 100644 --- a/ui/gui_generated.cpp +++ b/ui/gui_generated.cpp @@ -42,7 +42,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const m_menuItemSave = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("S&ave configuration...") ) + wxT('\t') + wxT("Ctrl-S"), wxEmptyString, wxITEM_NORMAL ); m_menuFile->Append( m_menuItemSave ); - m_menuItemLoad = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("&Load configuration...") ) + wxT('\t') + wxT("Ctrl-L"), wxEmptyString, wxITEM_NORMAL ); + m_menuItemLoad = new wxMenuItem( m_menuFile, wxID_ANY, wxString( _("&Load configuration...") ) + wxT('\t') + wxT("Ctrl-O"), wxEmptyString, wxITEM_NORMAL ); m_menuFile->Append( m_menuItemLoad ); wxMenuItem* m_separator3; @@ -332,7 +332,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const m_gridLeft->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); m_gridLeft->SetMinSize( wxSize( 1,1 ) ); - bSizer7->Add( m_gridLeft, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 5 ); + bSizer7->Add( m_gridLeft, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_panelLeft->SetSizer( bSizer7 ); m_panelLeft->Layout(); @@ -369,7 +369,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const // Cell Defaults m_gridMiddle->SetDefaultCellFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxT("Arial") ) ); m_gridMiddle->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); - bSizer18->Add( m_gridMiddle, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + bSizer18->Add( m_gridMiddle, 1, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_panelMiddle->SetSizer( bSizer18 ); m_panelMiddle->Layout(); @@ -406,7 +406,7 @@ MainDialogGenerated::MainDialogGenerated( wxWindow* parent, wxWindowID id, const m_gridRight->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_CENTRE ); m_gridRight->SetMinSize( wxSize( 1,1 ) ); - bSizer10->Add( m_gridRight, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT, 5 ); + bSizer10->Add( m_gridRight, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); m_panelRight->SetSizer( bSizer10 ); m_panelRight->Layout(); @@ -1031,7 +1031,7 @@ BatchDlgGenerated::BatchDlgGenerated( wxWindow* parent, wxWindowID id, const wxS wxBoxSizer* bSizer70; bSizer70 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText44 = new wxStaticText( this, wxID_ANY, _("Assemble a batch file for automated synchronization. To start in batch mode simply pass the name of the file to the FreeFileSync executable: FreeFileSync.exe <batchfile>. This can also be scheduled in your operating system's task planner."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText44 = new wxStaticText( this, wxID_ANY, _("Create a batch file for automated synchronization. To start in batch mode simply double-click the file or execute via command line: FreeFileSync.exe <batchfile>. This can also be scheduled in your operating system's task planner."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText44->Wrap( 500 ); bSizer70->Add( m_staticText44, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); @@ -1682,9 +1682,6 @@ SyncCfgDlgGenerated::SyncCfgDlgGenerated( wxWindow* parent, wxWindowID id, const bSizer29->Add( bSizer201, 0, wxTOP|wxBOTTOM, 5 ); - - bSizer29->Add( 0, 5, 1, 0, 5 ); - wxBoxSizer* bSizer291; bSizer291 = new wxBoxSizer( wxHORIZONTAL ); @@ -1709,7 +1706,16 @@ SyncCfgDlgGenerated::SyncCfgDlgGenerated( wxWindow* parent, wxWindowID id, const bSizer181->Add( 10, 0, 0, 0, 5 ); - sbSizerSyncDirections = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Configuration") ), wxVERTICAL ); + wxStaticBoxSizer* sbSizer2453245; + sbSizer2453245 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Configuration") ), wxVERTICAL ); + + + sbSizer2453245->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_bitmapDatabase = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 70,70 ), 0 ); + sbSizer2453245->Add( m_bitmapDatabase, 1, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 10 ); + + sbSizerSyncDirections = new wxBoxSizer( wxVERTICAL ); wxGridSizer* gSizer3; gSizer3 = new wxGridSizer( 1, 2, 0, 5 ); @@ -1734,105 +1740,104 @@ SyncCfgDlgGenerated::SyncCfgDlgGenerated( wxWindow* parent, wxWindowID id, const wxBoxSizer* bSizer121; bSizer121 = new wxBoxSizer( wxVERTICAL ); - wxBoxSizer* bSizer122; - bSizer122 = new wxBoxSizer( wxHORIZONTAL ); + bSizerLeftOnly = new wxBoxSizer( wxHORIZONTAL ); m_bitmapLeftOnly = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapLeftOnly->SetToolTip( _("Files/folders that exist on left side only") ); + m_bitmapLeftOnly->SetToolTip( _("File/folder exists on left side only") ); - bSizer122->Add( m_bitmapLeftOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerLeftOnly->Add( m_bitmapLeftOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer122->Add( 5, 0, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizerLeftOnly->Add( 5, 0, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_bpButtonLeftOnly = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer122->Add( m_bpButtonLeftOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerLeftOnly->Add( m_bpButtonLeftOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer122, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerLeftOnly, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - wxBoxSizer* bSizer123; - bSizer123 = new wxBoxSizer( wxHORIZONTAL ); + bSizerRightOnly = new wxBoxSizer( wxHORIZONTAL ); m_bitmapRightOnly = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapRightOnly->SetToolTip( _("Files/folders that exist on right side only") ); + m_bitmapRightOnly->SetToolTip( _("File/folder exists on right side only") ); - bSizer123->Add( m_bitmapRightOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerRightOnly->Add( m_bitmapRightOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer123->Add( 5, 0, 0, 0, 5 ); + bSizerRightOnly->Add( 5, 0, 0, 0, 5 ); m_bpButtonRightOnly = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer123->Add( m_bpButtonRightOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerRightOnly->Add( m_bpButtonRightOnly, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer123, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerRightOnly, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - wxBoxSizer* bSizer124; - bSizer124 = new wxBoxSizer( wxHORIZONTAL ); + bSizerLeftNewer = new wxBoxSizer( wxHORIZONTAL ); m_bitmapLeftNewer = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapLeftNewer->SetToolTip( _("Files that exist on both sides, left one is newer") ); + m_bitmapLeftNewer->SetToolTip( _("Left file is newer") ); - bSizer124->Add( m_bitmapLeftNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerLeftNewer->Add( m_bitmapLeftNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer124->Add( 5, 0, 0, 0, 5 ); + bSizerLeftNewer->Add( 5, 0, 0, 0, 5 ); m_bpButtonLeftNewer = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer124->Add( m_bpButtonLeftNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerLeftNewer->Add( m_bpButtonLeftNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer124, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerLeftNewer, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - wxBoxSizer* bSizer125; - bSizer125 = new wxBoxSizer( wxHORIZONTAL ); + bSizerRightNewer = new wxBoxSizer( wxHORIZONTAL ); m_bitmapRightNewer = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapRightNewer->SetToolTip( _("Files that exist on both sides, right one is newer") ); + m_bitmapRightNewer->SetToolTip( _("Right file is newer") ); - bSizer125->Add( m_bitmapRightNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerRightNewer->Add( m_bitmapRightNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer125->Add( 5, 0, 0, 0, 5 ); + bSizerRightNewer->Add( 5, 0, 0, 0, 5 ); m_bpButtonRightNewer = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer125->Add( m_bpButtonRightNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerRightNewer->Add( m_bpButtonRightNewer, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer125, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerRightNewer, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - wxBoxSizer* bSizer126; - bSizer126 = new wxBoxSizer( wxHORIZONTAL ); + bSizerDifferent = new wxBoxSizer( wxHORIZONTAL ); m_bitmapDifferent = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapDifferent->SetToolTip( _("Files that have different content") ); + m_bitmapDifferent->SetToolTip( _("Files have different content") ); - bSizer126->Add( m_bitmapDifferent, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDifferent->Add( m_bitmapDifferent, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer126->Add( 5, 0, 0, 0, 5 ); + bSizerDifferent->Add( 5, 0, 0, 0, 5 ); m_bpButtonDifferent = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer126->Add( m_bpButtonDifferent, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerDifferent->Add( m_bpButtonDifferent, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer126, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerDifferent, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - wxBoxSizer* bSizer127; - bSizer127 = new wxBoxSizer( wxHORIZONTAL ); + bSizerConflict = new wxBoxSizer( wxHORIZONTAL ); m_bitmapConflict = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 45,45 ), 0 ); - m_bitmapConflict->SetToolTip( _("Conflicts/files that cannot be categorized") ); + m_bitmapConflict->SetToolTip( _("Conflict/file cannot be categorized") ); - bSizer127->Add( m_bitmapConflict, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerConflict->Add( m_bitmapConflict, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer127->Add( 5, 0, 0, 0, 5 ); + bSizerConflict->Add( 5, 0, 0, 0, 5 ); m_bpButtonConflict = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - bSizer127->Add( m_bpButtonConflict, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizerConflict->Add( m_bpButtonConflict, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer121->Add( bSizer127, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer121->Add( bSizerConflict, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); sbSizerSyncDirections->Add( bSizer121, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizer181->Add( sbSizerSyncDirections, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + sbSizer2453245->Add( sbSizerSyncDirections, 0, wxEXPAND, 5 ); + + + sbSizer2453245->Add( 0, 0, 1, wxEXPAND, 5 ); + + bSizer181->Add( sbSizer2453245, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); bSizer7->Add( bSizer181, 0, wxALL, 5 ); @@ -2565,7 +2570,7 @@ AboutDlgGenerated::AboutDlgGenerated( wxWindow* parent, wxWindowID id, const wxS bSizer172->Add( m_hyperlink8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_hyperlink15 = new wxHyperlinkCtrl( m_panel33, wxID_ANY, _("TinyXML"), wxT("http://www.grinninglizard.com/tinyxml"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + m_hyperlink15 = new wxHyperlinkCtrl( m_panel33, wxID_ANY, _("zenXML"), wxT("http://sourceforge.net/projects/zenxml/"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); m_hyperlink15->SetBackgroundColour( wxColour( 208, 208, 208 ) ); bSizer172->Add( m_hyperlink15, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); diff --git a/ui/gui_generated.h b/ui/gui_generated.h index ef0462bc..13a4ea00 100644 --- a/ui/gui_generated.h +++ b/ui/gui_generated.h @@ -456,34 +456,42 @@ protected: wxPanel* m_panelCustomDeletionDir; wxTextCtrl* m_textCtrlCustomDelFolder; FfsDirPickerCtrl* m_dirPickerCustomDelFolder; - wxButton* m_buttonOK; wxButton* m_button16; - wxStaticBoxSizer* sbSizerSyncDirections; + + wxStaticBitmap* m_bitmapDatabase; + wxBoxSizer* sbSizerSyncDirections; wxStaticText* m_staticText21; wxStaticText* m_staticText31; wxStaticLine* m_staticline3; + wxBoxSizer* bSizerLeftOnly; wxStaticBitmap* m_bitmapLeftOnly; wxBitmapButton* m_bpButtonLeftOnly; + wxBoxSizer* bSizerRightOnly; wxStaticBitmap* m_bitmapRightOnly; wxBitmapButton* m_bpButtonRightOnly; + wxBoxSizer* bSizerLeftNewer; wxStaticBitmap* m_bitmapLeftNewer; wxBitmapButton* m_bpButtonLeftNewer; + wxBoxSizer* bSizerRightNewer; wxStaticBitmap* m_bitmapRightNewer; wxBitmapButton* m_bpButtonRightNewer; + wxBoxSizer* bSizerDifferent; wxStaticBitmap* m_bitmapDifferent; wxBitmapButton* m_bpButtonDifferent; + wxBoxSizer* bSizerConflict; wxStaticBitmap* m_bitmapConflict; wxBitmapButton* m_bpButtonConflict; + // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnSyncAutomatic( wxCommandEvent& event ) { event.Skip(); } diff --git a/ui/gui_status_handler.cpp b/ui/gui_status_handler.cpp index 09c59b92..3319d07a 100644 --- a/ui/gui_status_handler.cpp +++ b/ui/gui_status_handler.cpp @@ -204,14 +204,14 @@ void CompareStatusHandler::OnAbortCompare(wxCommandEvent& event) void CompareStatusHandler::abortThisProcess() { requestAbortion(); - throw zen::AbortThisProcess(); + throw GuiAbortProcess(); } //######################################################################################################## SyncStatusHandler::SyncStatusHandler(MainDialog* parentDlg, OnGuiError handleError, const wxString& jobName) : parentDlg_(parentDlg), - syncStatusFrame(*this, parentDlg, false, jobName), + syncStatusFrame(*this, parentDlg, SyncStatus::SYNCHRONIZING, false, jobName), handleError_(handleError) { } @@ -361,5 +361,5 @@ void SyncStatusHandler::forceUiRefresh() void SyncStatusHandler::abortThisProcess() { requestAbortion(); - throw zen::AbortThisProcess(); //abort can be triggered by syncStatusFrame + throw GuiAbortProcess(); //abort can be triggered by syncStatusFrame } diff --git a/ui/gui_status_handler.h b/ui/gui_status_handler.h index bd5b061a..7f41e649 100644 --- a/ui/gui_status_handler.h +++ b/ui/gui_status_handler.h @@ -17,6 +17,8 @@ class SyncStatus; class wxCommandEvent; +//Exception class used to abort the "compare" and "sync" process +class GuiAbortProcess {}; //classes handling sync and compare error as well as status information class CompareStatusHandler : private wxEvtHandler, public StatusHandler diff --git a/ui/main_dlg.cpp b/ui/main_dlg.cpp index 6e6c17f7..c5e8ef72 100644 --- a/ui/main_dlg.cpp +++ b/ui/main_dlg.cpp @@ -43,7 +43,6 @@ #include "../shared/file_handling.h" #include "../shared/resolve_path.h" #include "../shared/recycler.h" -#include "../shared/xml_base.h" #include "../shared/standard_paths.h" #include "../shared/toggle_button.h" #include "folder_pair.h" @@ -108,11 +107,11 @@ public: xmlAccess::XmlGuiConfig guiCfg; try { - convertConfig(droppedFiles, guiCfg); //throw (xmlAccess::XmlError) + convertConfig(droppedFiles, guiCfg); //throw (xmlAccess::FfsXmlError) } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { - if (error.getSeverity() == xmlAccess::XmlError::WARNING) + if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING) wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING); else { @@ -369,13 +368,13 @@ MainDialog::MainDialog(const wxString& cfgFileName, xmlAccess::XmlGlobalSettings std::vector<wxString> filenames; filenames.push_back(currentConfigFile); - xmlAccess::convertConfig(filenames, guiCfg); //throw (xmlAccess::XmlError) + xmlAccess::convertConfig(filenames, guiCfg); //throw (xmlAccess::FfsXmlError) loadCfgSuccess = true; } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { - if (error.getSeverity() == xmlAccess::XmlError::WARNING) + if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING) wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING); else wxMessageBox(error.msg(), _("Error"), wxOK | wxICON_ERROR); @@ -656,7 +655,16 @@ void MainDialog::cleanUp(bool saveLastUsedConfig) //save configuration if (saveLastUsedConfig) - writeConfigurationToXml(lastRunConfigName()); //don't throw exceptions in destructors + { + const xmlAccess::XmlGuiConfig guiCfg = getCurrentConfiguration(); + try + { + xmlAccess::writeConfig(guiCfg, lastRunConfigName()); + setLastUsedConfig(lastRunConfigName(), guiCfg); + } + //don't annoy users on read-only drives: no error checking should be fine since this is not a config the user explitily wanted to save + catch (const xmlAccess::FfsXmlError&) {} + } } } @@ -664,18 +672,13 @@ void MainDialog::cleanUp(bool saveLastUsedConfig) void MainDialog::readGlobalSettings() { //apply window size and position at program startup ONLY - widthNotMaximized = globalSettings->gui.widthNotMaximized; - heightNotMaximized = globalSettings->gui.heightNotMaximized; - posXNotMaximized = globalSettings->gui.posXNotMaximized; - posYNotMaximized = globalSettings->gui.posYNotMaximized; - //apply window size and position - if (widthNotMaximized != wxDefaultCoord && - heightNotMaximized != wxDefaultCoord && - posXNotMaximized != wxDefaultCoord && - posYNotMaximized != wxDefaultCoord && - wxDisplay::GetFromPoint(wxPoint(posXNotMaximized, posYNotMaximized)) != wxNOT_FOUND) //make sure upper left corner is in visible view - SetSize(posXNotMaximized, posYNotMaximized, widthNotMaximized, heightNotMaximized); + if (globalSettings->gui.dlgSize.GetWidth () != wxDefaultCoord && + globalSettings->gui.dlgSize.GetHeight() != wxDefaultCoord && + globalSettings->gui.dlgPos.x != wxDefaultCoord && + globalSettings->gui.dlgPos.y != wxDefaultCoord && + wxDisplay::GetFromPoint(globalSettings->gui.dlgPos) != wxNOT_FOUND) //make sure upper left corner is in visible view + SetSize(wxRect(globalSettings->gui.dlgPos, globalSettings->gui.dlgSize)); else Centre(); @@ -723,11 +726,7 @@ void MainDialog::readGlobalSettings() void MainDialog::writeGlobalSettings() { //write global settings to (global) variable stored in application instance - globalSettings->gui.widthNotMaximized = widthNotMaximized; - globalSettings->gui.heightNotMaximized = heightNotMaximized; - globalSettings->gui.posXNotMaximized = posXNotMaximized; - globalSettings->gui.posYNotMaximized = posYNotMaximized; - globalSettings->gui.isMaximized = IsMaximized(); + globalSettings->gui.isMaximized = IsMaximized(); //retrieve column attributes globalSettings->gui.columnAttribLeft = m_gridLeft->getColumnAttributes(); @@ -832,6 +831,9 @@ void MainDialog::copySelectionToClipboard(CustomGrid& selectedGrid) const std::set<size_t> selectedRows = getSelectedRows(&selectedGrid); if (selectedRows.size() > 0) { + //fast replacement for wxString modelling exponential growth + typedef Zbase<wchar_t> zxString; + zxString clipboardString; //perf: wxString doesn't model exponential growth and so is out const int colCount = selectedGrid.GetNumberCols(); @@ -840,7 +842,7 @@ void MainDialog::copySelectionToClipboard(CustomGrid& selectedGrid) { for (int k = 0; k < colCount; ++k) { - clipboardString += wxToZx(selectedGrid.GetCellValue(static_cast<int>(*i), k)); + clipboardString += cvrtString<zxString>(selectedGrid.GetCellValue(static_cast<int>(*i), k)); if (k != colCount - 1) clipboardString += wxT('\t'); } @@ -853,7 +855,7 @@ void MainDialog::copySelectionToClipboard(CustomGrid& selectedGrid) { // these data objects are held by the clipboard, // so do not delete them in the app. - wxTheClipboard->SetData(new wxTextDataObject(zxToWx(clipboardString))); + wxTheClipboard->SetData(new wxTextDataObject(cvrtString<wxString>(clipboardString))); wxTheClipboard->Close(); } } @@ -881,6 +883,9 @@ std::set<size_t> MainDialog::getSelectedRows() const } +//Exception class used to abort the "compare" and "sync" process +class AbortDeleteProcess {}; + class ManualDeletionHandler : private wxEvtHandler, public DeleteFilesHandler { public: @@ -910,7 +915,7 @@ public: virtual Response reportError(const wxString& errorMessage) { if (abortRequested) - throw zen::AbortThisProcess(); + throw AbortDeleteProcess(); if (ignoreErrors) return DeleteFilesHandler::IGNORE_ERROR; @@ -925,7 +930,7 @@ public: case ReturnErrorDlg::BUTTON_RETRY: return DeleteFilesHandler::RETRY; case ReturnErrorDlg::BUTTON_ABORT: - throw zen::AbortThisProcess(); + throw AbortDeleteProcess(); } assert (false); @@ -950,7 +955,7 @@ public: } if (abortRequested) //test after (implicit) call to wxApp::Yield() - throw zen::AbortThisProcess(); + throw AbortDeleteProcess(); } private: @@ -1014,7 +1019,7 @@ void MainDialog::deleteSelectedFiles(const std::set<size_t>& viewSelectionLeft, globalSettings->gui.useRecyclerForManualDeletion, statusHandler); } - catch (zen::AbortThisProcess&) {} + catch (AbortDeleteProcess&) {} //remove rows that are empty: just a beautification, invalid rows shouldn't cause issues gridDataView->removeInvalidRows(); @@ -1114,9 +1119,11 @@ void MainDialog::openExternalApplication(size_t rowNumber, bool leftSide, const if (name.empty()) { if (leftSide) - zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<LEFT_SIDE>()) + L"\""); + zen::shellExecute(wxString(L"\"") + zToWx(fsObj->getBaseDirPf<LEFT_SIDE>()) + L"\""); + //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<LEFT_SIDE>()) + L"\""); else - zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<RIGHT_SIDE>()) + L"\""); + zen::shellExecute(wxString(L"\"") + zToWx(fsObj->getBaseDirPf<RIGHT_SIDE>()) + L"\""); + //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + zToWx(fsObj->getBaseDirPf<RIGHT_SIDE>()) + L"\""); return; } #endif @@ -1131,7 +1138,8 @@ void MainDialog::openExternalApplication(size_t rowNumber, bool leftSide, const std::swap(dir, dirCo); #ifdef FFS_WIN - zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + dir + L"\""); //default + zen::shellExecute(wxString(L"\"") + dir + L"\""); //default + //zen::shellExecute(wxString(wxT("explorer ")) + L"\"" + dir + L"\""); //default return; #endif } @@ -1233,24 +1241,16 @@ void MainDialog::OnResize(wxSizeEvent& event) { if (!IsMaximized()) { - int width = 0; - int height = 0; - int x = 0; - int y = 0; - - GetSize(&width, &height); - GetPosition(&x, &y); + wxSize sz = GetSize(); + wxPoint ps = GetPosition(); //test ALL parameters at once, since width/height are invalid if the window is minimized (eg x,y == -32000; height = 28, width = 160) //note: negative values for x and y are possible when using multiple monitors! - if (width > 0 && height > 0 && x >= -3360 && y >= -200 && - wxDisplay::GetFromPoint(wxPoint(x, y)) != wxNOT_FOUND) //make sure upper left corner is in visible view + if (sz.GetWidth() > 0 && sz.GetHeight() > 0 && ps.x >= -3360 && ps.y >= -200 && + wxDisplay::GetFromPoint(ps) != wxNOT_FOUND) //make sure upper left corner is in visible view { - widthNotMaximized = width; //visible coordinates x < 0 and y < 0 are possible with dual monitors! - heightNotMaximized = height; - - posXNotMaximized = x; - posYNotMaximized = y; + globalSettings->gui.dlgSize = sz; + globalSettings->gui.dlgPos = ps; } } @@ -1700,11 +1700,6 @@ void MainDialog::OnContextRim(wxGridEvent& event) const FileSystemObject* fsObj = gridDataView->getObject(selectionBegin); -#ifndef _MSC_VER -#warning context menu buttons komplett lokalisieren: ALT+LEFT, SPACE D-Click, ENTER.. -#warning statt "Set direction: *-" besser "Set direction: ->" -#endif - //####################################################### //re-create context menu contextMenu.reset(new wxMenu); @@ -1716,24 +1711,21 @@ void MainDialog::OnContextRim(wxGridEvent& event) { //CONTEXT_SYNC_DIR_LEFT wxMenuItem* menuItemSyncDirLeft = new wxMenuItem(contextMenu.get(), wxID_ANY, wxString(_("Set direction:")) + - wxT(" ") + getSymbol(fsObj->testSyncOperation(true, SYNC_DIR_LEFT)) + - wxT("\tAlt + Left")); //Linux needs a direction, "<-", because it has no context menu icons! + wxT(" <-") + wxT("\tAlt - Left")); //Linux needs a direction, "<-", because it has no context menu icons! menuItemSyncDirLeft->SetBitmap(getSyncOpImage(fsObj->testSyncOperation(true, SYNC_DIR_LEFT))); contextMenu->Append(menuItemSyncDirLeft); contextMenu->Connect(menuItemSyncDirLeft->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSyncDirLeft), NULL, this); //CONTEXT_SYNC_DIR_NONE wxMenuItem* menuItemSyncDirNone = new wxMenuItem(contextMenu.get(), wxID_ANY, wxString(_("Set direction:")) + - wxT(" ") + getSymbol(fsObj->testSyncOperation(true, SYNC_DIR_NONE)) + - wxT("\tAlt + Up")); + wxT(" -") + wxT("\tAlt - Up")); menuItemSyncDirNone->SetBitmap(getSyncOpImage(fsObj->testSyncOperation(true, SYNC_DIR_NONE))); contextMenu->Append(menuItemSyncDirNone); contextMenu->Connect(menuItemSyncDirNone->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSyncDirNone), NULL, this); //CONTEXT_SYNC_DIR_RIGHT wxMenuItem* menuItemSyncDirRight = new wxMenuItem(contextMenu.get(), wxID_ANY, wxString(_("Set direction:")) + - wxT(" ") + getSymbol(fsObj->testSyncOperation(true, SYNC_DIR_RIGHT)) + - wxT("\tAlt + Right")); + wxT(" ->") + wxT("\tAlt - Right")); menuItemSyncDirRight->SetBitmap(getSyncOpImage(fsObj->testSyncOperation(true, SYNC_DIR_RIGHT))); contextMenu->Append(menuItemSyncDirRight); contextMenu->Connect(menuItemSyncDirRight->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSyncDirRight), NULL, this); @@ -1867,7 +1859,7 @@ void MainDialog::OnContextRim(wxGridEvent& event) wxMenuItem* itemExtApp = NULL; if (i == globalSettings->gui.externelApplications.begin()) - itemExtApp = contextMenu->Append(wxID_ANY, description + wxT("\t") + wxString(_("D-Click")) + wxT("; Enter")); + itemExtApp = contextMenu->Append(wxID_ANY, description + wxT("\t") + wxString(_("D-Click")) + wxT(" Enter")); else itemExtApp = contextMenu->Append(wxID_ANY, description); contextMenu->Enable(itemExtApp->GetId(), externalAppEnabled); @@ -1882,13 +1874,8 @@ void MainDialog::OnContextRim(wxGridEvent& event) contextMenu->AppendSeparator(); - -#ifndef _MSC_VER -#warning context menu buttons: nicht mehr all caps -#endif - //CONTEXT_DELETE_FILES - wxMenuItem* menuItemDelFiles = contextMenu->Append(wxID_ANY, _("Delete files\tDEL")); + wxMenuItem* menuItemDelFiles = contextMenu->Append(wxID_ANY, wxString(_("Delete")) + wxT("\tDel")); contextMenu->Enable(menuItemDelFiles->GetId(), selection.size() > 0); contextMenu->Connect(menuItemDelFiles->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextDeleteFiles), NULL, this); @@ -2067,9 +2054,9 @@ void MainDialog::OnContextCustColumnLeft(wxCommandEvent& event) { m_gridLeft->setColumnAttributes(colAttr); - m_gridLeft->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); //hide sort direction indicator on GUI grids + m_gridLeft ->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); //hide sort direction indicator on GUI grids m_gridMiddle->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); - m_gridRight->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); + m_gridRight ->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); } } @@ -2082,9 +2069,9 @@ void MainDialog::OnContextCustColumnRight(wxCommandEvent& event) { m_gridRight->setColumnAttributes(colAttr); - m_gridLeft->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); //hide sort direction indicator on GUI grids + m_gridLeft ->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); //hide sort direction indicator on GUI grids m_gridMiddle->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); - m_gridRight->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); + m_gridRight ->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); } } @@ -2150,12 +2137,10 @@ void MainDialog::OnContextMiddleLabel(wxGridEvent& event) void MainDialog::OnContextSetLayout(wxMouseEvent& event) { - int itemId = 1000; - contextMenu.reset(new wxMenu); //re-create context menu - contextMenu->Append(++itemId, _("Reset view")); - contextMenu->Connect(itemId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSetLayoutReset), NULL, this); + wxMenuItem* itemReset = contextMenu->Append(wxID_ANY, _("Reset view")); + contextMenu->Connect(itemReset->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSetLayoutReset), NULL, this); typedef std::vector<std::pair<wxString, wxString> > CaptionNameMapping; CaptionNameMapping captionNameMap; @@ -2174,8 +2159,8 @@ void MainDialog::OnContextSetLayout(wxMouseEvent& event) wxString entry = _("Show \"%x\""); entry.Replace(wxT("%x"), i->first); - contextMenu->Append(++itemId, entry); - contextMenu->Connect(itemId, + wxMenuItem* newItem = contextMenu->Append(wxID_ANY, entry); + contextMenu->Connect(newItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainDialog::OnContextSetLayoutShowPanel), new CtxtSelectionString(i->second), //ownership passed! @@ -2328,7 +2313,11 @@ bool MainDialog::trySaveConfig() //return true if saved successfully defaultFileName.Replace(wxT(".ffs_batch"), wxT(".ffs_gui"), false); - wxFileDialog filePicker(this, wxEmptyString, wxEmptyString, defaultFileName, wxString(_("FreeFileSync configuration")) + wxT(" (*.ffs_gui)|*.ffs_gui"), wxFD_SAVE); //creating this on freestore leads to memleak! + wxFileDialog filePicker(this, + wxEmptyString, + wxEmptyString, + defaultFileName, + wxString(_("FreeFileSync configuration")) + wxT(" (*.ffs_gui)|*.ffs_gui"), wxFD_SAVE); //creating this on freestore leads to memleak! if (filePicker.ShowModal() == wxID_OK) { const wxString newFileName = filePicker.GetPath(); @@ -2355,7 +2344,7 @@ void MainDialog::OnLoadConfig(wxCommandEvent& event) { wxFileDialog filePicker(this, wxEmptyString, - wxEmptyString, + beforeLast(currentConfigFileName, common::FILE_NAME_SEPARATOR), //set default dir: empty string if "currentConfigFileName" is empty or has no path separator wxEmptyString, wxString(_("FreeFileSync configuration")) + wxT(" (*.ffs_gui;*.ffs_batch)|*.ffs_gui;*.ffs_batch"), wxFD_OPEN); @@ -2538,13 +2527,13 @@ bool MainDialog::readConfigurationFromXml(const wxString& filename) std::vector<wxString> filenames; filenames.push_back(filename); - xmlAccess::convertConfig(filenames, newGuiCfg); //throw (xmlAccess::XmlError) + xmlAccess::convertConfig(filenames, newGuiCfg); //throw (xmlAccess::FfsXmlError) parsingError = false; } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { - if (error.getSeverity() == xmlAccess::XmlError::WARNING) + if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING) wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING); else { @@ -2592,7 +2581,7 @@ bool MainDialog::writeConfigurationToXml(const wxString& filename) setLastUsedConfig(filename, guiCfg); return true; } - catch (const xmlAccess::XmlError& error) + catch (const xmlAccess::FfsXmlError& error) { wxMessageBox(error.msg().c_str(), _("Error"), wxOK | wxICON_ERROR); return false; @@ -3027,7 +3016,7 @@ void MainDialog::OnCompare(wxCommandEvent& event) if (fileExists(wxToZ(soundFile))) wxSound::Play(soundFile, wxSOUND_ASYNC); } - catch (AbortThisProcess&) + catch (GuiAbortProcess&) { //disable the sync button syncPreview->enableSynchronization(false); @@ -3078,20 +3067,6 @@ void MainDialog::updateGuiGrid() m_gridMiddle->updateGridSizes(); m_gridRight ->updateGridSizes(); - //enlarge label width to display row numbers correctly - const int nrOfRows = m_gridLeft->GetNumberRows(); - if (nrOfRows >= 0) - { -#ifdef FFS_WIN - const size_t digitWidth = 8; -#elif defined FFS_LINUX - const size_t digitWidth = 10; -#endif - const size_t nrOfDigits = common::getDigitCount(static_cast<size_t>(nrOfRows)); - m_gridLeft ->SetRowLabelSize(static_cast<int>(nrOfDigits * digitWidth + 4)); - m_gridRight->SetRowLabelSize(static_cast<int>(nrOfDigits * digitWidth + 4)); - } - //support for column auto adjustment if (globalSettings->gui.autoAdjustColumnsLeft) m_gridLeft->autoSizeColumns(); @@ -3257,7 +3232,7 @@ void MainDialog::OnStartSync(wxCommandEvent& event) if (fileExists(wxToZ(soundFile))) wxSound::Play(soundFile, wxSOUND_ASYNC); } - catch (AbortThisProcess&) + catch (GuiAbortProcess&) { //do NOT disable the sync button: user might want to try to sync the REMAINING rows } //enableSynchronization(false); @@ -3338,12 +3313,12 @@ void MainDialog::OnSortLeftGrid(wxGridEvent& event) gridDataView->sortView(st, true, sortAscending); - updateGuiGrid(); //refresh gridDataView - //set sort direction indicator on UI m_gridMiddle->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); - m_gridRight->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); - m_gridLeft->setSortMarker(CustomGrid::SortMarker(currentSortColumn, sortAscending ? CustomGrid::ASCENDING : CustomGrid::DESCENDING)); + m_gridRight ->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); + m_gridLeft ->setSortMarker(CustomGrid::SortMarker(currentSortColumn, sortAscending ? CustomGrid::ASCENDING : CustomGrid::DESCENDING)); + + updateGuiGrid(); //refresh gridDataView } } @@ -3426,12 +3401,12 @@ void MainDialog::OnSortRightGrid(wxGridEvent& event) gridDataView->sortView(st, false, sortAscending); - updateGuiGrid(); //refresh gridDataView - //set sort direction indicator on UI m_gridLeft->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); m_gridMiddle->setSortMarker(CustomGrid::SortMarker(-1, CustomGrid::ASCENDING)); m_gridRight->setSortMarker(CustomGrid::SortMarker(currentSortColumn, sortAscending ? CustomGrid::ASCENDING : CustomGrid::DESCENDING)); + + updateGuiGrid(); //refresh gridDataView } } @@ -3942,13 +3917,15 @@ void MainDialog::OnMenuGlobalSettings(wxCommandEvent& event) namespace { +typedef Zbase<wchar_t> zxString; + inline void addCellValue(zxString& exportString, const wxString& cellVal) { if (cellVal.find(wxT(';')) != wxString::npos) - exportString += wxT('\"') + wxToZx(cellVal) + wxT('\"'); + exportString += wxT('\"') + cvrtString<zxString>(cellVal) + wxT('\"'); else - exportString += wxToZx(cellVal); + exportString += cvrtString<zxString>(cellVal); } } @@ -3975,28 +3952,28 @@ void MainDialog::OnMenuExportFileList(wxCommandEvent& event) zxString exportString; //perf: wxString doesn't model exponential growth and so is out //write legend - exportString += wxToZx(_("Legend")) + wxT('\n'); + exportString += cvrtString<zxString>(_("Legend")) + wxT('\n'); if (syncPreview->previewIsEnabled()) { - exportString += wxT("\"") + wxToZx(getDescription(SO_CREATE_NEW_LEFT)) + wxT("\";") + wxToZx(getSymbol(SO_CREATE_NEW_LEFT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_CREATE_NEW_RIGHT)) + wxT("\";") + wxToZx(getSymbol(SO_CREATE_NEW_RIGHT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_DELETE_LEFT)) + wxT("\";") + wxToZx(getSymbol(SO_DELETE_LEFT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_DELETE_RIGHT)) + wxT("\";") + wxToZx(getSymbol(SO_DELETE_RIGHT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_OVERWRITE_LEFT)) + wxT("\";") + wxToZx(getSymbol(SO_OVERWRITE_LEFT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_OVERWRITE_RIGHT)) + wxT("\";") + wxToZx(getSymbol(SO_OVERWRITE_RIGHT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_DO_NOTHING)) + wxT("\";") + wxToZx(getSymbol(SO_DO_NOTHING)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_EQUAL)) + wxT("\";") + wxToZx(getSymbol(SO_EQUAL)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(SO_UNRESOLVED_CONFLICT)) + wxT("\";") + wxToZx(getSymbol(SO_UNRESOLVED_CONFLICT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_CREATE_NEW_LEFT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_CREATE_NEW_LEFT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_CREATE_NEW_RIGHT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_CREATE_NEW_RIGHT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_DELETE_LEFT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_DELETE_LEFT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_DELETE_RIGHT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_DELETE_RIGHT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_OVERWRITE_LEFT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_OVERWRITE_LEFT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_OVERWRITE_RIGHT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_OVERWRITE_RIGHT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_DO_NOTHING)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_DO_NOTHING)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_EQUAL)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_EQUAL)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(SO_UNRESOLVED_CONFLICT)) + wxT("\";") + cvrtString<zxString>(getSymbol(SO_UNRESOLVED_CONFLICT)) + wxT('\n'); } else { - exportString += wxT("\"") + wxToZx(getDescription(FILE_LEFT_SIDE_ONLY)) + wxT("\";") + wxToZx(getSymbol(FILE_LEFT_SIDE_ONLY)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_RIGHT_SIDE_ONLY)) + wxT("\";") + wxToZx(getSymbol(FILE_RIGHT_SIDE_ONLY)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_LEFT_NEWER)) + wxT("\";") + wxToZx(getSymbol(FILE_LEFT_NEWER)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_RIGHT_NEWER)) + wxT("\";") + wxToZx(getSymbol(FILE_RIGHT_NEWER)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_DIFFERENT)) + wxT("\";") + wxToZx(getSymbol(FILE_DIFFERENT)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_EQUAL)) + wxT("\";") + wxToZx(getSymbol(FILE_EQUAL)) + wxT('\n'); - exportString += wxT("\"") + wxToZx(getDescription(FILE_CONFLICT)) + wxT("\";") + wxToZx(getSymbol(FILE_CONFLICT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_LEFT_SIDE_ONLY)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_LEFT_SIDE_ONLY)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_RIGHT_SIDE_ONLY)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_RIGHT_SIDE_ONLY)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_LEFT_NEWER)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_LEFT_NEWER)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_RIGHT_NEWER)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_RIGHT_NEWER)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_DIFFERENT)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_DIFFERENT)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_EQUAL)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_EQUAL)) + wxT('\n'); + exportString += wxT("\"") + cvrtString<zxString>(getDescription(FILE_CONFLICT)) + wxT("\";") + cvrtString<zxString>(getSymbol(FILE_CONFLICT)) + wxT('\n'); } exportString += wxT('\n'); diff --git a/ui/main_dlg.h b/ui/main_dlg.h index 9f12e284..4d00ff2a 100644 --- a/ui/main_dlg.h +++ b/ui/main_dlg.h @@ -252,12 +252,6 @@ private: //folder pairs: std::auto_ptr<DirectoryPairFirst> firstFolderPair; //always bound!!! std::vector<DirectoryPair*> additionalFolderPairs; //additional pairs to the first pair - - //gui settings - int widthNotMaximized; - int heightNotMaximized; - int posXNotMaximized; - int posYNotMaximized; //------------------------------------- diff --git a/ui/progress_indicator.cpp b/ui/progress_indicator.cpp index f71abab4..949384b9 100644 --- a/ui/progress_indicator.cpp +++ b/ui/progress_indicator.cpp @@ -15,7 +15,7 @@ #include <wx/wupdlock.h> #include "../shared/global_func.h" #include "tray_icon.h" -#include <boost/shared_ptr.hpp> +#include <memory> #include "../shared/mouse_move_dlg.h" #include "../library/error_log.h" #include "../shared/toggle_button.h" @@ -452,24 +452,26 @@ private: const std::vector<wxString>& messages = log_.getFormattedMessages(includedTypes); + //fast replacement for wxString modelling exponential growth + typedef Zbase<wchar_t> zxString; zxString newLogText; //perf: wxString doesn't model exponential growth and so is out if (!messages.empty()) for (std::vector<wxString>::const_iterator i = messages.begin(); i != messages.end(); ++i) { - newLogText += wxToZx(*i); + newLogText += cvrtString<zxString>(*i); newLogText += wxT("\n\n"); } else //if no messages match selected view filter, show final status message at least { const std::vector<wxString>& allMessages = log_.getFormattedMessages(); if (!allMessages.empty()) - newLogText = wxToZx(allMessages.back()); + newLogText = cvrtString<zxString>(allMessages.back()); } wxWindowUpdateLocker dummy(m_textCtrlInfo); - m_textCtrlInfo->ChangeValue(zxToWx(newLogText)); + m_textCtrlInfo->ChangeValue(cvrtString<wxString>(newLogText)); m_textCtrlInfo->ShowPosition(m_textCtrlInfo->GetLastPosition()); } @@ -482,7 +484,7 @@ private: class SyncStatus::SyncStatusImpl : public SyncStatusDlgGenerated { public: - SyncStatusImpl(AbortCallback& abortCb, MainDialog* parentWindow, const wxString& jobName); + SyncStatusImpl(AbortCallback& abortCb, MainDialog* parentWindow, SyncStatusID startStatus, const wxString& jobName); ~SyncStatusImpl(); void resetGauge(int totalObjectsToProcess, zen::Int64 totalDataToProcess); @@ -529,11 +531,11 @@ private: SyncStatus::SyncStatusID currentStatus; #ifdef FFS_WIN - std::auto_ptr<util::TaskbarProgress> taskbar_; + std::unique_ptr<util::TaskbarProgress> taskbar_; #endif //remaining time - std::auto_ptr<Statistics> statistics; + std::unique_ptr<Statistics> statistics; long lastStatCallSpeed; //used for calculating intervals between statistics update long lastStatCallRemTime; // @@ -543,13 +545,17 @@ private: wxString progressTextLast; float progressPercentLast; - boost::shared_ptr<MinimizeToTray> minimizedToSysTray; //optional: if filled, hides all visible windows, shows again if destroyed + std::shared_ptr<MinimizeToTray> minimizedToSysTray; //optional: if filled, hides all visible windows, shows again if destroyed }; //redirect to implementation -SyncStatus::SyncStatus(AbortCallback& abortCb, MainDialog* parentWindow, bool startSilent, const wxString& jobName) : - pimpl(new SyncStatusImpl(abortCb, parentWindow, jobName)) +SyncStatus::SyncStatus(AbortCallback& abortCb, + MainDialog* parentWindow, + SyncStatusID startStatus, + bool startSilent, + const wxString& jobName) : + pimpl(new SyncStatusImpl(abortCb, parentWindow, startStatus, jobName)) { if (startSilent) pimpl->minimizeToTray(); @@ -612,7 +618,10 @@ void SyncStatus::processHasFinished(SyncStatusID id, const ErrorLogging& log) //######################################################################################## -SyncStatus::SyncStatusImpl::SyncStatusImpl(AbortCallback& abortCb, MainDialog* parentWindow, const wxString& jobName) : +SyncStatus::SyncStatusImpl::SyncStatusImpl(AbortCallback& abortCb, + MainDialog* parentWindow, + SyncStatusID startStatus, + const wxString& jobName) : SyncStatusDlgGenerated(parentWindow, wxID_ANY, parentWindow ? wxString(wxEmptyString) : (wxString(wxT("FreeFileSync - ")) + _("Folder Comparison and Synchronization")), @@ -679,6 +688,8 @@ SyncStatus::SyncStatusImpl::SyncStatusImpl(AbortCallback& abortCb, MainDialog* p //register key event Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(SyncStatusImpl::OnKeyPressed), NULL, this); + + setCurrentStatus(startStatus); //first state: will be shown while waiting for dir locks (if at all) } @@ -730,7 +741,9 @@ void SyncStatus::SyncStatusImpl::resetGauge(int totalObjectsToProcess, zen::Int6 lastStatCallSpeed = -1000000; //some big number lastStatCallRemTime = -1000000; - m_gauge1->SetValue(totalDataToProcess == 0 ? GAUGE_FULL_RANGE : 0); //explicitly reset and end "pending" state (if not data will be synced) + //set to 0 even if totalDataToProcess is 0: due to a bug in wxGauge::SetValue, it doesn't change to determinate mode when setting the old value again + //so give updateStatusDialogNow() a chance to set a different value + m_gauge1->SetValue(0); } @@ -855,10 +868,22 @@ void SyncStatus::SyncStatusImpl::updateStatusDialogNow() bool updateLayout = false; //avoid screen flicker by calling layout() only if necessary //progress indicator - if (currentStatus == SyncStatus::SCANNING) - m_gauge1->Pulse(); - else - m_gauge1->SetValue(common::round(to<double>(currentData) * scalingFactor)); + switch (currentStatus) + { + case SyncStatus::SCANNING: + m_gauge1->Pulse(); + break; + case SyncStatus::COMPARING_CONTENT: + case SyncStatus::SYNCHRONIZING: + case SyncStatus::FINISHED_WITH_SUCCESS: + case SyncStatus::FINISHED_WITH_ERROR: + case SyncStatus::ABORTED: + m_gauge1->SetValue(totalData == 0 ? GAUGE_FULL_RANGE : + common::round(to<double>(currentData) * scalingFactor)); + break; + case SyncStatus::PAUSE: //no change to gauge: don't switch between indeterminate/determinate modus + break; + } //status text const wxString statusTxt = zToWx(currentStatusText); diff --git a/ui/progress_indicator.h b/ui/progress_indicator.h index 34e2c1a5..528ec562 100644 --- a/ui/progress_indicator.h +++ b/ui/progress_indicator.h @@ -44,14 +44,6 @@ private: class SyncStatus { public: - SyncStatus(AbortCallback& abortCb, - MainDialog* parentWindow, //may be NULL - bool startSilent, - const wxString& jobName); - ~SyncStatus(); - - wxWindow* getAsWindow(); //convenience! don't abuse! - enum SyncStatusID { ABORTED, @@ -63,6 +55,15 @@ public: SYNCHRONIZING }; + SyncStatus(AbortCallback& abortCb, + MainDialog* parentWindow, //may be NULL + SyncStatusID startStatus, + bool startSilent, + const wxString& jobName); + ~SyncStatus(); + + wxWindow* getAsWindow(); //convenience! don't abuse! + void resetGauge(int totalObjectsToProcess, zen::Int64 totalDataToProcess); void incScannedObjects_NoUpdate(int number); void incProgressIndicator_NoUpdate(int objectsProcessed, zen::Int64 dataProcessed); diff --git a/ui/small_dlgs.cpp b/ui/small_dlgs.cpp index cb81431b..f6694586 100644 --- a/ui/small_dlgs.cpp +++ b/ui/small_dlgs.cpp @@ -11,6 +11,7 @@ #include "../algorithm.h" #include "../shared/string_conv.h" #include "../shared/util.h" +#include "../shared/wx_choice_enum.h" #include "../synchronization.h" #include "../library/custom_grid.h" #include "../shared/custom_button.h" diff --git a/ui/sorting.h b/ui/sorting.h index 52921f84..28f0b8e4 100644 --- a/ui/sorting.h +++ b/ui/sorting.h @@ -56,7 +56,7 @@ struct Compare<false> template <bool ascending, SelectedSide side> inline -bool sortByFileName(const FileSystemObject& a, const FileSystemObject& b) +bool lessShortFileName(const FileSystemObject& a, const FileSystemObject& b) { //presort types: first files, then directories then empty rows if (a.isEmpty<side>()) @@ -84,7 +84,7 @@ bool sortByFileName(const FileSystemObject& a, const FileSystemObject& b) template <bool ascending, SelectedSide side> -bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) +bool lessRelativeName(const FileSystemObject& a, const FileSystemObject& b) { if (a.isEmpty<side>()) return false; //empty rows always last @@ -120,7 +120,7 @@ bool sortByRelativeName(const FileSystemObject& a, const FileSystemObject& b) template <bool ascending, SelectedSide side> inline -bool sortByFileSize(const FileSystemObject& a, const FileSystemObject& b) +bool lessFilesize(const FileSystemObject& a, const FileSystemObject& b) { //empty rows always last if (a.isEmpty<side>()) @@ -153,7 +153,7 @@ bool sortByFileSize(const FileSystemObject& a, const FileSystemObject& b) template <bool ascending, SelectedSide side> inline -bool sortByDate(const FileSystemObject& a, const FileSystemObject& b) +bool lessFiletime(const FileSystemObject& a, const FileSystemObject& b) { if (a.isEmpty<side>()) return false; //empty rows always last @@ -182,7 +182,7 @@ bool sortByDate(const FileSystemObject& a, const FileSystemObject& b) template <bool ascending, SelectedSide side> inline -bool sortByExtension(const FileSystemObject& a, const FileSystemObject& b) +bool lessExtension(const FileSystemObject& a, const FileSystemObject& b) { if (a.isEmpty<side>()) return false; //empty rows always last @@ -198,13 +198,13 @@ bool sortByExtension(const FileSystemObject& a, const FileSystemObject& b) else if (fileObjB == NULL) return true; //directories last - return Compare<ascending>().isSmallerThan(fileObjA->getExtension<side>(), fileObjB->getExtension<side>()); + return Compare<ascending>().isSmallerThan(cmpFileName(fileObjA->getExtension<side>(), fileObjB->getExtension<side>()), 0); } template <bool ascending> inline -bool sortByCmpResult(const FileSystemObject& a, const FileSystemObject& b) +bool lessCmpResult(const FileSystemObject& a, const FileSystemObject& b) { //presort result: equal shall appear at end of list if (a.getCategory() == FILE_EQUAL) @@ -218,7 +218,7 @@ bool sortByCmpResult(const FileSystemObject& a, const FileSystemObject& b) template <bool ascending> inline -bool sortBySyncDirection(const FileSystemObject& a, const FileSystemObject& b) +bool lessSyncDirection(const FileSystemObject& a, const FileSystemObject& b) { return Compare<ascending>().isSmallerThan(a.getSyncOperation(), b.getSyncOperation()); } diff --git a/ui/sync_cfg.cpp b/ui/sync_cfg.cpp index 3a7283e1..0bbe8809 100644 --- a/ui/sync_cfg.cpp +++ b/ui/sync_cfg.cpp @@ -13,7 +13,7 @@ #include "../shared/dir_picker_i18n.h" #include "gui_generated.h" #include <memory> -#include "../shared/util.h" +#include "../shared/wx_choice_enum.h" #include "../shared/dir_name.h" using namespace zen; @@ -75,8 +75,7 @@ private: -void updateConfigIcons(const CompareVariant compareVar, - const SyncConfig& syncConfig, +void updateConfigIcons(const SyncConfig& syncConfig, wxBitmapButton* buttonLeftOnly, wxBitmapButton* buttonRightOnly, wxBitmapButton* buttonLeftNewer, @@ -88,46 +87,9 @@ void updateConfigIcons(const CompareVariant compareVar, wxStaticBitmap* bitmapLeftNewer, wxStaticBitmap* bitmapRightNewer, wxStaticBitmap* bitmapDifferent, - wxStaticBitmap* bitmapConflict, - wxSizer* syncDirections) //sizer containing all sync-directions + wxStaticBitmap* bitmapConflict) //sizer containing all sync-directions { - //display only relevant sync options - syncDirections->Show(true); - - buttonLeftOnly ->Show(); // - buttonRightOnly ->Show(); // - buttonLeftNewer ->Show(); // - buttonRightNewer->Show(); // enable everything by default - buttonDifferent ->Show(); // - buttonConflict ->Show(); // - - bitmapLeftOnly ->Show(); // - bitmapRightOnly ->Show(); // - bitmapLeftNewer ->Show(); // - bitmapRightNewer->Show(); // - bitmapDifferent ->Show(); // - bitmapConflict ->Show(); // - - switch (compareVar) - { - case CMP_BY_TIME_SIZE: - buttonDifferent ->Hide(); - - bitmapDifferent ->Hide(); - break; - - case CMP_BY_CONTENT: - buttonLeftNewer ->Hide(); - buttonRightNewer->Hide(); - - bitmapLeftNewer ->Hide(); - bitmapRightNewer->Hide(); - break; - } - - if (syncConfig.var == SyncConfig::AUTOMATIC) //automatic mode needs no sync-directions - syncDirections->Show(false); - else + if (syncConfig.var != SyncConfig::AUTOMATIC) //automatic mode needs no sync-directions { const DirectionSet dirCfg = extractDirections(syncConfig); @@ -283,6 +245,7 @@ SyncCfgDialog::SyncCfgDialog(wxWindow* window, m_bitmapRightNewer->SetBitmap(GlobalResources::instance().getImage(wxT("rightNewer"))); m_bitmapDifferent ->SetBitmap(GlobalResources::instance().getImage(wxT("different"))); m_bitmapConflict ->SetBitmap(GlobalResources::instance().getImage(wxT("conflictGrey"))); + m_bitmapDatabase ->SetBitmap(GlobalResources::instance().getImage(wxT("database"))); bSizer201->Layout(); //wxButtonWithImage size might have changed @@ -307,8 +270,7 @@ void SyncCfgDialog::updateGui() wxWindowUpdateLocker dummy7(m_bpButtonDifferent); wxWindowUpdateLocker dummy8(m_bpButtonConflict); - updateConfigIcons(cmpVariant, - currentSyncConfig, + updateConfigIcons(currentSyncConfig, m_bpButtonLeftOnly, m_bpButtonRightOnly, m_bpButtonLeftNewer, @@ -320,8 +282,31 @@ void SyncCfgDialog::updateGui() m_bitmapLeftNewer, m_bitmapRightNewer, m_bitmapDifferent, - m_bitmapConflict, - sbSizerSyncDirections); + m_bitmapConflict); + + //display only relevant sync options + m_bitmapDatabase->Show(true); + sbSizerSyncDirections->Show(true); + + if (currentSyncConfig.var == SyncConfig::AUTOMATIC) + { + sbSizerSyncDirections->Show(false); + } + else + { + m_bitmapDatabase->Show(false); + switch (cmpVariant) + { + case CMP_BY_TIME_SIZE: + bSizerDifferent ->Show(false); + break; + + case CMP_BY_CONTENT: + bSizerLeftNewer ->Show(false); + bSizerRightNewer->Show(false); + break; + } + } //set radiobuttons -> have no parameter-ownership at all! switch (currentSyncConfig.var) @@ -340,6 +325,7 @@ void SyncCfgDialog::updateGui() break; } + Layout(); GetSizer()->SetSizeHints(this); //this works like a charm for GTK2 with window resizing problems!!! (includes call to Fit()) m_panelCustomDeletionDir->Enable(getEnumVal(enumDelhandDescr, *m_choiceHandleDeletion) == zen::MOVE_TO_CUSTOM_DIRECTORY); |