PageRenderTime 37ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llpanelsnapshotprofile.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 101 lines | 53 code | 15 blank | 33 comment | 0 complexity | b97f82ecda40a80594109fd3bf3ac1f4 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llpanelsnapshotprofile.cpp
  3. * @brief Posts a snapshot to My Profile feed.
  4. *
  5. * $LicenseInfo:firstyear=2011&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2011, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. // libs
  28. #include "llcombobox.h"
  29. #include "llfloaterreg.h"
  30. #include "llpanel.h"
  31. #include "llspinctrl.h"
  32. // newview
  33. #include "llfloatersnapshot.h"
  34. #include "llpanelsnapshot.h"
  35. #include "llsidetraypanelcontainer.h"
  36. #include "llwebprofile.h"
  37. /**
  38. * Posts a snapshot to My Profile feed.
  39. */
  40. class LLPanelSnapshotProfile
  41. : public LLPanelSnapshot
  42. {
  43. LOG_CLASS(LLPanelSnapshotProfile);
  44. public:
  45. LLPanelSnapshotProfile();
  46. /*virtual*/ BOOL postBuild();
  47. /*virtual*/ void onOpen(const LLSD& key);
  48. private:
  49. /*virtual*/ std::string getWidthSpinnerName() const { return "profile_snapshot_width"; }
  50. /*virtual*/ std::string getHeightSpinnerName() const { return "profile_snapshot_height"; }
  51. /*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; }
  52. /*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; }
  53. /*virtual*/ std::string getImageSizePanelName() const { return "profile_image_size_lp"; }
  54. /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; }
  55. /*virtual*/ void updateControls(const LLSD& info);
  56. void onSend();
  57. };
  58. static LLRegisterPanelClassWrapper<LLPanelSnapshotProfile> panel_class("llpanelsnapshotprofile");
  59. LLPanelSnapshotProfile::LLPanelSnapshotProfile()
  60. {
  61. mCommitCallbackRegistrar.add("PostToProfile.Send", boost::bind(&LLPanelSnapshotProfile::onSend, this));
  62. mCommitCallbackRegistrar.add("PostToProfile.Cancel", boost::bind(&LLPanelSnapshotProfile::cancel, this));
  63. }
  64. // virtual
  65. BOOL LLPanelSnapshotProfile::postBuild()
  66. {
  67. return LLPanelSnapshot::postBuild();
  68. }
  69. // virtual
  70. void LLPanelSnapshotProfile::onOpen(const LLSD& key)
  71. {
  72. LLPanelSnapshot::onOpen(key);
  73. }
  74. // virtual
  75. void LLPanelSnapshotProfile::updateControls(const LLSD& info)
  76. {
  77. const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
  78. getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot);
  79. }
  80. void LLPanelSnapshotProfile::onSend()
  81. {
  82. std::string caption = getChild<LLUICtrl>("caption")->getValue().asString();
  83. bool add_location = getChild<LLUICtrl>("add_location_cb")->getValue().asBoolean();
  84. LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location);
  85. LLFloaterSnapshot::postSave();
  86. }