llprefsskins.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * @file llprefsskins.cpp
  3. * @brief General preferences panel in preferences floater
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "llprefsskins.h"
  34. #include "llbutton.h"
  35. #include "lldir.h"
  36. #include "llradiogroup.h"
  37. #include "lluictrlfactory.h"
  38. #include "llviewercontrol.h"
  39. LLPrefSkins::LLPrefSkins()
  40. {
  41. LLUICtrlFactory::getInstance()->buildPanel(this,
  42. "panel_preferences_skins.xml");
  43. }
  44. bool LLPrefSkins::postBuild()
  45. {
  46. mSkinsSelector = getChild<LLRadioGroup>("skin_selection");
  47. mSkinsSelector->setCommitCallback(onSelectSkin);
  48. mSkinsSelector->setCallbackUserData(this);
  49. if (!gDirUtil.hasSkin("custom"))
  50. {
  51. LLRadioCtrl* radiop = mSkinsSelector->getRadioButton(3);
  52. if (radiop)
  53. {
  54. radiop->setEnabled(false);
  55. }
  56. if (gSavedSettings.getString("SkinCurrent") == "custom")
  57. {
  58. llwarns << "Skin 'custom' does not exist, switching to default skin."
  59. << llendl;
  60. gSavedSettings.setString("SkinCurrent", "default");
  61. }
  62. }
  63. childSetAction("classic_preview", onClickClassic, this);
  64. childSetAction("silver_preview", onClickSilver, this);
  65. childSetAction("dark_preview", onClickDark, this);
  66. refresh();
  67. return true;
  68. }
  69. void LLPrefSkins::refresh()
  70. {
  71. mSkin = gSavedSettings.getString("SkinCurrent");
  72. mSkinsSelector->setValue(mSkin);
  73. }
  74. void LLPrefSkins::apply()
  75. {
  76. if (mSkin != gSavedSettings.getString("SkinCurrent"))
  77. {
  78. gNotifications.add("ChangeSkin");
  79. refresh();
  80. }
  81. }
  82. void LLPrefSkins::cancel()
  83. {
  84. // Reverts any changes to current skin
  85. gSavedSettings.setString("SkinCurrent", mSkin);
  86. }
  87. //static
  88. void LLPrefSkins::onSelectSkin(LLUICtrl* ctrl, void* data)
  89. {
  90. std::string skin_selection = ctrl->getValue().asString();
  91. gSavedSettings.setString("SkinCurrent", skin_selection);
  92. }
  93. //static
  94. void LLPrefSkins::onClickClassic(void* data)
  95. {
  96. LLPrefSkins* self = (LLPrefSkins*)data;
  97. gSavedSettings.setString("SkinCurrent", "default");
  98. self->mSkinsSelector->setValue("default");
  99. }
  100. //static
  101. void LLPrefSkins::onClickSilver(void* data)
  102. {
  103. LLPrefSkins* self = (LLPrefSkins*)data;
  104. gSavedSettings.setString("SkinCurrent", "silver");
  105. self->mSkinsSelector->setValue("silver");
  106. }
  107. //static
  108. void LLPrefSkins::onClickDark(void* data)
  109. {
  110. LLPrefSkins* self = (LLPrefSkins*)data;
  111. gSavedSettings.setString("SkinCurrent", "dark");
  112. self->mSkinsSelector->setValue("dark");
  113. }