Fix ancient dumb code breaking shiny modern features
Now if you have your date or time format set via debug settings, they'll only be overwritten if you use the preferences UI for them Be warned that the cancel button will not restore your custom formats debug settings are nice to use, but you are an edge case power user This commit cleans up a buncha duplicated code and makes it look nice and neat Thanks to Router for making sure I wasn't crazy~
This commit is contained in:
@@ -112,53 +112,71 @@ void LLPrefsAscentChat::onSpellBaseComboBoxCommit(const LLSD& value)
|
|||||||
glggHunSpell->newDictSelection(value.asString());
|
glggHunSpell->newDictSelection(value.asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTimeDateFormats(const S8& tempTimeFormat, const S8& tempDateFormat)
|
||||||
|
{
|
||||||
|
std::string short_date, long_date, short_time, long_time, timestamp;
|
||||||
|
|
||||||
|
if (tempDateFormat == -1)
|
||||||
|
{
|
||||||
|
if (tempDateFormat < 3)
|
||||||
|
{
|
||||||
|
short_date = !tempDateFormat ? "%F" :
|
||||||
|
tempDateFormat == 1 ? "%Y/%m/%d" :
|
||||||
|
"%d/%m/%Y";
|
||||||
|
long_date = "%A, %d %B %Y";
|
||||||
|
timestamp = "%a %d %b %Y";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
short_date = "%m/%d/%Y";
|
||||||
|
long_date = "%A, %B %d %Y";
|
||||||
|
timestamp = "%a %b %d %Y";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempTimeFormat == -1)
|
||||||
|
{
|
||||||
|
if (tempTimeFormat == 0)
|
||||||
|
{
|
||||||
|
short_time = "%R";
|
||||||
|
long_time = "%T";
|
||||||
|
timestamp += " %T";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
short_time = "%I:%M %p";
|
||||||
|
long_time = "%I:%M:%S %p";
|
||||||
|
timestamp += " %I:%M %p";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!short_date.empty())
|
||||||
|
{
|
||||||
|
gSavedSettings.setString("ShortDateFormat", short_date);
|
||||||
|
gSavedSettings.setString("LongDateFormat", long_date);
|
||||||
|
}
|
||||||
|
if (!short_time.empty())
|
||||||
|
{
|
||||||
|
gSavedSettings.setString("ShortTimeFormat", short_time);
|
||||||
|
gSavedSettings.setString("LongTimeFormat", long_time);
|
||||||
|
}
|
||||||
|
if (!timestamp.empty())
|
||||||
|
gSavedSettings.setString("TimestampFormat", timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
void LLPrefsAscentChat::onCommitTimeDate(LLUICtrl* ctrl)
|
void LLPrefsAscentChat::onCommitTimeDate(LLUICtrl* ctrl)
|
||||||
{
|
{
|
||||||
LLComboBox* combo = static_cast<LLComboBox*>(ctrl);
|
LLComboBox* combo = static_cast<LLComboBox*>(ctrl);
|
||||||
if (ctrl->getName() == "time_format_combobox")
|
if (ctrl->getName() == "time_format_combobox")
|
||||||
{
|
|
||||||
tempTimeFormat = combo->getCurrentIndex();
|
|
||||||
}
|
|
||||||
else if (ctrl->getName() == "date_format_combobox")
|
|
||||||
{
|
|
||||||
tempDateFormat = combo->getCurrentIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string short_date, long_date, short_time, long_time, timestamp;
|
|
||||||
|
|
||||||
if (tempDateFormat < 3)
|
|
||||||
{
|
{
|
||||||
short_date = !tempDateFormat ? "%F" :
|
tempTimeFormat = combo->getCurrentIndex();
|
||||||
tempDateFormat == 1 ? "%Y/%m/%d" :
|
}
|
||||||
"%d/%m/%Y";
|
else if (ctrl->getName() == "date_format_combobox")
|
||||||
long_date = "%A, %d %B %Y";
|
{
|
||||||
timestamp = "%a %d %b %Y";
|
tempDateFormat = combo->getCurrentIndex();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
short_date = "%m/%d/%Y";
|
|
||||||
long_date = "%A, %B %d %Y";
|
|
||||||
timestamp = "%a %b %d %Y";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempTimeFormat == 0)
|
setTimeDateFormats(tempTimeFormat, tempDateFormat);
|
||||||
{
|
|
||||||
short_time = "%R";
|
|
||||||
long_time = "%T";
|
|
||||||
timestamp += " %T";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
short_time = "%I:%M %p";
|
|
||||||
long_time = "%I:%M:%S %p";
|
|
||||||
timestamp += " %I:%M %p";
|
|
||||||
}
|
|
||||||
|
|
||||||
gSavedSettings.setString("ShortDateFormat", short_date);
|
|
||||||
gSavedSettings.setString("LongDateFormat", long_date);
|
|
||||||
gSavedSettings.setString("ShortTimeFormat", short_time);
|
|
||||||
gSavedSettings.setString("LongTimeFormat", long_time);
|
|
||||||
gSavedSettings.setString("TimestampFormat", timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLPrefsAscentChat::onCommitKeywords(LLUICtrl* ctrl)
|
void LLPrefsAscentChat::onCommitKeywords(LLUICtrl* ctrl)
|
||||||
@@ -204,28 +222,16 @@ void LLPrefsAscentChat::refreshValues()
|
|||||||
mSecondsInLog = gSavedSettings.getBOOL("SecondsInLog");
|
mSecondsInLog = gSavedSettings.getBOOL("SecondsInLog");
|
||||||
|
|
||||||
std::string format = gSavedSettings.getString("ShortTimeFormat");
|
std::string format = gSavedSettings.getString("ShortTimeFormat");
|
||||||
if (format.find("%p") == std::string::npos)
|
mTimeFormat = format == "%R" ? 0
|
||||||
{
|
: format == "%I:%M %p" ? 1
|
||||||
mTimeFormat = 0;
|
: -1;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mTimeFormat = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
format = gSavedSettings.getString("ShortDateFormat");
|
format = gSavedSettings.getString("ShortDateFormat");
|
||||||
if (format.find("%D") != std::string::npos || format.find("%m/%d/%") != std::string::npos)
|
mDateFormat = format == "%F" ? 0 :
|
||||||
{
|
format == "%Y/%m/%d" ? 1 :
|
||||||
mDateFormat = 2;
|
format == "%d/%m/%Y" ? 2 :
|
||||||
}
|
format == "%m/%d/%Y" ? 3 :
|
||||||
else if (format.find("%d/%m/%") != std::string::npos)
|
-1;
|
||||||
{
|
|
||||||
mDateFormat = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mDateFormat = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tempTimeFormat = mTimeFormat;
|
tempTimeFormat = mTimeFormat;
|
||||||
tempDateFormat = mDateFormat;
|
tempDateFormat = mDateFormat;
|
||||||
@@ -312,20 +318,24 @@ void LLPrefsAscentChat::refreshValues()
|
|||||||
// Update controls based on current settings
|
// Update controls based on current settings
|
||||||
void LLPrefsAscentChat::refresh()
|
void LLPrefsAscentChat::refresh()
|
||||||
{
|
{
|
||||||
//Chat --------------------------------------------------------------------------------
|
//Chat --------------------------------------------------------------------------------
|
||||||
// time format combobox
|
// time format combobox
|
||||||
LLComboBox* combo = getChild<LLComboBox>("time_format_combobox");
|
if (mTimeFormat != -1)
|
||||||
if (combo)
|
{
|
||||||
{
|
if (auto combo = getChild<LLComboBox>("time_format_combobox"))
|
||||||
combo->setCurrentByIndex(mTimeFormat);
|
{
|
||||||
}
|
combo->setCurrentByIndex(mTimeFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// date format combobox
|
// date format combobox
|
||||||
combo = getChild<LLComboBox>("date_format_combobox");
|
if (mDateFormat != -1)
|
||||||
if (combo)
|
{
|
||||||
{
|
if (auto combo = getChild<LLComboBox>("date_format_combobox"))
|
||||||
combo->setCurrentByIndex(mDateFormat);
|
{
|
||||||
}
|
combo->setCurrentByIndex(mDateFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Chat UI -----------------------------------------------------------------------------
|
//Chat UI -----------------------------------------------------------------------------
|
||||||
if (combo = getChild<LLComboBox>("chat_tabs_namesystem_combobox"))
|
if (combo = getChild<LLComboBox>("chat_tabs_namesystem_combobox"))
|
||||||
@@ -430,45 +440,7 @@ void LLPrefsAscentChat::cancel()
|
|||||||
gSavedSettings.setBOOL("SecondsInChatAndIMs", mSecondsInChatAndIMs);
|
gSavedSettings.setBOOL("SecondsInChatAndIMs", mSecondsInChatAndIMs);
|
||||||
gSavedSettings.setBOOL("SecondsInLog", mSecondsInLog);
|
gSavedSettings.setBOOL("SecondsInLog", mSecondsInLog);
|
||||||
|
|
||||||
std::string short_date, long_date, short_time, long_time, timestamp;
|
setTimeDateFormats(mTimeFormat, mDateFormat);
|
||||||
|
|
||||||
if (mTimeFormat == 0)
|
|
||||||
{
|
|
||||||
short_time = "%H:%M";
|
|
||||||
long_time = "%H:%M:%S";
|
|
||||||
timestamp = " %H:%M:%S";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
short_time = "%I:%M %p";
|
|
||||||
long_time = "%I:%M:%S %p";
|
|
||||||
timestamp = " %I:%M %p";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mDateFormat == 0)
|
|
||||||
{
|
|
||||||
short_date = "%Y-%m-%d";
|
|
||||||
long_date = "%A %d %B %Y";
|
|
||||||
timestamp = "%a %d %b %Y" + timestamp;
|
|
||||||
}
|
|
||||||
else if (mDateFormat == 1)
|
|
||||||
{
|
|
||||||
short_date = "%d/%m/%Y";
|
|
||||||
long_date = "%A %d %B %Y";
|
|
||||||
timestamp = "%a %d %b %Y" + timestamp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
short_date = "%m/%d/%Y";
|
|
||||||
long_date = "%A, %B %d %Y";
|
|
||||||
timestamp = "%a %b %d %Y" + timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
gSavedSettings.setString("ShortDateFormat", short_date);
|
|
||||||
gSavedSettings.setString("LongDateFormat", long_date);
|
|
||||||
gSavedSettings.setString("ShortTimeFormat", short_time);
|
|
||||||
gSavedSettings.setString("LongTimeFormat", long_time);
|
|
||||||
gSavedSettings.setString("TimestampFormat", timestamp);
|
|
||||||
|
|
||||||
//Chat UI -----------------------------------------------------------------------------
|
//Chat UI -----------------------------------------------------------------------------
|
||||||
gSavedSettings.setBOOL("WoLfVerticalIMTabs", mWoLfVerticalIMTabs);
|
gSavedSettings.setBOOL("WoLfVerticalIMTabs", mWoLfVerticalIMTabs);
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ private:
|
|||||||
bool mEnableMUPose;
|
bool mEnableMUPose;
|
||||||
bool mEnableOOCAutoClose;
|
bool mEnableOOCAutoClose;
|
||||||
U32 mLinksForChattingObjects;
|
U32 mLinksForChattingObjects;
|
||||||
U32 mTimeFormat;
|
S8 mTimeFormat;
|
||||||
U32 mDateFormat;
|
S8 mDateFormat;
|
||||||
U32 tempTimeFormat;
|
S8 tempTimeFormat;
|
||||||
U32 tempDateFormat;
|
S8 tempDateFormat;
|
||||||
bool mSecondsInChatAndIMs;
|
bool mSecondsInChatAndIMs;
|
||||||
bool mSecondsInLog;
|
bool mSecondsInLog;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user