summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtTranslator.h12
-rw-r--r--Swift/QtUI/Roster/RosterTooltip.cpp15
2 files changed, 21 insertions, 6 deletions
diff --git a/Swift/QtUI/QtTranslator.h b/Swift/QtUI/QtTranslator.h
index cdb259f..92abf77 100644
--- a/Swift/QtUI/QtTranslator.h
+++ b/Swift/QtUI/QtTranslator.h
@@ -7,9 +7,12 @@
#pragma once
#include <QCoreApplication>
+#include <QDateTime>
#include <Swift/Controllers/Translator.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
class QtTranslator : public Swift::Translator {
public:
QtTranslator() {
@@ -22,4 +25,13 @@ class QtTranslator : public Swift::Translator {
return std::string(QCoreApplication::translate(context.c_str(), text.c_str(), 0, QCoreApplication::UnicodeUTF8).toUtf8());
#endif
}
+
+ virtual std::string ptimeToHumanReadableString(const boost::posix_time::ptime& time) {
+ return Q2PSTRING(QDateTime::fromTime_t(posixTimeToTimeT(time)).toString(Qt::SystemLocaleLongDate));
+ }
+
+ private:
+ static std::time_t posixTimeToTimeT(boost::posix_time::ptime pt) {
+ return std::time_t((pt - boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_seconds());
+ }
};
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/>";
}