2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Original author: Emilio Sandoz
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "PrefsUnifiedDlg.h"
29 #include <common/Constants.h>
30 #include <common/Macros.h> // Needed for itemsof()
32 #include <wx/colordlg.h>
33 #include <wx/tooltip.h>
35 #include "amule.h" // Needed for theApp
37 #include "MuleColour.h"
38 #include "EditServerListDlg.h"
39 #include "SharedFileList.h" // Needed for CSharedFileList
40 #include "StatisticsDlg.h" // Needed for graph parameters, colors
41 #include "IPFilter.h" // Needed for CIPFilter
42 #include "ClientList.h"
43 #include "DirectoryTreeCtrl.h" // Needed for CDirectoryTreeCtrl
44 #include "Preferences.h"
45 #include "muuli_wdr.h"
47 #include <common/Format.h> // Needed for CFormat
48 #include "TransferWnd.h" // Needed for CTransferWnd::UpdateCatTabTitles()
49 #include "KadDlg.h" // Needed for CKadDlg
50 #include "OScopeCtrl.h" // Needed for OScopeCtrl
51 #include "ServerList.h"
52 #include "Statistics.h"
53 #include "UserEvents.h"
54 #include "PlatformSpecific.h" // Needed for PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE
56 BEGIN_EVENT_TABLE(PrefsUnifiedDlg
,wxDialog
)
58 #define USEREVENTS_EVENT(ID, NAME, VARS) \
59 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 1, PrefsUnifiedDlg::OnCheckBoxChange) \
60 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 3, PrefsUnifiedDlg::OnCheckBoxChange)
61 USEREVENTS_EVENTLIST()
62 #undef USEREVENTS_EVENT
65 EVT_CHECKBOX(ID_PROXY_ENABLE_PROXY
, PrefsUnifiedDlg::OnCheckBoxChange
)
66 EVT_CHECKBOX(ID_PROXY_ENABLE_PASSWORD
, PrefsUnifiedDlg::OnCheckBoxChange
)
67 // EVT_CHECKBOX(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY, PrefsUnifiedDlg::OnCheckBoxChange)
70 EVT_SPINCTRL(IDC_PORT
, PrefsUnifiedDlg::OnTCPClientPortChange
)
72 // The rest. Organize it!
73 EVT_CHECKBOX(IDC_UDPENABLE
, PrefsUnifiedDlg::OnCheckBoxChange
)
74 EVT_CHECKBOX(IDC_CHECKDISKSPACE
, PrefsUnifiedDlg::OnCheckBoxChange
)
75 EVT_CHECKBOX(IDC_ONLINESIG
, PrefsUnifiedDlg::OnCheckBoxChange
)
76 EVT_CHECKBOX(IDC_REMOVEDEAD
, PrefsUnifiedDlg::OnCheckBoxChange
)
77 EVT_CHECKBOX(IDC_AUTOSERVER
, PrefsUnifiedDlg::OnCheckBoxChange
)
78 EVT_CHECKBOX(IDC_AUTOIPFILTER
, PrefsUnifiedDlg::OnCheckBoxChange
)
79 EVT_CHECKBOX(IDC_MSGFILTER
, PrefsUnifiedDlg::OnCheckBoxChange
)
80 EVT_CHECKBOX(IDC_MSGFILTER_ALL
, PrefsUnifiedDlg::OnCheckBoxChange
)
81 EVT_CHECKBOX(IDC_MSGFILTER_WORD
, PrefsUnifiedDlg::OnCheckBoxChange
)
82 EVT_CHECKBOX(IDC_FILTERCOMMENTS
, PrefsUnifiedDlg::OnCheckBoxChange
)
83 EVT_CHECKBOX(IDC_STARTNEXTFILE
, PrefsUnifiedDlg::OnCheckBoxChange
)
84 EVT_CHECKBOX(IDC_ENABLETRAYICON
, PrefsUnifiedDlg::OnCheckBoxChange
)
85 EVT_CHECKBOX(IDC_MACHIDEONCLOSE
, PrefsUnifiedDlg::OnCheckBoxChange
)
86 EVT_CHECKBOX(IDC_VERTTOOLBAR
, PrefsUnifiedDlg::OnCheckBoxChange
)
87 EVT_CHECKBOX(IDC_SUPPORT_PO
, PrefsUnifiedDlg::OnCheckBoxChange
)
88 EVT_CHECKBOX(IDC_ENABLE_PO_OUTGOING
, PrefsUnifiedDlg::OnCheckBoxChange
)
89 EVT_CHECKBOX(IDC_ENFORCE_PO_INCOMING
, PrefsUnifiedDlg::OnCheckBoxChange
)
90 EVT_CHECKBOX(IDC_SHOWRATEONTITLE
, PrefsUnifiedDlg::OnCheckBoxChange
)
91 EVT_CHECKBOX(IDC_NETWORKED2K
, PrefsUnifiedDlg::OnCheckBoxChange
)
92 EVT_CHECKBOX(IDC_NETWORKKAD
, PrefsUnifiedDlg::OnCheckBoxChange
)
93 EVT_CHECKBOX(IDC_UPNP_ENABLED
, PrefsUnifiedDlg::OnCheckBoxChange
)
94 EVT_CHECKBOX(IDC_UPNP_WEBSERVER_ENABLED
,PrefsUnifiedDlg::OnCheckBoxChange
)
97 EVT_BUTTON(ID_PREFS_OK_TOP
, PrefsUnifiedDlg::OnOk
)
98 EVT_BUTTON(ID_PREFS_CANCEL_TOP
, PrefsUnifiedDlg::OnCancel
)
101 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
102 EVT_BUTTON(IDC_BROWSEV
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
103 EVT_BUTTON(IDC_SELTEMPDIR
, PrefsUnifiedDlg::OnButtonDir
)
104 EVT_BUTTON(IDC_SELINCDIR
, PrefsUnifiedDlg::OnButtonDir
)
105 EVT_BUTTON(IDC_SELOSDIR
, PrefsUnifiedDlg::OnButtonDir
)
106 EVT_BUTTON(IDC_SELBROWSER
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
108 EVT_SPINCTRL(IDC_TOOLTIPDELAY
, PrefsUnifiedDlg::OnToolTipDelayChange
)
110 EVT_BUTTON(IDC_EDITADR
, PrefsUnifiedDlg::OnButtonEditAddr
)
111 EVT_BUTTON(IDC_IPFRELOAD
, PrefsUnifiedDlg::OnButtonIPFilterReload
)
112 EVT_BUTTON(IDC_COLOR_BUTTON
, PrefsUnifiedDlg::OnButtonColorChange
)
113 EVT_BUTTON(IDC_IPFILTERUPDATE
, PrefsUnifiedDlg::OnButtonIPFilterUpdate
)
114 EVT_CHOICE(IDC_COLORSELECTOR
, PrefsUnifiedDlg::OnColorCategorySelected
)
115 EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL
,PrefsUnifiedDlg::OnPrefsPageChange
)
117 EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog
)
119 EVT_COMMAND_SCROLL(IDC_SLIDER
, PrefsUnifiedDlg::OnScrollBarChange
)
120 EVT_COMMAND_SCROLL(IDC_SLIDER3
, PrefsUnifiedDlg::OnScrollBarChange
)
121 EVT_COMMAND_SCROLL(IDC_SLIDER4
, PrefsUnifiedDlg::OnScrollBarChange
)
122 EVT_COMMAND_SCROLL(IDC_SLIDER2
, PrefsUnifiedDlg::OnScrollBarChange
)
123 EVT_COMMAND_SCROLL(IDC_FILEBUFFERSIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
124 EVT_COMMAND_SCROLL(IDC_QUEUESIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
125 EVT_COMMAND_SCROLL(IDC_SERVERKEEPALIVE
, PrefsUnifiedDlg::OnScrollBarChange
)
127 EVT_SPINCTRL(IDC_MAXUP
, PrefsUnifiedDlg::OnRateLimitChanged
)
129 EVT_LIST_ITEM_SELECTED(IDC_EVENTLIST
, PrefsUnifiedDlg::OnUserEventSelected
)
131 EVT_CHOICE(IDC_LANGUAGE
, PrefsUnifiedDlg::OnLanguageChoice
)
133 EVT_CLOSE(PrefsUnifiedDlg::OnClose
)
139 * Creates an command-event for the given checkbox.
141 * This can be used enforce logical constraints by passing by
142 * sending a check-box event for each checkbox, when transfering
143 * to the UI. However, it should also be used for checkboxes that
144 * have no side-effects other than enabling/disabling other
145 * widgets in the preferences dialogs.
147 static void SendCheckBoxEvent(wxWindow
* parent
, int id
)
149 wxCheckBox
* widget
= CastByID(id
, parent
, wxCheckBox
);
150 wxCHECK_RET(widget
, wxT("Invalid widget in CreateEvent"));
152 wxCommandEvent
evt(wxEVT_COMMAND_CHECKBOX_CLICKED
, id
);
153 evt
.SetInt(widget
->IsChecked() ? 1 : 0);
155 parent
->GetEventHandler()->ProcessEvent(evt
);
161 * This struct provides a general way to represent config-tabs.
165 //! The title of the page, used on the listctrl.
167 //! Function pointer to the wxDesigner function creating the dialog.
168 wxSizer
* (*m_function
)(wxWindow
*, bool, bool );
169 //! The index of the image used on the list.
176 { wxTRANSLATE("General"), PreferencesGeneralTab
, 13 },
177 { wxTRANSLATE("Connection"), PreferencesConnectionTab
, 14 },
178 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab
, 17 },
179 { wxTRANSLATE("Servers"), PreferencesServerTab
, 15 },
180 { wxTRANSLATE("Files"), PreferencesFilesTab
, 16 },
181 { wxTRANSLATE("Security"), PreferencesSecurityTab
, 22 },
182 { wxTRANSLATE("Interface"), PreferencesGuiTweaksTab
, 19 },
183 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab
, 10 },
184 { wxTRANSLATE("Proxy"), PreferencesProxyTab
, 24 },
185 { wxTRANSLATE("Filters"), PreferencesFilteringTab
, 23 },
186 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab
, 11 },
187 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab
, 21 },
188 { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab
, 12 },
189 { wxTRANSLATE("Events"), PreferencesEventsTab
, 5 }
191 ,{ wxTRANSLATE("Debugging"), PreferencesDebug
, 25 }
196 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow
*parent
)
198 wxDialog(parent
, -1, _("Preferences"),
199 wxDefaultPosition
, wxDefaultSize
,
200 wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
)
202 preferencesDlgTop(this, false);
204 m_PrefsIcons
= CastChild(ID_PREFSLISTCTRL
, wxListCtrl
);
205 wxImageList
*icon_list
= new wxImageList(16, 16);
206 m_PrefsIcons
->AssignImageList(icon_list
, wxIMAGE_LIST_SMALL
);
208 // Add the single column used
209 m_PrefsIcons
->InsertColumn(
210 0, wxEmptyString
, wxLIST_FORMAT_LEFT
,
211 m_PrefsIcons
->GetSize().GetWidth()-5);
213 // Temp variables for finding the smallest height and width needed
217 // Add each page to the page-list
218 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
219 // Add the icon and label associated with the page
220 icon_list
->Add(amuleSpecial(pages
[i
].m_imageidx
));
221 m_PrefsIcons
->InsertItem(i
, wxGetTranslation(pages
[i
].m_title
), i
);
224 // Set list-width so that there aren't any scrollers
225 m_PrefsIcons
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
226 m_PrefsIcons
->SetMinSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
227 m_PrefsIcons
->SetMaxSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
229 // Now add the pages and calculate the minimum size
230 wxPanel
* DefaultWidget
= NULL
;
231 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
232 // Create a container widget and the contents of the page
233 wxPanel
* Widget
= new wxPanel(this, -1);
234 // Widget is stored as user data in the list control
235 m_PrefsIcons
->SetItemPtrData(i
, (wxUIntPtr
) Widget
);
236 pages
[i
].m_function(Widget
, true, true);
238 DefaultWidget
= Widget
;
241 // Add it to the sizer
242 prefs_sizer
->Add(Widget
, 0, wxGROW
|wxEXPAND
);
244 if (pages
[i
].m_function
== PreferencesGeneralTab
) {
245 // This must be done now or pages won't Fit();
247 CastChild(IDC_BROWSERTABS
, wxCheckBox
)->Enable(false);
248 #endif /* __WINDOWS__ */
249 CastChild(IDC_PREVIEW_NOTE
, wxStaticText
)->SetLabel(_("The following variables will be substituted:\n %PARTFILE - full path to the file\n %PARTNAME - file name only"));
251 FindWindow(IDC_ENABLETRAYICON
)->Show(false);
252 FindWindow(IDC_MINTRAY
)->Show(false);
254 FindWindow(IDC_MACHIDEONCLOSE
)->Show(false);
255 thePrefs::SetHideOnClose(false);
257 } else if (pages
[i
].m_function
== PreferencesEventsTab
) {
259 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
260 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, Widget); break;
262 wxListCtrl
*list
= CastChild(IDC_EVENTLIST
, wxListCtrl
);
263 list
->InsertColumn(0, wxEmptyString
);
264 for (unsigned int idx
= 0; idx
< CUserEvents::GetCount(); ++idx
) {
265 long lidx
= list
->InsertItem(idx
,
266 wxGetTranslation(CUserEvents::GetDisplayName(
267 static_cast<enum CUserEvents::EventType
>(idx
))));
269 list
->SetItemData(lidx
,
270 USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
);
272 USEREVENTS_EVENTLIST()
273 /* This macro expands to handle all user event types. Here is an example:
274 case CUserEvents::NewChatSession: {
275 CreateEventPanels(idx, wxString(wxT("\n %SENDER - ")) + wxTRANSLATE("Message sender."), Widget);
281 list
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
283 else if (pages
[i
].m_function
== PreferencesServerTab
) {
284 m_IndexServerTab
= i
;
285 m_ServerWidget
= Widget
;
287 else if (pages
[i
].m_function
== PreferencesaMuleTweaksTab
) {
288 wxStaticText
*txt
= CastChild(IDC_AMULE_TWEAKS_WARNING
, wxStaticText
);
289 // Do not wrap this line, Windows _() can't handle wrapped strings
290 txt
->SetLabel(_("Do not change these setting unless you know\nwhat you are doing, otherwise you can easily\nmake things worse for yourself.\n\naMule will run fine without adjusting any of\nthese settings."));
291 #if defined CLIENT_GUI || !PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE
292 CastChild(IDC_PREVENT_SLEEP
, wxCheckBox
)->Enable(false);
293 thePrefs::SetPreventSleepWhileDownloading(false);
297 else if (pages
[i
].m_function
== PreferencesDebug
) {
298 int count
= theLogger
.GetDebugCategoryCount();
299 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
301 for ( int j
= 0; j
< count
; j
++ ) {
302 list
->Append( theLogger
.GetDebugCategory( j
).GetName() );
307 // Align and resize the page
311 // Find the greatest sizes
312 wxSize size
= prefs_sizer
->GetSize();
313 if (size
.GetWidth() > width
) {
314 width
= size
.GetWidth();
317 if (size
.GetHeight() > height
) {
318 height
= size
.GetHeight();
322 prefs_sizer
->Detach(Widget
);
326 // Default to the General tab
327 m_CurrentPanel
= DefaultWidget
;
328 prefs_sizer
->Add(DefaultWidget
, 0, wxGROW
|wxEXPAND
);
329 m_CurrentPanel
->Show( true );
331 // Select the first item
332 m_PrefsIcons
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
334 // We now have the needed minimum height and width
335 prefs_sizer
->SetMinSize(width
, height
);
337 // Don't show server prefs if ED2K is disabled
338 m_ServerTabVisible
= true;
339 EnableServerTab(thePrefs::GetNetworkED2K());
341 // Store some often used pointers
342 m_ShareSelector
= CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
);
343 m_buttonColor
= CastChild(IDC_COLOR_BUTTON
, wxButton
);
344 m_choiceColor
= CastChild(IDC_COLORSELECTOR
, wxChoice
);
346 // Connect the Cfgs with their widgets
347 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
348 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
349 // Checking for failures
350 if ( !it
->second
->ConnectToWidget(it
->first
, this) ) {
351 AddLogLineNS(CFormat(_("Failed to connect Cfg to widget with the ID %d and key %s"))
352 % it
->first
% it
->second
->GetKey());
357 // It must not be resized to something smaller than what it currently is
358 wxSize size
= GetClientSize();
359 SetSizeHints(size
.GetWidth(), size
.GetHeight());
361 // Position the dialog.
366 void PrefsUnifiedDlg::EnableServerTab(bool enable
)
368 if (enable
&& !m_ServerTabVisible
) {
369 // turn server widget on
370 m_PrefsIcons
->InsertItem(m_IndexServerTab
, wxGetTranslation(pages
[m_IndexServerTab
].m_title
), m_IndexServerTab
);
371 m_PrefsIcons
->SetItemPtrData(m_IndexServerTab
, (wxUIntPtr
) m_ServerWidget
);
372 m_ServerTabVisible
= true;
373 } else if (!enable
&& m_ServerTabVisible
) {
374 // turn server widget off
375 m_PrefsIcons
->DeleteItem(m_IndexServerTab
);
376 m_ServerTabVisible
= false;
381 Cfg_Base
* PrefsUnifiedDlg::GetCfg(int id
)
383 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.find( id
);
385 if ( it
!= thePrefs::s_CfgList
.end() ) {
393 bool PrefsUnifiedDlg::TransferToWindow()
395 // Connect the Cfgs with their widgets
396 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
397 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
398 // Checking for failures
399 if ( !it
->second
->TransferToWindow() ) {
400 AddLogLineNS(CFormat(_("Failed to transfer data from Cfg to Widget with the ID %d and key %s"))
401 % it
->first
% it
->second
->GetKey());
405 m_ShareSelector
->SetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
407 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
408 thePrefs::s_colors
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
409 thePrefs::s_colors_ref
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
414 OnTCPClientPortChange(e
);
416 // Proxy tab initialization
417 FindWindow(ID_PROXY_TYPE
)->SetToolTip(_("The type of proxy you are connecting to"));
418 if (!CastChild(ID_PROXY_ENABLE_PROXY
, wxCheckBox
)->IsChecked()) {
419 FindWindow(ID_PROXY_TYPE
)->Enable(false);
420 FindWindow(ID_PROXY_NAME
)->Enable(false);
421 FindWindow(ID_PROXY_PORT
)->Enable(false);
423 if (!CastChild(ID_PROXY_ENABLE_PASSWORD
, wxCheckBox
)->IsChecked()) {
424 FindWindow(ID_PROXY_USER
)->Enable(false);
425 FindWindow(ID_PROXY_PASSWORD
)->Enable(false);
427 // This option from the proxy tab is currently unused
428 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
)->Enable(false);
430 // Enable/Disable some controls
431 FindWindow( IDC_MINDISKSPACE
)->Enable( thePrefs::IsCheckDiskspaceEnabled() );
432 FindWindow( IDC_OSDIR
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
433 FindWindow( IDC_OSUPDATE
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
434 FindWindow( IDC_UDPENABLE
)->Enable( !thePrefs::GetNetworkKademlia());
435 FindWindow( IDC_UDPPORT
)->Enable( thePrefs::s_UDPEnable
);
436 FindWindow( IDC_SERVERRETRIES
)->Enable( thePrefs::DeadServer() );
437 FindWindow( IDC_STARTNEXTFILE_SAME
)->Enable(thePrefs::StartNextFile());
438 FindWindow( IDC_STARTNEXTFILE_ALPHA
)->Enable(thePrefs::StartNextFile());
440 FindWindow(IDC_MACHIDEONCLOSE
)->Enable(true);
441 FindWindow(IDC_EXIT
)->Enable(!thePrefs::HideOnClose());
442 if (thePrefs::HideOnClose()) {
443 CastChild(IDC_EXIT
, wxCheckBox
)->SetValue(false);
446 FindWindow(IDC_MINTRAY
)->Enable(thePrefs::UseTrayIcon());
448 if (!CastChild(IDC_MSGFILTER
, wxCheckBox
)->IsChecked()) {
449 FindWindow(IDC_MSGFILTER_ALL
)->Enable(false);
450 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
451 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
452 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
453 FindWindow(IDC_MSGWORD
)->Enable(false);
454 } else if (CastChild(IDC_MSGFILTER_ALL
, wxCheckBox
)->IsChecked()) {
455 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
456 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
457 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
458 FindWindow(IDC_MSGWORD
)->Enable(false);
461 FindWindow(IDC_MSGWORD
)->Enable(CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
462 FindWindow(IDC_COMMENTWORD
)->Enable(CastChild(IDC_FILTERCOMMENTS
, wxCheckBox
)->IsChecked());
465 // Disable dirpickers unless it's a localhost connection
466 if (!theApp
->m_connect
->IsConnectedToLocalHost()) {
467 FindWindow(IDC_SELINCDIR
)->Enable(false);
468 FindWindow(IDC_SELTEMPDIR
)->Enable(false);
472 // Protocol obfuscation
473 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO
);
474 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING
);
475 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING
);
477 #ifndef ENABLE_IP2COUNTRY
478 CastChild(IDC_SHOW_COUNTRY_FLAGS
, wxCheckBox
)->Enable(false);
479 thePrefs::SetGeoIPEnabled(false);
483 // Version is always shown on the title in development versions
484 CastChild(IDC_SHOWVERSIONONTITLE
, wxCheckBox
)->SetValue(true);
485 CastChild(IDC_SHOWVERSIONONTITLE
, wxCheckBox
)->Enable(false);
488 // Show rates on title
489 FindWindow(IDC_RATESBEFORETITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
490 FindWindow(IDC_RATESAFTERTITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
491 CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->SetValue(thePrefs::GetShowRatesOnTitle() != 0);
492 CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() == 2);
493 CastChild(IDC_RATESAFTERTITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() != 2);
497 FindWindow(IDC_UPNP_ENABLED
)->Enable(false);
498 FindWindow(IDC_UPNPTCPPORT
)->Enable(false);
499 FindWindow(IDC_UPNPTCPPORTTEXT
)->Enable(false);
500 thePrefs::SetUPnPEnabled(false);
501 FindWindow(IDC_UPNP_WEBSERVER_ENABLED
)->Enable(false);
502 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(false);
503 FindWindow(IDC_WEBUPNPTCPPORTTEXT
)->Enable(false);
504 thePrefs::SetUPnPWebServerEnabled(false);
505 FindWindow(IDC_UPNP_EC_ENABLED
)->Enable(false);
506 thePrefs::SetUPnPECEnabled(false);
508 FindWindow(IDC_UPNPTCPPORT
)->Enable(thePrefs::GetUPnPEnabled());
509 FindWindow(IDC_UPNPTCPPORTTEXT
)->Enable(thePrefs::GetUPnPEnabled());
510 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(thePrefs::GetUPnPWebServerEnabled());
511 FindWindow(IDC_WEBUPNPTCPPORTTEXT
)->Enable(thePrefs::GetUPnPWebServerEnabled());
514 #if !wxCHECK_VERSION(2,9,0)
515 CastChild(IDC_NOTIF
, wxCheckBox
)->SetValue(false);
516 FindWindow(IDC_NOTIF
)->Enable(false);
520 // Set debugging toggles
521 int count
= theLogger
.GetDebugCategoryCount();
522 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
524 for ( int i
= 0; i
< count
; i
++ ) {
525 list
->Check( i
, theLogger
.GetDebugCategory( i
).IsEnabled() );
529 m_verticalToolbar
= thePrefs::VerticalToolbar();
530 m_toolbarOrientationChanged
= false;
536 bool PrefsUnifiedDlg::TransferFromWindow()
538 // Connect the Cfgs with their widgets
539 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
540 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
541 // Checking for failures
542 if ( !it
->second
->TransferFromWindow() ) {
543 AddLogLineNS(CFormat(_("Failed to transfer data from Widget to Cfg with the ID %d and key %s"))
544 % it
->first
% it
->second
->GetKey());
548 theApp
->glob_prefs
->shareddir_list
.clear();
549 m_ShareSelector
->GetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
551 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
552 if ( thePrefs::s_colors
[i
] != thePrefs::s_colors_ref
[i
] ) {
553 CStatisticsDlg::acrStat
[i
] = thePrefs::s_colors
[i
];
554 theApp
->amuledlg
->m_statisticswnd
->ApplyStatsColor(i
);
557 theApp
->amuledlg
->m_kademliawnd
->SetGraphColors();
561 // Get debugging toggles
562 int count
= theLogger
.GetDebugCategoryCount();
563 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
565 for ( int i
= 0; i
< count
; i
++ ) {
566 theLogger
.SetEnabled( theLogger
.GetDebugCategory( i
).GetType(), list
->IsChecked( i
) );
570 thePrefs::SetShowRatesOnTitle(CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->GetValue() ? (CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->GetValue() ? 2 : 1) : 0);
573 // Send preferences to core.
574 theApp
->glob_prefs
->SendToRemote();
581 bool PrefsUnifiedDlg::CfgChanged(int ID
)
583 Cfg_Base
* cfg
= GetCfg(ID
);
586 return cfg
->HasChanged();
593 void PrefsUnifiedDlg::OnOk(wxCommandEvent
& WXUNUSED(event
))
595 TransferFromWindow();
597 bool restart_needed
= false;
598 wxString restart_needed_msg
= _("aMule must be restarted to enable these changes:\n\n");
600 // do sanity checking, special processing, and user notifications here
601 thePrefs::CheckUlDlRatio();
603 if (CfgChanged(IDC_PORT
)) {
604 restart_needed
= true;
605 restart_needed_msg
+= _("- TCP port changed.\n");
608 if (CfgChanged(IDC_UDPPORT
)) {
609 restart_needed
= true;
610 restart_needed_msg
+= _("- UDP port changed.\n");
613 if (CfgChanged(IDC_EXT_CONN_TCP_PORT
)) {
614 restart_needed
= true;
615 restart_needed_msg
+= _("- External connect port changed.\n");
617 if (CfgChanged(IDC_EXT_CONN_ACCEPT
)) {
618 restart_needed
= true;
619 restart_needed_msg
+= _("- External connect acceptance changed.\n");
621 if (CfgChanged(IDC_EXT_CONN_IP
)) {
622 restart_needed
= true;
623 restart_needed_msg
+= _("- External connect interface changed.\n");
625 if (CfgChanged(IDC_SUPPORT_PO
)) {
626 restart_needed
= true;
627 restart_needed_msg
+= _("- Protocol obfuscation support changed.\n");
630 // Force port checking
631 thePrefs::SetPort(thePrefs::GetPort());
633 if ((CPath::GetFileSize(thePrefs::GetConfigDir() + wxT("addresses.dat")) == 0) &&
634 CastChild(IDC_AUTOSERVER
, wxCheckBox
)->IsChecked() ) {
635 thePrefs::UnsetAutoServerStart();
636 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
637 _("Message"), wxOK
| wxICON_INFORMATION
, this);
640 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
641 thePrefs::EnableExternalConnections( false );
643 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
646 // save the preferences on ok
647 theApp
->glob_prefs
->Save();
649 if (CfgChanged(IDC_FED2KLH
) && theApp
->amuledlg
->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND
) {
650 theApp
->amuledlg
->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
653 if (CfgChanged(IDC_LANGUAGE
)) {
654 restart_needed
= true;
655 restart_needed_msg
+= _("- Language changed.\n");
658 if (CfgChanged(IDC_TEMPFILES
)) {
659 restart_needed
= true;
660 restart_needed_msg
+= _("- Temp folder changed.\n");
663 if (CfgChanged(IDC_NETWORKED2K
) && thePrefs::GetNetworkED2K()) {
664 restart_needed
= true;
665 restart_needed_msg
+= _("- ED2K network enabled.\n");
668 if (CfgChanged(IDC_INCFILES
) || CfgChanged(IDC_TEMPFILES
) || m_ShareSelector
->HasChanged
) {
669 theApp
->sharedfiles
->Reload();
672 if (CfgChanged(IDC_OSDIR
) || CfgChanged(IDC_ONLINESIG
)) {
673 wxTextCtrl
* widget
= CastChild( IDC_OSDIR
, wxTextCtrl
);
675 // Build the filenames for the two OS files
676 theApp
->SetOSFiles( widget
->GetValue() );
679 if (CfgChanged(IDC_IPFCLIENTS
) && thePrefs::IsFilteringClients()) {
680 theApp
->clientlist
->FilterQueues();
683 if (CfgChanged(IDC_IPFSERVERS
) && thePrefs::IsFilteringServers()) {
684 theApp
->serverlist
->FilterServers();
687 if (CfgChanged(ID_IPFILTERLEVEL
)) {
688 theApp
->ipfilter
->Reload();
691 theApp
->ResetTitle();
693 if (thePrefs::GetShowRatesOnTitle()) {
694 // This avoids a 5 seconds delay to show the title
695 theApp
->amuledlg
->ShowTransferRate();
697 // This resets the title
698 theApp
->amuledlg
->SetTitle(theApp
->m_FrameTitle
);
701 if (CfgChanged(IDC_EXTCATINFO
)) {
702 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
705 // Changes related to the statistics-dlg
706 if (CfgChanged(IDC_SLIDER
)) {
707 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
708 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
711 if ( CfgChanged(IDC_SLIDER3
) ) {
712 theApp
->amuledlg
->m_statisticswnd
->ResetAveragingTime();
715 if (CfgChanged(IDC_DOWNLOAD_CAP
)) {
716 theApp
->amuledlg
->m_statisticswnd
->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
719 if (CfgChanged(IDC_UPLOAD_CAP
)) {
720 theApp
->amuledlg
->m_statisticswnd
->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
723 if (CfgChanged(IDC_SKIN
)) {
724 theApp
->amuledlg
->Create_Toolbar(thePrefs::VerticalToolbar());
727 if (!thePrefs::GetNetworkED2K() && theApp
->IsConnectedED2K()) {
728 theApp
->DisconnectED2K();
731 if (!thePrefs::GetNetworkKademlia() && theApp
->IsConnectedKad()) {
735 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
737 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
740 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
741 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
742 _("Message"), wxOK
| wxICON_INFORMATION
, this);
745 if (CfgChanged(IDC_NETWORKKAD
) || CfgChanged(IDC_NETWORKED2K
)) {
746 theApp
->amuledlg
->DoNetworkRearrange();
749 if (CfgChanged(IDC_SHOW_COUNTRY_FLAGS
)) {
750 theApp
->amuledlg
->EnableIP2Country();
753 if (restart_needed
) {
754 wxMessageBox(restart_needed_msg
+ _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
755 _("WARNING"), wxOK
| wxICON_EXCLAMATION
, this);
762 void PrefsUnifiedDlg::OnClose(wxCloseEvent
& event
)
766 // Try to keep the window alive when possible
767 if (event
.CanVeto()) {
770 if (theApp
->amuledlg
) {
771 theApp
->amuledlg
->m_prefsDialog
= NULL
;
774 // Un-Connect the Cfgs
775 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
776 for (; it
!= thePrefs::s_CfgList
.end(); ++it
) {
777 // Checking for failures
778 it
->second
->ConnectToWidget( 0 );
786 void PrefsUnifiedDlg::OnCancel(wxCommandEvent
& WXUNUSED(event
))
789 // restore state of server tab if necessary
790 EnableServerTab(thePrefs::GetNetworkED2K());
792 if (m_toolbarOrientationChanged
) {
793 theApp
->amuledlg
->Create_Toolbar(m_verticalToolbar
);
794 // Update the first tool (conn button)
795 theApp
->amuledlg
->ShowConnectionState();
796 theApp
->amuledlg
->Layout();
801 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent
& event
)
803 bool value
= event
.IsChecked();
804 int id
= event
.GetId();
806 // Check if this checkbox is one of the User Events checkboxes
807 if (id
>= USEREVENTS_FIRST_ID
&&
808 id
< USEREVENTS_FIRST_ID
+
809 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT
) {
810 // The corresponding text control always has
811 // an ID one greater than the checkbox
812 FindWindow(id
+ 1)->Enable(value
);
818 FindWindow( IDC_UDPPORT
)->Enable(value
);
821 case IDC_UPNP_ENABLED
:
822 FindWindow(IDC_UPNPTCPPORT
)->Enable(value
);
823 FindWindow(IDC_UPNPTCPPORTTEXT
)->Enable(value
);
826 case IDC_UPNP_WEBSERVER_ENABLED
:
827 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(value
);
828 FindWindow(IDC_WEBUPNPTCPPORTTEXT
)->Enable(value
);
831 case IDC_NETWORKKAD
: {
832 wxCheckBox
* udpPort
= (wxCheckBox
*) FindWindow(IDC_UDPENABLE
);
834 // Kad enabled: disable check box, turn UDP on, enable port spin control
835 udpPort
->Enable(false);
836 udpPort
->SetValue(true);
837 FindWindow(IDC_UDPPORT
)->Enable(true);
839 // Kad disabled: enable check box
840 udpPort
->Enable(true);
845 case IDC_CHECKDISKSPACE
:
846 FindWindow( IDC_MINDISKSPACE
)->Enable(value
);
850 FindWindow( IDC_OSDIR
)->Enable(value
);;
851 FindWindow(IDC_OSUPDATE
)->Enable(value
);
855 FindWindow( IDC_SERVERRETRIES
)->Enable(value
);;
859 if ((CPath::GetFileSize(thePrefs::GetConfigDir() + wxT("addresses.dat")) == 0) &&
860 CastChild(event
.GetId(), wxCheckBox
)->IsChecked() ) {
861 wxMessageBox(_("Your Auto-update servers list is in blank.\nPlease fill in at least one URL to point to a valid server.met file.\nClick on the button \"List\" by this checkbox to enter an URL."),
862 _("Message"), wxOK
| wxICON_INFORMATION
);
863 CastChild(event
.GetId(), wxCheckBox
)->SetValue(false);
868 // Toogle All filter options
869 FindWindow(IDC_MSGFILTER_ALL
)->Enable(value
);
870 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(value
);
871 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(value
);
872 FindWindow(IDC_MSGFILTER_WORD
)->Enable(value
);
874 FindWindow(IDC_MSGWORD
)->Enable(
875 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
877 FindWindow(IDC_MSGWORD
)->Enable(false);
881 case IDC_MSGFILTER_ALL
:
882 // Toogle filtering by data.
883 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(!value
);
884 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(!value
);
885 FindWindow(IDC_MSGFILTER_WORD
)->Enable(!value
);
887 FindWindow(IDC_MSGWORD
)->Enable(
888 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
890 FindWindow(IDC_MSGWORD
)->Enable(false);
894 case IDC_MSGFILTER_WORD
:
895 // Toogle filter word list.
896 FindWindow(IDC_MSGWORD
)->Enable(value
);
899 case IDC_FILTERCOMMENTS
:
900 FindWindow(IDC_COMMENTWORD
)->Enable(value
);
903 case ID_PROXY_ENABLE_PROXY
:
904 FindWindow(ID_PROXY_TYPE
)->Enable(value
);
905 FindWindow(ID_PROXY_NAME
)->Enable(value
);
906 FindWindow(ID_PROXY_PORT
)->Enable(value
);
909 case ID_PROXY_ENABLE_PASSWORD
:
910 FindWindow(ID_PROXY_USER
)->Enable(value
);
911 FindWindow(ID_PROXY_PASSWORD
)->Enable(value
);
914 case IDC_STARTNEXTFILE
:
915 FindWindow(IDC_STARTNEXTFILE_SAME
)->Enable(value
);
916 FindWindow(IDC_STARTNEXTFILE_ALPHA
)->Enable(value
);
919 case IDC_MACHIDEONCLOSE
:
920 FindWindow(IDC_EXIT
)->Enable(!value
);
921 CastChild(IDC_EXIT
, wxCheckBox
)->SetValue(!value
&& thePrefs::IsConfirmExitEnabled());
924 case IDC_ENABLETRAYICON
:
925 FindWindow(IDC_MINTRAY
)->Enable(value
);
927 theApp
->amuledlg
->CreateSystray();
929 theApp
->amuledlg
->RemoveSystray();
931 thePrefs::SetUseTrayIcon(value
);
935 FindWindow(IDC_NOTIF
)->Enable(value
);
938 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
:
941 case IDC_VERTTOOLBAR
:
942 m_toolbarOrientationChanged
= (m_verticalToolbar
!= value
);
943 theApp
->amuledlg
->Create_Toolbar(value
);
944 // Update the first tool (conn button)
945 theApp
->amuledlg
->ShowConnectionState();
946 theApp
->amuledlg
->Layout();
949 case IDC_ENFORCE_PO_INCOMING
:
950 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(!value
);
953 case IDC_ENABLE_PO_OUTGOING
:
954 FindWindow(IDC_SUPPORT_PO
)->Enable(!value
);
955 FindWindow(IDC_ENFORCE_PO_INCOMING
)->Enable(value
);
959 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(value
);
962 case IDC_SHOWRATEONTITLE
:
963 FindWindow(IDC_RATESBEFORETITLE
)->Enable(value
);
964 FindWindow(IDC_RATESAFTERTITLE
)->Enable(value
);
967 case IDC_NETWORKED2K
: {
968 EnableServerTab(value
);
970 OnTCPClientPortChange(e
);
980 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent
& WXUNUSED(event
))
982 int index
= m_choiceColor
->GetSelection();
983 wxColour col
= wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors
[index
]) );
985 m_buttonColor
->SetBackgroundColour( col
);
986 thePrefs::s_colors
[index
] = CMuleColour(col
).GetULong();
991 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent
& WXUNUSED(evt
))
993 m_buttonColor
->SetBackgroundColour(CMuleColour(thePrefs::s_colors
[ m_choiceColor
->GetSelection() ] ) );
997 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent
& event
)
1002 switch ( event
.GetId() ) {
1003 case IDC_SELTEMPDIR
:
1005 type
= _("Temporary files");
1010 type
= _("Incoming files");
1015 type
= _("Online Signatures");
1018 // case IDC_SELSKIN:
1020 // type = _("Skins directory");
1028 type
= CFormat(_("Choose a folder for %s")) % type
;
1029 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
1030 wxString dir
= widget
->GetValue();
1031 wxString str
= wxDirSelector(
1034 wxDefaultPosition
, this);
1035 if (!str
.IsEmpty()) {
1036 widget
->SetValue(str
);
1041 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent
& event
)
1045 switch ( event
.GetId() ) {
1047 id
= IDC_VIDEOPLAYER
;
1048 title
= _("Browse for videoplayer");
1050 case IDC_SELBROWSER
:
1051 id
= IDC_BROWSERSELF
;
1052 title
= _("Select browser");
1058 wxString wildcard
= CFormat(_("Executable%s"))
1060 % wxT(" (*.exe)|*.exe");
1065 wxString str
= wxFileSelector( title
, wxEmptyString
, wxEmptyString
,
1066 wxEmptyString
, wildcard
, 0, this );
1068 if ( !str
.IsEmpty() ) {
1069 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
1070 widget
->SetValue( str
);
1075 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent
& WXUNUSED(evt
))
1077 wxString
fullpath( thePrefs::GetConfigDir() + wxT("addresses.dat") );
1079 EditServerListDlg
* test
= new EditServerListDlg(this, _("Edit server list"),
1080 _("Add here URL's to download server.met files.\nOnly one url on each line."),
1088 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent
& WXUNUSED(event
))
1090 theApp
->ipfilter
->Reload();
1094 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent
& WXUNUSED(event
))
1096 theApp
->ipfilter
->Update( CastChild( IDC_IPFILTERURL
, wxTextCtrl
)->GetValue() );
1100 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent
& event
)
1102 prefs_sizer
->Detach( m_CurrentPanel
);
1103 m_CurrentPanel
->Show( false );
1105 m_CurrentPanel
= reinterpret_cast<wxPanel
*>(m_PrefsIcons
->GetItemData(event
.GetIndex()));
1106 if (pages
[event
.GetIndex()].m_function
== PreferencesDirectoriesTab
) {
1107 CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
)->Init();
1110 prefs_sizer
->Add( m_CurrentPanel
, 0, wxGROW
|wxEXPAND
);
1111 m_CurrentPanel
->Show( true );
1119 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent
& event
)
1121 wxToolTip::SetDelay( event
.GetPosition() * 1000 );
1125 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent
& WXUNUSED(evt
) )
1127 // This function exists solely to avoid automatic transfer-to-widget calls
1131 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent
& event
)
1136 switch ( event
.GetId() ) {
1138 id
= IDC_SLIDERINFO
;
1139 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1140 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(event
.GetPosition());
1141 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(event
.GetPosition());
1145 id
= IDC_SLIDERINFO3
;
1146 label
= CFormat(wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event
.GetPosition())) % event
.GetPosition();
1147 theApp
->m_statistics
->SetAverageMinutes(event
.GetPosition());
1151 id
= IDC_SLIDERINFO4
;
1152 label
= CFormat(_("Connections Graph Scale: %d")) % event
.GetPosition();
1153 theApp
->amuledlg
->m_statisticswnd
->GetConnScope()->SetRanges(0, event
.GetPosition());
1157 id
= IDC_SLIDERINFO2
;
1158 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1161 case IDC_FILEBUFFERSIZE
:
1162 id
= IDC_FILEBUFFERSIZE_STATIC
;
1163 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1164 label
= CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event
.GetPosition() * 15000)) % (event
.GetPosition() * 15000);
1168 id
= IDC_QUEUESIZE_STATIC
;
1169 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1170 label
= CFormat(wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event
.GetPosition() * 100)) % (event
.GetPosition() * 100);
1173 case IDC_SERVERKEEPALIVE
:
1174 id
= IDC_SERVERKEEPALIVE_LABEL
;
1176 if ( event
.GetPosition() ) {
1177 label
= CFormat(wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event
.GetPosition())) % event
.GetPosition();
1179 label
= _("Server connection refresh interval: Disabled");
1187 wxStaticText
* widget
= CastChild( id
, wxStaticText
);
1190 widget
->SetLabel( label
);
1191 widget
->GetParent()->Layout();
1196 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent
& event
)
1198 // Here we do immediate sanity checking of the up/down ratio,
1199 // so that the user can see if his choice is illegal
1201 // We only do checks if the rate is limited
1202 if ( event
.GetPosition() != (int)UNLIMITED
) {
1203 wxSpinCtrl
* dlrate
= CastChild( IDC_MAXDOWN
, wxSpinCtrl
);
1205 if ( event
.GetPosition() < 4 ) {
1206 if ( ( event
.GetPosition() * 3 < dlrate
->GetValue() ) ||
1207 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1208 dlrate
->SetValue( event
.GetPosition() * 3 );
1210 } else if ( event
.GetPosition() < 10 ) {
1211 if ( ( event
.GetPosition() * 4 < dlrate
->GetValue() ) ||
1212 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1213 dlrate
->SetValue( event
.GetPosition() * 4 );
1220 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent
& WXUNUSED(event
))
1222 CastChild(ID_TEXT_CLIENT_UDP_PORT
, wxStaticText
)->SetLabel(
1223 m_ServerTabVisible
? (wxString() << (CastChild(IDC_PORT
, wxSpinCtrl
)->GetValue() + 3))
1224 : wxString(_("disabled")));
1227 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent
& event
)
1229 for (unsigned int i
= 0; i
< CUserEvents::GetCount(); ++i
) {
1230 IDC_PREFS_EVENTS_PAGE
->Hide(i
+1);
1233 IDC_PREFS_EVENTS_PAGE
->Show((event
.GetData() - USEREVENTS_FIRST_ID
) / USEREVENTS_IDS_PER_EVENT
+ 1, true);
1235 IDC_PREFS_EVENTS_PAGE
->Layout();
1240 void PrefsUnifiedDlg::OnLanguageChoice(wxCommandEvent
&evt
)
1242 thePrefs::GetCfgLang()->UpdateChoice(evt
.GetSelection());
1245 void PrefsUnifiedDlg::CreateEventPanels(const int idx
, const wxString
& vars
, wxWindow
* parent
)
1247 wxStaticBox
*item8
= new wxStaticBox( parent
, -1, CFormat(_("Execute command on '%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType
>(idx
))) );
1248 wxStaticBoxSizer
*item7
= new wxStaticBoxSizer( item8
, wxVERTICAL
);
1250 wxCheckBox
*item9
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 1, _("Enable command execution on core"), wxDefaultPosition
, wxDefaultSize
, 0 );
1251 item7
->Add( item9
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1253 wxFlexGridSizer
*item10
= new wxFlexGridSizer( 3, 0, 0 );
1254 item10
->AddGrowableCol( 2 );
1256 item10
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1258 wxStaticText
*item11
= new wxStaticText( parent
, -1, _("Core command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1259 item10
->Add( item11
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1261 wxTextCtrl
*item12
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 2, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1262 item12
->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1263 item10
->Add( item12
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1265 item7
->Add( item10
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1267 wxCheckBox
*item14
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 3, _("Enable command execution on GUI"), wxDefaultPosition
, wxDefaultSize
, 0 );
1268 item7
->Add( item14
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1270 wxFlexGridSizer
*item15
= new wxFlexGridSizer( 3, 0, 0 );
1271 item15
->AddGrowableCol( 2 );
1273 item15
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1275 wxStaticText
*item16
= new wxStaticText( parent
, -1, _("GUI command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1276 item15
->Add( item16
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1278 wxTextCtrl
*item17
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 4, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1279 item17
->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1280 item15
->Add( item17
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1282 item7
->Add( item15
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1284 wxStaticText
*item13
= new wxStaticText( parent
, -1, _("The following variables will be replaced:") + vars
, wxDefaultPosition
, wxDefaultSize
, 0 );
1285 item7
->Add( item13
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1287 IDC_PREFS_EVENTS_PAGE
->Add(item7
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
1289 IDC_PREFS_EVENTS_PAGE
->Layout();
1290 IDC_PREFS_EVENTS_PAGE
->Hide(idx
+ 1);
1292 // File_checked_for_headers