From 65e144d9fec4bb441050e73136ed95b48e6e363c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 2 Nov 2011 19:05:13 +0200 Subject: STORM-1580 WIP Initial commit for PO review. --- indra/newview/llpanelsnapshotprofile.cpp | 162 +++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 indra/newview/llpanelsnapshotprofile.cpp (limited to 'indra/newview/llpanelsnapshotprofile.cpp') diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp new file mode 100644 index 0000000000..80a379a5a0 --- /dev/null +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -0,0 +1,162 @@ +/** + * @file llpanelsnapshotprofile.cpp + * @brief Posts a snapshot to My Profile feed. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +// libs +#include "llcombobox.h" +#include "llfloaterreg.h" +#include "llpanel.h" +#include "llspinctrl.h" + +// newview +#include "llfloatersnapshot.h" +#include "llpanelsnapshot.h" +#include "llsidetraypanelcontainer.h" +#include "llwebprofile.h" + +/** + * Posts a snapshot to My Profile feed. + */ +class LLPanelSnapshotProfile +: public LLPanelSnapshot +{ + LOG_CLASS(LLPanelSnapshotProfile); + +public: + LLPanelSnapshotProfile(); + + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); + +private: + /*virtual*/ std::string getWidthSpinnerName() const { return "profile_snapshot_width"; } + /*virtual*/ std::string getHeightSpinnerName() const { return "profile_snapshot_height"; } + /*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; } + /*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; } + /*virtual*/ void updateControls(const LLSD& info); + + void updateCustomResControls(); ///< Enable/disable custom resolution controls (spinners and checkbox) + + void onSend(); + void onCancel(); + void onResolutionComboCommit(LLUICtrl* ctrl); + void onCustomResolutionCommit(LLUICtrl* ctrl); + void onKeepAspectRatioCommit(LLUICtrl* ctrl); +}; + +static LLRegisterPanelClassWrapper panel_class("llpanelsnapshotprofile"); + +LLPanelSnapshotProfile::LLPanelSnapshotProfile() +{ + mCommitCallbackRegistrar.add("PostToProfile.Send", boost::bind(&LLPanelSnapshotProfile::onSend, this)); + mCommitCallbackRegistrar.add("PostToProfile.Cancel", boost::bind(&LLPanelSnapshotProfile::onCancel, this)); +} + +// virtual +BOOL LLPanelSnapshotProfile::postBuild() +{ + getChild(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onResolutionComboCommit, this, _1)); + getChild(getWidthSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); + getChild(getHeightSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); + getChild(getAspectRatioCBName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onKeepAspectRatioCommit, this, _1)); + return TRUE; +} + +// virtual +void LLPanelSnapshotProfile::onOpen(const LLSD& key) +{ + updateCustomResControls(); +} + +// virtual +void LLPanelSnapshotProfile::updateControls(const LLSD& info) +{ + const bool have_snapshot = info.has("have-snapshot") ? info["have-snapshot"].asBoolean() : true; + getChild("post_btn")->setEnabled(have_snapshot); +} + +void LLPanelSnapshotProfile::updateCustomResControls() ///< Enable/disable custom resolution controls (spinners and checkbox) +{ + LLComboBox* combo = getChild(getImageSizeComboName()); + S32 selected_idx = combo->getFirstSelectedIndex(); + bool enable = selected_idx == 0 || selected_idx == (combo->getItemCount() - 1); // Current Window or Custom selected + + getChild(getWidthSpinnerName())->setEnabled(enable); + getChild(getWidthSpinnerName())->setAllowEdit(enable); + getChild(getHeightSpinnerName())->setEnabled(enable); + getChild(getHeightSpinnerName())->setAllowEdit(enable); + getChild(getAspectRatioCBName())->setEnabled(enable); +} + +void LLPanelSnapshotProfile::onSend() +{ + std::string caption = getChild("caption")->getValue().asString(); + bool add_location = getChild("add_location_cb")->getValue().asBoolean(); + + LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location); + LLFloaterSnapshot::postSave(); + + // Switch to upload progress display. + LLSideTrayPanelContainer* parent = getParentContainer(); + if (parent) + { + parent->openPanel("panel_post_progress", LLSD().with("post-type", "profile")); + } +} + +void LLPanelSnapshotProfile::onCancel() +{ + LLSideTrayPanelContainer* parent = getParentContainer(); + if (parent) + { + parent->openPreviousPanel(); + } +} + +void LLPanelSnapshotProfile::onResolutionComboCommit(LLUICtrl* ctrl) +{ + updateCustomResControls(); + + LLSD info; + info["combo-res-change"]["control-name"] = ctrl->getName(); + LLFloaterSnapshot::getInstance()->notify(info); +} + +void LLPanelSnapshotProfile::onCustomResolutionCommit(LLUICtrl* ctrl) +{ + S32 w = getChild(getWidthSpinnerName())->getValue().asInteger(); + S32 h = getChild(getHeightSpinnerName())->getValue().asInteger(); + LLSD info; + info["w"] = w; + info["h"] = h; + LLFloaterSnapshot::getInstance()->notify(LLSD().with("custom-res-change", info)); +} + +void LLPanelSnapshotProfile::onKeepAspectRatioCommit(LLUICtrl* ctrl) +{ + LLFloaterSnapshot::getInstance()->notify(LLSD().with("keep-aspect-change", ctrl->getValue().asBoolean())); +} -- cgit v1.2.3 From ce05b9f7e5347c28780b399efa70992cb7bf5229 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Thu, 3 Nov 2011 15:39:12 +0200 Subject: STORM-1580 WIP Implemented new "Working" and "Success/Failure" screens. --- indra/newview/llpanelsnapshotprofile.cpp | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'indra/newview/llpanelsnapshotprofile.cpp') diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index 80a379a5a0..33237fd84f 100644 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -62,7 +62,6 @@ private: void updateCustomResControls(); ///< Enable/disable custom resolution controls (spinners and checkbox) void onSend(); - void onCancel(); void onResolutionComboCommit(LLUICtrl* ctrl); void onCustomResolutionCommit(LLUICtrl* ctrl); void onKeepAspectRatioCommit(LLUICtrl* ctrl); @@ -73,7 +72,7 @@ static LLRegisterPanelClassWrapper panel_class("llpanels LLPanelSnapshotProfile::LLPanelSnapshotProfile() { mCommitCallbackRegistrar.add("PostToProfile.Send", boost::bind(&LLPanelSnapshotProfile::onSend, this)); - mCommitCallbackRegistrar.add("PostToProfile.Cancel", boost::bind(&LLPanelSnapshotProfile::onCancel, this)); + mCommitCallbackRegistrar.add("PostToProfile.Cancel", boost::bind(&LLPanelSnapshotProfile::cancel, this)); } // virtual @@ -83,13 +82,15 @@ BOOL LLPanelSnapshotProfile::postBuild() getChild(getWidthSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); getChild(getHeightSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); getChild(getAspectRatioCBName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onKeepAspectRatioCommit, this, _1)); - return TRUE; + + return LLPanelSnapshot::postBuild(); } // virtual void LLPanelSnapshotProfile::onOpen(const LLSD& key) { updateCustomResControls(); + LLPanelSnapshot::onOpen(key); } // virtual @@ -119,22 +120,6 @@ void LLPanelSnapshotProfile::onSend() LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location); LLFloaterSnapshot::postSave(); - - // Switch to upload progress display. - LLSideTrayPanelContainer* parent = getParentContainer(); - if (parent) - { - parent->openPanel("panel_post_progress", LLSD().with("post-type", "profile")); - } -} - -void LLPanelSnapshotProfile::onCancel() -{ - LLSideTrayPanelContainer* parent = getParentContainer(); - if (parent) - { - parent->openPreviousPanel(); - } } void LLPanelSnapshotProfile::onResolutionComboCommit(LLUICtrl* ctrl) -- cgit v1.2.3 From 3b3b6c38a4afe3a061c54cc9fa9f8d7c65dcb990 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 7 Nov 2011 15:12:22 +0200 Subject: STORM-1580 WIP Switched profile feed snapshot format to PNG for better clarity. --- indra/newview/llpanelsnapshotprofile.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llpanelsnapshotprofile.cpp') diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index 33237fd84f..e633049af8 100644 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -57,6 +57,7 @@ private: /*virtual*/ std::string getHeightSpinnerName() const { return "profile_snapshot_height"; } /*virtual*/ std::string getAspectRatioCBName() const { return "profile_keep_aspect_check"; } /*virtual*/ std::string getImageSizeComboName() const { return "profile_size_combo"; } + /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; } /*virtual*/ void updateControls(const LLSD& info); void updateCustomResControls(); ///< Enable/disable custom resolution controls (spinners and checkbox) -- cgit v1.2.3 From 84ff583717e6c55e5eb5d33ef19795adbf201521 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 7 Nov 2011 19:47:11 +0200 Subject: STORM-1690 FIXED Constrain Proportions option was broken. By the way: - Fixed a crash in the postcard floater (accessing destroyed buttons). - Minor code cleanups. --- indra/newview/llpanelsnapshotprofile.cpp | 48 -------------------------------- 1 file changed, 48 deletions(-) (limited to 'indra/newview/llpanelsnapshotprofile.cpp') diff --git a/indra/newview/llpanelsnapshotprofile.cpp b/indra/newview/llpanelsnapshotprofile.cpp index e633049af8..89245fc804 100644 --- a/indra/newview/llpanelsnapshotprofile.cpp +++ b/indra/newview/llpanelsnapshotprofile.cpp @@ -60,12 +60,7 @@ private: /*virtual*/ LLFloaterSnapshot::ESnapshotFormat getImageFormat() const { return LLFloaterSnapshot::SNAPSHOT_FORMAT_PNG; } /*virtual*/ void updateControls(const LLSD& info); - void updateCustomResControls(); ///< Enable/disable custom resolution controls (spinners and checkbox) - void onSend(); - void onResolutionComboCommit(LLUICtrl* ctrl); - void onCustomResolutionCommit(LLUICtrl* ctrl); - void onKeepAspectRatioCommit(LLUICtrl* ctrl); }; static LLRegisterPanelClassWrapper panel_class("llpanelsnapshotprofile"); @@ -79,18 +74,12 @@ LLPanelSnapshotProfile::LLPanelSnapshotProfile() // virtual BOOL LLPanelSnapshotProfile::postBuild() { - getChild(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onResolutionComboCommit, this, _1)); - getChild(getWidthSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); - getChild(getHeightSpinnerName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onCustomResolutionCommit, this, _1)); - getChild(getAspectRatioCBName())->setCommitCallback(boost::bind(&LLPanelSnapshotProfile::onKeepAspectRatioCommit, this, _1)); - return LLPanelSnapshot::postBuild(); } // virtual void LLPanelSnapshotProfile::onOpen(const LLSD& key) { - updateCustomResControls(); LLPanelSnapshot::onOpen(key); } @@ -101,19 +90,6 @@ void LLPanelSnapshotProfile::updateControls(const LLSD& info) getChild("post_btn")->setEnabled(have_snapshot); } -void LLPanelSnapshotProfile::updateCustomResControls() ///< Enable/disable custom resolution controls (spinners and checkbox) -{ - LLComboBox* combo = getChild(getImageSizeComboName()); - S32 selected_idx = combo->getFirstSelectedIndex(); - bool enable = selected_idx == 0 || selected_idx == (combo->getItemCount() - 1); // Current Window or Custom selected - - getChild(getWidthSpinnerName())->setEnabled(enable); - getChild(getWidthSpinnerName())->setAllowEdit(enable); - getChild(getHeightSpinnerName())->setEnabled(enable); - getChild(getHeightSpinnerName())->setAllowEdit(enable); - getChild(getAspectRatioCBName())->setEnabled(enable); -} - void LLPanelSnapshotProfile::onSend() { std::string caption = getChild("caption")->getValue().asString(); @@ -122,27 +98,3 @@ void LLPanelSnapshotProfile::onSend() LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location); LLFloaterSnapshot::postSave(); } - -void LLPanelSnapshotProfile::onResolutionComboCommit(LLUICtrl* ctrl) -{ - updateCustomResControls(); - - LLSD info; - info["combo-res-change"]["control-name"] = ctrl->getName(); - LLFloaterSnapshot::getInstance()->notify(info); -} - -void LLPanelSnapshotProfile::onCustomResolutionCommit(LLUICtrl* ctrl) -{ - S32 w = getChild(getWidthSpinnerName())->getValue().asInteger(); - S32 h = getChild(getHeightSpinnerName())->getValue().asInteger(); - LLSD info; - info["w"] = w; - info["h"] = h; - LLFloaterSnapshot::getInstance()->notify(LLSD().with("custom-res-change", info)); -} - -void LLPanelSnapshotProfile::onKeepAspectRatioCommit(LLUICtrl* ctrl) -{ - LLFloaterSnapshot::getInstance()->notify(LLSD().with("keep-aspect-change", ctrl->getValue().asBoolean())); -} -- cgit v1.2.3