PageRenderTime 57ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/xbmc/settings/GUIWindowSettingsCategory.cpp

https://github.com/weitao2012/android-1
C++ | 2836 lines | 2518 code | 199 blank | 119 comment | 804 complexity | 8c98e4602011a2a06db116b9e7036ecb MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * Copyright (C) 2005-2008 Team XBMC
  3. * http://www.xbmc.org
  4. *
  5. * This Program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2, or (at your option)
  8. * any later version.
  9. *
  10. * This Program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with XBMC; see the file COPYING. If not, write to
  17. * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. */
  21. #include "system.h"
  22. #include "GUIUserMessages.h"
  23. #include "GUIWindowSettingsCategory.h"
  24. #include "Application.h"
  25. #include "ApplicationMessenger.h"
  26. #include "interfaces/Builtins.h"
  27. #include "input/KeyboardLayoutConfiguration.h"
  28. #include "filesystem/Directory.h"
  29. #include "Util.h"
  30. #include "guilib/GUISpinControlEx.h"
  31. #include "guilib/GUIRadioButtonControl.h"
  32. #include "guilib/GUIEditControl.h"
  33. #include "guilib/GUIImage.h"
  34. #include "utils/Weather.h"
  35. #include "music/MusicDatabase.h"
  36. #include "video/VideoDatabase.h"
  37. #include "ViewDatabase.h"
  38. #ifdef HAS_LCD
  39. #include "utils/LCDFactory.h"
  40. #endif
  41. #include "PlayListPlayer.h"
  42. #include "addons/Skin.h"
  43. #include "guilib/GUIAudioManager.h"
  44. #include "network/libscrobbler/lastfmscrobbler.h"
  45. #include "network/libscrobbler/librefmscrobbler.h"
  46. #include "GUIPassword.h"
  47. #include "dialogs/GUIDialogFileBrowser.h"
  48. #include "addons/GUIDialogAddonSettings.h"
  49. #include "addons/GUIWindowAddonBrowser.h"
  50. #include "dialogs/GUIDialogContextMenu.h"
  51. #include "dialogs/GUIDialogYesNo.h"
  52. #include "dialogs/GUIDialogOK.h"
  53. #include "dialogs/GUIDialogProgress.h"
  54. #include "dialogs/GUIDialogKaiToast.h"
  55. #include "addons/Visualisation.h"
  56. #include "addons/AddonManager.h"
  57. #include "addons/AddonInstaller.h"
  58. #include "storage/MediaManager.h"
  59. #include "network/Network.h"
  60. #include "guilib/GUIControlGroupList.h"
  61. #include "guilib/GUIWindowManager.h"
  62. #include "guilib/GUIFontManager.h"
  63. #include "cores/AudioEngine/AEFactory.h"
  64. #ifdef _LINUX
  65. #include "LinuxTimezone.h"
  66. #include <dlfcn.h>
  67. #ifdef HAS_HAL
  68. #include "HALManager.h"
  69. #endif
  70. #endif
  71. #if defined(TARGET_DARWIN_OSX)
  72. #include "XBMCHelper.h"
  73. #endif
  74. #include "network/GUIDialogAccessPoints.h"
  75. #include "filesystem/Directory.h"
  76. #include "FileItem.h"
  77. #include "guilib/GUIToggleButtonControl.h"
  78. #include "filesystem/SpecialProtocol.h"
  79. #include "network/Zeroconf.h"
  80. #include "peripherals/Peripherals.h"
  81. #include "peripherals/dialogs/GUIDialogPeripheralManager.h"
  82. #ifdef _WIN32
  83. #include "WIN32Util.h"
  84. #endif
  85. #include <map>
  86. #include "Settings.h"
  87. #include "AdvancedSettings.h"
  88. #include "input/MouseStat.h"
  89. #if defined(TARGET_WINDOWS)
  90. #include "input/windows/WINJoystick.h"
  91. #elif defined(HAS_SDL_JOYSTICK)
  92. #include "input/SDLJoystick.h"
  93. #endif
  94. #include "guilib/LocalizeStrings.h"
  95. #include "LangInfo.h"
  96. #include "utils/StringUtils.h"
  97. #include "utils/URIUtils.h"
  98. #include "utils/SystemInfo.h"
  99. #include "windowing/WindowingFactory.h"
  100. #if defined(HAVE_LIBCRYSTALHD)
  101. #include "cores/dvdplayer/DVDCodecs/Video/CrystalHD.h"
  102. #endif
  103. #if defined(HAS_AIRPLAY)
  104. #include "network/AirPlayServer.h"
  105. #endif
  106. #if defined(HAS_WEB_SERVER)
  107. #include "network/WebServer.h"
  108. #endif
  109. using namespace std;
  110. using namespace XFILE;
  111. using namespace ADDON;
  112. using namespace PERIPHERALS;
  113. #define CONTROL_GROUP_BUTTONS 0
  114. #define CONTROL_GROUP_SETTINGS 1
  115. #define CONTROL_SETTINGS_LABEL 2
  116. #define CATEGORY_GROUP_ID 3
  117. #define SETTINGS_GROUP_ID 5
  118. #define CONTROL_DEFAULT_BUTTON 7
  119. #define CONTROL_DEFAULT_RADIOBUTTON 8
  120. #define CONTROL_DEFAULT_SPIN 9
  121. #define CONTROL_DEFAULT_CATEGORY_BUTTON 10
  122. #define CONTROL_DEFAULT_SEPARATOR 11
  123. #define CONTROL_DEFAULT_EDIT 12
  124. #define CONTROL_START_BUTTONS -100
  125. #define CONTROL_START_CONTROL -80
  126. CGUIWindowSettingsCategory::CGUIWindowSettingsCategory(void)
  127. : CGUIWindow(WINDOW_SETTINGS_MYPICTURES, "SettingsCategory.xml")
  128. {
  129. m_pOriginalSpin = NULL;
  130. m_pOriginalRadioButton = NULL;
  131. m_pOriginalButton = NULL;
  132. m_pOriginalCategoryButton = NULL;
  133. m_pOriginalImage = NULL;
  134. m_pOriginalEdit = NULL;
  135. // set the correct ID range...
  136. m_idRange = 8;
  137. m_iScreen = 0;
  138. m_strOldTrackFormat = "";
  139. m_strOldTrackFormatRight = "";
  140. m_returningFromSkinLoad = false;
  141. m_delayedSetting = NULL;
  142. }
  143. CGUIWindowSettingsCategory::~CGUIWindowSettingsCategory(void)
  144. {
  145. FreeControls();
  146. delete m_pOriginalEdit;
  147. }
  148. bool CGUIWindowSettingsCategory::OnBack(int actionID)
  149. {
  150. g_settings.Save();
  151. m_lastControlID = 0; // don't save the control as we go to a different window each time
  152. return CGUIWindow::OnBack(actionID);
  153. }
  154. bool CGUIWindowSettingsCategory::OnMessage(CGUIMessage &message)
  155. {
  156. switch (message.GetMessage())
  157. {
  158. case GUI_MSG_CLICKED:
  159. {
  160. unsigned int iControl = message.GetSenderId();
  161. for (unsigned int i = 0; i < m_vecSettings.size(); i++)
  162. {
  163. if (m_vecSettings[i]->GetID() == (int)iControl)
  164. OnClick(m_vecSettings[i]);
  165. }
  166. }
  167. break;
  168. case GUI_MSG_FOCUSED:
  169. {
  170. CGUIWindow::OnMessage(message);
  171. int focusedControl = GetFocusedControlID();
  172. if (focusedControl >= CONTROL_START_BUTTONS && focusedControl < (int)(CONTROL_START_BUTTONS + m_vecSections.size()) &&
  173. focusedControl - CONTROL_START_BUTTONS != m_iSection && !m_returningFromSkinLoad)
  174. {
  175. // changing section, check for updates and cancel any delayed changes
  176. m_delayedSetting = NULL;
  177. CheckForUpdates();
  178. if (m_vecSections[focusedControl-CONTROL_START_BUTTONS]->m_strCategory == "masterlock")
  179. {
  180. if (!g_passwordManager.IsMasterLockUnlocked(true))
  181. { // unable to go to this category - focus the previous one
  182. SET_CONTROL_FOCUS(CONTROL_START_BUTTONS + m_iSection, 0);
  183. return false;
  184. }
  185. }
  186. m_iSection = focusedControl - CONTROL_START_BUTTONS;
  187. CreateSettings();
  188. }
  189. return true;
  190. }
  191. case GUI_MSG_LOAD_SKIN:
  192. {
  193. if (IsActive())
  194. m_returningFromSkinLoad = true;
  195. }
  196. break;
  197. case GUI_MSG_WINDOW_INIT:
  198. {
  199. m_delayedSetting = NULL;
  200. if (message.GetParam1() != WINDOW_INVALID && !m_returningFromSkinLoad)
  201. { // coming to this window first time (ie not returning back from some other window)
  202. // so we reset our section and control states
  203. m_iSection = 0;
  204. ResetControlStates();
  205. }
  206. m_iScreen = (int)message.GetParam2() - (int)CGUIWindow::GetID();
  207. CGUIWindow::OnMessage(message);
  208. m_returningFromSkinLoad = false;
  209. return true;
  210. }
  211. break;
  212. case GUI_MSG_UPDATE_ITEM:
  213. if (m_delayedSetting)
  214. {
  215. OnSettingChanged(m_delayedSetting);
  216. m_delayedSetting = NULL;
  217. return true;
  218. }
  219. break;
  220. case GUI_MSG_NOTIFY_ALL:
  221. {
  222. if (message.GetParam1() == GUI_MSG_WINDOW_RESIZE)
  223. {
  224. // Cancel delayed setting - it's only used for res changing anyway
  225. m_delayedSetting = NULL;
  226. if (IsActive() && g_guiSettings.GetResolution() != g_graphicsContext.GetVideoResolution())
  227. {
  228. g_guiSettings.SetResolution(g_graphicsContext.GetVideoResolution());
  229. CreateSettings();
  230. }
  231. }
  232. }
  233. break;
  234. case GUI_MSG_WINDOW_DEINIT:
  235. {
  236. m_delayedSetting = NULL;
  237. CheckForUpdates();
  238. CGUIWindow::OnMessage(message);
  239. FreeControls();
  240. return true;
  241. }
  242. break;
  243. }
  244. return CGUIWindow::OnMessage(message);
  245. }
  246. void CGUIWindowSettingsCategory::SetupControls()
  247. {
  248. // cleanup first, if necessary
  249. FreeControls();
  250. m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN);
  251. m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON);
  252. m_pOriginalCategoryButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_CATEGORY_BUTTON);
  253. m_pOriginalButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON);
  254. m_pOriginalImage = (CGUIImage *)GetControl(CONTROL_DEFAULT_SEPARATOR);
  255. if (!m_pOriginalCategoryButton || !m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalButton)
  256. return ;
  257. m_pOriginalEdit = (CGUIEditControl *)GetControl(CONTROL_DEFAULT_EDIT);
  258. if (!m_pOriginalEdit || m_pOriginalEdit->GetControlType() != CGUIControl::GUICONTROL_EDIT)
  259. {
  260. delete m_pOriginalEdit;
  261. m_pOriginalEdit = new CGUIEditControl(*m_pOriginalButton);
  262. }
  263. m_pOriginalSpin->SetVisible(false);
  264. m_pOriginalRadioButton->SetVisible(false);
  265. m_pOriginalButton->SetVisible(false);
  266. m_pOriginalCategoryButton->SetVisible(false);
  267. m_pOriginalEdit->SetVisible(false);
  268. if (m_pOriginalImage) m_pOriginalImage->SetVisible(false);
  269. // setup our control groups...
  270. CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CATEGORY_GROUP_ID);
  271. if (!group)
  272. return;
  273. // get a list of different sections
  274. CSettingsGroup *pSettingsGroup = g_guiSettings.GetGroup(m_iScreen);
  275. if (!pSettingsGroup) return ;
  276. // update the screen string
  277. SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, pSettingsGroup->GetLabelID());
  278. // get the categories we need
  279. pSettingsGroup->GetCategories(m_vecSections);
  280. // run through and create our buttons...
  281. int j=0;
  282. for (unsigned int i = 0; i < m_vecSections.size(); i++)
  283. {
  284. if (m_vecSections[i]->m_labelID == 12360 && !g_settings.IsMasterUser())
  285. continue;
  286. CGUIButtonControl *pButton = NULL;
  287. if (m_pOriginalCategoryButton->GetControlType() == CGUIControl::GUICONTROL_TOGGLEBUTTON)
  288. pButton = new CGUIToggleButtonControl(*(CGUIToggleButtonControl *)m_pOriginalCategoryButton);
  289. else
  290. pButton = new CGUIButtonControl(*m_pOriginalCategoryButton);
  291. pButton->SetLabel(g_localizeStrings.Get(m_vecSections[i]->m_labelID));
  292. pButton->SetID(CONTROL_START_BUTTONS + j);
  293. pButton->SetVisible(true);
  294. pButton->AllocResources();
  295. group->AddControl(pButton);
  296. j++;
  297. }
  298. if (m_iSection < 0 || m_iSection >= (int)m_vecSections.size())
  299. m_iSection = 0;
  300. CreateSettings();
  301. // set focus correctly
  302. m_defaultControl = CONTROL_START_BUTTONS;
  303. }
  304. CGUIControl* CGUIWindowSettingsCategory::AddIntBasedSpinControl(CSetting *pSetting, float groupWidth, int &iControlID)
  305. {
  306. CSettingInt *pSettingInt = (CSettingInt*)pSetting;
  307. CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, groupWidth, iControlID);
  308. if (!pSettingInt->m_entries.empty())
  309. {
  310. for (map<int,int>::iterator it=pSettingInt->m_entries.begin(); it != pSettingInt->m_entries.end();++it)
  311. pControl->AddLabel(g_localizeStrings.Get(it->first), it->second);
  312. pControl->SetValue(pSettingInt->GetData());
  313. }
  314. return pControl;
  315. }
  316. void CGUIWindowSettingsCategory::CreateSettings()
  317. {
  318. FreeSettingsControls();
  319. CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(SETTINGS_GROUP_ID);
  320. if (!group)
  321. return;
  322. vecSettings settings;
  323. g_guiSettings.GetSettingsGroup(m_vecSections[m_iSection], settings);
  324. int iControlID = CONTROL_START_CONTROL;
  325. for (unsigned int i = 0; i < settings.size(); i++)
  326. {
  327. CSetting *pSetting = settings[i];
  328. CStdString strSetting = pSetting->GetSetting();
  329. if (pSetting->GetType() == SETTINGS_TYPE_INT)
  330. {
  331. CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddIntBasedSpinControl(pSetting, group->GetWidth(), iControlID);
  332. CSettingInt *pSettingInt = (CSettingInt*)pSetting;
  333. if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
  334. {
  335. pControl->AddLabel(g_localizeStrings.Get(13551), 0);
  336. for (int i = 1; i <= MAXREFRESHCHANGEDELAY; i++)
  337. {
  338. CStdString delayText;
  339. delayText.Format(g_localizeStrings.Get(13553).c_str(), (double)i / 10.0);
  340. pControl->AddLabel(delayText, i);
  341. }
  342. pControl->SetValue(pSettingInt->GetData());
  343. }
  344. else if (strSetting.Equals("subtitles.color"))
  345. {
  346. for (int i = SUBTITLE_COLOR_START; i <= SUBTITLE_COLOR_END; i++)
  347. pControl->AddLabel(g_localizeStrings.Get(760 + i), i);
  348. pControl->SetValue(pSettingInt->GetData());
  349. }
  350. else if (strSetting.Equals("lookandfeel.startupwindow"))
  351. FillInStartupWindow(pSetting);
  352. else if (strSetting.Equals("subtitles.height") || strSetting.Equals("karaoke.fontheight") )
  353. FillInSubtitleHeights(pSetting, pControl);
  354. else if (strSetting.Equals("videoscreen.screen"))
  355. FillInScreens(strSetting, g_guiSettings.GetResolution());
  356. else if (strSetting.Equals("videoscreen.resolution"))
  357. FillInResolutions(strSetting, g_guiSettings.GetInt("videoscreen.screen"), g_guiSettings.GetResolution(), false);
  358. continue;
  359. }
  360. #ifdef HAS_WEB_SERVER
  361. else if (strSetting.Equals("services.webserverport"))
  362. {
  363. AddSetting(pSetting, group->GetWidth(), iControlID);
  364. CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
  365. control->SetDelayed();
  366. continue;
  367. }
  368. #endif
  369. else if (strSetting.Equals("services.esport"))
  370. {
  371. #ifdef HAS_EVENT_SERVER
  372. AddSetting(pSetting, group->GetWidth(), iControlID);
  373. CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
  374. control->SetDelayed();
  375. continue;
  376. #endif
  377. }
  378. else if (strSetting.Equals("network.httpproxyport"))
  379. {
  380. AddSetting(pSetting, group->GetWidth(), iControlID);
  381. CBaseSettingControl *control = GetSetting(pSetting->GetSetting());
  382. control->SetDelayed();
  383. continue;
  384. }
  385. else if (strSetting.Equals("subtitles.font") || strSetting.Equals("karaoke.font") )
  386. {
  387. AddSetting(pSetting, group->GetWidth(), iControlID);
  388. FillInSubtitleFonts(pSetting);
  389. continue;
  390. }
  391. else if (strSetting.Equals("subtitles.charset") || strSetting.Equals("locale.charset") || strSetting.Equals("karaoke.charset"))
  392. {
  393. AddSetting(pSetting, group->GetWidth(), iControlID);
  394. FillInCharSets(pSetting);
  395. continue;
  396. }
  397. else if (strSetting.Equals("lookandfeel.font"))
  398. {
  399. AddSetting(pSetting, group->GetWidth(), iControlID);
  400. FillInSkinFonts(pSetting);
  401. continue;
  402. }
  403. else if (strSetting.Equals("lookandfeel.soundskin"))
  404. {
  405. AddSetting(pSetting, group->GetWidth(), iControlID);
  406. FillInSoundSkins(pSetting);
  407. continue;
  408. }
  409. else if (strSetting.Equals("locale.language"))
  410. {
  411. AddSetting(pSetting, group->GetWidth(), iControlID);
  412. GetSetting(pSetting->GetSetting())->SetDelayed();
  413. FillInLanguages(pSetting);
  414. continue;
  415. }
  416. else if (strSetting.Equals("locale.audiolanguage") || strSetting.Equals("locale.subtitlelanguage"))
  417. {
  418. AddSetting(pSetting, group->GetWidth(), iControlID);
  419. vector<CStdString> languages;
  420. languages.push_back(g_localizeStrings.Get(308));
  421. languages.push_back(g_localizeStrings.Get(309));
  422. vector<CStdString> languageKeys;
  423. languageKeys.push_back("original");
  424. languageKeys.push_back("default");
  425. FillInLanguages(pSetting, languages, languageKeys);
  426. continue;
  427. }
  428. #ifdef _LINUX
  429. else if (strSetting.Equals("locale.timezonecountry"))
  430. {
  431. CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
  432. int myTimezeoneCountryIndex = 0;
  433. CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
  434. vector<CStdString> countries = g_timezone.GetCounties();
  435. for (unsigned int i=0; i < countries.size(); i++)
  436. {
  437. if (countries[i] == myTimezoneCountry)
  438. myTimezeoneCountryIndex = i;
  439. pControl->AddLabel(countries[i], i);
  440. }
  441. pControl->SetValue(myTimezeoneCountryIndex);
  442. continue;
  443. }
  444. else if (strSetting.Equals("locale.timezone"))
  445. {
  446. CStdString myTimezoneCountry = g_guiSettings.GetString("locale.timezonecountry");
  447. CStdString myTimezone = g_guiSettings.GetString("locale.timezone");
  448. int myTimezoneIndex = 0;
  449. CGUISpinControlEx *pControl = (CGUISpinControlEx *)AddSetting(pSetting, group->GetWidth(), iControlID);
  450. pControl->Clear();
  451. vector<CStdString> timezones = g_timezone.GetTimezonesByCountry(myTimezoneCountry);
  452. for (unsigned int i=0; i < timezones.size(); i++)
  453. {
  454. if (timezones[i] == myTimezone)
  455. myTimezoneIndex = i;
  456. pControl->AddLabel(timezones[i], i);
  457. }
  458. pControl->SetValue(myTimezoneIndex);
  459. continue;
  460. }
  461. #endif
  462. else if (strSetting.Equals("videoscreen.screenmode"))
  463. {
  464. AddSetting(pSetting, group->GetWidth(), iControlID);
  465. FillInRefreshRates(strSetting, g_guiSettings.GetResolution(), false);
  466. continue;
  467. }
  468. else if (strSetting.Equals("lookandfeel.skintheme"))
  469. {
  470. AddSetting(pSetting, group->GetWidth(), iControlID);
  471. FillInSkinThemes(pSetting);
  472. continue;
  473. }
  474. else if (strSetting.Equals("lookandfeel.skincolors"))
  475. {
  476. AddSetting(pSetting, group->GetWidth(), iControlID);
  477. FillInSkinColors(pSetting);
  478. continue;
  479. }
  480. /*
  481. FIXME: setting is hidden in GUI because not supported properly.
  482. else if (strSetting.Equals("videoplayer.displayresolution") || strSetting.Equals("pictures.displayresolution"))
  483. {
  484. FillInResolutions(pSetting);
  485. }
  486. */
  487. else if (strSetting.Equals("locale.country"))
  488. {
  489. AddSetting(pSetting, group->GetWidth(), iControlID);
  490. FillInRegions(pSetting);
  491. continue;
  492. }
  493. else if (strSetting.Equals("network.interface"))
  494. {
  495. FillInNetworkInterfaces(pSetting, group->GetWidth(), iControlID);
  496. continue;
  497. }
  498. else if (strSetting.Equals("audiooutput.audiodevice"))
  499. {
  500. AddSetting(pSetting, group->GetWidth(), iControlID);
  501. FillInAudioDevices(pSetting);
  502. continue;
  503. }
  504. else if (strSetting.Equals("audiooutput.passthroughdevice"))
  505. {
  506. AddSetting(pSetting, group->GetWidth(), iControlID);
  507. FillInAudioDevices(pSetting,true);
  508. continue;
  509. }
  510. AddSetting(pSetting, group->GetWidth(), iControlID);
  511. }
  512. if (m_vecSections[m_iSection]->m_strCategory == "network")
  513. NetworkInterfaceChanged();
  514. // update our settings (turns controls on/off as appropriate)
  515. UpdateSettings();
  516. }
  517. void CGUIWindowSettingsCategory::UpdateSettings()
  518. {
  519. for (unsigned int i = 0; i < m_vecSettings.size(); i++)
  520. {
  521. CBaseSettingControl *pSettingControl = m_vecSettings[i];
  522. pSettingControl->Update();
  523. CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
  524. #ifdef HAVE_LIBVDPAU
  525. if (strSetting.Equals("videoplayer.vdpauUpscalingLevel"))
  526. {
  527. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  528. if (pControl)
  529. {
  530. pControl->SetEnabled(true);
  531. }
  532. }
  533. else
  534. #endif
  535. if (strSetting.Equals("videoscreen.resolution"))
  536. {
  537. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  538. if (pControl)
  539. pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
  540. }
  541. else if (strSetting.Equals("videoscreen.screenmode"))
  542. {
  543. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  544. if (pControl)
  545. pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
  546. }
  547. else if (strSetting.Equals("videoscreen.fakefullscreen"))
  548. {
  549. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  550. if (pControl)
  551. pControl->SetEnabled(g_guiSettings.GetInt("videoscreen.screen") != DM_WINDOWED);
  552. }
  553. #if defined(TARGET_DARWIN_OSX) || defined(_WIN32)
  554. else if (strSetting.Equals("videoscreen.blankdisplays"))
  555. {
  556. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  557. if (pControl)
  558. {
  559. if (g_Windowing.IsFullScreen())
  560. pControl->SetEnabled(true);
  561. else
  562. pControl->SetEnabled(false);
  563. }
  564. }
  565. #endif
  566. #if defined(TARGET_DARWIN_OSX)
  567. else if (strSetting.Equals("input.appleremotemode"))
  568. {
  569. int remoteMode = g_guiSettings.GetInt("input.appleremotemode");
  570. // if it's not disabled, start the event server or else apple remote won't work
  571. if ( remoteMode != APPLE_REMOTE_DISABLED )
  572. {
  573. g_guiSettings.SetBool("services.esenabled", true);
  574. if (!g_application.StartEventServer())
  575. CGUIDialogKaiToast::QueueNotification("DefaultIconWarning.png", g_localizeStrings.Get(33102), g_localizeStrings.Get(33100));
  576. }
  577. // if XBMC helper is running, prompt user before effecting change
  578. if ( XBMCHelper::GetInstance().IsRunning() && XBMCHelper::GetInstance().GetMode()!=remoteMode )
  579. {
  580. bool cancelled;
  581. if (!CGUIDialogYesNo::ShowAndGetInput(13144, 13145, 13146, 13147, -1, -1, cancelled, 10000))
  582. {
  583. // user declined, restore previous spinner state and appleremote mode
  584. CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
  585. g_guiSettings.SetInt("input.appleremotemode", XBMCHelper::GetInstance().GetMode());
  586. pControl->SetValue(XBMCHelper::GetInstance().GetMode());
  587. }
  588. else
  589. {
  590. // reload configuration
  591. XBMCHelper::GetInstance().Configure();
  592. }
  593. }
  594. else
  595. {
  596. // set new configuration.
  597. XBMCHelper::GetInstance().Configure();
  598. }
  599. if (XBMCHelper::GetInstance().ErrorStarting() == true)
  600. {
  601. // inform user about error
  602. CGUIDialogOK::ShowAndGetInput(13620, 13621, 20022, 20022);
  603. // reset spinner to disabled state
  604. CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
  605. pControl->SetValue(APPLE_REMOTE_DISABLED);
  606. }
  607. }
  608. else if (strSetting.Equals("input.appleremotealwayson"))
  609. {
  610. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  611. if (pControl)
  612. {
  613. int value = g_guiSettings.GetInt("input.appleremotemode");
  614. if (value != APPLE_REMOTE_DISABLED)
  615. pControl->SetEnabled(true);
  616. else
  617. pControl->SetEnabled(false);
  618. }
  619. }
  620. else if (strSetting.Equals("input.appleremotesequencetime"))
  621. {
  622. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  623. if (pControl)
  624. {
  625. int value = g_guiSettings.GetInt("input.appleremotemode");
  626. if (value == APPLE_REMOTE_UNIVERSAL)
  627. pControl->SetEnabled(true);
  628. else
  629. pControl->SetEnabled(false);
  630. }
  631. }
  632. #endif
  633. else if (strSetting.Equals("filelists.allowfiledeletion"))
  634. {
  635. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  636. if (pControl) pControl->SetEnabled(!g_settings.GetCurrentProfile().filesLocked() || g_passwordManager.bMasterUser);
  637. }
  638. else if (strSetting.Equals("filelists.showaddsourcebuttons"))
  639. {
  640. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  641. if (pControl) pControl->SetEnabled(g_settings.GetCurrentProfile().canWriteSources() || g_passwordManager.bMasterUser);
  642. }
  643. else if (strSetting.Equals("masterlock.startuplock"))
  644. {
  645. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  646. if (pControl) pControl->SetEnabled(g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE);
  647. }
  648. else if (!strSetting.Equals("services.esenabled")
  649. && strSetting.Left(11).Equals("services.es"))
  650. {
  651. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  652. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("services.esenabled"));
  653. }
  654. else if (strSetting.Equals("audiocds.quality"))
  655. { // only visible if we are doing non-WAV ripping
  656. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  657. if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
  658. g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC);
  659. }
  660. else if (strSetting.Equals("audiocds.bitrate"))
  661. { // only visible if we are ripping to CBR
  662. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  663. if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_WAV &&
  664. g_guiSettings.GetInt("audiocds.encoder") != CDDARIP_ENCODER_FLAC &&
  665. g_guiSettings.GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR);
  666. }
  667. else if (strSetting.Equals("audiocds.compressionlevel"))
  668. { // only visible if we are doing FLAC ripping
  669. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  670. if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("audiocds.encoder") == CDDARIP_ENCODER_FLAC);
  671. }
  672. else if (
  673. strSetting.Equals("audiooutput.passthroughdevice") ||
  674. strSetting.Equals("audiooutput.ac3passthrough") ||
  675. strSetting.Equals("audiooutput.dtspassthrough") ||
  676. strSetting.Equals("audiooutput.passthroughaac"))
  677. { // only visible if we are in digital mode
  678. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  679. if (pControl) pControl->SetEnabled(AUDIO_IS_BITSTREAM(g_guiSettings.GetInt("audiooutput.mode")));
  680. }
  681. else if (
  682. strSetting.Equals("audiooutput.multichannellpcm" ) ||
  683. strSetting.Equals("audiooutput.truehdpassthrough") ||
  684. strSetting.Equals("audiooutput.dtshdpassthrough" ))
  685. {
  686. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  687. if (pControl)
  688. {
  689. if (strSetting.Equals("audiooutput.dtshdpassthrough") && !g_guiSettings.GetBool("audiooutput.dtspassthrough"))
  690. pControl->SetEnabled(false);
  691. else
  692. pControl->SetEnabled(g_guiSettings.GetInt("audiooutput.mode") == AUDIO_HDMI);
  693. }
  694. }
  695. else if (strSetting.Equals("audiooutput.guisoundmode"))
  696. {
  697. CAEFactory::SetSoundMode(g_guiSettings.GetInt("audiooutput.guisoundmode"));
  698. }
  699. else if (strSetting.Equals("musicplayer.crossfade"))
  700. {
  701. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  702. if (pControl) pControl->SetEnabled(g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
  703. }
  704. else if (strSetting.Equals("musicplayer.crossfadealbumtracks"))
  705. {
  706. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  707. if (pControl) pControl->SetEnabled(g_guiSettings.GetInt("musicplayer.crossfade") > 0 &&
  708. g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") == CStdString::npos);
  709. }
  710. #ifdef HAS_WEB_SERVER
  711. else if (strSetting.Equals("services.webserverusername") ||
  712. strSetting.Equals("services.webserverpassword"))
  713. {
  714. CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
  715. if (pControl)
  716. pControl->SetEnabled(g_guiSettings.GetBool("services.webserver"));
  717. }
  718. #endif
  719. #ifdef HAS_AIRPLAY
  720. else if ( strSetting.Equals("services.airplaypassword") ||
  721. strSetting.Equals("services.useairplaypassword"))
  722. {
  723. if (strSetting.Equals("services.airplaypassword"))
  724. {
  725. CGUIEditControl *pControl = (CGUIEditControl *)GetControl(pSettingControl->GetID());
  726. if (pControl)
  727. pControl->SetEnabled(g_guiSettings.GetBool("services.useairplaypassword"));
  728. }
  729. else//useairplaypassword
  730. {
  731. CGUIRadioButtonControl *pControl = (CGUIRadioButtonControl *)GetControl(pSettingControl->GetID());
  732. if (pControl)
  733. pControl->SetEnabled(g_guiSettings.GetBool("services.airplay"));
  734. }
  735. //set credentials to airplay server
  736. if (g_guiSettings.GetBool("services.airplay"))
  737. {
  738. CStdString password = g_guiSettings.GetString("services.airplaypassword");
  739. CAirPlayServer::SetCredentials(g_guiSettings.GetBool("services.useairplaypassword"),
  740. password);
  741. }
  742. }
  743. #endif//HAS_AIRPLAY
  744. else if (strSetting.Equals("network.ipaddress") || strSetting.Equals("network.subnet") || strSetting.Equals("network.gateway") || strSetting.Equals("network.dns"))
  745. {
  746. #ifdef _LINUX
  747. bool enabled = (geteuid() == 0);
  748. #else
  749. bool enabled = false;
  750. #endif
  751. CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
  752. if (pControl1)
  753. enabled = (pControl1->GetValue() == NETWORK_STATIC);
  754. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  755. if (pControl) pControl->SetEnabled(enabled);
  756. }
  757. else if (strSetting.Equals("network.assignment"))
  758. {
  759. CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
  760. #ifdef HAS_LINUX_NETWORK
  761. if (pControl1)
  762. pControl1->SetEnabled(geteuid() == 0);
  763. #endif
  764. }
  765. else if (strSetting.Equals("network.essid") || strSetting.Equals("network.enc") || strSetting.Equals("network.key"))
  766. {
  767. // Get network information
  768. CGUISpinControlEx *ifaceControl = (CGUISpinControlEx *)GetControl(GetSetting("network.interface")->GetID());
  769. CStdString ifaceName = ifaceControl->GetLabel();
  770. CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
  771. bool bIsWireless = iface->IsWireless();
  772. #ifdef HAS_LINUX_NETWORK
  773. bool enabled = bIsWireless && (geteuid() == 0);
  774. #else
  775. bool enabled = bIsWireless;
  776. #endif
  777. CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.assignment")->GetID());
  778. if (pControl1)
  779. enabled &= (pControl1->GetValue() != NETWORK_DISABLED);
  780. if (strSetting.Equals("network.key"))
  781. {
  782. pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
  783. if (pControl1) enabled &= (pControl1->GetValue() != ENC_NONE);
  784. }
  785. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  786. if (pControl) pControl->SetEnabled(enabled);
  787. }
  788. else if (strSetting.Equals("network.httpproxyserver") || strSetting.Equals("network.httpproxyport") ||
  789. strSetting.Equals("network.httpproxyusername") || strSetting.Equals("network.httpproxypassword"))
  790. {
  791. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  792. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("network.usehttpproxy"));
  793. }
  794. #ifdef HAS_LINUX_NETWORK
  795. else if (strSetting.Equals("network.key"))
  796. {
  797. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  798. CGUISpinControlEx* pControl1 = (CGUISpinControlEx *)GetControl(GetSetting("network.enc")->GetID());
  799. if (pControl && pControl1)
  800. pControl->SetEnabled(!pControl1->IsDisabled() && pControl1->GetValue() > 0);
  801. }
  802. else if (strSetting.Equals("network.save"))
  803. {
  804. CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
  805. pControl->SetEnabled(geteuid() == 0);
  806. }
  807. #endif
  808. else if (strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
  809. {
  810. CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
  811. if (pControl)
  812. pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.lastfmsubmit") | g_guiSettings.GetBool("scrobbler.lastfmsubmitradio"));
  813. }
  814. else if (strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
  815. {
  816. CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
  817. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("scrobbler.librefmsubmit"));
  818. }
  819. else if (strSetting.Equals("subtitles.color") || strSetting.Equals("subtitles.style") || strSetting.Equals("subtitles.charset"))
  820. {
  821. CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
  822. pControl->SetEnabled(CUtil::IsUsingTTFSubtitles());
  823. }
  824. else if (strSetting.Equals("locale.charset"))
  825. { // TODO: Determine whether we are using a TTF font or not.
  826. // CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  827. // if (pControl) pControl->SetEnabled(g_guiSettings.GetString("lookandfeel.font").Right(4) == ".ttf");
  828. }
  829. else if (strSetting.Equals("screensaver.settings"))
  830. {
  831. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  832. AddonPtr addon;
  833. if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
  834. pControl->SetEnabled(addon->HasSettings());
  835. else
  836. pControl->SetEnabled(false);
  837. }
  838. else if (strSetting.Equals("screensaver.preview") ||
  839. strSetting.Equals("screensaver.usedimonpause") ||
  840. strSetting.Equals("screensaver.usemusicvisinstead"))
  841. {
  842. CGUIControl *pControl = (CGUIControl *)GetControl(GetSetting(strSetting)->GetID());
  843. pControl->SetEnabled(!g_guiSettings.GetString("screensaver.mode").IsEmpty());
  844. if (strSetting.Equals("screensaver.usedimonpause") && g_guiSettings.GetString("screensaver.mode").Equals("screensaver.xbmc.builtin.dim"))
  845. pControl->SetEnabled(false);
  846. }
  847. else if (strSetting.Equals("musicfiles.trackformat"))
  848. {
  849. if (m_strOldTrackFormat != g_guiSettings.GetString("musicfiles.trackformat"))
  850. {
  851. CUtil::DeleteMusicDatabaseDirectoryCache();
  852. m_strOldTrackFormat = g_guiSettings.GetString("musicfiles.trackformat");
  853. }
  854. }
  855. else if (strSetting.Equals("musicfiles.trackformatright"))
  856. {
  857. if (m_strOldTrackFormatRight != g_guiSettings.GetString("musicfiles.trackformatright"))
  858. {
  859. CUtil::DeleteMusicDatabaseDirectoryCache();
  860. m_strOldTrackFormatRight = g_guiSettings.GetString("musicfiles.trackformatright");
  861. }
  862. }
  863. #ifdef HAS_TIME_SERVER
  864. else if (strSetting.Equals("locale.timeserveraddress"))
  865. {
  866. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  867. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("locale.timeserver"));
  868. }
  869. #endif
  870. else if (strSetting.Equals("audiocds.recordingpath") || strSetting.Equals("debug.screenshotpath"))
  871. {
  872. CGUIButtonControl *pControl = (CGUIButtonControl *)GetControl(pSettingControl->GetID());
  873. if (pControl && g_guiSettings.GetString(strSetting, false).IsEmpty())
  874. pControl->SetLabel2("");
  875. }
  876. else if (strSetting.Equals("lookandfeel.rssedit"))
  877. {
  878. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  879. pControl->SetEnabled(g_guiSettings.GetBool("lookandfeel.enablerssfeeds"));
  880. }
  881. else if (strSetting.Equals("videoplayer.pauseafterrefreshchange"))
  882. {
  883. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  884. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.adjustrefreshrate"));
  885. }
  886. else if (strSetting.Equals("videoplayer.synctype"))
  887. {
  888. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  889. if (pControl) pControl->SetEnabled(g_guiSettings.GetBool("videoplayer.usedisplayasclock"));
  890. }
  891. else if (strSetting.Equals("videoplayer.maxspeedadjust"))
  892. {
  893. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  894. if (pControl)
  895. {
  896. bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
  897. (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
  898. pControl->SetEnabled(enabled);
  899. }
  900. }
  901. else if (strSetting.Equals("videoplayer.resamplequality"))
  902. {
  903. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  904. if (pControl)
  905. {
  906. bool enabled = (g_guiSettings.GetBool("videoplayer.usedisplayasclock")) &&
  907. (g_guiSettings.GetInt("videoplayer.synctype") == SYNC_RESAMPLE);
  908. pControl->SetEnabled(enabled);
  909. }
  910. }
  911. else if (strSetting.Equals("weather.addonsettings"))
  912. {
  913. AddonPtr addon;
  914. if (CAddonMgr::Get().GetAddon(g_guiSettings.GetString("weather.addon"), addon, ADDON_SCRIPT_WEATHER))
  915. {
  916. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  917. if (pControl)
  918. pControl->SetEnabled(addon->HasSettings());
  919. }
  920. }
  921. else if (strSetting.Equals("input.peripherals"))
  922. {
  923. CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
  924. if (pControl)
  925. pControl->SetEnabled(g_peripherals.GetNumberOfPeripherals() > 0);
  926. }
  927. }
  928. }
  929. void CGUIWindowSettingsCategory::OnClick(CBaseSettingControl *pSettingControl)
  930. {
  931. CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
  932. if (strSetting.Equals("weather.addonsettings"))
  933. {
  934. CStdString name = g_guiSettings.GetString("weather.addon");
  935. AddonPtr addon;
  936. if (CAddonMgr::Get().GetAddon(name, addon, ADDON_SCRIPT_WEATHER))
  937. { // TODO: maybe have ShowAndGetInput return a bool if settings changed, then only reset weather if true.
  938. CGUIDialogAddonSettings::ShowAndGetInput(addon);
  939. g_weatherManager.Refresh();
  940. }
  941. }
  942. else if (strSetting.Equals("lookandfeel.rssedit"))
  943. {
  944. AddonPtr addon;
  945. CAddonMgr::Get().GetAddon("script.rss.editor",addon);
  946. if (!addon)
  947. {
  948. if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),"RSS Editor",g_localizeStrings.Get(24101)))
  949. return;
  950. CAddonInstaller::Get().Install("script.rss.editor", true, "", false);
  951. }
  952. CBuiltins::Execute("RunScript(script.rss.editor)");
  953. }
  954. else if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
  955. { // prompt for the addon
  956. CSettingAddon *setting = (CSettingAddon *)pSettingControl->GetSetting();
  957. CStdString addonID = setting->GetData();
  958. if (CGUIWindowAddonBrowser::SelectAddonID(setting->m_type, addonID, setting->m_type == ADDON_SCREENSAVER || setting->m_type == ADDON_VIZ || setting->m_type == ADDON_SCRIPT_WEATHER) == 1)
  959. setting->SetData(addonID);
  960. else
  961. return;
  962. }
  963. else if (strSetting.Equals("input.peripherals"))
  964. {
  965. CGUIDialogPeripheralManager *dialog = (CGUIDialogPeripheralManager *)g_windowManager.GetWindow(WINDOW_DIALOG_PERIPHERAL_MANAGER);
  966. if (dialog)
  967. dialog->DoModal();
  968. return;
  969. }
  970. // if OnClick() returns false, the setting hasn't changed or doesn't
  971. // require immediate update
  972. if (!pSettingControl->OnClick())
  973. {
  974. UpdateSettings();
  975. if (!pSettingControl->IsDelayed())
  976. return;
  977. }
  978. if (pSettingControl->IsDelayed())
  979. { // delayed setting
  980. m_delayedSetting = pSettingControl;
  981. m_delayedTimer.StartZero();
  982. }
  983. else
  984. OnSettingChanged(pSettingControl);
  985. }
  986. void CGUIWindowSettingsCategory::CheckForUpdates()
  987. {
  988. for (unsigned int i = 0; i < m_vecSettings.size(); i++)
  989. {
  990. CBaseSettingControl *pSettingControl = m_vecSettings[i];
  991. if (pSettingControl->NeedsUpdate())
  992. {
  993. OnSettingChanged(pSettingControl);
  994. pSettingControl->Reset();
  995. }
  996. }
  997. }
  998. void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingControl)
  999. {
  1000. CStdString strSetting = pSettingControl->GetSetting()->GetSetting();
  1001. // ok, now check the various special things we need to do
  1002. if (pSettingControl->GetSetting()->GetType() == SETTINGS_TYPE_ADDON)
  1003. {
  1004. CSettingAddon *pSettingAddon = (CSettingAddon*)pSettingControl->GetSetting();
  1005. if (pSettingAddon->m_type == ADDON_SKIN)
  1006. {
  1007. g_application.ReloadSkin();
  1008. }
  1009. else if (pSettingAddon->m_type == ADDON_SCRIPT_WEATHER)
  1010. {
  1011. g_weatherManager.Refresh();
  1012. }
  1013. }
  1014. else if (strSetting.Equals("musicplayer.visualisation"))
  1015. { // new visualisation choosen...
  1016. CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
  1017. CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
  1018. if (pControl->GetValue() == 0)
  1019. pSettingString->SetData("None");
  1020. else
  1021. pSettingString->SetData(pControl->GetCurrentLabel());
  1022. }
  1023. else if (strSetting.Equals("debug.showloginfo"))
  1024. {
  1025. if (g_guiSettings.GetBool("debug.showloginfo"))
  1026. {
  1027. int level = std::max(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG_FREEMEM);
  1028. g_advancedSettings.m_logLevel = level;
  1029. CLog::SetLogLevel(level);
  1030. CLog::Log(LOGNOTICE, "Enabled debug logging due to GUI setting. Level %d.", level);
  1031. }
  1032. else
  1033. {
  1034. int level = std::min(g_advancedSettings.m_logLevelHint, LOG_LEVEL_DEBUG/*LOG_LEVEL_NORMAL*/);
  1035. CLog::Log(LOGNOTICE, "Disabled debug logging due to GUI setting. Level %d.", level);
  1036. g_advancedSettings.m_logLevel = level;
  1037. CLog::SetLogLevel(level);
  1038. }
  1039. }
  1040. /*else if (strSetting.Equals("musicfiles.repeat"))
  1041. {
  1042. g_playlistPlayer.SetRepeat(PLAYLIST_MUSIC_TEMP, g_guiSettings.GetBool("musicfiles.repeat") ? PLAYLIST::REPEAT_ALL : PLAYLIST::REPEAT_NONE);
  1043. }*/
  1044. else if (strSetting.Equals("musiclibrary.cleanup"))
  1045. {
  1046. CMusicDatabase musicdatabase;
  1047. musicdatabase.Clean();
  1048. CUtil::DeleteMusicDatabaseDirectoryCache();
  1049. }
  1050. else if (strSetting.Equals("videolibrary.cleanup"))
  1051. {
  1052. if (CGUIDialogYesNo::ShowAndGetInput(313, 333, 0, 0))
  1053. g_application.StartVideoCleanup();
  1054. }
  1055. else if (strSetting.Equals("videolibrary.export"))
  1056. CBuiltins::Execute("exportlibrary(video)");
  1057. else if (strSetting.Equals("musiclibrary.export"))
  1058. CBuiltins::Execute("exportlibrary(music)");
  1059. else if (strSetting.Equals("karaoke.export") )
  1060. {
  1061. CContextButtons choices;
  1062. choices.Add(1, g_localizeStrings.Get(22034));
  1063. choices.Add(2, g_localizeStrings.Get(22035));
  1064. int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices);
  1065. if ( retVal > 0 )
  1066. {
  1067. CStdString path(g_settings.GetDatabaseFolder());
  1068. VECSOURCES shares;
  1069. g_mediaManager.GetLocalDrives(shares);
  1070. if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true))
  1071. {
  1072. CMusicDatabase musicdatabase;
  1073. musicdatabase.Open();
  1074. if ( retVal == 1 )
  1075. {
  1076. URIUtils::AddFileToFolder(path, "karaoke.html", path);
  1077. musicdatabase.ExportKaraokeInfo( path, true );
  1078. }
  1079. else
  1080. {
  1081. URIUtils::AddFileToFolder(path, "karaoke.csv", path);
  1082. musicdatabase.ExportKaraokeInfo( path, false );
  1083. }
  1084. musicdatabase.Close();
  1085. }
  1086. }
  1087. }
  1088. else if (strSetting.Equals("videolibrary.import"))
  1089. {
  1090. CStdString path;
  1091. VECSOURCES shares;
  1092. g_mediaManager.GetLocalDrives(shares);
  1093. if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path))
  1094. {
  1095. CVideoDatabase videodatabase;
  1096. videodatabase.Open();
  1097. videodatabase.ImportFromXML(path);
  1098. videodatabase.Close();
  1099. }
  1100. }
  1101. else if (strSetting.Equals("musiclibrary.import"))
  1102. {
  1103. CStdString path;
  1104. VECSOURCES shares;
  1105. g_mediaManager.GetLocalDrives(shares);
  1106. if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path))
  1107. {
  1108. CMusicDatabase musicdatabase;
  1109. musicdatabase.Open();
  1110. musicdatabase.ImportFromXML(path);
  1111. musicdatabase.Close();
  1112. }
  1113. }
  1114. else if (strSetting.Equals("karaoke.importcsv"))
  1115. {
  1116. CStdString path(g_settings.GetDatabaseFolder());
  1117. VECSOURCES shares;
  1118. g_mediaManager.GetLocalDrives(shares);
  1119. if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path))
  1120. {
  1121. CMusicDatabase musicdatabase;
  1122. musicdatabase.Open();
  1123. musicdatabase.ImportKaraokeInfo(path);
  1124. musicdatabase.Close();
  1125. }
  1126. }
  1127. else if (strSetting.Equals("scrobbler.lastfmsubmit") || strSetting.Equals("scrobbler.lastfmsubmitradio") || strSetting.Equals("scrobbler.lastfmusername") || strSetting.Equals("scrobbler.lastfmpass"))
  1128. {
  1129. CStdString strPassword=g_guiSettings.GetString("scrobbler.lastfmpass");
  1130. CStdString strUserName=g_guiSettings.GetString("scrobbler.lastfmusername");
  1131. if ((g_guiSettings.GetBool("scrobbler.lastfmsubmit") ||
  1132. g_guiSettings.GetBool("scrobbler.lastfmsubmitradio")) &&
  1133. !strUserName.IsEmpty() && !strPassword.IsEmpty())
  1134. {
  1135. CLastfmScrobbler::GetInstance()->Init();
  1136. }
  1137. else
  1138. {
  1139. CLastfmScrobbler::GetInstance()->Term();
  1140. }
  1141. }
  1142. else if (strSetting.Equals("scrobbler.librefmsubmit") || strSetting.Equals("scrobbler.librefmsubmitradio") || strSetting.Equals("scrobbler.librefmusername") || strSetting.Equals("scrobbler.librefmpass"))
  1143. {
  1144. CStdString strPassword=g_guiSettings.GetString("scrobbler.librefmpass");
  1145. CStdString strUserName=g_guiSettings.GetString("scrobbler.librefmusername");
  1146. if ((g_guiSettings.GetBool("scrobbler.librefmsubmit") ||
  1147. g_guiSettings.GetBool("scrobbler.librefmsubmitradio")) &&
  1148. !strUserName.IsEmpty() && !strPassword.IsEmpty())
  1149. {
  1150. CLibrefmScrobbler::GetInstance()->Init();
  1151. }
  1152. else
  1153. {
  1154. CLibrefmScrobbler::GetInstance()->Term();
  1155. }
  1156. }
  1157. else if (strSetting.Left(22).Equals("MusicPlayer.ReplayGain"))
  1158. { // Update our replaygain settings
  1159. g_guiSettings.m_replayGain.iType = g_guiSettings.GetInt("musicplayer.replaygaintype");
  1160. g_guiSettings.m_replayGain.iPreAmp = g_guiSettings.GetInt("musicplayer.replaygainpreamp");
  1161. g_guiSettings.m_replayGain.iNoGainPreAmp = g_guiSettings.GetInt("musicplayer.replaygainnogainpreamp");
  1162. g_guiSettings.m_replayGain.bAvoidClipping = g_guiSettings.GetBool("musicplayer.replaygainavoidclipping");
  1163. }
  1164. #ifdef HAS_LCD
  1165. else if (strSetting.Equals("videoscreen.haslcd"))
  1166. {
  1167. g_lcd->Stop();
  1168. CLCDFactory factory;
  1169. delete g_lcd;
  1170. g_lcd = factory.Create();
  1171. g_lcd->Initialize();
  1172. }
  1173. #endif
  1174. #ifdef HAS_WEB_SERVER
  1175. else if ( strSetting.Equals("services.webserver") || strSetting.Equals("services.webserverport"))
  1176. {
  1177. if (strSetting.Equals("services.webserverport"))
  1178. ValidatePortNumber(pSettingControl, "8080", "80");
  1179. g_application.StopWebServer();
  1180. if (g_guiSettings.GetBool("services.webserver"))
  1181. if (!g_application.StartWebServer())
  1182. {
  1183. CGUIDialogOK::ShowAndGetInput(g_localizeStrings.Get(33101), "", g_localizeStrings.Get(33100), "");
  1184. g_guiSettings.SetBool("services.webserver", false);
  1185. }
  1186. }
  1187. else if (strSetting.Equals("services.webserverusername") || strSetting.Equals("services.webserverpassword"))
  1188. {
  1189. g_application.m_WebServer.SetCredentials(g_guiSettings.GetString("services.webserverusername"), g_guiSettings.GetString("services.webserverpassword"));
  1190. }
  1191. #endif
  1192. else if (strSetting.Equals("services.zeroconf"))
  1193. {
  1194. #ifdef HAS_ZEROCONF
  1195. //ifdef zeroconf here because it's only found in guisettings if defined
  1196. if(g_guiSettings.GetBool("services.zeroconf"))
  1197. {
  1198. CZeroconf::GetInstance()->Stop();
  1199. CZeroconf::GetInstance()->Start();
  1200. }
  1201. #ifdef HAS_AIRPLAY
  1202. else
  1203. {
  1204. g_application.StopAirplayServer(true);
  1205. g_guiSettings.SetBool("services.airplay", false);
  1206. CZeroconf::GetInstance()->Stop();
  1207. }
  1208. #endif
  1209. #endif
  1210. }
  1211. else if (strSetting.Equals("services.airplay"))
  1212. {
  1213. #ifdef HAS_AIRPLAY
  1214. if (g_guiSettings.GetBool("services.airplay"))
  1215. {
  1216. #ifdef HAS_ZEROCONF
  1217. // AirPlay needs zeroconf
  1218. if(!g_guiSettings.GetBool("services.zeroconf"))
  1219. {
  1220. g_guiSettings.SetBool("services.zeroconf", true);
  1221. CZeroconf::GetInstance()->Stop();
  1222. CZeroconf::GetInstance()->Start();
  1223. }
  1224. #endif //HAS_ZEROCONF
  1225. g_application.StartAirplayServer();//will stop the server before internal
  1226. }
  1227. else
  1228. g_application.StopAirplayServer(true);//will stop the server before internal
  1229. #endif//HAS_AIRPLAY
  1230. }
  1231. else if (strSetting.Equals("network.ipaddress"))
  1232. {
  1233. if (g_guiSettings.GetInt("network.assignment") == NETWORK_STATIC)
  1234. {
  1235. CStdString strDefault = g_guiSettings.GetString("network.ipaddress").Left(g_guiSettings.GetString("network.ipaddress").ReverseFind('.'))+".1";
  1236. if (g_guiSettings.GetString("network.gateway").Equals("0.0.0.0"))
  1237. g_guiSettings.SetString("network.gateway",strDefault);
  1238. if (g_guiSettings.GetString("network.dns").Equals("0.0.0.0"))
  1239. g_guiSettings.SetString("network.dns",strDefault);
  1240. }
  1241. }
  1242. else if (strSetting.Equals("network.httpproxyport"))
  1243. {
  1244. ValidatePortNumber(pSettingControl, "8080", "8080", false);
  1245. }
  1246. else if (strSetting.Equals("videoplayer.calibrate") || strSetting.Equals("videoscreen.guicalibration"))
  1247. { // activate the video calibration screen
  1248. g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION);
  1249. }
  1250. else if (strSetting.Equals("videoscreen.testpattern"))
  1251. { // activate the test pattern
  1252. g_windowManager.ActivateWindow(WINDOW_TEST_PATTERN);
  1253. }
  1254. else if (strSetting.Equals("subtitles.height"))
  1255. {
  1256. if (!CUtil::IsUsingTTFSubtitles())
  1257. {
  1258. CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
  1259. ((CSettingInt *)pSettingControl->GetSetting())->FromString(pControl->GetCurrentLabel());
  1260. }
  1261. }
  1262. else if (strSetting.Equals("subtitles.font"))
  1263. {
  1264. CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
  1265. CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
  1266. pSettingString->SetData(pControl->GetCurrentLabel());
  1267. CSetting *pSetting = (CSetting *)g_guiSettings.GetSetting("subtitles.height");
  1268. FillInSubtitleHeights(pSetting, (CGUISpinControlEx *)GetControl(GetSetting(pS

Large files files are truncated, but you can click here to view the full file