Refactor of the money tracker:

* Tracker now uses a scroll list (table) for improved convience and clarity
* Selective payments can be deleted and copied into clipboard in CSV format
* Added option to track payments even if the tracker window is closed
Ansariel 2015-03-03 12:41:06 +01:00
parent b5f4944ab5
commit 791fb13a5d
14 changed files with 292 additions and 97 deletions

View File

@ -300,6 +300,8 @@ public:
void setMaxSelectable(U32 max_selected) { mMaxSelectable = max_selected; }
S32 getMaxSelectable() { return mMaxSelectable; }
// <FS:Ansariel> Convenience method
LLScrollbar* getScrollbar() const { return mScrollbar; }
virtual S32 getScrollPos() const;
virtual void setScrollPos( S32 pos );

View File

@ -23171,6 +23171,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>1</integer>
</map>
<key>FSAlwaysTrackPayments</key>
<map>
<key>Comment</key>
<string>Always track payments even if the money tracker is closed</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>0</integer>
</map>
</map>
</llsd>

View File

@ -2,8 +2,9 @@
* @file fsmoneytracker.cpp
* @brief Tip Tracker Window
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
* Copyright (c) 2011 Arrehn Oberlander
* Copyright (c) 2015 Ansariel Hiller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,69 +19,84 @@
* 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
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "fschathistory.h"
#include "fsmoneytracker.h"
#include "llviewercontrol.h"
#include "llclipboard.h"
#include "llfloaterreg.h"
#include "llnamelistctrl.h"
#include "llslurl.h"
#include "lltrans.h"
#include "llviewercontrol.h"
FSMoneyTracker::FSMoneyTracker(const LLSD& seed)
: LLFloater(seed)
FSMoneyTracker::FSMoneyTracker(const LLSD& key)
: LLFloater(key)
{
}
FSMoneyTracker::~FSMoneyTracker()
{
if (mTransactionHistory)
mTransactionHistory->clear();
}
BOOL FSMoneyTracker::postBuild()
{
mTransactionHistory = getChild<FSChatHistory>("money_chat_history");
mTransactionHistory->clear();
mTransactionHistory = getChild<LLNameListCtrl>("payment_list");
mTransactionHistory->setContextMenu(&gFSMoneyTrackerListMenu);
clear();
// Button Actions
childSetAction("Clear", boost::bind(&FSMoneyTracker::clear,this));
childSetAction("Clear", boost::bind(&FSMoneyTracker::clear, this));
return TRUE;
}
void FSMoneyTracker::addMessage(const LLChat& chat,bool archive,const LLSD &args)
void FSMoneyTracker::onClose(bool app_quitting)
{
LLChat& tmp_chat = const_cast<LLChat&>(chat);
tmp_chat.mFromName = chat.mFromName;
LLSD chat_args = args;
chat_args["use_plain_text_chat_history"] = true;
chat_args["show_time"] = true;
if(tmp_chat.mTimeStr.empty())
tmp_chat.mTimeStr = appendTime();
mTransactionHistory->appendMessage(tmp_chat, chat_args);
if (!gSavedSettings.getBOOL("FSAlwaysTrackPayments"))
{
clear();
}
}
std::string FSMoneyTracker::appendTime()
void FSMoneyTracker::addPayment(const LLUUID other_id, bool is_group, S32 amount, bool incoming)
{
time_t utc_time;
utc_time = time_corrected();
std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:[" + LLTrans::getString("TimeMin")+"]";
// <FS:PP> Attempt to speed up things a little
// if (gSavedSettings.getBOOL("FSSecondsinChatTimestamps"))
static LLCachedControl<bool> FSSecondsinChatTimestamps(gSavedSettings, "FSSecondsinChatTimestamps");
if (FSSecondsinChatTimestamps)
// </FS:PP>
S32 scroll_pos = mTransactionHistory->getScrollPos();
bool at_end = mTransactionHistory->getScrollbar()->isAtEnd();
LLNameListCtrl::NameItem item_params;
item_params.value = other_id;
item_params.name = LLTrans::getString("AvatarNameWaiting");
item_params.target = is_group ? LLNameListCtrl::GROUP : LLNameListCtrl::INDIVIDUAL;
item_params.columns.add().column("time").value(getTime());
item_params.columns.add().column("name");
item_params.columns.add().column("amount")
.value((incoming ? amount : -amount))
.color(LLUIColorTable::instance().getColor((incoming ? "MoneyTrackerIncrease" : "MoneyTrackerDecrease")));
mTransactionHistory->addNameItemRow(item_params);
if (at_end)
{
timeStr += ":[" + LLTrans::getString("TimeSec")+"]";
mTransactionHistory->setScrollPos(scroll_pos + 1);
}
}
std::string FSMoneyTracker::getTime()
{
time_t utc_time = time_corrected();
std::string timeStr = "[" + LLTrans::getString("TimeHour") + "]:[" + LLTrans::getString("TimeMin") + "]";
if (gSavedSettings.getBOOL("FSSecondsinChatTimestamps"))
{
timeStr += ":[" + LLTrans::getString("TimeSec") + "]";
}
LLSD substitution;
substitution["datetime"] = (S32) utc_time;
LLStringUtil::format (timeStr, substitution);
substitution["datetime"] = (S32)utc_time;
LLStringUtil::format(timeStr, substitution);
return timeStr;
}
@ -88,5 +104,80 @@ std::string FSMoneyTracker::appendTime()
void FSMoneyTracker::clear()
{
LL_INFOS() << "Cleared." << LL_ENDL;
mTransactionHistory->clear();
mTransactionHistory->clearRows();
}
//////////////////////////////////////////////////////////////////////////////
// FSMoneyTrackerListMenu
//////////////////////////////////////////////////////////////////////////////
LLContextMenu* FSMoneyTrackerListMenu::createMenu()
{
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar;
registrar.add("MoneyTrackerList.Action", boost::bind(&FSMoneyTrackerListMenu::onContextMenuItemClick, this, _2));
enable_registrar.add("MoneyTrackerList.Enable", boost::bind(&FSMoneyTrackerListMenu::onContextMenuItemEnable, this, _2));
return createFromFile("menu_fs_moneytracker_list.xml");
}
void FSMoneyTrackerListMenu::onContextMenuItemClick(const LLSD& userdata)
{
std::string option = userdata.asString();
if (option == "copy")
{
FSMoneyTracker* floater = LLFloaterReg::findTypedInstance<FSMoneyTracker>("money_tracker");
if (floater)
{
std::string copy_text;
LLNameListCtrl* list = floater->getChild<LLNameListCtrl>("payment_list");
std::vector<LLScrollListItem*> selected = list->getAllSelected();
for (std::vector<LLScrollListItem*>::iterator it = selected.begin(); it != selected.end(); ++it)
{
const LLScrollListItem* item = *it;
copy_text += ( (copy_text.empty() ? "" : "\n")
+ item->getColumn(0)->getValue().asString() + ";"
+ item->getColumn(1)->getValue().asString() + ";"
+ item->getColumn(2)->getValue().asString()
);
}
if (!copy_text.empty())
{
LLClipboard::instance().copyToClipboard(utf8str_to_wstring(copy_text), 0, copy_text.size() );
}
}
}
else if (option == "delete")
{
FSMoneyTracker* floater = LLFloaterReg::findTypedInstance<FSMoneyTracker>("money_tracker");
if (floater)
{
std::string copy_text;
LLNameListCtrl* list = floater->getChild<LLNameListCtrl>("payment_list");
list->operateOnSelection(LLCtrlListInterface::OP_DELETE);
}
}
}
bool FSMoneyTrackerListMenu::onContextMenuItemEnable(const LLSD& userdata)
{
std::string item = userdata.asString();
if (item == "can_copy" || item == "can_delete")
{
FSMoneyTracker* floater = LLFloaterReg::findTypedInstance<FSMoneyTracker>("money_tracker");
if (floater)
{
LLNameListCtrl* list = floater->getChild<LLNameListCtrl>("payment_list");
return (list->getNumSelected() > 0);
}
}
return false;
}
FSMoneyTrackerListMenu gFSMoneyTrackerListMenu;

