diff options
Diffstat (limited to 'RealtimeSync')
-rw-r--r-- | RealtimeSync/RealtimeSync.vcxproj | 3 | ||||
-rw-r--r-- | RealtimeSync/application.cpp | 2 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.cpp | 42 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.h | 6 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.cpp | 31 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.h | 21 | ||||
-rw-r--r-- | RealtimeSync/tray_menu.cpp | 6 | ||||
-rw-r--r-- | RealtimeSync/watcher.cpp | 4 | ||||
-rw-r--r-- | RealtimeSync/xml_ffs.cpp | 2 |
9 files changed, 74 insertions, 43 deletions
diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj index 764ec0a9..3a2ebf8b 100644 --- a/RealtimeSync/RealtimeSync.vcxproj +++ b/RealtimeSync/RealtimeSync.vcxproj @@ -109,6 +109,7 @@ <ForcedIncludeFiles>zen/warn_static.h;wx+/pch.h</ForcedIncludeFiles> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <MinimalRebuild>false</MinimalRebuild> + <SmallerTypeCheck>true</SmallerTypeCheck> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -138,6 +139,7 @@ <SuppressStartupBanner>true</SuppressStartupBanner> <MinimalRebuild>false</MinimalRebuild> <ShowIncludes>false</ShowIncludes> + <SmallerTypeCheck>true</SmallerTypeCheck> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -229,6 +231,7 @@ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> </ClCompile> <ClCompile Include="..\wx+\mouse_move_dlg.cpp" /> + <ClCompile Include="..\zen\debug_memory_leaks.cpp" /> <ClCompile Include="..\zen\dir_watcher.cpp" /> <ClCompile Include="..\zen\dst_hack.cpp" /> <ClCompile Include="..\zen\file_handling.cpp" /> diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp index 435a6b86..23e7ab25 100644 --- a/RealtimeSync/application.cpp +++ b/RealtimeSync/application.cpp @@ -18,7 +18,7 @@ #include "lib/error_log.h" #ifdef FFS_WIN -#include <zen/win_ver.h> +#include <zen/win_ver.h> #elif defined FFS_LINUX #include <gtk/gtk.h> #endif diff --git a/RealtimeSync/gui_generated.cpp b/RealtimeSync/gui_generated.cpp index 4651099c..1e817367 100644 --- a/RealtimeSync/gui_generated.cpp +++ b/RealtimeSync/gui_generated.cpp @@ -84,9 +84,11 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr bSizer1->Add( bSizer13, 0, wxEXPAND|wxRIGHT|wxLEFT, 20 ); m_staticline2 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer1->Add( m_staticline2, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); + bSizer1->Add( m_staticline2, 0, wxEXPAND|wxTOP, 5 ); - sbSizerDirToWatch2 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Folders to watch") ), wxVERTICAL ); + m_staticText7 = new wxStaticText( m_panelMain, wxID_ANY, _("Folders to watch"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText7->Wrap( -1 ); + bSizer1->Add( m_staticText7, 0, wxALL, 5 ); m_panelMainFolder = new wxPanel( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer10; @@ -134,43 +136,51 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr m_panelMainFolder->SetSizer( bSizer10 ); m_panelMainFolder->Layout(); bSizer10->Fit( m_panelMainFolder ); - sbSizerDirToWatch2->Add( m_panelMainFolder, 0, wxEXPAND, 5 ); + bSizer1->Add( m_panelMainFolder, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 ); m_scrolledWinFolders = new wxScrolledWindow( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); - m_scrolledWinFolders->SetScrollRate( 5, 5 ); + m_scrolledWinFolders->SetScrollRate( 10, 10 ); bSizerFolders = new wxBoxSizer( wxVERTICAL ); m_scrolledWinFolders->SetSizer( bSizerFolders ); m_scrolledWinFolders->Layout(); bSizerFolders->Fit( m_scrolledWinFolders ); - sbSizerDirToWatch2->Add( m_scrolledWinFolders, 0, wxEXPAND, 5 ); + bSizer1->Add( m_scrolledWinFolders, 1, wxRIGHT|wxLEFT|wxEXPAND, 5 ); + m_staticline212 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer1->Add( m_staticline212, 0, wxEXPAND|wxTOP, 5 ); - bSizer1->Add( sbSizerDirToWatch2, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + wxBoxSizer* bSizer14; + bSizer14 = new wxBoxSizer( wxHORIZONTAL ); - wxStaticBoxSizer* sbSizer4; - sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Delay [seconds]") ), wxVERTICAL ); + m_staticText8 = new wxStaticText( m_panelMain, wxID_ANY, _("Delay [seconds]"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText8->Wrap( -1 ); + bSizer14->Add( m_staticText8, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer14->Add( 0, 0, 1, wxEXPAND, 5 ); m_spinCtrlDelay = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 2000000000, 0 ); m_spinCtrlDelay->SetToolTip( _("Idle time between last detected change and execution of command") ); - sbSizer4->Add( m_spinCtrlDelay, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer14->Add( m_spinCtrlDelay, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizer1->Add( bSizer14, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - bSizer1->Add( sbSizer4, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + m_staticline211 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer1->Add( m_staticline211, 0, wxEXPAND|wxTOP, 5 ); - wxStaticBoxSizer* sbSizer3; - sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Command line") ), wxVERTICAL ); + m_staticText6 = new wxStaticText( m_panelMain, wxID_ANY, _("Command line"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText6->Wrap( -1 ); + bSizer1->Add( m_staticText6, 0, wxALL, 5 ); m_textCtrlCommand = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_textCtrlCommand->SetMaxLength( 0 ); m_textCtrlCommand->SetToolTip( _("The command is triggered if:\n- files or subfolders change\n- new folders arrive (e.g. USB stick insert)") ); - sbSizer3->Add( m_textCtrlCommand, 0, wxEXPAND, 5 ); - - - bSizer1->Add( sbSizer3, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); + bSizer1->Add( m_textCtrlCommand, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_buttonStart = new zen::BitmapButton( m_panelMain, wxID_OK, _("Start"), wxDefaultPosition, wxSize( -1,50 ), 0 ); m_buttonStart->SetDefault(); diff --git a/RealtimeSync/gui_generated.h b/RealtimeSync/gui_generated.h index aa267a02..56488f86 100644 --- a/RealtimeSync/gui_generated.h +++ b/RealtimeSync/gui_generated.h @@ -59,7 +59,7 @@ protected: wxStaticText* m_staticText5; wxStaticText* m_staticText811; wxStaticLine* m_staticline2; - wxStaticBoxSizer* sbSizerDirToWatch2; + wxStaticText* m_staticText7; wxPanel* m_panelMainFolder; wxStaticText* m_staticTextFinalPath; wxBitmapButton* m_bpButtonAddFolder; @@ -68,7 +68,11 @@ protected: wxButton* m_buttonSelectDirMain; wxScrolledWindow* m_scrolledWinFolders; wxBoxSizer* bSizerFolders; + wxStaticLine* m_staticline212; + wxStaticText* m_staticText8; wxSpinCtrl* m_spinCtrlDelay; + wxStaticLine* m_staticline211; + wxStaticText* m_staticText6; wxTextCtrl* m_textCtrlCommand; zen::BitmapButton* m_buttonStart; wxButton* m_buttonCancel; diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp index bb9ac75b..ca6fa4fa 100644 --- a/RealtimeSync/main_dlg.cpp +++ b/RealtimeSync/main_dlg.cpp @@ -28,6 +28,21 @@ using namespace zen; +class DirectoryPanel : public FolderGenerated +{ +public: + DirectoryPanel(wxWindow* parent) : + FolderGenerated(parent), + dirName(*this, *m_buttonSelectDir, *m_txtCtrlDirectory) {} + + void setName(const wxString& dirname) { dirName.setName(dirname); } + wxString getName() const { return dirName.getName(); } + +private: + zen::DirectoryName<wxTextCtrl> dirName; +}; + + MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) : MainDlgGenerated(dlg) { @@ -59,7 +74,7 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) if (!cfgFileName.empty() || wxFileExists(lastConfigFileName())) try { - rts::readRealOrBatchConfig(toZ(currentConfigFile), newConfig); + rts::readRealOrBatchConfig(toZ(currentConfigFile), newConfig); //throw FfsXmlError loadCfgSuccess = true; } catch (const xmlAccess::FfsXmlError& error) @@ -92,6 +107,10 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) } else m_buttonStart->SetFocus(); //don't "steal" focus if program is running from sys-tray" + + //drag and drop .ffs_real and .ffs_batch on main dialog + setupFileDrop(*m_panelMain); + m_panelMain->Connect(EVENT_DROP_FILE, FileDropEventHandler(MainDialog::onFilesDropped), nullptr, this); } @@ -102,7 +121,7 @@ MainDialog::~MainDialog() try //write config to XML { - writeRealConfig(currentCfg, toZ(lastConfigFileName())); + writeRealConfig(currentCfg, toZ(lastConfigFileName())); //throw FfsXmlError } catch (const xmlAccess::FfsXmlError& error) { @@ -255,6 +274,14 @@ void MainDialog::OnConfigLoad(wxCommandEvent& event) } +void MainDialog::onFilesDropped(FileDropEvent& event) +{ + const auto& files = event.getFiles(); + if (!files.empty()) + loadConfig(files[0]); +} + + void MainDialog::setConfiguration(const xmlAccess::XmlRealConfig& cfg) { //clear existing folders diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h index 3e1b807e..82d27944 100644 --- a/RealtimeSync/main_dlg.h +++ b/RealtimeSync/main_dlg.h @@ -10,28 +10,14 @@ #include "gui_generated.h" #include <vector> #include <memory> +#include <wx+/file_drop.h> #include "../ui/dir_name.h" namespace xmlAccess { struct XmlRealConfig; } - - -class DirectoryPanel : public FolderGenerated -{ -public: - DirectoryPanel(wxWindow* parent) : - FolderGenerated(parent), - dirName(*this, *m_buttonSelectDir, *m_txtCtrlDirectory) {} - - void setName(const wxString& dirname) { dirName.setName(dirname); } - wxString getName() const { return dirName.getName(); } - -private: - zen::DirectoryName<wxTextCtrl> dirName; -}; - +class DirectoryPanel; class MainDialog: public MainDlgGenerated @@ -40,9 +26,9 @@ public: MainDialog(wxDialog* dlg, const wxString& cfgFileName); ~MainDialog(); +private: void loadConfig(const wxString& filename); -private: virtual void OnClose (wxCloseEvent& event) { Destroy(); } virtual void OnQuit (wxCommandEvent& event) { Destroy(); } virtual void OnShowHelp (wxCommandEvent& event); @@ -54,6 +40,7 @@ private: virtual void OnStart (wxCommandEvent& event); virtual void OnConfigSave (wxCommandEvent& event); virtual void OnConfigLoad (wxCommandEvent& event); + void onFilesDropped(zen::FileDropEvent& event); void setConfiguration(const xmlAccess::XmlRealConfig& cfg); xmlAccess::XmlRealConfig getConfiguration(); diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp index a30081bf..3319f427 100644 --- a/RealtimeSync/tray_menu.cpp +++ b/RealtimeSync/tray_menu.cpp @@ -129,9 +129,9 @@ class TrayIconHolder { public: TrayIconHolder(const wxString& jobname, AbortCallback& abortCb) : - jobName_(jobname) + jobName_(jobname), + trayMenu(new RtsTrayIconRaw(abortCb)) { - trayMenu = new RtsTrayIconRaw(abortCb); //not in initialization list: give it a valid parent object! showIconActive(); } @@ -175,8 +175,8 @@ public: } private: - RtsTrayIconRaw* trayMenu; const wxString jobName_; //RTS job name, may be empty + RtsTrayIconRaw* trayMenu; }; diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp index bfdb79c2..8ed37ea3 100644 --- a/RealtimeSync/watcher.cpp +++ b/RealtimeSync/watcher.cpp @@ -30,7 +30,7 @@ TickVal lastExec = getTicks(); bool rts::updateUiIsAllowed() { const TickVal now = getTicks(); //0 on error - if (now - lastExec >= TICKS_UPDATE_INTERVAL) //perform ui updates not more often than necessary + if (dist(lastExec, now) >= TICKS_UPDATE_INTERVAL) //perform ui updates not more often than necessary { lastExec = now; return true; @@ -98,7 +98,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt, const bool checkDirExistNow = [&]() -> bool //checking once per sec should suffice { const TickVal now = getTicks(); //0 on error - if (now - lastCheck >= TICKS_DIR_CHECK_INTERVAL) + if (dist(lastCheck, now) >= TICKS_DIR_CHECK_INTERVAL) { lastCheck = now; return true; diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp index 11151a09..8126ec05 100644 --- a/RealtimeSync/xml_ffs.cpp +++ b/RealtimeSync/xml_ffs.cpp @@ -79,7 +79,7 @@ int rts::getProgramLanguage() { xmlAccess::readConfig(settings); } - catch (const xmlAccess::FfsXmlError&) {} //user default language if error occured + catch (const xmlAccess::FfsXmlError&) {} //user default language if error occurred return settings.programLanguage; } |