Support for Timezone switching in Teleport History
- Added FSTPHistoryTZ variable - overrides the utc variable in datetime setting. - Adds menu to LLTEleportHistoryPanel gear menu - modifies behaviour of LLTeleportHistoryPanel::getNextTab to use TZ watershedsmeow-7.2.2
parent
ec4e09c910
commit
8be7e412ef
|
|
@ -353,6 +353,17 @@
|
|||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
<key>FSTPHistoryTZ</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Select the timezone to be used with Teleport History. ('utc' = default, 'slt' = Second Life Time, 'local' = the local timezone of the client)</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>String</string>
|
||||
<key>Value</key>
|
||||
<string>utc</string>
|
||||
</map>
|
||||
<key>ShowStreamMetadata</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@
|
|||
#include "lllandmarkactions.h"
|
||||
#include "llclipboard.h"
|
||||
#include "lltrans.h"
|
||||
|
||||
//<FS:Beq [timezone support for teleport history]>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
//</FS:Beq>
|
||||
#include "llviewercontrol.h"
|
||||
|
||||
#include "fsfloaterplacedetails.h"
|
||||
|
|
@ -254,6 +256,13 @@ std::string LLTeleportHistoryFlatItem::getTimestamp()
|
|||
LLSD args;
|
||||
args["datetime"] = date.secondsSinceEpoch();
|
||||
timestamp = getString("DateFmt");
|
||||
//<FS:Beq [timezone support for teleport history]>
|
||||
// Check whether we have an override for the timezone
|
||||
static const std::string xml_timezone = "utc"; // In case we decide to change the XML default !
|
||||
static LLCachedControl<std::string> sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ");
|
||||
boost::replace_all(timestamp, xml_timezone, sFSTPHistoryTZ());
|
||||
LL_DEBUGS() << "Replacement DateFmt: " << timestamp << LL_ENDL;
|
||||
//</FS:Beq>
|
||||
LLStringUtil::format(timestamp, args);
|
||||
// </FS:Ansariel>
|
||||
|
||||
|
|
@ -510,6 +519,10 @@ LLTeleportHistoryPanel::LLTeleportHistoryPanel()
|
|||
mIsStandAlone(false)
|
||||
// </FS:Ansariel>
|
||||
{
|
||||
// <FS:Beq> [timezone support for teleport history]
|
||||
mCommitCallbackRegistrar.add("TeleportHistory.TimeZone.Set", boost::bind(&LLTeleportHistoryPanel::onTimeZoneChecked, this, _2));
|
||||
mEnableCallbackRegistrar.add("TeleportHistory.TimeZone.Check", boost::bind(&LLTeleportHistoryPanel::isTimeZoneChecked, this, _2));
|
||||
// </FS:Beq>
|
||||
buildFromFile( "panel_teleport_history.xml");
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +594,6 @@ BOOL LLTeleportHistoryPanel::postBuild()
|
|||
registrar.add("TeleportHistory.CollapseAllFolders", boost::bind(&LLTeleportHistoryPanel::onCollapseAllFolders, this));
|
||||
registrar.add("TeleportHistory.ClearTeleportHistory", boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistory, this));
|
||||
mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", boost::bind(&LLTeleportHistoryPanel::isActionEnabled, this, _2));
|
||||
|
||||
// mMenuGearButton = getChild<LLMenuButton>("gear_btn");
|
||||
|
||||
// LLToggleableMenu* gear_menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_teleport_history_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());;
|
||||
|
|
@ -723,14 +735,50 @@ void LLTeleportHistoryPanel::updateVerbs()
|
|||
void LLTeleportHistoryPanel::getNextTab(const LLDate& item_date, S32& tab_idx, LLDate& tab_date)
|
||||
{
|
||||
const U32 seconds_in_day = 24 * 60 * 60;
|
||||
|
||||
//<FS:Beq [timezone support for teleport history]>
|
||||
static LLCachedControl<std::string> sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ");
|
||||
//</FS:Beq>
|
||||
S32 tabs_cnt = mItemContainers.size();
|
||||
S32 curr_year = 0, curr_month = 0, curr_day = 0;
|
||||
|
||||
tab_date = LLDate::now();
|
||||
tab_date = LLDate::now();
|
||||
//<FS:Beq [timezone support for teleport history]>
|
||||
// 1) Tab_date is now() which is UTC so we need to onvert that to timezoen by dedcuting the offset
|
||||
// before we flatten to current day
|
||||
// Given currrent date/time in UTC (tab_date) apply the offset for the users selected preference
|
||||
// Must be done before the split and adjust to get midnight today
|
||||
if (sFSTPHistoryTZ() == "local") // local
|
||||
{
|
||||
tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() - LLStringOps::getLocalTimeOffset());
|
||||
}
|
||||
else if (sFSTPHistoryTZ() != "utc") // slt
|
||||
{
|
||||
// note that SLT is a +ve offset
|
||||
tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() - LLStringOps::getPacificTimeOffset());
|
||||
}
|
||||
// we now have the adjusted date time which maybe a different day to the UTC day
|
||||
//</FS:Beq>
|
||||
tab_date.split(&curr_year, &curr_month, &curr_day);
|
||||
tab_date.fromYMDHMS(curr_year, curr_month, curr_day); // Set hour, min, and sec to 0
|
||||
tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + seconds_in_day);
|
||||
//<FS:Beq [timezone support for teleport history]>
|
||||
// 2) Tab_date is cutrrently last second of the selected TZ current day. Adjust back
|
||||
// Given date/time in midnight UTC (tab_date) apply the offset for the users selected preference
|
||||
// (add offset).
|
||||
if (sFSTPHistoryTZ() == "local") // local
|
||||
{
|
||||
tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + LLStringOps::getLocalTimeOffset());
|
||||
}
|
||||
else if (sFSTPHistoryTZ() != "utc") // slt
|
||||
{
|
||||
// note that SLT is a +ve offset
|
||||
tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + LLStringOps::getPacificTimeOffset());
|
||||
}
|
||||
// we now have the adjusted date time which maybe a different day to the UTC day
|
||||
// Note that the existing logic below is "slightly" broken. Adding "seconds_in_day" to establish "next 23:59" will be wrong for leapseconds
|
||||
// however fixing it is more risky than the change warrants.
|
||||
// Other edge cases can feasibily occur due to change of time during list build. not important
|
||||
//</FS:Beq>
|
||||
|
||||
tab_idx = -1;
|
||||
|
||||
|
|
@ -1106,6 +1154,7 @@ void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y
|
|||
mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded() ? true : false);
|
||||
mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded() ? true : false);
|
||||
|
||||
|
||||
mAccordionTabMenu->show(x, y);
|
||||
LLMenuGL::showPopup(tab, mAccordionTabMenu, x, y);
|
||||
}
|
||||
|
|
@ -1149,6 +1198,24 @@ void LLTeleportHistoryPanel::onCollapseAllFolders()
|
|||
}
|
||||
}
|
||||
|
||||
// <FS:Beq> [timezone support for teleport history]
|
||||
void LLTeleportHistoryPanel::onTimeZoneChecked(const LLSD& userdata)
|
||||
{
|
||||
static LLCachedControl<std::string> sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ");
|
||||
gSavedSettings.setString("FSTPHistoryTZ", userdata.asString());
|
||||
onTeleportHistoryChange(-1); // force recreate all
|
||||
}
|
||||
|
||||
|
||||
bool LLTeleportHistoryPanel::isTimeZoneChecked(const LLSD& userdata)
|
||||
{
|
||||
static LLCachedControl<std::string> sFSTPHistoryTZ(gSavedSettings, "FSTPHistoryTZ");
|
||||
|
||||
const std::string zone_string = userdata.asString();
|
||||
return ( sFSTPHistoryTZ() == zone_string);
|
||||
}
|
||||
// </FS:Beq>
|
||||
|
||||
void LLTeleportHistoryPanel::onClearTeleportHistory()
|
||||
{
|
||||
LLNotificationsUtil::add("ConfirmClearTeleportHistory", LLSD(), LLSD(), boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistoryDialog, this, _1, _2));
|
||||
|
|
|
|||
|
|
@ -92,6 +92,10 @@ private:
|
|||
void onAccordionTabClose(LLAccordionCtrlTab *tab);
|
||||
void onExpandAllFolders();
|
||||
void onCollapseAllFolders();
|
||||
// <FS:Beq> [timezone support for teleport history]
|
||||
void onTimeZoneChecked(const LLSD& userdata);
|
||||
bool isTimeZoneChecked(const LLSD& userdata);
|
||||
// </FS:Beq>
|
||||
void onClearTeleportHistory();
|
||||
bool onClearTeleportHistoryDialog(const LLSD& notification, const LLSD& response);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,41 @@
|
|||
function="TeleportHistory.GearMenu.Enable"
|
||||
parameter="collapse_all" />
|
||||
</menu_item_call>
|
||||
<menu_item_separator layout="topleft" />
|
||||
<!-- FS:Beq [timezone support for teleport history] -->
|
||||
<menu name="TPHistoryTimeZone" label="Select Timezone...">
|
||||
<menu_item_check
|
||||
name="teleport_history_tz_utc"
|
||||
label="UTC">
|
||||
<on_click
|
||||
function="TeleportHistory.TimeZone.Set"
|
||||
parameter="utc" />
|
||||
<on_check
|
||||
function="TeleportHistory.TimeZone.Check"
|
||||
parameter="utc" />
|
||||
</menu_item_check>
|
||||
<menu_item_check
|
||||
name="teleport_history_tz_slt"
|
||||
label="SLT">
|
||||
<on_click
|
||||
function="TeleportHistory.TimeZone.Set"
|
||||
parameter="slt" />
|
||||
<on_check
|
||||
function="TeleportHistory.TimeZone.Check"
|
||||
parameter="slt" />
|
||||
</menu_item_check>
|
||||
<menu_item_check
|
||||
name="teleport_history_tz_local"
|
||||
label="Local">
|
||||
<on_click
|
||||
function="TeleportHistory.TimeZone.Set"
|
||||
parameter="local" />
|
||||
<on_check
|
||||
function="TeleportHistory.TimeZone.Check"
|
||||
parameter="local" />
|
||||
</menu_item_check>
|
||||
</menu>
|
||||
<!-- /FS:Beq [timezone support for teleport history] -->
|
||||
<menu_item_separator layout="topleft" />
|
||||
<menu_item_call
|
||||
label="Clear Teleport History"
|
||||
name="Clear Teleport History">
|
||||
|
|
|
|||
Loading…
Reference in New Issue