View File

@ -2,8 +2,9 @@
* @file fsmoneytracker.h
* @brief Tip Tracker Window
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* $LicenseInfo:firstyear=2011&license=viewerlgpl$
* Copyright (c) 2011 Arrehn Oberlander
* Copyright (c) 2015 Ansariel Hiller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -18,6 +19,9 @@
* 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
*
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
* http://www.firestormviewer.org
* $/LicenseInfo$
*/
@ -25,25 +29,35 @@
#define FS_MONEYTRACKER_H
#include "llfloater.h"
#include "lllistcontextmenu.h"
class LLNameListCtrl;
class FSChatHistory;
class LLChat;
class LLTextBox;
class LLViewerRegion;
class FSMoneyTracker: public LLFloater
{
public:
FSMoneyTracker(const LLSD& seed);
virtual ~FSMoneyTracker();
FSMoneyTracker(const LLSD& key);
virtual ~FSMoneyTracker() {};
virtual void onClose(bool app_quitting);
BOOL postBuild();
void addMessage(const LLChat& chat,bool archive,const LLSD &args);
void addPayment(const LLUUID other_id, bool is_group, S32 amount, bool incoming);
private:
void clear();
std::string appendTime();
FSChatHistory* mTransactionHistory;
std::string getTime();
LLNameListCtrl* mTransactionHistory;
};
class FSMoneyTrackerListMenu : public LLListContextMenu
{
public:
/*virtual*/ LLContextMenu* createMenu();
private:
void onContextMenuItemClick(const LLSD& userdata);
bool onContextMenuItemEnable(const LLSD& userdata);
};
extern FSMoneyTrackerListMenu gFSMoneyTrackerListMenu;
#endif // FS_MONEYTRACKER_H

