diff --git a/saoriview.cpp b/saoriview.cpp index 76a0199..f09164b 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -104,18 +104,18 @@ auto i = SaoriApplication::findInstance(QUrl(instance)); if (!i) return QString(); QString result; - result = (tr("
%1
" - "
%2
" - "
%3
" - "
email : %4
" - "
%5
" - "
version : %6
" - ).arg(i->instanceInfo("title").toString(), - i->instanceInfo("uri").toString(), - i->instanceInfo("description").toString(), - i->instanceInfo("email").toString(), - accountParser(i->instanceInfo("contact_account").toObject()), - i->instanceInfo("version").toString())); + result = QString(htmlDiv("instance_title","%1") + + htmlDiv("instance_uri","%2") + + htmlDiv("instance_description","%3") + + htmlDiv("instance_email","email : %4") + + htmlDiv("instance_contact_account","%5") + + htmlDiv("instance_version","Version : %6") + ).arg(i->instanceInfo("title").toString(), + i->instanceInfo("uri").toString(), + i->instanceInfo("description").toString(), + i->instanceInfo("email").toString(), + accountParser(i->instanceInfo("contact_account").toObject()), + i->instanceInfo("version").toString()); return result; } @@ -123,39 +123,28 @@ { QString result; if (json.isEmpty()) return QString(); - bool rebloged = false; - if (!json["reblog"].isNull()) rebloged = true; - if (rebloged) { - result += statusParser(json["reblog"].toObject()); - result += "
"; - } else { - result += "
"; - } - if (rebloged) { - result += "
"; - result += tr("created at :"); - QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ"); - dt.setTimeSpec(Qt::UTC); - result += dt.toLocalTime().toString(); - result += "
"; - } - if (!rebloged) { - result += "
"; - result += contentParser(json["content"].toString()); - result += "
"; + + QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ"); + dt.setTimeSpec(Qt::UTC); + + result = (!json["reblog"].isNull()) ? + (statusParser(json["reblog"].toObject()) + + htmlDiv("reblogger",htmlHr() + + htmlImg("mavatar",json["account"].toObject()["avatar"].toString()) + + tr("boosted by: %1").arg(json["account"].toObject()["display_name"].toString())) + ) : + (htmlDiv("status",accountParser(json["account"].toObject()) + + htmlDiv("created_at",tr("created at :") + + dt.toLocalTime().toString()) + + htmlDiv("content",contentParser(json["content"].toString()))) + ); + if (json["reblog"].isNull()) { + QString media; for (auto j:json["media_attachments"].toArray()) { - result += mediaParser(j.toObject()); + media += mediaParser(j.toObject()); } - result += "
"; - result += "
"; + result += htmlDiv("media",media); } - result += "
"; return result; } @@ -183,19 +172,10 @@ const QString SaoriView::mediaParser(const QJsonObject json) { QString result; - result += ""; - if (json["type"].toString() == "image") { - result += ""; - } - result += ""; + + QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ"); + dt.setTimeSpec(Qt::UTC); + QStringList type; type << "mention" << "reblog" << "favourite" << "follow"; - result += "
"; + QString title; switch (type.indexOf(json["type"].toString())) { case 0: - result += ""; - result += tr("%1 mentioned your status.").arg(json["account"].toObject()["display_name"].toString()); + title += htmlImg("mavatar",":/icons/ionicons/chatbubbles.svg"); + title += tr("%1 mentioned your status.").arg(json["account"].toObject()["display_name"].toString()); break; case 1: - result += ""; - result += tr("%1 boosted your status.").arg(json["account"].toObject()["display_name"].toString()); + title += htmlImg("mavatar",":/icons/ionicons/share.svg"); + title += tr("%1 boosted your status.").arg(json["account"].toObject()["display_name"].toString()); break; case 2: - result += ""; - result += tr("%1 favourited your status.").arg(json["account"].toObject()["display_name"].toString()); + title += htmlImg("mavatar",":/icons/ionicons/heart.svg"); + title += tr("%1 favourited your status.").arg(json["account"].toObject()["display_name"].toString()); break; case 3: - result += ""; - result += tr("%1 followed you.").arg(json["account"].toObject()["display_name"].toString()); + title += htmlImg("mavatar",":/icons/ionicons/person-add.svg"); + title += tr("%1 followed you.").arg(json["account"].toObject()["display_name"].toString()); break; default: break; } - result += "
"; - result += "
"; - result += tr("created at :"); - QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ"); - dt.setTimeSpec(Qt::UTC); - result += dt.toLocalTime().toString(); - result += "
"; - result += statusParser(json["status"].toObject()); - - result += "
"; - result += "
").arg(type,url); + return QString("").arg(type,url); } const QString SaoriView::htmlAnc(const QString link, const QString text)