Ticket #5009: Patch4993_5009.diff
File Patch4993_5009.diff, 15.9 KB (added by , 15 years ago) |
---|
-
src/interface/settings/optionspage_transfer.h
8 8 virtual bool LoadPage(); 9 9 virtual bool SavePage(); 10 10 virtual bool Validate(); 11 12 protected: 13 DECLARE_EVENT_TABLE() 14 void OnBrowseDefaultDownloadDirectory(wxCommandEvent& event); 15 void OnRadioOrCheckEvent(wxCommandEvent& event); 16 void SetCtrlState(); 11 17 }; 12 18 13 19 #endif //__OPTIONSPAGE_TRANSFER_H__ -
src/interface/settings/optionspage_transfer.cpp
4 4 #include "optionspage.h" 5 5 #include "optionspage_transfer.h" 6 6 7 BEGIN_EVENT_TABLE(COptionsPageTransfer, COptionsPage) 8 EVT_BUTTON(XRCID("ID_BROWSEDEFDIR"), COptionsPageTransfer::OnBrowseDefaultDownloadDirectory) 9 EVT_CHECKBOX(XRCID("ID_ENABLE_DEFDOWNLOADDIR"), COptionsPageTransfer::OnRadioOrCheckEvent) 10 END_EVENT_TABLE() 11 12 7 13 bool COptionsPageTransfer::LoadPage() 8 14 { 9 15 bool failure = false; … … 40 46 #endif 41 47 XRCCTRL(*this, "ID_REPLACED", wxStaticText)->SetLabel(filtered); 42 48 49 SetCheckFromOption(XRCID("ID_ENABLE_DEFDOWNLOADDIR"), OPTION_ENABLE_DEFAULT_DOWNLOAD_DIRECTORY, failure); 50 51 SetTextFromOption(XRCID("ID_DEFAULTDIR"), OPTION_DEFAULT_DOWNLOAD_DIRECTORY, failure); 52 53 // Update control state 54 if (!failure) 55 SetCtrlState(); 56 43 57 return !failure; 44 58 } 45 59 … … 53 67 m_pOptions->SetOption(OPTION_SPEEDLIMIT_BURSTTOLERANCE, GetChoice(XRCID("ID_BURSTTOLERANCE"))); 54 68 SetOptionFromText(XRCID("ID_REPLACE"), OPTION_INVALID_CHAR_REPLACE); 55 69 SetOptionFromCheck(XRCID("ID_ENABLE_REPLACE"), OPTION_INVALID_CHAR_REPLACE_ENABLE); 70 71 SetOptionFromCheck(XRCID("ID_ENABLE_DEFDOWNLOADDIR"), OPTION_ENABLE_DEFAULT_DOWNLOAD_DIRECTORY); 72 SetOptionFromText(XRCID("ID_DEFAULTDIR"), OPTION_DEFAULT_DOWNLOAD_DIRECTORY); 56 73 57 74 return true; 58 75 } … … 103 120 104 121 return true; 105 122 } 123 124 void COptionsPageTransfer::OnBrowseDefaultDownloadDirectory(wxCommandEvent& event) 125 { 126 // Get control handler 127 wxTextCtrl* pTextCtrl = XRCCTRL(*this, "ID_DEFAULTDIR", wxTextCtrl); 128 129 // Select a folder for default download directory 130 const wxString& curDir = pTextCtrl->GetValue(); 131 132 // Open DirSelector 133 const wxString& dir = ::wxDirSelector(_("Default Download Directory"), curDir); 134 135 // Pressed OK 136 if (!dir.empty()) 137 { 138 // Update setting 139 wxTextCtrl* pTextCtrl = XRCCTRL(*this, "ID_DEFAULTDIR", wxTextCtrl); 140 141 pTextCtrl->ChangeValue(dir); 142 } 143 } 144 145 void COptionsPageTransfer::SetCtrlState() 146 { 147 FindWindow(XRCID("ID_DEFAULTDIR"))->Enable(GetCheck(XRCID("ID_ENABLE_DEFDOWNLOADDIR"))); 148 FindWindow(XRCID("ID_BROWSEDEFDIR"))->Enable(GetCheck(XRCID("ID_ENABLE_DEFDOWNLOADDIR"))); 149 } 150 151 void COptionsPageTransfer::OnRadioOrCheckEvent(wxCommandEvent& event) 152 { 153 SetCtrlState(); 154 } 155 -
src/interface/settings/optionspage_edit.h
16 16 DECLARE_EVENT_TABLE(); 17 17 void OnBrowseEditor(wxCommandEvent& event); 18 18 void OnRadioButton(wxCommandEvent& event); 19 void OnBrowseTmpDir(wxCommandEvent& event); 20 void OnRadioOrCheckEvent(wxCommandEvent& event); 21 19 22 }; 20 23 21 24 #endif //__OPTIONSPAGE_EDIT_H__ -
src/interface/settings/optionspage_edit.cpp
8 8 BEGIN_EVENT_TABLE(COptionsPageEdit, COptionsPage) 9 9 EVT_BUTTON(XRCID("ID_BROWSE"), COptionsPageEdit::OnBrowseEditor) 10 10 EVT_RADIOBUTTON(wxID_ANY, COptionsPageEdit::OnRadioButton) 11 EVT_BUTTON(XRCID("ID_BROWSE_TMP"), COptionsPageEdit::OnBrowseTmpDir) 12 EVT_CHECKBOX(XRCID("ID_ENABLE_CUSTOM_TEMPEDITDIR"), COptionsPageEdit::OnRadioOrCheckEvent) 11 13 END_EVENT_TABLE() 12 14 13 15 bool COptionsPageEdit::LoadPage() … … 37 39 38 40 SetCheckFromOption(XRCID("ID_EDIT_TRACK_LOCAL"), OPTION_EDIT_TRACK_LOCAL, failure); 39 41 42 SetCheckFromOption(XRCID("ID_ENABLE_CUSTOM_TEMPEDITDIR"), OPTION_ENABLE_CUSTOM_TEMPORARY_DIRECTORY, failure); 43 44 SetTextFromOption(XRCID("ID_CUSTOM_TEMPEDITDIR"), OPTION_CUSTOM_TEMPORARY_DIRECTORY, failure); 45 40 46 if (!failure) 41 47 SetCtrlState(); 42 48 … … 59 65 60 66 SetOptionFromCheck(XRCID("ID_EDIT_TRACK_LOCAL"), OPTION_EDIT_TRACK_LOCAL); 61 67 68 SetOptionFromCheck(XRCID("ID_ENABLE_CUSTOM_TEMPEDITDIR"), OPTION_ENABLE_CUSTOM_TEMPORARY_DIRECTORY); 69 70 SetOptionFromText(XRCID("ID_CUSTOM_TEMPEDITDIR"), OPTION_CUSTOM_TEMPORARY_DIRECTORY); 71 62 72 return true; 63 73 } 64 74 … … 198 208 XRCCTRL(*this, "ID_BROWSE", wxButton)->Enable(custom); 199 209 200 210 XRCCTRL(*this, "ID_USEDEFAULT", wxRadioButton)->Enable(!GetRCheck(XRCID("ID_DEFAULT_NONE")) || GetRCheck(XRCID("ID_USEDEFAULT"))); 211 212 FindWindow(XRCID("ID_CUSTOM_TEMPEDITDIR"))->Enable(GetCheck(XRCID("ID_ENABLE_CUSTOM_TEMPEDITDIR"))); 213 FindWindow(XRCID("ID_BROWSE_TMP"))->Enable(GetCheck(XRCID("ID_ENABLE_CUSTOM_TEMPEDITDIR"))); 201 214 } 202 215 203 216 void COptionsPageEdit::OnRadioButton(wxCommandEvent& event) 204 217 { 205 218 SetCtrlState(); 206 219 } 220 221 void COptionsPageEdit::OnBrowseTmpDir(wxCommandEvent& event) 222 { 223 // Get control handler 224 wxTextCtrl* pTextCtrl = XRCCTRL(*this, "ID_CUSTOM_TEMPEDITDIR", wxTextCtrl); 225 226 // Select a folder for custom tmp dir 227 const wxString& curDir = pTextCtrl->GetValue(); 228 229 // Open DirSelector 230 const wxString& dir = ::wxDirSelector(_("Custom Temporary Directory"), curDir); 231 232 // Pressed OK 233 if (!dir.empty()) 234 { 235 // Update setting 236 wxTextCtrl* pTextCtrl = XRCCTRL(*this, "ID_CUSTOM_TEMPEDITDIR", wxTextCtrl); 237 238 pTextCtrl->ChangeValue(dir); 239 } 240 } 241 242 void COptionsPageEdit::OnRadioOrCheckEvent(wxCommandEvent& event) 243 { 244 SetCtrlState(); 245 } 246 -
src/interface/Mainfrm.cpp
534 534 if (!RestoreSplitterPositions()) 535 535 SetDefaultSplitterPositions(); 536 536 537 wxString localDir = COptions::Get()->GetOption(OPTION_LASTLOCALDIR); 538 if (!pState->SetLocalDir(localDir)) 539 pState->SetLocalDir(_T("/")); 540 537 // Check if "Default Download Directory" is enabled 538 if (COptions::Get()->GetOptionVal(OPTION_ENABLE_DEFAULT_DOWNLOAD_DIRECTORY)) 539 { 540 SetDefaultDownloadDirectory(pState); 541 } 542 else 543 { 544 wxString localDir = COptions::Get()->GetOption(OPTION_LASTLOCALDIR); 545 if (!pState->SetLocalDir(localDir)) 546 pState->SetLocalDir(_T("/")); 547 } 548 541 549 wxAcceleratorEntry entries[11]; 542 550 entries[0].Set(wxACCEL_CMD | wxACCEL_SHIFT, 'I', XRCID("ID_MENU_VIEW_FILTERS")); 543 551 for (int i = 0; i < 10; i++) … … 3657 3665 3658 3666 pState->GetRecursiveOperationHandler()->SetQueue(m_pQueueView); 3659 3667 3660 pState->SetLocalDir(_T("/")); 3668 // Set default donwload directory as well 3669 if (COptions::Get()->GetOptionVal(OPTION_ENABLE_DEFAULT_DOWNLOAD_DIRECTORY)) 3670 { 3671 SetDefaultDownloadDirectory(pState); 3672 } 3673 else 3674 { 3675 pState->SetLocalDir(_T("/")); 3676 } 3661 3677 3662 3678 CContextManager::Get()->SetCurrentContext(pState); 3663 3679 … … 3706 3722 { 3707 3723 CreateTab(); 3708 3724 } 3725 3726 // Wrap setting default download directory as function as creating tab also needs this 3727 bool CMainFrame::SetDefaultDownloadDirectory(CState *pState) 3728 { 3729 wxString error; 3730 3731 // Fetch setting 3732 const wxString& defaultDownloadDirectory = COptions::Get()->GetOption(OPTION_DEFAULT_DOWNLOAD_DIRECTORY); 3733 3734 // Set Local Dir 3735 if ((defaultDownloadDirectory != _T("")) && (!pState->SetLocalDir(defaultDownloadDirectory, &error))) 3736 { 3737 if (error != _T("")) 3738 { 3739 wxMessageBox(error, _("Failed to change default download directory"), wxICON_INFORMATION); 3740 } 3741 else 3742 { 3743 wxBell(); 3744 } 3745 3746 pState->SetLocalDir(_T("/")); 3747 3748 return false; 3749 } 3750 else 3751 { 3752 // Return success 3753 return true; 3754 } 3755 3756 } -
src/interface/Options.h
79 79 OPTION_INVALID_CHAR_REPLACE_ENABLE, 80 80 OPTION_INVALID_CHAR_REPLACE, 81 81 OPTION_ALREADYCONNECTED_CHOICE, 82 OPTION_ENABLE_DEFAULT_DOWNLOAD_DIRECTORY, 83 OPTION_DEFAULT_DOWNLOAD_DIRECTORY, 84 OPTION_ENABLE_CUSTOM_TEMPORARY_DIRECTORY, 85 OPTION_CUSTOM_TEMPORARY_DIRECTORY, 82 86 83 87 // Has to be last element 84 88 OPTIONS_NUM -
src/interface/resources/settings.xrc
971 971 </object> 972 972 <flag>wxGROW</flag> 973 973 </object> 974 <object class="sizeritem"> 975 <option>1</option> 976 <flag>wxEXPAND</flag> 977 <border>5</border> 978 <object class="wxStaticBoxSizer"> 979 <orient>wxVERTICAL</orient> 980 <label>Default Download Directory</label> 981 <object class="sizeritem"> 982 <option>1</option> 983 <flag>wxEXPAND</flag> 984 <border>5</border> 985 <object class="wxFlexGridSizer"> 986 <vgap>0</vgap> 987 <hgap>0</hgap> 988 <growablecols></growablecols> 989 <growablerows></growablerows> 990 <object class="sizeritem"> 991 <option>1</option> 992 <flag>wxEXPAND</flag> 993 <border>5</border> 994 <object class="wxBoxSizer"> 995 <orient>wxHORIZONTAL</orient> 996 <object class="sizeritem"> 997 <option>0</option> 998 <flag>wxALIGN_CENTER|wxALL</flag> 999 <border>5</border> 1000 <object class="wxCheckBox" name="ID_ENABLE_DEFDOWNLOADDIR"> 1001 <label>Enable default download directory</label> 1002 <checked>0</checked> 1003 </object> 1004 </object> 1005 <object class="sizeritem"> 1006 <option>0</option> 1007 <flag>wxALIGN_CENTER|wxALL</flag> 1008 <border>5</border> 1009 <object class="wxTextCtrl" name="ID_DEFAULTDIR"> 1010 <value></value> 1011 <maxlength>0</maxlength> 1012 </object> 1013 </object> 1014 <object class="sizeritem"> 1015 <option>0</option> 1016 <flag>wxALIGN_CENTER|wxALL</flag> 1017 <border>5</border> 1018 <object class="wxButton" name="ID_BROWSEDEFDIR"> 1019 <label>Browse</label> 1020 <default>0</default> 1021 </object> 1022 </object> 1023 </object> 1024 </object> 1025 </object> 1026 </object> 1027 </object> 1028 </object> 974 1029 </object> 975 1030 </object> 976 1031 <object class="wxPanel" name="ID_SETTINGS_FILETYPE"> … … 1840 1895 <label>&Watch locally edited files and prompt to upload modifications</label> 1841 1896 </object> 1842 1897 </object> 1898 <object class="sizeritem"> 1899 <option>0</option> 1900 <flag>wxEXPAND | wxALL</flag> 1901 <border>5</border> 1902 <object class="wxStaticLine" name="m_staticline3"> 1903 <style>wxLI_HORIZONTAL</style> 1904 </object> 1905 </object> 1906 <object class="sizeritem"> 1907 <option>1</option> 1908 <flag>wxALL|wxEXPAND</flag> 1909 <border>0</border> 1910 <object class="wxStaticBoxSizer"> 1911 <orient>wxVERTICAL</orient> 1912 <label>Temporary Directory</label> 1913 <object class="sizeritem"> 1914 <option>0</option> 1915 <flag>wxALL</flag> 1916 <border>5</border> 1917 <object class="wxCheckBox" name="ID_ENABLE_CUSTOM_TEMPEDITDIR"> 1918 <label>Enable custom temporary directory</label> 1919 <checked>0</checked> 1920 </object> 1921 </object> 1922 <object class="sizeritem"> 1923 <option>1</option> 1924 <flag>wxEXPAND</flag> 1925 <border>5</border> 1926 <object class="wxBoxSizer"> 1927 <orient>wxHORIZONTAL</orient> 1928 <object class="sizeritem"> 1929 <option>1</option> 1930 <flag>wxRIGHT|wxALIGN_CENTRE_VERTICAL</flag> 1931 <border>5</border> 1932 <object class="wxTextCtrl" name="ID_CUSTOM_TEMPEDITDIR"> 1933 <value></value> 1934 <maxlength>0</maxlength> 1935 </object> 1936 </object> 1937 <object class="sizeritem"> 1938 <option>0</option> 1939 <flag>wxALIGN_CENTRE_VERTICAL</flag> 1940 <border>0</border> 1941 <object class="wxButton" name="ID_BROWSE_TMP"> 1942 <label>B&rowse...</label> 1943 <default>0</default> 1944 </object> 1945 </object> 1946 </object> 1947 </object> 1948 </object> 1949 </object> 1843 1950 <cols>1</cols> 1844 1951 <vgap>5</vgap> 1845 1952 <growablecols>0</growablecols> … … 2159 2266 </object> 2160 2267 </object> 2161 2268 </object> 2162 </resource> 2163 No newline at end of file 2269 </resource> -
src/interface/Options.cpp
147 147 { "Filteredit window size", string, _T(""), false }, 148 148 { "Enable invalid char filter", number, _T("1"), false }, 149 149 { "Invalid char replace", string, _T("_"), false }, 150 { "Already connected choice", number, _T("0"), false } 150 { "Already connected choice", number, _T("0"), false }, 151 { "Use default download dir", number, _T("0"), false }, 152 { "Default Download Directory", string, _T(""), false }, 153 { "Use custom temp dir", number, _T("0"), false }, 154 { "Custom temporary directory", string, _T(""), false } 151 155 }; 152 156 153 157 struct t_default_option -
src/interface/Mainfrm.h
234 234 #endif 235 235 236 236 wxAuiNotebookEx* m_tabs; 237 238 // Set default download directory 239 // Return true for success, false for failure 240 bool SetDefaultDownloadDirectory(CState *pState); 237 241 }; 238 242 239 243 #endif -
src/interface/edithandler.cpp
125 125 { 126 126 if (m_localDir != _T("")) 127 127 return m_localDir; 128 128 129 129 wxFileName tmpdir(wxFileName::GetTempDir(), _T("")); 130 131 // If custom temp dir is enabled 132 if (COptions::Get()->GetOptionVal(OPTION_ENABLE_CUSTOM_TEMPORARY_DIRECTORY )) 133 { 134 wxFileName customDir(COptions::Get()->GetOption(OPTION_CUSTOM_TEMPORARY_DIRECTORY), _T("")); 135 136 // Set the tmpdir iff it exists 137 if (customDir.DirExists()) 138 { 139 tmpdir = customDir; 140 } 141 } 142 130 143 // Need to call GetLongPath on MSW, GetTempDir can return short path 131 144 // which will cause problems when calculating maximum allowed file 132 145 // length