PageRenderTime 363ms CodeModel.GetById 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llsidepaneltaskinfo.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1266 lines | 984 code | 152 blank | 130 comment | 178 complexity | 2bace816b3f7cb00d1da4e2e284c53f2 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llsidepaneltaskinfo.cpp
  3. * @brief LLSidepanelTaskInfo class implementation
  4. * This class represents the panel in the build view for
  5. * viewing/editing object names, owners, permissions, etc.
  6. *
  7. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "llviewerprecompiledheaders.h"
  29. #include "llsidepaneltaskinfo.h"
  30. #include "lluuid.h"
  31. #include "llpermissions.h"
  32. #include "llcategory.h"
  33. #include "llclickaction.h"
  34. #include "llfocusmgr.h"
  35. #include "llnotificationsutil.h"
  36. #include "llstring.h"
  37. #include "llviewerwindow.h"
  38. #include "llresmgr.h"
  39. #include "lltextbox.h"
  40. #include "llbutton.h"
  41. #include "llcheckboxctrl.h"
  42. #include "llviewerobject.h"
  43. #include "llselectmgr.h"
  44. #include "llagent.h"
  45. #include "llstatusbar.h" // for getBalance()
  46. #include "lllineeditor.h"
  47. #include "llcombobox.h"
  48. #include "lluiconstants.h"
  49. #include "lldbstrings.h"
  50. #include "llfloatergroups.h"
  51. #include "llfloaterreg.h"
  52. #include "llavataractions.h"
  53. #include "llnamebox.h"
  54. #include "llviewercontrol.h"
  55. #include "llviewermenu.h"
  56. #include "lluictrlfactory.h"
  57. #include "llspinctrl.h"
  58. #include "roles_constants.h"
  59. #include "llgroupactions.h"
  60. ///----------------------------------------------------------------------------
  61. /// Class llsidepaneltaskinfo
  62. ///----------------------------------------------------------------------------
  63. LLSidepanelTaskInfo* LLSidepanelTaskInfo::sActivePanel = NULL;
  64. static LLRegisterPanelClassWrapper<LLSidepanelTaskInfo> t_task_info("sidepanel_task_info");
  65. // Default constructor
  66. LLSidepanelTaskInfo::LLSidepanelTaskInfo()
  67. {
  68. setMouseOpaque(FALSE);
  69. LLSelectMgr::instance().mUpdateSignal.connect(boost::bind(&LLSidepanelTaskInfo::refreshAll, this));
  70. }
  71. LLSidepanelTaskInfo::~LLSidepanelTaskInfo()
  72. {
  73. if (sActivePanel == this)
  74. sActivePanel = NULL;
  75. }
  76. // virtual
  77. BOOL LLSidepanelTaskInfo::postBuild()
  78. {
  79. LLSidepanelInventorySubpanel::postBuild();
  80. mOpenBtn = getChild<LLButton>("open_btn");
  81. mOpenBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onOpenButtonClicked, this));
  82. mPayBtn = getChild<LLButton>("pay_btn");
  83. mPayBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onPayButtonClicked, this));
  84. mBuyBtn = getChild<LLButton>("buy_btn");
  85. mBuyBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuyButtonClicked, this));
  86. mDetailsBtn = getChild<LLButton>("details_btn");
  87. mDetailsBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onDetailsButtonClicked, this));
  88. mLabelGroupName = getChild<LLNameBox>("Group Name Proxy");
  89. childSetCommitCallback("Object Name", LLSidepanelTaskInfo::onCommitName,this);
  90. getChild<LLLineEditor>("Object Name")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
  91. childSetCommitCallback("Object Description", LLSidepanelTaskInfo::onCommitDesc,this);
  92. getChild<LLLineEditor>("Object Description")->setPrevalidate(LLTextValidate::validateASCIIPrintableNoPipe);
  93. getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLSidepanelTaskInfo::onClickGroup,this));
  94. childSetCommitCallback("checkbox share with group", &LLSidepanelTaskInfo::onCommitGroupShare,this);
  95. childSetAction("button deed", &LLSidepanelTaskInfo::onClickDeedToGroup,this);
  96. childSetCommitCallback("checkbox allow everyone move", &LLSidepanelTaskInfo::onCommitEveryoneMove,this);
  97. childSetCommitCallback("checkbox allow everyone copy", &LLSidepanelTaskInfo::onCommitEveryoneCopy,this);
  98. childSetCommitCallback("checkbox for sale", &LLSidepanelTaskInfo::onCommitSaleInfo,this);
  99. childSetCommitCallback("sale type", &LLSidepanelTaskInfo::onCommitSaleType,this);
  100. childSetCommitCallback("Edit Cost", &LLSidepanelTaskInfo::onCommitSaleInfo, this);
  101. childSetCommitCallback("checkbox next owner can modify", &LLSidepanelTaskInfo::onCommitNextOwnerModify,this);
  102. childSetCommitCallback("checkbox next owner can copy", &LLSidepanelTaskInfo::onCommitNextOwnerCopy,this);
  103. childSetCommitCallback("checkbox next owner can transfer", &LLSidepanelTaskInfo::onCommitNextOwnerTransfer,this);
  104. childSetCommitCallback("clickaction", &LLSidepanelTaskInfo::onCommitClickAction,this);
  105. childSetCommitCallback("search_check", &LLSidepanelTaskInfo::onCommitIncludeInSearch,this);
  106. mDAPermModify = getChild<LLUICtrl>("perm_modify");
  107. mDACreator = getChildView("Creator:");
  108. mDACreatorName = getChild<LLUICtrl>("Creator Name");
  109. mDAOwner = getChildView("Owner:");
  110. mDAOwnerName = getChild<LLUICtrl>("Owner Name");
  111. mDAGroup = getChildView("Group:");
  112. mDAGroupName = getChild<LLUICtrl>("Group Name");
  113. mDAButtonSetGroup = getChildView("button set group");
  114. mDAObjectName = getChild<LLUICtrl>("Object Name");
  115. mDAName = getChildView("Name:");
  116. mDADescription = getChildView("Description:");
  117. mDAObjectDescription = getChild<LLUICtrl>("Object Description");
  118. mDAPermissions = getChildView("Permissions:");
  119. mDACheckboxShareWithGroup = getChild<LLUICtrl>("checkbox share with group");
  120. mDAButtonDeed = getChildView("button deed");
  121. mDACheckboxAllowEveryoneMove = getChild<LLUICtrl>("checkbox allow everyone move");
  122. mDACheckboxAllowEveryoneCopy = getChild<LLUICtrl>("checkbox allow everyone copy");
  123. mDANextOwnerCan = getChildView("Next owner can:");
  124. mDACheckboxNextOwnerCanModify = getChild<LLUICtrl>("checkbox next owner can modify");
  125. mDACheckboxNextOwnerCanCopy = getChild<LLUICtrl>("checkbox next owner can copy");
  126. mDACheckboxNextOwnerCanTransfer = getChild<LLUICtrl>("checkbox next owner can transfer");
  127. mDACheckboxForSale = getChild<LLUICtrl>("checkbox for sale");
  128. mDASearchCheck = getChild<LLUICtrl>("search_check");
  129. mDAComboSaleType = getChild<LLComboBox>("sale type");
  130. mDACost = getChild<LLUICtrl>("Cost");
  131. mDAEditCost = getChild<LLUICtrl>("Edit Cost");
  132. mDALabelClickAction = getChildView("label click action");
  133. mDAComboClickAction = getChild<LLComboBox>("clickaction");
  134. mDAB = getChildView("B:");
  135. mDAO = getChildView("O:");
  136. mDAG = getChildView("G:");
  137. mDAE = getChildView("E:");
  138. mDAN = getChildView("N:");
  139. mDAF = getChildView("F:");
  140. return TRUE;
  141. }
  142. /*virtual*/ void LLSidepanelTaskInfo::handleVisibilityChange ( BOOL visible )
  143. {
  144. if (visible)
  145. {
  146. sActivePanel = this;
  147. mObject = getFirstSelectedObject();
  148. }
  149. else
  150. {
  151. sActivePanel = NULL;
  152. // drop selection reference
  153. mObjectSelection = NULL;
  154. }
  155. }
  156. void LLSidepanelTaskInfo::disableAll()
  157. {
  158. mDAPermModify->setEnabled(FALSE);
  159. mDAPermModify->setValue(LLStringUtil::null);
  160. mDACreator->setEnabled(FALSE);
  161. mDACreatorName->setValue(LLStringUtil::null);
  162. mDACreatorName->setEnabled(FALSE);
  163. mDAOwner->setEnabled(FALSE);
  164. mDAOwnerName->setValue(LLStringUtil::null);
  165. mDAOwnerName->setEnabled(FALSE);
  166. mDAGroup->setEnabled(FALSE);
  167. mDAGroupName->setValue(LLStringUtil::null);
  168. mDAGroupName->setEnabled(FALSE);
  169. mDAButtonSetGroup->setEnabled(FALSE);
  170. mDAObjectName->setValue(LLStringUtil::null);
  171. mDAObjectName->setEnabled(FALSE);
  172. mDAName->setEnabled(FALSE);
  173. mDAGroupName->setValue(LLStringUtil::null);
  174. mDAGroupName->setEnabled(FALSE);
  175. mDADescription->setEnabled(FALSE);
  176. mDAObjectDescription->setValue(LLStringUtil::null);
  177. mDAObjectDescription->setEnabled(FALSE);
  178. mDAPermissions->setEnabled(FALSE);
  179. mDACheckboxShareWithGroup->setValue(FALSE);
  180. mDACheckboxShareWithGroup->setEnabled(FALSE);
  181. mDAButtonDeed->setEnabled(FALSE);
  182. mDACheckboxAllowEveryoneMove->setValue(FALSE);
  183. mDACheckboxAllowEveryoneMove->setEnabled(FALSE);
  184. mDACheckboxAllowEveryoneCopy->setValue(FALSE);
  185. mDACheckboxAllowEveryoneCopy->setEnabled(FALSE);
  186. //Next owner can:
  187. mDANextOwnerCan->setEnabled(FALSE);
  188. mDACheckboxNextOwnerCanModify->setValue(FALSE);
  189. mDACheckboxNextOwnerCanModify->setEnabled(FALSE);
  190. mDACheckboxNextOwnerCanCopy->setValue(FALSE);
  191. mDACheckboxNextOwnerCanCopy->setEnabled(FALSE);
  192. mDACheckboxNextOwnerCanTransfer->setValue(FALSE);
  193. mDACheckboxNextOwnerCanTransfer->setEnabled(FALSE);
  194. //checkbox for sale
  195. mDACheckboxForSale->setValue(FALSE);
  196. mDACheckboxForSale->setEnabled(FALSE);
  197. //checkbox include in search
  198. mDASearchCheck->setValue(FALSE);
  199. mDASearchCheck->setEnabled(FALSE);
  200. mDAComboSaleType->setValue(LLSaleInfo::FS_COPY);
  201. mDAComboSaleType->setEnabled(FALSE);
  202. mDACost->setEnabled(FALSE);
  203. mDACost->setValue(getString("Cost Default"));
  204. mDAEditCost->setValue(LLStringUtil::null);
  205. mDAEditCost->setEnabled(FALSE);
  206. mDALabelClickAction->setEnabled(FALSE);
  207. if (mDAComboClickAction)
  208. {
  209. mDAComboClickAction->setEnabled(FALSE);
  210. mDAComboClickAction->clear();
  211. }
  212. mDAB->setVisible(FALSE);
  213. mDAO->setVisible(FALSE);
  214. mDAG->setVisible(FALSE);
  215. mDAE->setVisible(FALSE);
  216. mDAN->setVisible(FALSE);
  217. mDAF->setVisible(FALSE);
  218. mOpenBtn->setEnabled(FALSE);
  219. mPayBtn->setEnabled(FALSE);
  220. mBuyBtn->setEnabled(FALSE);
  221. }
  222. void LLSidepanelTaskInfo::refresh()
  223. {
  224. LLButton* btn_deed_to_group = getChild<LLButton>("button deed");
  225. if (btn_deed_to_group)
  226. {
  227. std::string deedText;
  228. if (gWarningSettings.getBOOL("DeedObject"))
  229. {
  230. deedText = getString("text deed continued");
  231. }
  232. else
  233. {
  234. deedText = getString("text deed");
  235. }
  236. btn_deed_to_group->setLabelSelected(deedText);
  237. btn_deed_to_group->setLabelUnselected(deedText);
  238. }
  239. BOOL root_selected = TRUE;
  240. LLSelectNode* nodep = mObjectSelection->getFirstRootNode();
  241. S32 object_count = mObjectSelection->getRootObjectCount();
  242. if (!nodep || (object_count == 0))
  243. {
  244. nodep = mObjectSelection->getFirstNode();
  245. object_count = mObjectSelection->getObjectCount();
  246. root_selected = FALSE;
  247. }
  248. LLViewerObject* objectp = NULL;
  249. if (nodep)
  250. {
  251. objectp = nodep->getObject();
  252. }
  253. // ...nothing selected
  254. if (!nodep || !objectp)
  255. {
  256. disableAll();
  257. return;
  258. }
  259. // figure out a few variables
  260. const BOOL is_one_object = (object_count == 1);
  261. // BUG: fails if a root and non-root are both single-selected.
  262. const BOOL is_perm_modify = (mObjectSelection->getFirstRootNode() && LLSelectMgr::getInstance()->selectGetRootsModify()) ||
  263. LLSelectMgr::getInstance()->selectGetModify();
  264. S32 string_index = 0;
  265. std::string MODIFY_INFO_STRINGS[] =
  266. {
  267. getString("text modify info 1"),
  268. getString("text modify info 2"),
  269. getString("text modify info 3"),
  270. getString("text modify info 4")
  271. };
  272. if (!is_perm_modify)
  273. {
  274. string_index += 2;
  275. }
  276. if (!is_one_object)
  277. {
  278. ++string_index;
  279. }
  280. getChildView("perm_modify")->setEnabled(TRUE);
  281. getChild<LLUICtrl>("perm_modify")->setValue(MODIFY_INFO_STRINGS[string_index]);
  282. getChildView("Permissions:")->setEnabled(TRUE);
  283. // Update creator text field
  284. getChildView("Creator:")->setEnabled(TRUE);
  285. BOOL creators_identical;
  286. std::string creator_name;
  287. creators_identical = LLSelectMgr::getInstance()->selectGetCreator(mCreatorID,
  288. creator_name);
  289. getChild<LLUICtrl>("Creator Name")->setValue(creator_name);
  290. getChildView("Creator Name")->setEnabled(TRUE);
  291. // Update owner text field
  292. getChildView("Owner:")->setEnabled(TRUE);
  293. std::string owner_name;
  294. const BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(mOwnerID, owner_name);
  295. if (mOwnerID.isNull())
  296. {
  297. if (LLSelectMgr::getInstance()->selectIsGroupOwned())
  298. {
  299. // Group owned already displayed by selectGetOwner
  300. }
  301. else
  302. {
  303. // Display last owner if public
  304. std::string last_owner_name;
  305. LLSelectMgr::getInstance()->selectGetLastOwner(mLastOwnerID, last_owner_name);
  306. // It should never happen that the last owner is null and the owner
  307. // is null, but it seems to be a bug in the simulator right now. JC
  308. if (!mLastOwnerID.isNull() && !last_owner_name.empty())
  309. {
  310. owner_name.append(", last ");
  311. owner_name.append(last_owner_name);
  312. }
  313. }
  314. }
  315. getChild<LLUICtrl>("Owner Name")->setValue(owner_name);
  316. getChildView("Owner Name")->setEnabled(TRUE);
  317. // update group text field
  318. getChildView("Group:")->setEnabled(TRUE);
  319. getChild<LLUICtrl>("Group Name")->setValue(LLStringUtil::null);
  320. LLUUID group_id;
  321. BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
  322. if (groups_identical)
  323. {
  324. if (mLabelGroupName)
  325. {
  326. mLabelGroupName->setNameID(group_id,TRUE);
  327. mLabelGroupName->setEnabled(TRUE);
  328. }
  329. }
  330. else
  331. {
  332. if (mLabelGroupName)
  333. {
  334. mLabelGroupName->setNameID(LLUUID::null, TRUE);
  335. mLabelGroupName->refresh(LLUUID::null, std::string(), true);
  336. mLabelGroupName->setEnabled(FALSE);
  337. }
  338. }
  339. getChildView("button set group")->setEnabled(owners_identical && (mOwnerID == gAgent.getID()));
  340. getChildView("Name:")->setEnabled(TRUE);
  341. LLLineEditor* LineEditorObjectName = getChild<LLLineEditor>("Object Name");
  342. getChildView("Description:")->setEnabled(TRUE);
  343. LLLineEditor* LineEditorObjectDesc = getChild<LLLineEditor>("Object Description");
  344. if (is_one_object)
  345. {
  346. if (!LineEditorObjectName->hasFocus())
  347. {
  348. getChild<LLUICtrl>("Object Name")->setValue(nodep->mName);
  349. }
  350. if (LineEditorObjectDesc)
  351. {
  352. if (!LineEditorObjectDesc->hasFocus())
  353. {
  354. LineEditorObjectDesc->setText(nodep->mDescription);
  355. }
  356. }
  357. }
  358. else
  359. {
  360. getChild<LLUICtrl>("Object Name")->setValue(LLStringUtil::null);
  361. LineEditorObjectDesc->setText(LLStringUtil::null);
  362. }
  363. // figure out the contents of the name, description, & category
  364. BOOL edit_name_desc = FALSE;
  365. if (is_one_object && objectp->permModify())
  366. {
  367. edit_name_desc = TRUE;
  368. }
  369. if (edit_name_desc)
  370. {
  371. getChildView("Object Name")->setEnabled(TRUE);
  372. getChildView("Object Description")->setEnabled(TRUE);
  373. }
  374. else
  375. {
  376. getChildView("Object Name")->setEnabled(FALSE);
  377. getChildView("Object Description")->setEnabled(FALSE);
  378. }
  379. S32 total_sale_price = 0;
  380. S32 individual_sale_price = 0;
  381. BOOL is_for_sale_mixed = FALSE;
  382. BOOL is_sale_price_mixed = FALSE;
  383. U32 num_for_sale = FALSE;
  384. LLSelectMgr::getInstance()->selectGetAggregateSaleInfo(num_for_sale,
  385. is_for_sale_mixed,
  386. is_sale_price_mixed,
  387. total_sale_price,
  388. individual_sale_price);
  389. const BOOL self_owned = (gAgent.getID() == mOwnerID);
  390. const BOOL group_owned = LLSelectMgr::getInstance()->selectIsGroupOwned() ;
  391. const BOOL public_owned = (mOwnerID.isNull() && !LLSelectMgr::getInstance()->selectIsGroupOwned());
  392. const BOOL can_transfer = LLSelectMgr::getInstance()->selectGetRootsTransfer();
  393. const BOOL can_copy = LLSelectMgr::getInstance()->selectGetRootsCopy();
  394. if (!owners_identical)
  395. {
  396. getChildView("Cost")->setEnabled(FALSE);
  397. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  398. getChildView("Edit Cost")->setEnabled(FALSE);
  399. }
  400. // You own these objects.
  401. else if (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id,GP_OBJECT_SET_SALE)))
  402. {
  403. // If there are multiple items for sale then set text to PRICE PER UNIT.
  404. if (num_for_sale > 1)
  405. {
  406. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Per Unit"));
  407. }
  408. else
  409. {
  410. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  411. }
  412. LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
  413. if (!edit_price->hasFocus())
  414. {
  415. // If the sale price is mixed then set the cost to MIXED, otherwise
  416. // set to the actual cost.
  417. if ((num_for_sale > 0) && is_for_sale_mixed)
  418. {
  419. edit_price->setTentative(TRUE);
  420. }
  421. else if ((num_for_sale > 0) && is_sale_price_mixed)
  422. {
  423. edit_price->setTentative(TRUE);
  424. }
  425. else
  426. {
  427. edit_price->setValue(individual_sale_price);
  428. }
  429. }
  430. // The edit fields are only enabled if you can sell this object
  431. // and the sale price is not mixed.
  432. BOOL enable_edit = (num_for_sale && can_transfer) ? !is_for_sale_mixed : FALSE;
  433. getChildView("Cost")->setEnabled(enable_edit);
  434. getChildView("Edit Cost")->setEnabled(enable_edit);
  435. }
  436. // Someone, not you, owns these objects.
  437. else if (!public_owned)
  438. {
  439. getChildView("Cost")->setEnabled(FALSE);
  440. getChildView("Edit Cost")->setEnabled(FALSE);
  441. // Don't show a price if none of the items are for sale.
  442. if (num_for_sale)
  443. getChild<LLUICtrl>("Edit Cost")->setValue(llformat("%d",total_sale_price));
  444. else
  445. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  446. // If multiple items are for sale, set text to TOTAL PRICE.
  447. if (num_for_sale > 1)
  448. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Total"));
  449. else
  450. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  451. }
  452. // This is a public object.
  453. else
  454. {
  455. getChildView("Cost")->setEnabled(FALSE);
  456. getChild<LLUICtrl>("Cost")->setValue(getString("Cost Default"));
  457. getChild<LLUICtrl>("Edit Cost")->setValue(LLStringUtil::null);
  458. getChildView("Edit Cost")->setEnabled(FALSE);
  459. }
  460. // Enable and disable the permissions checkboxes
  461. // based on who owns the object.
  462. // TODO: Creator permissions
  463. U32 base_mask_on = 0;
  464. U32 base_mask_off = 0;
  465. U32 owner_mask_off = 0;
  466. U32 owner_mask_on = 0;
  467. U32 group_mask_on = 0;
  468. U32 group_mask_off = 0;
  469. U32 everyone_mask_on = 0;
  470. U32 everyone_mask_off = 0;
  471. U32 next_owner_mask_on = 0;
  472. U32 next_owner_mask_off = 0;
  473. BOOL valid_base_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_BASE,
  474. &base_mask_on,
  475. &base_mask_off);
  476. //BOOL valid_owner_perms =//
  477. LLSelectMgr::getInstance()->selectGetPerm(PERM_OWNER,
  478. &owner_mask_on,
  479. &owner_mask_off);
  480. BOOL valid_group_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_GROUP,
  481. &group_mask_on,
  482. &group_mask_off);
  483. BOOL valid_everyone_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_EVERYONE,
  484. &everyone_mask_on,
  485. &everyone_mask_off);
  486. BOOL valid_next_perms = LLSelectMgr::getInstance()->selectGetPerm(PERM_NEXT_OWNER,
  487. &next_owner_mask_on,
  488. &next_owner_mask_off);
  489. if (gSavedSettings.getBOOL("DebugPermissions") )
  490. {
  491. if (valid_base_perms)
  492. {
  493. getChild<LLUICtrl>("B:")->setValue("B: " + mask_to_string(base_mask_on));
  494. getChildView("B:")->setVisible( TRUE);
  495. getChild<LLUICtrl>("O:")->setValue("O: " + mask_to_string(owner_mask_on));
  496. getChildView("O:")->setVisible( TRUE);
  497. getChild<LLUICtrl>("G:")->setValue("G: " + mask_to_string(group_mask_on));
  498. getChildView("G:")->setVisible( TRUE);
  499. getChild<LLUICtrl>("E:")->setValue("E: " + mask_to_string(everyone_mask_on));
  500. getChildView("E:")->setVisible( TRUE);
  501. getChild<LLUICtrl>("N:")->setValue("N: " + mask_to_string(next_owner_mask_on));
  502. getChildView("N:")->setVisible( TRUE);
  503. }
  504. U32 flag_mask = 0x0;
  505. if (objectp->permMove()) flag_mask |= PERM_MOVE;
  506. if (objectp->permModify()) flag_mask |= PERM_MODIFY;
  507. if (objectp->permCopy()) flag_mask |= PERM_COPY;
  508. if (objectp->permTransfer()) flag_mask |= PERM_TRANSFER;
  509. getChild<LLUICtrl>("F:")->setValue("F:" + mask_to_string(flag_mask));
  510. getChildView("F:")->setVisible( TRUE);
  511. }
  512. else
  513. {
  514. getChildView("B:")->setVisible( FALSE);
  515. getChildView("O:")->setVisible( FALSE);
  516. getChildView("G:")->setVisible( FALSE);
  517. getChildView("E:")->setVisible( FALSE);
  518. getChildView("N:")->setVisible( FALSE);
  519. getChildView("F:")->setVisible( FALSE);
  520. }
  521. BOOL has_change_perm_ability = FALSE;
  522. BOOL has_change_sale_ability = FALSE;
  523. if (valid_base_perms &&
  524. (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_MANIPULATE))))
  525. {
  526. has_change_perm_ability = TRUE;
  527. }
  528. if (valid_base_perms &&
  529. (self_owned || (group_owned && gAgent.hasPowerInGroup(group_id, GP_OBJECT_SET_SALE))))
  530. {
  531. has_change_sale_ability = TRUE;
  532. }
  533. if (!has_change_perm_ability && !has_change_sale_ability && !root_selected)
  534. {
  535. // ...must select root to choose permissions
  536. getChild<LLUICtrl>("perm_modify")->setValue(getString("text modify warning"));
  537. }
  538. if (has_change_perm_ability)
  539. {
  540. getChildView("checkbox share with group")->setEnabled(TRUE);
  541. getChildView("checkbox allow everyone move")->setEnabled(owner_mask_on & PERM_MOVE);
  542. getChildView("checkbox allow everyone copy")->setEnabled(owner_mask_on & PERM_COPY && owner_mask_on & PERM_TRANSFER);
  543. }
  544. else
  545. {
  546. getChildView("checkbox share with group")->setEnabled(FALSE);
  547. getChildView("checkbox allow everyone move")->setEnabled(FALSE);
  548. getChildView("checkbox allow everyone copy")->setEnabled(FALSE);
  549. }
  550. if (has_change_sale_ability && (owner_mask_on & PERM_TRANSFER))
  551. {
  552. getChildView("checkbox for sale")->setEnabled(can_transfer || (!can_transfer && num_for_sale));
  553. // Set the checkbox to tentative if the prices of each object selected
  554. // are not the same.
  555. getChild<LLUICtrl>("checkbox for sale")->setTentative( is_for_sale_mixed);
  556. getChildView("sale type")->setEnabled(num_for_sale && can_transfer && !is_sale_price_mixed);
  557. getChildView("Next owner can:")->setEnabled(TRUE);
  558. getChildView("checkbox next owner can modify")->setEnabled(base_mask_on & PERM_MODIFY);
  559. getChildView("checkbox next owner can copy")->setEnabled(base_mask_on & PERM_COPY);
  560. getChildView("checkbox next owner can transfer")->setEnabled(next_owner_mask_on & PERM_COPY);
  561. }
  562. else
  563. {
  564. getChildView("checkbox for sale")->setEnabled(FALSE);
  565. getChildView("sale type")->setEnabled(FALSE);
  566. getChildView("Next owner can:")->setEnabled(FALSE);
  567. getChildView("checkbox next owner can modify")->setEnabled(FALSE);
  568. getChildView("checkbox next owner can copy")->setEnabled(FALSE);
  569. getChildView("checkbox next owner can transfer")->setEnabled(FALSE);
  570. }
  571. if (valid_group_perms)
  572. {
  573. if ((group_mask_on & PERM_COPY) && (group_mask_on & PERM_MODIFY) && (group_mask_on & PERM_MOVE))
  574. {
  575. getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
  576. getChild<LLUICtrl>("checkbox share with group")->setTentative( FALSE);
  577. getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
  578. }
  579. else if ((group_mask_off & PERM_COPY) && (group_mask_off & PERM_MODIFY) && (group_mask_off & PERM_MOVE))
  580. {
  581. getChild<LLUICtrl>("checkbox share with group")->setValue(FALSE);
  582. getChild<LLUICtrl>("checkbox share with group")->setTentative( FALSE);
  583. getChildView("button deed")->setEnabled(FALSE);
  584. }
  585. else
  586. {
  587. getChild<LLUICtrl>("checkbox share with group")->setValue(TRUE);
  588. getChild<LLUICtrl>("checkbox share with group")->setTentative( TRUE);
  589. getChildView("button deed")->setEnabled(gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED) && (group_mask_on & PERM_MOVE) && (owner_mask_on & PERM_TRANSFER) && !group_owned && can_transfer);
  590. }
  591. }
  592. if (valid_everyone_perms)
  593. {
  594. // Move
  595. if (everyone_mask_on & PERM_MOVE)
  596. {
  597. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
  598. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( FALSE);
  599. }
  600. else if (everyone_mask_off & PERM_MOVE)
  601. {
  602. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(FALSE);
  603. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( FALSE);
  604. }
  605. else
  606. {
  607. getChild<LLUICtrl>("checkbox allow everyone move")->setValue(TRUE);
  608. getChild<LLUICtrl>("checkbox allow everyone move")->setTentative( TRUE);
  609. }
  610. // Copy == everyone can't copy
  611. if (everyone_mask_on & PERM_COPY)
  612. {
  613. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
  614. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( !can_copy || !can_transfer);
  615. }
  616. else if (everyone_mask_off & PERM_COPY)
  617. {
  618. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(FALSE);
  619. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( FALSE);
  620. }
  621. else
  622. {
  623. getChild<LLUICtrl>("checkbox allow everyone copy")->setValue(TRUE);
  624. getChild<LLUICtrl>("checkbox allow everyone copy")->setTentative( TRUE);
  625. }
  626. }
  627. if (valid_next_perms)
  628. {
  629. // Modify == next owner canot modify
  630. if (next_owner_mask_on & PERM_MODIFY)
  631. {
  632. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
  633. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( FALSE);
  634. }
  635. else if (next_owner_mask_off & PERM_MODIFY)
  636. {
  637. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(FALSE);
  638. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( FALSE);
  639. }
  640. else
  641. {
  642. getChild<LLUICtrl>("checkbox next owner can modify")->setValue(TRUE);
  643. getChild<LLUICtrl>("checkbox next owner can modify")->setTentative( TRUE);
  644. }
  645. // Copy == next owner cannot copy
  646. if (next_owner_mask_on & PERM_COPY)
  647. {
  648. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
  649. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( !can_copy);
  650. }
  651. else if (next_owner_mask_off & PERM_COPY)
  652. {
  653. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(FALSE);
  654. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( FALSE);
  655. }
  656. else
  657. {
  658. getChild<LLUICtrl>("checkbox next owner can copy")->setValue(TRUE);
  659. getChild<LLUICtrl>("checkbox next owner can copy")->setTentative( TRUE);
  660. }
  661. // Transfer == next owner cannot transfer
  662. if (next_owner_mask_on & PERM_TRANSFER)
  663. {
  664. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
  665. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( !can_transfer);
  666. }
  667. else if (next_owner_mask_off & PERM_TRANSFER)
  668. {
  669. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(FALSE);
  670. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( FALSE);
  671. }
  672. else
  673. {
  674. getChild<LLUICtrl>("checkbox next owner can transfer")->setValue(TRUE);
  675. getChild<LLUICtrl>("checkbox next owner can transfer")->setTentative( TRUE);
  676. }
  677. }
  678. // reflect sale information
  679. LLSaleInfo sale_info;
  680. BOOL valid_sale_info = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
  681. LLSaleInfo::EForSale sale_type = sale_info.getSaleType();
  682. LLComboBox* combo_sale_type = getChild<LLComboBox>("sale type");
  683. if (valid_sale_info)
  684. {
  685. combo_sale_type->setValue( sale_type == LLSaleInfo::FS_NOT ? LLSaleInfo::FS_COPY : sale_type);
  686. combo_sale_type->setTentative( FALSE); // unfortunately this doesn't do anything at the moment.
  687. }
  688. else
  689. {
  690. // default option is sell copy, determined to be safest
  691. combo_sale_type->setValue( LLSaleInfo::FS_COPY);
  692. combo_sale_type->setTentative( TRUE); // unfortunately this doesn't do anything at the moment.
  693. }
  694. getChild<LLUICtrl>("checkbox for sale")->setValue((num_for_sale != 0));
  695. // HACK: There are some old objects in world that are set for sale,
  696. // but are no-transfer. We need to let users turn for-sale off, but only
  697. // if for-sale is set.
  698. bool cannot_actually_sell = !can_transfer || (!can_copy && sale_type == LLSaleInfo::FS_COPY);
  699. if (cannot_actually_sell)
  700. {
  701. if (num_for_sale && has_change_sale_ability)
  702. {
  703. getChildView("checkbox for sale")->setEnabled(true);
  704. }
  705. }
  706. // Check search status of objects
  707. const BOOL all_volume = LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME );
  708. bool include_in_search;
  709. const BOOL all_include_in_search = LLSelectMgr::getInstance()->selectionGetIncludeInSearch(&include_in_search);
  710. getChildView("search_check")->setEnabled(has_change_sale_ability && all_volume);
  711. getChild<LLUICtrl>("search_check")->setValue(include_in_search);
  712. getChild<LLUICtrl>("search_check")->setTentative( !all_include_in_search);
  713. // Click action (touch, sit, buy)
  714. U8 click_action = 0;
  715. if (LLSelectMgr::getInstance()->selectionGetClickAction(&click_action))
  716. {
  717. LLComboBox* ComboClickAction = getChild<LLComboBox>("clickaction");
  718. if (ComboClickAction)
  719. {
  720. ComboClickAction->setCurrentByIndex((S32)click_action);
  721. }
  722. }
  723. getChildView("label click action")->setEnabled(is_perm_modify && all_volume);
  724. getChildView("clickaction")->setEnabled(is_perm_modify && all_volume);
  725. if (!getIsEditing())
  726. {
  727. const std::string no_item_names[] =
  728. {
  729. "Object Name",
  730. "Object Description",
  731. "button set group",
  732. "checkbox share with group",
  733. "button deed",
  734. "checkbox allow everyone move",
  735. "checkbox allow everyone copy",
  736. "checkbox for sale",
  737. "sale type",
  738. "Edit Cost",
  739. "checkbox next owner can modify",
  740. "checkbox next owner can copy",
  741. "checkbox next owner can transfer",
  742. "clickaction",
  743. "search_check",
  744. "perm_modify",
  745. "Group Name",
  746. };
  747. for (size_t t=0; t<LL_ARRAY_SIZE(no_item_names); ++t)
  748. {
  749. getChildView(no_item_names[t])->setEnabled( FALSE);
  750. }
  751. }
  752. updateVerbs();
  753. }
  754. // static
  755. void LLSidepanelTaskInfo::onClickClaim(void*)
  756. {
  757. // try to claim ownership
  758. LLSelectMgr::getInstance()->sendOwner(gAgent.getID(), gAgent.getGroupID());
  759. }
  760. // static
  761. void LLSidepanelTaskInfo::onClickRelease(void*)
  762. {
  763. // try to release ownership
  764. LLSelectMgr::getInstance()->sendOwner(LLUUID::null, LLUUID::null);
  765. }
  766. void LLSidepanelTaskInfo::onClickGroup()
  767. {
  768. LLUUID owner_id;
  769. std::string name;
  770. BOOL owners_identical = LLSelectMgr::getInstance()->selectGetOwner(owner_id, name);
  771. LLFloater* parent_floater = gFloaterView->getParentFloater(this);
  772. if (owners_identical && (owner_id == gAgent.getID()))
  773. {
  774. LLFloaterGroupPicker* fg = LLFloaterReg::showTypedInstance<LLFloaterGroupPicker>("group_picker", LLSD(gAgent.getID()));
  775. if (fg)
  776. {
  777. fg->setSelectGroupCallback( boost::bind(&LLSidepanelTaskInfo::cbGroupID, this, _1) );
  778. if (parent_floater)
  779. {
  780. LLRect new_rect = gFloaterView->findNeighboringPosition(parent_floater, fg);
  781. fg->setOrigin(new_rect.mLeft, new_rect.mBottom);
  782. parent_floater->addDependentFloater(fg);
  783. }
  784. }
  785. }
  786. }
  787. void LLSidepanelTaskInfo::cbGroupID(LLUUID group_id)
  788. {
  789. if (mLabelGroupName)
  790. {
  791. mLabelGroupName->setNameID(group_id, TRUE);
  792. }
  793. LLSelectMgr::getInstance()->sendGroup(group_id);
  794. }
  795. static bool callback_deed_to_group(const LLSD& notification, const LLSD& response)
  796. {
  797. const S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  798. if (option == 0)
  799. {
  800. LLUUID group_id;
  801. const BOOL groups_identical = LLSelectMgr::getInstance()->selectGetGroup(group_id);
  802. if (group_id.notNull() && groups_identical && (gAgent.hasPowerInGroup(group_id, GP_OBJECT_DEED)))
  803. {
  804. LLSelectMgr::getInstance()->sendOwner(LLUUID::null, group_id, FALSE);
  805. // LLViewerStats::getInstance()->incStat(LLViewerStats::ST_RELEASE_COUNT);
  806. }
  807. }
  808. return FALSE;
  809. }
  810. void LLSidepanelTaskInfo::onClickDeedToGroup(void *data)
  811. {
  812. LLNotificationsUtil::add("DeedObjectToGroup", LLSD(), LLSD(), callback_deed_to_group);
  813. }
  814. ///----------------------------------------------------------------------------
  815. /// Permissions checkboxes
  816. ///----------------------------------------------------------------------------
  817. // static
  818. void LLSidepanelTaskInfo::onCommitPerm(LLUICtrl *ctrl, void *data, U8 field, U32 perm)
  819. {
  820. LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject();
  821. if(!object) return;
  822. // Checkbox will have toggled itself
  823. // LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
  824. LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
  825. BOOL new_state = check->get();
  826. LLSelectMgr::getInstance()->selectionSetObjectPermissions(field, new_state, perm);
  827. }
  828. // static
  829. void LLSidepanelTaskInfo::onCommitGroupShare(LLUICtrl *ctrl, void *data)
  830. {
  831. onCommitPerm(ctrl, data, PERM_GROUP, PERM_MODIFY | PERM_MOVE | PERM_COPY);
  832. }
  833. // static
  834. void LLSidepanelTaskInfo::onCommitEveryoneMove(LLUICtrl *ctrl, void *data)
  835. {
  836. onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_MOVE);
  837. }
  838. // static
  839. void LLSidepanelTaskInfo::onCommitEveryoneCopy(LLUICtrl *ctrl, void *data)
  840. {
  841. onCommitPerm(ctrl, data, PERM_EVERYONE, PERM_COPY);
  842. }
  843. // static
  844. void LLSidepanelTaskInfo::onCommitNextOwnerModify(LLUICtrl* ctrl, void* data)
  845. {
  846. //llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerModify" << llendl;
  847. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_MODIFY);
  848. }
  849. // static
  850. void LLSidepanelTaskInfo::onCommitNextOwnerCopy(LLUICtrl* ctrl, void* data)
  851. {
  852. //llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerCopy" << llendl;
  853. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_COPY);
  854. }
  855. // static
  856. void LLSidepanelTaskInfo::onCommitNextOwnerTransfer(LLUICtrl* ctrl, void* data)
  857. {
  858. //llinfos << "LLSidepanelTaskInfo::onCommitNextOwnerTransfer" << llendl;
  859. onCommitPerm(ctrl, data, PERM_NEXT_OWNER, PERM_TRANSFER);
  860. }
  861. // static
  862. void LLSidepanelTaskInfo::onCommitName(LLUICtrl*, void* data)
  863. {
  864. //llinfos << "LLSidepanelTaskInfo::onCommitName()" << llendl;
  865. LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
  866. LLLineEditor* tb = self->getChild<LLLineEditor>("Object Name");
  867. if(tb)
  868. {
  869. LLSelectMgr::getInstance()->selectionSetObjectName(tb->getText());
  870. // LLSelectMgr::getInstance()->selectionSetObjectName(self->mLabelObjectName->getText());
  871. }
  872. }
  873. // static
  874. void LLSidepanelTaskInfo::onCommitDesc(LLUICtrl*, void* data)
  875. {
  876. //llinfos << "LLSidepanelTaskInfo::onCommitDesc()" << llendl;
  877. LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
  878. LLLineEditor* le = self->getChild<LLLineEditor>("Object Description");
  879. if(le)
  880. {
  881. LLSelectMgr::getInstance()->selectionSetObjectDescription(le->getText());
  882. }
  883. }
  884. // static
  885. void LLSidepanelTaskInfo::onCommitSaleInfo(LLUICtrl*, void* data)
  886. {
  887. LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
  888. self->setAllSaleInfo();
  889. }
  890. // static
  891. void LLSidepanelTaskInfo::onCommitSaleType(LLUICtrl*, void* data)
  892. {
  893. LLSidepanelTaskInfo* self = (LLSidepanelTaskInfo*)data;
  894. self->setAllSaleInfo();
  895. }
  896. void LLSidepanelTaskInfo::setAllSaleInfo()
  897. {
  898. LLSaleInfo::EForSale sale_type = LLSaleInfo::FS_NOT;
  899. LLCheckBoxCtrl *checkPurchase = getChild<LLCheckBoxCtrl>("checkbox for sale");
  900. // Set the sale type if the object(s) are for sale.
  901. if(checkPurchase && checkPurchase->get())
  902. {
  903. sale_type = static_cast<LLSaleInfo::EForSale>(getChild<LLComboBox>("sale type")->getValue().asInteger());
  904. }
  905. S32 price = -1;
  906. LLSpinCtrl *edit_price = getChild<LLSpinCtrl>("Edit Cost");
  907. price = (edit_price->getTentative()) ? DEFAULT_PRICE : edit_price->getValue().asInteger();
  908. // If somehow an invalid price, turn the sale off.
  909. if (price < 0)
  910. sale_type = LLSaleInfo::FS_NOT;
  911. LLSaleInfo old_sale_info;
  912. LLSelectMgr::getInstance()->selectGetSaleInfo(old_sale_info);
  913. LLSaleInfo new_sale_info(sale_type, price);
  914. LLSelectMgr::getInstance()->selectionSetObjectSaleInfo(new_sale_info);
  915. U8 old_click_action = 0;
  916. LLSelectMgr::getInstance()->selectionGetClickAction(&old_click_action);
  917. if (old_sale_info.isForSale()
  918. && !new_sale_info.isForSale()
  919. && old_click_action == CLICK_ACTION_BUY)
  920. {
  921. // If turned off for-sale, make sure click-action buy is turned
  922. // off as well
  923. LLSelectMgr::getInstance()->
  924. selectionSetClickAction(CLICK_ACTION_TOUCH);
  925. }
  926. else if (new_sale_info.isForSale()
  927. && !old_sale_info.isForSale()
  928. && old_click_action == CLICK_ACTION_TOUCH)
  929. {
  930. // If just turning on for-sale, preemptively turn on one-click buy
  931. // unless user have a different click action set
  932. LLSelectMgr::getInstance()->
  933. selectionSetClickAction(CLICK_ACTION_BUY);
  934. }
  935. }
  936. struct LLSelectionPayable : public LLSelectedObjectFunctor
  937. {
  938. virtual bool apply(LLViewerObject* obj)
  939. {
  940. // can pay if you or your parent has money() event in script
  941. LLViewerObject* parent = (LLViewerObject*)obj->getParent();
  942. return (obj->flagTakesMoney() ||
  943. (parent && parent->flagTakesMoney()));
  944. }
  945. };
  946. static U8 string_value_to_click_action(std::string p_value)
  947. {
  948. if (p_value == "Touch")
  949. return CLICK_ACTION_TOUCH;
  950. if (p_value == "Sit")
  951. return CLICK_ACTION_SIT;
  952. if (p_value == "Buy")
  953. return CLICK_ACTION_BUY;
  954. if (p_value == "Pay")
  955. return CLICK_ACTION_PAY;
  956. if (p_value == "Open")
  957. return CLICK_ACTION_OPEN;
  958. if (p_value == "Zoom")
  959. return CLICK_ACTION_ZOOM;
  960. return CLICK_ACTION_TOUCH;
  961. }
  962. // static
  963. void LLSidepanelTaskInfo::onCommitClickAction(LLUICtrl* ctrl, void*)
  964. {
  965. LLComboBox* box = (LLComboBox*)ctrl;
  966. if (!box) return;
  967. std::string value = box->getValue().asString();
  968. U8 click_action = string_value_to_click_action(value);
  969. doClickAction(click_action);
  970. }
  971. // static
  972. void LLSidepanelTaskInfo::doClickAction(U8 click_action)
  973. {
  974. if (click_action == CLICK_ACTION_BUY)
  975. {
  976. LLSaleInfo sale_info;
  977. LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info);
  978. if (!sale_info.isForSale())
  979. {
  980. LLNotificationsUtil::add("CantSetBuyObject");
  981. // Set click action back to its old value
  982. U8 click_action = 0;
  983. LLSelectMgr::getInstance()->selectionGetClickAction(&click_action);
  984. // box->setCurrentByIndex((S32)click_action);
  985. return;
  986. }
  987. }
  988. else if (click_action == CLICK_ACTION_PAY)
  989. {
  990. // Verify object has script with money() handler
  991. LLSelectionPayable payable;
  992. bool can_pay = LLSelectMgr::getInstance()->getSelection()->applyToObjects(&payable);
  993. if (!can_pay)
  994. {
  995. // Warn, but do it anyway.
  996. LLNotificationsUtil::add("ClickActionNotPayable");
  997. }
  998. }
  999. LLSelectMgr::getInstance()->selectionSetClickAction(click_action);
  1000. }
  1001. // static
  1002. void LLSidepanelTaskInfo::onCommitIncludeInSearch(LLUICtrl* ctrl, void* data)
  1003. {
  1004. LLCheckBoxCtrl* box = (LLCheckBoxCtrl*)ctrl;
  1005. llassert(box);
  1006. LLSelectMgr::getInstance()->selectionSetIncludeInSearch(box->get());
  1007. }
  1008. // virtual
  1009. void LLSidepanelTaskInfo::updateVerbs()
  1010. {
  1011. LLSidepanelInventorySubpanel::updateVerbs();
  1012. /*
  1013. mOpenBtn->setVisible(!getIsEditing());
  1014. mPayBtn->setVisible(!getIsEditing());
  1015. mBuyBtn->setVisible(!getIsEditing());
  1016. //const LLViewerObject *obj = getFirstSelectedObject();
  1017. //mEditBtn->setEnabled(obj && obj->permModify());
  1018. */
  1019. LLSafeHandle<LLObjectSelection> object_selection = LLSelectMgr::getInstance()->getSelection();
  1020. const BOOL any_selected = (object_selection->getNumNodes() > 0);
  1021. mOpenBtn->setVisible(true);
  1022. mPayBtn->setVisible(true);
  1023. mBuyBtn->setVisible(true);
  1024. mDetailsBtn->setVisible(true);
  1025. mOpenBtn->setEnabled(enable_object_open());
  1026. mPayBtn->setEnabled(enable_pay_object());
  1027. mBuyBtn->setEnabled(enable_buy_object());
  1028. mDetailsBtn->setEnabled(any_selected);
  1029. }
  1030. void LLSidepanelTaskInfo::onOpenButtonClicked()
  1031. {
  1032. if (enable_object_open())
  1033. {
  1034. handle_object_open();
  1035. }
  1036. }
  1037. void LLSidepanelTaskInfo::onPayButtonClicked()
  1038. {
  1039. doClickAction(CLICK_ACTION_PAY);
  1040. }
  1041. void LLSidepanelTaskInfo::onBuyButtonClicked()
  1042. {
  1043. doClickAction(CLICK_ACTION_BUY);
  1044. }
  1045. void LLSidepanelTaskInfo::onDetailsButtonClicked()
  1046. {
  1047. LLFloaterReg::showInstance("inspect", LLSD());
  1048. }
  1049. // virtual
  1050. void LLSidepanelTaskInfo::save()
  1051. {
  1052. onCommitGroupShare(getChild<LLCheckBoxCtrl>("checkbox share with group"), this);
  1053. onCommitEveryoneMove(getChild<LLCheckBoxCtrl>("checkbox allow everyone move"), this);
  1054. onCommitEveryoneCopy(getChild<LLCheckBoxCtrl>("checkbox allow everyone copy"), this);
  1055. onCommitNextOwnerModify(getChild<LLCheckBoxCtrl>("checkbox next owner can modify"), this);
  1056. onCommitNextOwnerCopy(getChild<LLCheckBoxCtrl>("checkbox next owner can copy"), this);
  1057. onCommitNextOwnerTransfer(getChild<LLCheckBoxCtrl>("checkbox next owner can transfer"), this);
  1058. onCommitName(getChild<LLLineEditor>("Object Name"), this);
  1059. onCommitDesc(getChild<LLLineEditor>("Object Description"), this);
  1060. onCommitSaleInfo(NULL, this);
  1061. onCommitSaleType(NULL, this);
  1062. onCommitIncludeInSearch(getChild<LLCheckBoxCtrl>("search_check"), this);
  1063. }
  1064. // removes keyboard focus so that all fields can be updated
  1065. // and then restored focus
  1066. void LLSidepanelTaskInfo::refreshAll()
  1067. {
  1068. // update UI as soon as we have an object
  1069. // but remove keyboard focus first so fields are free to update
  1070. LLFocusableElement* focus = NULL;
  1071. if (hasFocus())
  1072. {
  1073. focus = gFocusMgr.getKeyboardFocus();
  1074. setFocus(FALSE);
  1075. }
  1076. refresh();
  1077. if (focus)
  1078. {
  1079. focus->setFocus(TRUE);
  1080. }
  1081. }
  1082. void LLSidepanelTaskInfo::setObjectSelection(LLObjectSelectionHandle selection)
  1083. {
  1084. mObjectSelection = selection;
  1085. refreshAll();
  1086. }
  1087. LLSidepanelTaskInfo* LLSidepanelTaskInfo::getActivePanel()
  1088. {
  1089. return sActivePanel;
  1090. }
  1091. LLViewerObject* LLSidepanelTaskInfo::getObject()
  1092. {
  1093. if (!mObject->isDead())
  1094. return mObject;
  1095. return NULL;
  1096. }
  1097. LLViewerObject* LLSidepanelTaskInfo::getFirstSelectedObject()
  1098. {
  1099. LLSelectNode *node = mObjectSelection->getFirstRootNode();
  1100. if (node)
  1101. {
  1102. return node->getObject();
  1103. }
  1104. return NULL;
  1105. }
  1106. const LLUUID& LLSidepanelTaskInfo::getSelectedUUID()
  1107. {
  1108. const LLViewerObject* obj = getFirstSelectedObject();
  1109. if (obj)
  1110. {
  1111. return obj->getID();
  1112. }
  1113. return LLUUID::null;
  1114. }