View File

@ -6871,21 +6871,6 @@ static void money_balance_avatar_notify(const LLUUID& agent_id,
// Notification is either PaymentReceived or PaymentSent
LLNotificationsUtil::add(notification, args, payload);
}
//<AO> TipTracker Support
FSMoneyTracker* tipTracker = (FSMoneyTracker*)LLFloaterReg::getInstance("money_tracker");
if (tipTracker->isShown() || tipTracker->isMinimized())
{
args["MESSAGE"] = args["SLURLMESSAGE"]; // Always use slurl forms in money tracking
LLChat chat;
chat.mText = llformat(args["MESSAGE"].asString().c_str(), av_name.getCompleteName().c_str());
chat.mSourceType = CHAT_SOURCE_SYSTEM;
LLSD chat_args;
tipTracker->addMessage(chat,false,chat_args);
}
//</AO>
}
static void process_money_balance_reply_extended(LLMessageSystem* msg)
@ -6900,9 +6885,9 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
S32 amount = 0;
std::string item_description;
BOOL success = FALSE;
// Ansariel: If we output to chat history and probably console,
// don't create an SLURL for the name or we will end
// up with a SLURL in the console
// <FS:Ansariel> If we output to chat history and probably console,
// don't create an SLURL for the name or we will end
// up with a SLURL in the console
static LLCachedControl<bool> balance_change_in_chat(gSavedSettings, "FSPaymentInfoInChat");
msg->getS32("TransactionInfo", "TransactionType", transaction_type);
@ -7014,7 +6999,7 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
final_args["MESSAGE"] = message;
notification = "PaymentSent";
//<AO>: Additionally, always add a SLURL-enabled form.
// <FS:AO> Additionally, always add a SLURL-enabled form.
args["NAME"] = dest_slurl;
is_name_group = is_dest_group;
name_id = dest_id;
@ -7069,7 +7054,7 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
payload["from_id"] = source_id;
notification = "PaymentReceived";
//<AO>: Additionally, always add a SLURL-enabled form.
// <FS:AO> Additionally, always add a SLURL-enabled form.
args["NAME"] = source_slurl;
is_name_group = is_source_group;
name_id = source_id;
@ -7082,9 +7067,17 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg)
message = LLTrans::getString("paid_you_ldollars_no_reason", args);
}
final_args["SLURLMESSAGE"] = message;
//</AO>
// </FS:AO>
}
// <FS:Ansariel> TipTracker Support
FSMoneyTracker* tipTracker = LLFloaterReg::getTypedInstance<FSMoneyTracker>("money_tracker");
if ((tipTracker->isShown() || tipTracker->isMinimized()) || gSavedSettings.getBOOL("FSAlwaysTrackPayments"))
{
tipTracker->addPayment(name_id, is_name_group, amount, !you_paid_someone);
}
// </FS:Ansariel>>
// Despite using SLURLs, wait until the name is available before
// showing the notification, otherwise the UI layout is strange and
// the user sees a "Loading..." message

View File

@ -1339,4 +1339,10 @@
<color
name="Slidermark"
reference="EmphasisColor" />
<color
name="MoneyTrackerIncrease"
reference="Green" />
<color
name="MoneyTrackerDecrease"
reference="Red" />
</colors>

View File

