FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display

meow-7.2.2
Zi Ree 2021-02-15 01:37:24 +01:00
parent 7130839035
commit 065e59634f
6 changed files with 124 additions and 24 deletions

View File

@ -25623,5 +25623,16 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>0</integer>
</map>
<key>StatusBarTimeFormat</key>
<map>
<key>Comment</key>
<string>Which time format to use for the status bar clock, e.g. 12 Hours, 24 Hours, etc. The default "Language" restores the original behavior of changing the time display mode per language.</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>String</string>
<key>Value</key>
<string>Language</string>
</map>
</map>
</llsd>

View File

@ -519,9 +519,53 @@ BOOL LLStatusBar::postBuild()
updateVolumeControlsVisibility(LLSD(FALSE));
}
// </FS:PP>
// <FS:Zi> FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display
mClockFormatChoices["12 Hour"] = "[hour12, datetime, slt]:[min, datetime, slt] [ampm, datetime, slt]";
mClockFormatChoices["12 Hour Seconds"] = "[hour12, datetime, slt]:[min, datetime, slt]:[second, datetime, slt] [ampm, datetime, slt]";
mClockFormatChoices["12 Hour TZ"] = "[hour12, datetime, slt]:[min, datetime, slt] [ampm, datetime, slt] [timezone,datetime, slt]";
mClockFormatChoices["12 Hour TZ Seconds"] = "[hour12, datetime, slt]:[min, datetime, slt]:[second, datetime, slt] [ampm, datetime, slt] [timezone,datetime, slt]";
mClockFormatChoices["24 Hour"] = "[hour24, datetime, slt]:[min, datetime, slt]";
mClockFormatChoices["24 Hour Seconds"] = "[hour24, datetime, slt]:[min, datetime, slt]:[second, datetime, slt]";
mClockFormatChoices["24 Hour TZ"] = "[hour24, datetime, slt]:[min, datetime, slt] [timezone, datetime, slt]";
mClockFormatChoices["24 Hour TZ Seconds"] = "[hour24, datetime, slt]:[min, datetime, slt]:[second, datetime, slt] [timezone, datetime, slt]";
// use the time format defined in the language's panel_status_bar.xml (default)
mClockFormatChoices["Language"] = getString("time");
mClockFormat = gSavedSettings.getString("StatusBarTimeFormat");
getChild<LLTextBox>("TimeText")->setClickedCallback(boost::bind(&LLStatusBar::onClockClicked, this));
getChild<LLTextBox>("TimeText")->setDoubleClickCallback(boost::bind(&LLStatusBar::onClockDoubleClicked, this));
gSavedSettings.getControl("StatusBarTimeFormat")->getSignal()->connect(boost::bind(&LLStatusBar::onTimeFormatChanged, this, _2));
// </FS:Zi>
return TRUE;
}
// <FS:Zi> FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display
void LLStatusBar::updateClockDisplay()
{
// Get current UTC time, adjusted for the user's clock
// being off.
time_t utc_time;
utc_time = time_corrected();
std::string timeStr = mClockFormatChoices[mClockFormat];
LLSD substitution;
substitution["datetime"] = (S32) utc_time;
LLStringUtil::format (timeStr, substitution);
mTextTime->setText(timeStr);
// <FS:Ansariel> Add seconds to clock
static const std::string tooltip_template = getString("timeTooltip");
std::string dtStr = tooltip_template;
// </FS:Ansariel>
LLStringUtil::format (dtStr, substitution);
mTextTime->setToolTip (dtStr);
}
// </FS:Zi>
// Per-frame updates of visibility
void LLStatusBar::refresh()
{
@ -562,29 +606,25 @@ void LLStatusBar::refresh()
{
mClockUpdateTimer.reset();
// Get current UTC time, adjusted for the user's clock
// being off.
time_t utc_time;
utc_time = time_corrected();
// <FS:Zi> FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display
// // Get current UTC time, adjusted for the user's clock
// // being off.
// time_t utc_time;
// utc_time = time_corrected();
// <FS:Ansariel> Add seconds to clock
//std::string timeStr = getString("time");
static const std::string time_template = getString("time");
std::string timeStr = time_template;
// </FS:Ansariel>
LLSD substitution;
substitution["datetime"] = (S32) utc_time;
LLStringUtil::format (timeStr, substitution);
mTextTime->setText(timeStr);
// std::string timeStr = getString("time");
// LLSD substitution;
// substitution["datetime"] = (S32) utc_time;
// LLStringUtil::format (timeStr, substitution);
// mTextTime->setText(timeStr);
// set the tooltip to have the date
// <FS:Ansariel> Add seconds to clock
//std::string dtStr = getString("timeTooltip");
static const std::string tooltip_template = getString("timeTooltip");
std::string dtStr = tooltip_template;
// </FS:Ansariel>
LLStringUtil::format (dtStr, substitution);
mTextTime->setToolTip (dtStr);
// // set the tooltip to have the date
// std::string dtStr = getString("timeTooltip");
// LLStringUtil::format (dtStr, substitution);
// mTextTime->setToolTip (dtStr);
updateClockDisplay();
// </FS:Zi>
}
// <FS:Zi> Pathfinding rebake functions
@ -1717,6 +1757,36 @@ void LLStatusBar::onPopupRolloverChanged(const LLSD& newvalue)
}
}
// <FS:Zi> FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display
void LLStatusBar::onClockClicked()
{
auto current_entry = mClockFormatChoices.find(mClockFormat);
// get the next time format from the list, skipping the "Language" entry
do
{
current_entry++;
if (current_entry == mClockFormatChoices.end())
{
current_entry = mClockFormatChoices.begin();
}
} while (current_entry->first == "Language");
gSavedSettings.setString("StatusBarTimeFormat", current_entry->first);
}
void LLStatusBar::onClockDoubleClicked()
{
gSavedSettings.setString("StatusBarTimeFormat", "Language");
}
void LLStatusBar::onTimeFormatChanged(const LLSD& new_format)
{
mClockFormat = new_format.asString();
updateClockDisplay();
}
// </FS:Zi>
// Implements secondlife:///app/balance/request to request a L$ balance
// update via UDP message system. JC
class LLBalanceHandler : public LLCommandHandler

