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>
31 #include <wx/colordlg.h>
32 #include <wx/tooltip.h>
34 #include "amule.h" // Needed for theApp
36 #include "MuleColour.h"
37 #include "EditServerListDlg.h"
38 #include "SharedFileList.h" // Needed for CSharedFileList
39 #include "StatisticsDlg.h" // Needed for graph parameters, colors
40 #include "IPFilter.h" // Needed for CIPFilter
41 #include "SearchList.h"
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"
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_VERTTOOLBAR
, PrefsUnifiedDlg::OnCheckBoxChange
)
86 EVT_CHECKBOX(IDC_SUPPORT_PO
, PrefsUnifiedDlg::OnCheckBoxChange
)
87 EVT_CHECKBOX(IDC_ENABLE_PO_OUTGOING
, PrefsUnifiedDlg::OnCheckBoxChange
)
88 EVT_CHECKBOX(IDC_ENFORCE_PO_INCOMING
, PrefsUnifiedDlg::OnCheckBoxChange
)
89 EVT_CHECKBOX(IDC_SHOWRATEONTITLE
, PrefsUnifiedDlg::OnCheckBoxChange
)
90 EVT_CHECKBOX(IDC_NETWORKED2K
, PrefsUnifiedDlg::OnCheckBoxChange
)
91 EVT_CHECKBOX(IDC_NETWORKKAD
, PrefsUnifiedDlg::OnCheckBoxChange
)
93 EVT_BUTTON(ID_PREFS_OK_TOP
, PrefsUnifiedDlg::OnOk
)
94 EVT_BUTTON(ID_PREFS_CANCEL_TOP
, PrefsUnifiedDlg::OnCancel
)
97 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
98 EVT_BUTTON(IDC_BROWSEV
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
99 EVT_BUTTON(IDC_SELTEMPDIR
, PrefsUnifiedDlg::OnButtonDir
)
100 EVT_BUTTON(IDC_SELINCDIR
, PrefsUnifiedDlg::OnButtonDir
)
101 EVT_BUTTON(IDC_SELOSDIR
, PrefsUnifiedDlg::OnButtonDir
)
102 EVT_BUTTON(IDC_SELBROWSER
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
104 EVT_SPINCTRL(IDC_TOOLTIPDELAY
, PrefsUnifiedDlg::OnToolTipDelayChange
)
106 EVT_BUTTON(IDC_EDITADR
, PrefsUnifiedDlg::OnButtonEditAddr
)
107 EVT_BUTTON(IDC_IPFRELOAD
, PrefsUnifiedDlg::OnButtonIPFilterReload
)
108 EVT_BUTTON(IDC_COLOR_BUTTON
, PrefsUnifiedDlg::OnButtonColorChange
)
109 EVT_BUTTON(IDC_IPFILTERUPDATE
, PrefsUnifiedDlg::OnButtonIPFilterUpdate
)
110 EVT_CHOICE(IDC_COLORSELECTOR
, PrefsUnifiedDlg::OnColorCategorySelected
)
111 EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL
,PrefsUnifiedDlg::OnPrefsPageChange
)
113 EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog
)
115 EVT_COMMAND_SCROLL(IDC_SLIDER
, PrefsUnifiedDlg::OnScrollBarChange
)
116 EVT_COMMAND_SCROLL(IDC_SLIDER3
, PrefsUnifiedDlg::OnScrollBarChange
)
117 EVT_COMMAND_SCROLL(IDC_SLIDER4
, PrefsUnifiedDlg::OnScrollBarChange
)
118 EVT_COMMAND_SCROLL(IDC_SLIDER2
, PrefsUnifiedDlg::OnScrollBarChange
)
119 EVT_COMMAND_SCROLL(IDC_FILEBUFFERSIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
120 EVT_COMMAND_SCROLL(IDC_QUEUESIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
121 EVT_COMMAND_SCROLL(IDC_SERVERKEEPALIVE
, PrefsUnifiedDlg::OnScrollBarChange
)
123 EVT_SPINCTRL(IDC_MAXUP
, PrefsUnifiedDlg::OnRateLimitChanged
)
125 EVT_LIST_ITEM_SELECTED(IDC_EVENTLIST
, PrefsUnifiedDlg::OnUserEventSelected
)
127 EVT_CHOICE(IDC_LANGUAGE
, PrefsUnifiedDlg::OnLanguageChoice
)
129 EVT_CLOSE(PrefsUnifiedDlg::OnClose
)
135 * Creates an command-event for the given checkbox.
137 * This can be used enforce logical constraints by passing by
138 * sending a check-box event for each checkbox, when transfering
139 * to the UI. However, it should also be used for checkboxes that
140 * have no side-effects other than enabling/disabling other
141 * widgets in the preferences dialogs.
143 void SendCheckBoxEvent(wxWindow
* parent
, int id
)
145 wxCheckBox
* widget
= CastByID(id
, parent
, wxCheckBox
);
146 wxCHECK_RET(widget
, wxT("Invalid widget in CreateEvent"));
148 wxCommandEvent
evt(wxEVT_COMMAND_CHECKBOX_CLICKED
, id
);
149 evt
.SetInt(widget
->IsChecked() ? 1 : 0);
151 parent
->GetEventHandler()->ProcessEvent(evt
);
157 * This struct provides a general way to represent config-tabs.
161 //! The title of the page, used on the listctrl.
163 //! Function pointer to the wxDesigner function creating the dialog.
164 wxSizer
* (*m_function
)(wxWindow
*, bool, bool );
165 //! The index of the image used on the list.
172 { wxTRANSLATE("General"), PreferencesGeneralTab
, 13 },
173 { wxTRANSLATE("Connection"), PreferencesConnectionTab
, 14 },
174 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab
, 17 },
175 { wxTRANSLATE("Servers"), PreferencesServerTab
, 15 },
176 { wxTRANSLATE("Files"), PreferencesFilesTab
, 16 },
177 { wxTRANSLATE("Security"), PreferencesSecurityTab
, 22 },
178 { wxTRANSLATE("Interface"), PreferencesGuiTweaksTab
, 19 },
179 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab
, 10 },
180 { wxTRANSLATE("Proxy"), PreferencesProxyTab
, 24 },
181 { wxTRANSLATE("Filters"), PreferencesFilteringTab
, 23 },
182 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab
, 11 },
183 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab
, 21 },
184 { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab
, 12 },
185 { wxTRANSLATE("Events"), PreferencesEventsTab
, 5 }
187 ,{ wxTRANSLATE("Debugging"), PreferencesDebug
, 25 }
192 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow
*parent
)
194 wxDialog(parent
, -1, _("Preferences"),
195 wxDefaultPosition
, wxDefaultSize
,
196 wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
)
198 preferencesDlgTop(this, false);
200 m_PrefsIcons
= CastChild(ID_PREFSLISTCTRL
, wxListCtrl
);
201 wxImageList
*icon_list
= new wxImageList(16, 16);
202 m_PrefsIcons
->AssignImageList(icon_list
, wxIMAGE_LIST_SMALL
);
204 // Add the single column used
205 m_PrefsIcons
->InsertColumn(
206 0, wxEmptyString
, wxLIST_FORMAT_LEFT
,
207 m_PrefsIcons
->GetSize().GetWidth()-5);
209 // Temp variables for finding the smallest height and width needed
213 // Add each page to the page-list
214 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
215 // Add the icon and label associated with the page
216 icon_list
->Add(amuleSpecial(pages
[i
].m_imageidx
));
217 m_PrefsIcons
->InsertItem(i
, wxGetTranslation(pages
[i
].m_title
), i
);
220 // Set list-width so that there aren't any scrollers
221 m_PrefsIcons
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
222 m_PrefsIcons
->SetMinSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
223 m_PrefsIcons
->SetMaxSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
225 // Now add the pages and calculate the minimum size
226 wxPanel
* DefaultWidget
= NULL
;
227 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
228 // Create a container widget and the contents of the page
229 wxPanel
* Widget
= new wxPanel(this, -1);
230 // Widget is stored as user data in the list control
231 m_PrefsIcons
->SetItemPtrData(i
, (wxUIntPtr
) Widget
);
232 pages
[i
].m_function(Widget
, true, true);
234 DefaultWidget
= Widget
;
237 // Add it to the sizer
238 prefs_sizer
->Add(Widget
, 0, wxGROW
|wxEXPAND
);
240 if (pages
[i
].m_function
== PreferencesGeneralTab
) {
241 // This must be done now or pages won't Fit();
243 CastChild(IDC_BROWSERTABS
, wxCheckBox
)->Enable(false);
244 #endif /* __WXMSW__ */
245 CastChild(IDC_PREVIEW_NOTE
, wxStaticText
)->SetLabel(_("The following variables will be substituted:\n %PARTFILE - full path to the file\n %PARTNAME - file name only"));
246 } else if (pages
[i
].m_function
== PreferencesEventsTab
) {
248 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
249 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, Widget); break;
251 wxListCtrl
*list
= CastChild(IDC_EVENTLIST
, wxListCtrl
);
252 list
->InsertColumn(0, wxEmptyString
);
253 for (unsigned int idx
= 0; idx
< CUserEvents::GetCount(); ++idx
) {
254 long lidx
= list
->InsertItem(idx
,
255 wxGetTranslation(CUserEvents::GetDisplayName(
256 static_cast<enum CUserEvents::EventType
>(idx
))));
258 list
->SetItemData(lidx
,
259 USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
);
261 USEREVENTS_EVENTLIST()
262 /* This macro expands to handle all user event types. Here is an example:
263 case CUserEvents::NewChatSession: {
264 CreateEventPanels(idx, wxString(wxT("\n %SENDER - ")) + wxTRANSLATE("Message sender."), Widget);
270 list
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
272 else if (pages
[i
].m_function
== PreferencesServerTab
) {
273 m_IndexServerTab
= i
;
274 m_ServerWidget
= Widget
;
276 else if (pages
[i
].m_function
== PreferencesaMuleTweaksTab
) {
277 wxStaticText
*txt
= CastChild(IDC_AMULE_TWEAKS_WARNING
, wxStaticText
);
278 // Do not wrap this line, Windows _() can't handle wrapped strings
279 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."));
280 #if defined CLIENT_GUI || !PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE
281 CastChild(IDC_PREVENT_SLEEP
, wxCheckBox
)->Enable(false);
282 thePrefs::SetPreventSleepWhileDownloading(false);
286 else if (pages
[i
].m_function
== PreferencesDebug
) {
287 int count
= theLogger
.GetDebugCategoryCount();
288 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
290 for ( int j
= 0; j
< count
; j
++ ) {
291 list
->Append( theLogger
.GetDebugCategory( j
).GetName() );
296 // Align and resize the page
300 // Find the greatest sizes
301 wxSize size
= prefs_sizer
->GetSize();
302 if (size
.GetWidth() > width
) {
303 width
= size
.GetWidth();
306 if (size
.GetHeight() > height
) {
307 height
= size
.GetHeight();
311 prefs_sizer
->Detach(Widget
);
315 // Default to the General tab
316 m_CurrentPanel
= DefaultWidget
;
317 prefs_sizer
->Add(DefaultWidget
, 0, wxGROW
|wxEXPAND
);
318 m_CurrentPanel
->Show( true );
320 // Select the first item
321 m_PrefsIcons
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
323 // We now have the needed minimum height and width
324 prefs_sizer
->SetMinSize(width
, height
);
326 // Don't show server prefs if ED2K is disabled
327 m_ServerTabVisible
= true;
328 EnableServerTab(thePrefs::GetNetworkED2K());
330 // Store some often used pointers
331 m_ShareSelector
= CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
);
332 m_buttonColor
= CastChild(IDC_COLOR_BUTTON
, wxButton
);
333 m_choiceColor
= CastChild(IDC_COLORSELECTOR
, wxChoice
);
335 // Connect the Cfgs with their widgets
336 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
337 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
338 // Checking for failures
339 if ( !it
->second
->ConnectToWidget(it
->first
, this) ) {
340 AddLogLineNS(CFormat(_("Failed to connect Cfg to widget with the ID %d and key %s"))
341 % it
->first
% it
->second
->GetKey());
346 // It must not be resized to something smaller than what it currently is
347 wxSize size
= GetClientSize();
348 SetSizeHints(size
.GetWidth(), size
.GetHeight());
350 // Position the dialog.
355 void PrefsUnifiedDlg::EnableServerTab(bool enable
)
357 if (enable
&& !m_ServerTabVisible
) {
358 // turn server widget on
359 m_PrefsIcons
->InsertItem(m_IndexServerTab
, wxGetTranslation(pages
[m_IndexServerTab
].m_title
), m_IndexServerTab
);
360 m_PrefsIcons
->SetItemPtrData(m_IndexServerTab
, (wxUIntPtr
) m_ServerWidget
);
361 m_ServerTabVisible
= true;
362 } else if (!enable
&& m_ServerTabVisible
) {
363 // turn server widget off
364 m_PrefsIcons
->DeleteItem(m_IndexServerTab
);
365 m_ServerTabVisible
= false;
370 Cfg_Base
* PrefsUnifiedDlg::GetCfg(int id
)
372 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.find( id
);
374 if ( it
!= thePrefs::s_CfgList
.end() ) {
382 bool PrefsUnifiedDlg::TransferToWindow()
384 // Connect the Cfgs with their widgets
385 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
386 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
387 // Checking for failures
388 if ( !it
->second
->TransferToWindow() ) {
389 AddLogLineNS(CFormat(_("Failed to transfer data from Cfg to Widget with the ID %d and key %s"))
390 % it
->first
% it
->second
->GetKey());
394 m_ShareSelector
->SetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
396 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
397 thePrefs::s_colors
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
398 thePrefs::s_colors_ref
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
403 OnTCPClientPortChange(e
);
405 // Proxy tab initialization
406 FindWindow(ID_PROXY_TYPE
)->SetToolTip(_("The type of proxy you are connecting to"));
407 if (!CastChild(ID_PROXY_ENABLE_PROXY
, wxCheckBox
)->IsChecked()) {
408 FindWindow(ID_PROXY_TYPE
)->Enable(false);
409 FindWindow(ID_PROXY_NAME
)->Enable(false);
410 FindWindow(ID_PROXY_PORT
)->Enable(false);
412 if (!CastChild(ID_PROXY_ENABLE_PASSWORD
, wxCheckBox
)->IsChecked()) {
413 FindWindow(ID_PROXY_USER
)->Enable(false);
414 FindWindow(ID_PROXY_PASSWORD
)->Enable(false);
416 // This option from the proxy tab is currently unused
417 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
)->Enable(false);
419 // Enable/Disable some controls
420 FindWindow( IDC_MINDISKSPACE
)->Enable( thePrefs::IsCheckDiskspaceEnabled() );
421 FindWindow( IDC_OSDIR
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
422 FindWindow( IDC_OSUPDATE
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
423 FindWindow( IDC_UDPENABLE
)->Enable( !thePrefs::GetNetworkKademlia());
424 FindWindow( IDC_UDPPORT
)->Enable( thePrefs::s_UDPEnable
);
425 FindWindow( IDC_SERVERRETRIES
)->Enable( thePrefs::DeadServer() );
426 FindWindow( IDC_STARTNEXTFILE_SAME
)->Enable(thePrefs::StartNextFile());
427 FindWindow( IDC_STARTNEXTFILE_ALPHA
)->Enable(thePrefs::StartNextFile());
430 FindWindow(IDC_ENABLETRAYICON
)->Enable(false);
431 FindWindow(IDC_MINTRAY
)->Enable(false);
433 FindWindow(IDC_MINTRAY
)->Enable(thePrefs::UseTrayIcon());
436 if (!CastChild(IDC_MSGFILTER
, wxCheckBox
)->IsChecked()) {
437 FindWindow(IDC_MSGFILTER_ALL
)->Enable(false);
438 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
439 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
440 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
441 FindWindow(IDC_MSGWORD
)->Enable(false);
442 } else if (CastChild(IDC_MSGFILTER_ALL
, wxCheckBox
)->IsChecked()) {
443 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
444 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
445 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
446 FindWindow(IDC_MSGWORD
)->Enable(false);
449 FindWindow(IDC_MSGWORD
)->Enable(CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
450 FindWindow(IDC_COMMENTWORD
)->Enable(CastChild(IDC_FILTERCOMMENTS
, wxCheckBox
)->IsChecked());
453 // Disable dirpickers unless it's a localhost connection
454 if (!theApp
->m_connect
->IsConnectedToLocalHost()) {
455 FindWindow(IDC_SELINCDIR
)->Enable(false);
456 FindWindow(IDC_SELTEMPDIR
)->Enable(false);
460 // Protocol obfuscation
461 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO
);
462 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING
);
463 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING
);
465 #ifndef ENABLE_IP2COUNTRY
466 CastChild(IDC_SHOW_COUNTRY_FLAGS
, wxCheckBox
)->Enable(false);
467 thePrefs::SetGeoIPEnabled(false);
471 // Version is always shown on the title in development versions
472 CastChild(IDC_SHOWVERSIONONTITLE
, wxCheckBox
)->SetValue(true);
473 CastChild(IDC_SHOWVERSIONONTITLE
, wxCheckBox
)->Enable(false);
476 // Show rates on title
477 FindWindow(IDC_RATESBEFORETITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
478 FindWindow(IDC_RATESAFTERTITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
479 CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->SetValue(thePrefs::GetShowRatesOnTitle() != 0);
480 CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() == 2);
481 CastChild(IDC_RATESAFTERTITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() != 2);
485 FindWindow(IDC_UPNP_ENABLED
)->Enable(false);
486 FindWindow(IDC_UPNPTCPPORT
)->Enable(false);
487 FindWindow(IDC_UPNPTCPPORTTEXT
)->Enable(false);
488 thePrefs::SetUPnPEnabled(false);
489 FindWindow(IDC_UPNP_WEBSERVER_ENABLED
)->Enable(false);
490 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(false);
491 FindWindow(IDC_WEBUPNPTCPPORTTEXT
)->Enable(false);
492 thePrefs::SetUPnPWebServerEnabled(false);
493 FindWindow(IDC_UPNP_EC_ENABLED
)->Enable(false);
494 thePrefs::SetUPnPECEnabled(false);
498 // Set debugging toggles
499 int count
= theLogger
.GetDebugCategoryCount();
500 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
502 for ( int i
= 0; i
< count
; i
++ ) {
503 list
->Check( i
, theLogger
.GetDebugCategory( i
).IsEnabled() );
511 bool PrefsUnifiedDlg::TransferFromWindow()
513 // Connect the Cfgs with their widgets
514 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
515 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
516 // Checking for failures
517 if ( !it
->second
->TransferFromWindow() ) {
518 AddLogLineNS(CFormat(_("Failed to transfer data from Widget to Cfg with the ID %d and key %s"))
519 % it
->first
% it
->second
->GetKey());
523 theApp
->glob_prefs
->shareddir_list
.clear();
524 m_ShareSelector
->GetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
526 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
527 if ( thePrefs::s_colors
[i
] != thePrefs::s_colors_ref
[i
] ) {
528 CStatisticsDlg::acrStat
[i
] = thePrefs::s_colors
[i
];
529 theApp
->amuledlg
->m_statisticswnd
->ApplyStatsColor(i
);
532 theApp
->amuledlg
->m_kademliawnd
->SetGraphColors();
536 // Get debugging toggles
537 int count
= theLogger
.GetDebugCategoryCount();
538 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
540 for ( int i
= 0; i
< count
; i
++ ) {
541 theLogger
.SetEnabled( theLogger
.GetDebugCategory( i
).GetType(), list
->IsChecked( i
) );
545 thePrefs::SetShowRatesOnTitle(CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->GetValue() ? (CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->GetValue() ? 2 : 1) : 0);
548 // Send preferences to core.
549 theApp
->glob_prefs
->SendToRemote();
556 bool PrefsUnifiedDlg::CfgChanged(int ID
)
558 Cfg_Base
* cfg
= GetCfg(ID
);
561 return cfg
->HasChanged();
568 void PrefsUnifiedDlg::OnOk(wxCommandEvent
& WXUNUSED(event
))
570 TransferFromWindow();
572 bool restart_needed
= false;
573 wxString restart_needed_msg
= _("aMule must be restarted to enable these changes:\n\n");
575 // do sanity checking, special processing, and user notifications here
576 thePrefs::CheckUlDlRatio();
578 if (CfgChanged(IDC_PORT
)) {
579 restart_needed
= true;
580 restart_needed_msg
+= _("- TCP port changed.\n");
583 if (CfgChanged(IDC_UDPPORT
)) {
584 restart_needed
= true;
585 restart_needed_msg
+= _("- UDP port changed.\n");
588 if (CfgChanged(IDC_EXT_CONN_TCP_PORT
)) {
589 restart_needed
= true;
590 restart_needed_msg
+= _("- External connect port changed.\n");
592 if (CfgChanged(IDC_EXT_CONN_ACCEPT
)) {
593 restart_needed
= true;
594 restart_needed_msg
+= _("- External connect acceptance changed.\n");
596 if (CfgChanged(IDC_EXT_CONN_IP
)) {
597 restart_needed
= true;
598 restart_needed_msg
+= _("- External connect interface changed.\n");
601 // Force port checking
602 thePrefs::SetPort(thePrefs::GetPort());
604 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
605 CastChild(IDC_AUTOSERVER
, wxCheckBox
)->IsChecked() ) {
606 thePrefs::UnsetAutoServerStart();
607 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
608 _("Message"), wxOK
| wxICON_INFORMATION
, this);
611 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
612 thePrefs::EnableExternalConnections( false );
614 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
617 // save the preferences on ok
618 theApp
->glob_prefs
->Save();
620 if (CfgChanged(IDC_FED2KLH
) && theApp
->amuledlg
->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND
) {
621 theApp
->amuledlg
->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
624 if (CfgChanged(IDC_LANGUAGE
)) {
625 restart_needed
= true;
626 restart_needed_msg
+= _("- Language changed.\n");
629 if (CfgChanged(IDC_TEMPFILES
)) {
630 restart_needed
= true;
631 restart_needed_msg
+= _("- Temp folder changed.\n");
634 if (CfgChanged(IDC_NETWORKED2K
) && thePrefs::GetNetworkED2K()) {
635 restart_needed
= true;
636 restart_needed_msg
+= _("- ED2K network enabled.\n");
639 if (CfgChanged(IDC_INCFILES
) || CfgChanged(IDC_TEMPFILES
) || m_ShareSelector
->HasChanged
) {
640 theApp
->sharedfiles
->Reload();
643 if (CfgChanged(IDC_OSDIR
) || CfgChanged(IDC_ONLINESIG
)) {
644 wxTextCtrl
* widget
= CastChild( IDC_OSDIR
, wxTextCtrl
);
646 // Build the filenames for the two OS files
647 theApp
->SetOSFiles( widget
->GetValue() );
650 if (CfgChanged(IDC_IPFCLIENTS
) && thePrefs::IsFilteringClients()) {
651 theApp
->clientlist
->FilterQueues();
654 if (CfgChanged(IDC_IPFSERVERS
) && thePrefs::IsFilteringServers()) {
655 theApp
->serverlist
->FilterServers();
658 if (CfgChanged(ID_IPFILTERLEVEL
)) {
659 theApp
->ipfilter
->Reload();
662 theApp
->ResetTitle();
664 if (thePrefs::GetShowRatesOnTitle()) {
665 // This avoids a 5 seconds delay to show the title
666 theApp
->amuledlg
->ShowTransferRate();
668 // This resets the title
669 theApp
->amuledlg
->SetTitle(theApp
->m_FrameTitle
);
672 if (CfgChanged(IDC_EXTCATINFO
)) {
673 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
676 // Changes related to the statistics-dlg
677 if (CfgChanged(IDC_SLIDER
)) {
678 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
679 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
682 if ( CfgChanged(IDC_SLIDER3
) ) {
683 theApp
->amuledlg
->m_statisticswnd
->ResetAveragingTime();
686 if (CfgChanged(IDC_DOWNLOAD_CAP
)) {
687 theApp
->amuledlg
->m_statisticswnd
->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
690 if (CfgChanged(IDC_UPLOAD_CAP
)) {
691 theApp
->amuledlg
->m_statisticswnd
->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
694 if (CfgChanged(IDC_SKIN
)) {
695 theApp
->amuledlg
->Create_Toolbar(thePrefs::VerticalToolbar());
698 if (!thePrefs::GetNetworkED2K() && theApp
->IsConnectedED2K()) {
699 theApp
->DisconnectED2K();
702 if (!thePrefs::GetNetworkKademlia() && theApp
->IsConnectedKad()) {
706 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
708 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
711 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
712 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
713 _("Message"), wxOK
| wxICON_INFORMATION
, this);
716 if (CfgChanged(IDC_NETWORKKAD
) || CfgChanged(IDC_NETWORKED2K
)) {
717 theApp
->amuledlg
->DoNetworkRearrange();
720 if (CfgChanged(IDC_SHOW_COUNTRY_FLAGS
)) {
721 theApp
->amuledlg
->EnableIP2Country();
724 if (restart_needed
) {
725 wxMessageBox(restart_needed_msg
+ _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
726 _("WARNING"), wxOK
| wxICON_EXCLAMATION
, this);
733 void PrefsUnifiedDlg::OnClose(wxCloseEvent
& event
)
737 // Try to keep the window alive when possible
738 if (event
.CanVeto()) {
741 if (theApp
->amuledlg
) {
742 theApp
->amuledlg
->m_prefsDialog
= NULL
;
745 // Un-Connect the Cfgs
746 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
747 for (; it
!= thePrefs::s_CfgList
.end(); ++it
) {
748 // Checking for failures
749 it
->second
->ConnectToWidget( 0 );
757 void PrefsUnifiedDlg::OnCancel(wxCommandEvent
& WXUNUSED(event
))
760 // restore state of server tab if necessary
761 EnableServerTab(thePrefs::GetNetworkED2K());
765 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent
& event
)
767 bool value
= event
.IsChecked();
768 int id
= event
.GetId();
770 // Check if this checkbox is one of the User Events checkboxes
771 if (id
>= USEREVENTS_FIRST_ID
&&
772 id
< USEREVENTS_FIRST_ID
+
773 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT
) {
774 // The corresponding text control always has
775 // an ID one greater than the checkbox
776 FindWindow(id
+ 1)->Enable(value
);
782 FindWindow( IDC_UDPPORT
)->Enable(value
);
785 case IDC_NETWORKKAD
: {
786 wxCheckBox
* udpPort
= (wxCheckBox
*) FindWindow(IDC_UDPENABLE
);
788 // Kad enabled: disable check box, turn UDP on, enable port spin control
789 udpPort
->Enable(false);
790 udpPort
->SetValue(true);
791 FindWindow(IDC_UDPPORT
)->Enable(true);
793 // Kad disabled: enable check box
794 udpPort
->Enable(true);
799 case IDC_CHECKDISKSPACE
:
800 FindWindow( IDC_MINDISKSPACE
)->Enable(value
);
804 FindWindow( IDC_OSDIR
)->Enable(value
);;
805 FindWindow(IDC_OSUPDATE
)->Enable(value
);
809 FindWindow( IDC_SERVERRETRIES
)->Enable(value
);;
813 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
814 CastChild(event
.GetId(), wxCheckBox
)->IsChecked() ) {
815 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."),
816 _("Message"), wxOK
| wxICON_INFORMATION
);
817 CastChild(event
.GetId(), wxCheckBox
)->SetValue(false);
822 // Toogle All filter options
823 FindWindow(IDC_MSGFILTER_ALL
)->Enable(value
);
824 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(value
);
825 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(value
);
826 FindWindow(IDC_MSGFILTER_WORD
)->Enable(value
);
828 FindWindow(IDC_MSGWORD
)->Enable(
829 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
831 FindWindow(IDC_MSGWORD
)->Enable(false);
835 case IDC_MSGFILTER_ALL
:
836 // Toogle filtering by data.
837 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(!value
);
838 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(!value
);
839 FindWindow(IDC_MSGFILTER_WORD
)->Enable(!value
);
841 FindWindow(IDC_MSGWORD
)->Enable(
842 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
844 FindWindow(IDC_MSGWORD
)->Enable(false);
848 case IDC_MSGFILTER_WORD
:
849 // Toogle filter word list.
850 FindWindow(IDC_MSGWORD
)->Enable(value
);
853 case IDC_FILTERCOMMENTS
:
854 FindWindow(IDC_COMMENTWORD
)->Enable(value
);
857 case ID_PROXY_ENABLE_PROXY
:
858 FindWindow(ID_PROXY_TYPE
)->Enable(value
);
859 FindWindow(ID_PROXY_NAME
)->Enable(value
);
860 FindWindow(ID_PROXY_PORT
)->Enable(value
);
863 case ID_PROXY_ENABLE_PASSWORD
:
864 FindWindow(ID_PROXY_USER
)->Enable(value
);
865 FindWindow(ID_PROXY_PASSWORD
)->Enable(value
);
868 case IDC_STARTNEXTFILE
:
869 FindWindow(IDC_STARTNEXTFILE_SAME
)->Enable(value
);
870 FindWindow(IDC_STARTNEXTFILE_ALPHA
)->Enable(value
);
873 case IDC_ENABLETRAYICON
:
874 FindWindow(IDC_MINTRAY
)->Enable(value
);
876 theApp
->amuledlg
->CreateSystray();
878 theApp
->amuledlg
->RemoveSystray();
880 thePrefs::SetUseTrayIcon(value
);
883 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
:
886 case IDC_VERTTOOLBAR
:
887 theApp
->amuledlg
->Create_Toolbar(value
);
888 // Update the first tool (conn button)
889 theApp
->amuledlg
->ShowConnectionState();
890 theApp
->amuledlg
->Layout();
893 case IDC_ENFORCE_PO_INCOMING
:
894 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(!value
);
897 case IDC_ENABLE_PO_OUTGOING
:
898 FindWindow(IDC_SUPPORT_PO
)->Enable(!value
);
899 FindWindow(IDC_ENFORCE_PO_INCOMING
)->Enable(value
);
903 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(value
);
906 case IDC_SHOWRATEONTITLE
:
907 FindWindow(IDC_RATESBEFORETITLE
)->Enable(value
);
908 FindWindow(IDC_RATESAFTERTITLE
)->Enable(value
);
911 case IDC_NETWORKED2K
: {
912 EnableServerTab(value
);
914 OnTCPClientPortChange(e
);
924 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent
& WXUNUSED(event
))
926 int index
= m_choiceColor
->GetSelection();
927 wxColour col
= wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors
[index
]) );
929 m_buttonColor
->SetBackgroundColour( col
);
930 thePrefs::s_colors
[index
] = CMuleColour(col
).GetULong();
935 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent
& WXUNUSED(evt
))
937 m_buttonColor
->SetBackgroundColour(CMuleColour(thePrefs::s_colors
[ m_choiceColor
->GetSelection() ] ) );
941 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent
& event
)
946 switch ( event
.GetId() ) {
949 type
= _("Temporary files");
954 type
= _("Incoming files");
959 type
= _("Online Signatures");
964 // type = _("Skins directory");
972 type
= CFormat(_("Choose a folder for %s")) % type
;
973 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
974 wxString dir
= widget
->GetValue();
975 wxString str
= wxDirSelector(
978 wxDefaultPosition
, this);
979 if (!str
.IsEmpty()) {
980 widget
->SetValue(str
);
985 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent
& event
)
989 switch ( event
.GetId() ) {
991 id
= IDC_VIDEOPLAYER
;
992 title
= _("Browse for videoplayer");
995 id
= IDC_BROWSERSELF
;
996 title
= _("Select browser");
1002 wxString wildcard
= CFormat(_("Executable%s"))
1004 % wxT(" (*.exe)|*.exe");
1009 wxString str
= wxFileSelector( title
, wxEmptyString
, wxEmptyString
,
1010 wxEmptyString
, wildcard
, 0, this );
1012 if ( !str
.IsEmpty() ) {
1013 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
1014 widget
->SetValue( str
);
1019 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent
& WXUNUSED(evt
))
1021 wxString
fullpath( theApp
->ConfigDir
+ wxT("addresses.dat") );
1023 EditServerListDlg
* test
= new EditServerListDlg(this, _("Edit server list"),
1024 _("Add here URL's to download server.met files.\nOnly one url on each line."),
1032 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent
& WXUNUSED(event
))
1034 theApp
->ipfilter
->Reload();
1038 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent
& WXUNUSED(event
))
1040 theApp
->ipfilter
->Update( CastChild( IDC_IPFILTERURL
, wxTextCtrl
)->GetValue() );
1044 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent
& event
)
1046 prefs_sizer
->Detach( m_CurrentPanel
);
1047 m_CurrentPanel
->Show( false );
1049 m_CurrentPanel
= (wxPanel
*) m_PrefsIcons
->GetItemData(event
.GetIndex());
1050 if (pages
[event
.GetIndex()].m_function
== PreferencesDirectoriesTab
) {
1051 CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
)->Init();
1054 prefs_sizer
->Add( m_CurrentPanel
, 0, wxGROW
|wxEXPAND
);
1055 m_CurrentPanel
->Show( true );
1063 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent
& event
)
1065 wxToolTip::SetDelay( event
.GetPosition() * 1000 );
1069 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent
& WXUNUSED(evt
) )
1071 // This function exists solely to avoid automatic transfer-to-widget calls
1075 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent
& event
)
1080 switch ( event
.GetId() ) {
1082 id
= IDC_SLIDERINFO
;
1083 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1084 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(event
.GetPosition());
1085 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(event
.GetPosition());
1089 id
= IDC_SLIDERINFO3
;
1090 label
= CFormat(wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event
.GetPosition())) % event
.GetPosition();
1091 theApp
->m_statistics
->SetAverageMinutes(event
.GetPosition());
1095 id
= IDC_SLIDERINFO4
;
1096 label
= CFormat(_("Connections Graph Scale: %d")) % event
.GetPosition();
1097 theApp
->amuledlg
->m_statisticswnd
->GetConnScope()->SetRanges(0, event
.GetPosition());
1101 id
= IDC_SLIDERINFO2
;
1102 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1105 case IDC_FILEBUFFERSIZE
:
1106 id
= IDC_FILEBUFFERSIZE_STATIC
;
1107 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1108 label
= CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event
.GetPosition() * 15000)) % (event
.GetPosition() * 15000);
1112 id
= IDC_QUEUESIZE_STATIC
;
1113 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1114 label
= CFormat(wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event
.GetPosition() * 100)) % (event
.GetPosition() * 100);
1117 case IDC_SERVERKEEPALIVE
:
1118 id
= IDC_SERVERKEEPALIVE_LABEL
;
1120 if ( event
.GetPosition() ) {
1121 label
= CFormat(wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event
.GetPosition())) % event
.GetPosition();
1123 label
= _("Server connection refresh interval: Disabled");
1131 wxStaticText
* widget
= CastChild( id
, wxStaticText
);
1134 widget
->SetLabel( label
);
1135 widget
->GetParent()->Layout();
1140 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent
& event
)
1142 // Here we do immediate sanity checking of the up/down ratio,
1143 // so that the user can see if his choice is illegal
1145 // We only do checks if the rate is limited
1146 if ( event
.GetPosition() != (int)UNLIMITED
) {
1147 wxSpinCtrl
* dlrate
= CastChild( IDC_MAXDOWN
, wxSpinCtrl
);
1149 if ( event
.GetPosition() < 4 ) {
1150 if ( ( event
.GetPosition() * 3 < dlrate
->GetValue() ) ||
1151 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1152 dlrate
->SetValue( event
.GetPosition() * 3 );
1154 } else if ( event
.GetPosition() < 10 ) {
1155 if ( ( event
.GetPosition() * 4 < dlrate
->GetValue() ) ||
1156 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1157 dlrate
->SetValue( event
.GetPosition() * 4 );
1164 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent
& WXUNUSED(event
))
1166 CastChild(ID_TEXT_CLIENT_UDP_PORT
, wxStaticText
)->SetLabel(
1167 m_ServerTabVisible
? (wxString() << (CastChild(IDC_PORT
, wxSpinCtrl
)->GetValue() + 3))
1168 : wxString(_("disabled")));
1171 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent
& event
)
1173 for (unsigned int i
= 0; i
< CUserEvents::GetCount(); ++i
) {
1174 IDC_PREFS_EVENTS_PAGE
->Hide(i
+1);
1177 IDC_PREFS_EVENTS_PAGE
->Show((event
.GetData() - USEREVENTS_FIRST_ID
) / USEREVENTS_IDS_PER_EVENT
+ 1, true);
1179 IDC_PREFS_EVENTS_PAGE
->Layout();
1184 void PrefsUnifiedDlg::OnLanguageChoice(wxCommandEvent
&evt
)
1186 thePrefs::GetCfgLang()->UpdateChoice(evt
.GetSelection());
1189 void PrefsUnifiedDlg::CreateEventPanels(const int idx
, const wxString
& vars
, wxWindow
* parent
)
1191 wxStaticBox
*item8
= new wxStaticBox( parent
, -1, CFormat(_("Execute command on '%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType
>(idx
))) );
1192 wxStaticBoxSizer
*item7
= new wxStaticBoxSizer( item8
, wxVERTICAL
);
1194 wxCheckBox
*item9
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 1, _("Enable command execution on core"), wxDefaultPosition
, wxDefaultSize
, 0 );
1195 item7
->Add( item9
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1197 wxFlexGridSizer
*item10
= new wxFlexGridSizer( 3, 0, 0 );
1198 item10
->AddGrowableCol( 2 );
1200 item10
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1202 wxStaticText
*item11
= new wxStaticText( parent
, -1, _("Core command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1203 item10
->Add( item11
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1205 wxTextCtrl
*item12
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 2, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1206 item12
->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1207 item10
->Add( item12
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1209 item7
->Add( item10
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1211 wxCheckBox
*item14
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 3, _("Enable command execution on GUI"), wxDefaultPosition
, wxDefaultSize
, 0 );
1212 item7
->Add( item14
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1214 wxFlexGridSizer
*item15
= new wxFlexGridSizer( 3, 0, 0 );
1215 item15
->AddGrowableCol( 2 );
1217 item15
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1219 wxStaticText
*item16
= new wxStaticText( parent
, -1, _("GUI command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1220 item15
->Add( item16
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1222 wxTextCtrl
*item17
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 4, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1223 item17
->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1224 item15
->Add( item17
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1226 item7
->Add( item15
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1228 wxStaticText
*item13
= new wxStaticText( parent
, -1, _("The following variables will be replaced:") + vars
, wxDefaultPosition
, wxDefaultSize
, 0 );
1229 item7
->Add( item13
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1231 IDC_PREFS_EVENTS_PAGE
->Add(item7
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
1233 IDC_PREFS_EVENTS_PAGE
->Layout();
1234 IDC_PREFS_EVENTS_PAGE
->Hide(idx
+ 1);
1236 // File_checked_for_headers