summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-07-29 20:59:54 (GMT)
committerKevin Smith <kevin.smith@isode.com>2016-08-09 20:15:12 (GMT)
commit42defb3516a8b7f06c7b0fbc832332a4e60c0f86 (patch)
treeb833bc3cf0166947da16345be511b71dcb04baca /Swift/QtUI/Roster
parent3c7b2b3dc884f347771f6e3036779193e7e45627 (diff)
downloadswift-42defb3516a8b7f06c7b0fbc832332a4e60c0f86.zip
swift-42defb3516a8b7f06c7b0fbc832332a4e60c0f86.tar.bz2
Enable better date formatting in the UI
This adds the ability to provide more specific date formatting via the Translator interface. The default translator will use Boost's formatting capabilities. The QtTranslator use more localized and better readable formatting. Test-Information: Tested with Qt 5.5.1 on OS X 10.11.6. Checked that tooltips and presence text in new chat views show the new formatting. Change-Id: I90ff5ab8b31fb41f2dcbea2c40b8846c534c355f
Diffstat (limited to 'Swift/QtUI/Roster')
-rw-r--r--Swift/QtUI/Roster/RosterTooltip.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Swift/QtUI/Roster/RosterTooltip.cpp b/Swift/QtUI/Roster/RosterTooltip.cpp
index 8ecd276..8d467fd 100644
--- a/Swift/QtUI/Roster/RosterTooltip.cpp
+++ b/Swift/QtUI/Roster/RosterTooltip.cpp
@@ -20,6 +20,7 @@
#include <Swift/Controllers/Roster/ContactRosterItem.h>
#include <Swift/Controllers/StatusUtil.h>
+#include <Swift/Controllers/Translator.h>
#include <Swift/QtUI/QtResourceHelper.h>
#include <Swift/QtUI/QtScaledAvatarCache.h>
@@ -93,15 +94,17 @@ QString RosterTooltip::buildDetailedTooltip(ContactRosterItem* contact, QtScaled
QString statusMessage = contact->getStatusText().empty() ? QObject::tr("(No message)") : P2QSTRING(contact->getStatusText());
- QString idleString = P2QSTRING(contact->getIdleText());
- if (!idleString.isEmpty()) {
- idleString = QObject::tr("Idle since %1").arg(idleString);
+ boost::posix_time::ptime idleTime = contact->getIdle();
+ QString idleString;
+ if (!idleTime.is_not_a_date_time()) {
+ idleString = QObject::tr("Idle since %1").arg(P2QSTRING(Swift::Translator::getInstance()->ptimeToHumanReadableString(idleTime)));
idleString = htmlEscape(idleString) + "<br/>";
}
- QString lastSeen = P2QSTRING(contact->getOfflineSinceText());
- if (!lastSeen.isEmpty()) {
- lastSeen = QObject::tr("Last seen %1").arg(lastSeen);
+ boost::posix_time::ptime lastSeenTime = contact->getOfflineSince();
+ QString lastSeen;
+ if (!lastSeenTime.is_not_a_date_time()) {
+ lastSeen = QObject::tr("Last seen %1").arg(P2QSTRING(Swift::Translator::getInstance()->ptimeToHumanReadableString(lastSeenTime)));
lastSeen = htmlEscape(lastSeen) + "<br/>";
}