@ -1339,4 +1339,10 @@
<color
name="Slidermark"
reference="EmphasisColor" />
<color
name="MoneyTrackerIncrease"
reference="Green" />
<color
name="MoneyTrackerDecrease"
reference="Red" />
</colors>

View File

@ -1294,4 +1294,10 @@
<color
name="Slidermark"
reference="DkGray" />
<color
name="MoneyTrackerIncrease"
reference="Green" />
<color
name="MoneyTrackerDecrease"
reference="Red" />
</colors>

View File

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<floater name="money_tracker" title="Tip-Tracker" width="250">
<fs_chat_history name="money_chat_history" width="248"/>
<button name="Clear" label="Löschen" width="242"/>
<floater name="money_tracker" title="Money-Tracker">
<name_list name="payment_list">
<name_list.columns name="time" label="Uhrzeit"/>
<name_list.columns name="name" label="Name"/>
<name_list.columns name="amount" label="Betrag"/>
</name_list>
<check_box label="Immer protokollieren" name="FSAlwaysTrackPayments" tool_tip="Zahlungen auch dann protokollieren, wenn der Money-Tracker geschlossen ist."/>
<button name="Clear" label="Löschen"/>
</floater>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<context_menu name="Money Tracker List Context Menu">
<menu_item_call label="Kopieren als CSV" name="Copy"/>
<menu_item_call label="Löschen" name="Delete"/>
</context_menu>

View File

@ -35,7 +35,7 @@
<menu_item_call label="Lag-Meter" name="Lag Meter"/>
<menu_item_call label="LSL-Brücke neu erstellen" name="Recreate LSL Bridge"/>
</menu>
<menu_item_call label="Tip-Tracker" name="money_tracker"/>
<menu_item_call label="Money-Tracker" name="money_tracker"/>
<menu_item_call label="Pose-Stand..." name="pose_stand"/>
<menu label="Hochladen" name="Upload">
<menu_item_call label="Bild ([COST])..." name="Upload Image"/>

View File

@ -2,31 +2,61 @@
<floater
name="money_tracker"
help_topic="fs_tip_tracker"
title="Tip Tracker"
title="Money Tracker"
width="200"
height="188"
height="200"
min_width="175"
min_height="175"
single_instance="true"
save_rect="true"
can_resize="true"
can_minimize="true"
can_close="true"
can_drag_on_left="false">
<fs_chat_history
font="SansSerifSmall"
follows="left|right|top|bottom"
height="155"
name="money_chat_history"
parse_highlights="true"
parse_urls="true"
left="1"
width="198">
</fs_chat_history>
<button
name="Clear"
label="Clear"
font="SansSerif"
mouse_opaque="true"
height="20"
width="192"
left="4"
follows="left|right|bottom"/>
<name_list
draw_heading="true"
follows="all"
bottom="-45"
layout="topleft"
left="4"
top="1"
sort_column="0"
sort_ascending="true"
name="payment_list"
draw_stripes="true"
multi_select="true"
name_column="name"
right="-1">
<name_list.columns
name="time"
label="Time"
width="50"/>
<name_list.columns
name="name"
label="Name"/>
<name_list.columns
name="amount"
label="Amount"
width="63"/>
</name_list>
<check_box
control_name="FSAlwaysTrackPayments"
follows="left|right|bottom"
height="16"
label="Track when closed"
layout="topleft"
name="FSAlwaysTrackPayments"
tool_tip="Always track payments, even if the money tracker is closed."
left="4"
right="-4"/>
<button
top_pad="1"
name="Clear"
label="Clear"
font="SansSerif"
mouse_opaque="true"
height="20"
width="192"
left="4"
follows="left|right|bottom"/>
</floater>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<context_menu
name="Money Tracker List Context Menu">
<menu_item_call
enabled="false"
label="Copy as CSV"
name="Copy">
<on_click
function="MoneyTrackerList.Action"
parameter="copy"/>
<on_enable
function="MoneyTrackerList.Enable"
parameter="can_copy"/>
</menu_item_call>
<menu_item_call
enabled="false"
label="Delete"
name="Delete">
<on_click
function="MoneyTrackerList.Action"
parameter="delete"/>
<on_enable
function="MoneyTrackerList.Enable"
parameter="can_delete"/>
</menu_item_call>
</context_menu>

View File

@ -290,7 +290,7 @@
</menu>
<menu_item_call
label="Tip Tracker"
label="Money Tracker"
name="money_tracker">
<menu_item_call.on_click
function="Floater.Toggle"