View File

@ -395,6 +395,16 @@ private:
void onMouseLeaveParcelInfo();
// </FS:Zi>
// <FS:Zi> FIRE-20390, FIRE-4269 - Option for 12/24 hour clock and seconds display
std::map<std::string,std::string> mClockFormatChoices;
std::string mClockFormat;
void updateClockDisplay();
void onClockClicked();
void onClockDoubleClicked();
void onTimeFormatChanged(const LLSD& new_format);
// </FS:Zi>
std::string mCurrentLocationString;
};

View File

@ -199,6 +199,9 @@
<panel.string
name="timeTooltip">
[weekday, datetime, slt], [day, datetime, slt] [month, datetime, slt] [year, datetime, slt]
Click to cycle through different time display modes.
Double click to restore to default, so time format depends on chosen viewer language.
</panel.string>
<panel.string
name="buycurrencylabel">
@ -307,7 +310,7 @@
font="SansSerifSmall"
text_color="TimeTextColor"
follows="right|top"
halign="left"
halign="center"
height="16"
h_pad="2"
top="4"

View File

@ -197,6 +197,9 @@
<panel.string
name="timeTooltip">
[weekday, datetime, slt], [day, datetime, slt] [month, datetime, slt] [year, datetime, slt]
Click to cycle through different time display modes.
Double click to restore to default, so time format depends on chosen viewer language.
</panel.string>
<panel.string
name="buycurrencylabel">
@ -336,7 +339,7 @@
font="SansSerifSmall"
text_color="TimeTextColor"
follows="right|top"
halign="left"
halign="center"
height="16"
h_pad="2"
top="4"

View File

@ -196,6 +196,9 @@
<panel.string
name="timeTooltip">
[weekday, datetime, slt], [day, datetime, slt] [month, datetime, slt] [year, datetime, slt]
Click to cycle through different time display modes.
Double click to restore to default, so time format depends on chosen viewer language.
</panel.string>
<panel.string
name="buycurrencylabel">
@ -332,7 +335,7 @@
font="SansSerifSmall"
text_color="TimeTextColor"
follows="right|top"
halign="left"
halign="center"
height="16"
h_pad="2"
top="4"