PageRenderTime 582ms CodeModel.GetById 209ms app.highlight 82ms RepoModel.GetById 181ms app.codeStats 1ms

/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
  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
 27#include "llviewerprecompiledheaders.h"
 28
 29// libs
 30#include "llcombobox.h"
 31#include "llfloaterreg.h"
 32#include "llpanel.h"
 33#include "llspinctrl.h"
 34
 35// newview
 36#include "llfloatersnapshot.h"
 37#include "llpanelsnapshot.h"
 38#include "llsidetraypanelcontainer.h"
 39#include "llwebprofile.h"
 40
 41/**
 42 * Posts a snapshot to My Profile feed.
 43 */
 44class LLPanelSnapshotProfile
 45:	public LLPanelSnapshot
 46{
 47	LOG_CLASS(LLPanelSnapshotProfile);
 48
 49public:
 50	LLPanelSnapshotProfile();
 51
 52	/*virtual*/ BOOL postBuild();
 53	/*virtual*/ void onOpen(const LLSD& key);
 54
 55private:
 56	/*virtual*/ std::string getWidthSpinnerName() const		{ return "profile_snapshot_width"; }
 57	/*virtual*/ std::string getHeightSpinnerName() const	{ return "profile_snapshot_height"; }
 58	/*virtual*/ std::string getAspectRatioCBName() const	{ return "profile_keep_aspect_check"; }
 59	/*virtual*/ std::string getImageSizeComboName() const	{ return "profile_size_combo"; }
 60	/*virtual*/ std::string getImageSizePanelName() const	{ return "profile_image_size_lp"; }
 61	/*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; }
 62	/*virtual*/ void updateControls(const LLSD& info);
 63
 64	void onSend();
 65};
 66
 67static LLRegisterPanelClassWrapper<LLPanelSnapshotProfile> panel_class("llpanelsnapshotprofile");
 68
 69LLPanelSnapshotProfile::LLPanelSnapshotProfile()
 70{
 71	mCommitCallbackRegistrar.add("PostToProfile.Send",		boost::bind(&LLPanelSnapshotProfile::onSend,		this));
 72	mCommitCallbackRegistrar.add("PostToProfile.Cancel",	boost::bind(&LLPanelSnapshotProfile::cancel,		this));
 73}
 74
 75// virtual
 76BOOL LLPanelSnapshotProfile::postBuild()
 77{
 78	return LLPanelSnapshot::postBuild();
 79}
 80
 81// virtual
 82void LLPanelSnapshotProfile::onOpen(const LLSD& key)
 83{
 84	LLPanelSnapshot::onOpen(key);
 85}
 86
 87// virtual
 88void LLPanelSnapshotProfile::updateControls(const LLSD& info)
 89{
 90	const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true;
 91	getChild<LLUICtrl>("post_btn")->setEnabled(have_snapshot);
 92}
 93
 94void LLPanelSnapshotProfile::onSend()
 95{
 96	std::string caption = getChild<LLUICtrl>("caption")->getValue().asString();
 97	bool add_location = getChild<LLUICtrl>("add_location_cb")->getValue().asBoolean();
 98
 99	LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location);
100	LLFloaterSnapshot::postSave();
101}