| |
---|
| | const QString SaoriView::mediaParser(const QJsonObject json) |
---|
| | { |
---|
| | QString result; |
---|
| | result += "<span class=\"media_preview\">"; |
---|
| | result += "<a href=\"media:"; |
---|
| | result += json["url"].toString(); |
---|
| | result += "\">"; |
---|
| | result += "<img("; |
---|
| | result += json["preview_url"].toString(); |
---|
| | result += ") width=200></span>"; |
---|
| | result += ") width=200></a></span>"; |
---|
| | return result; |
---|
| | } |
---|
| | |
---|
| | void SaoriView::recived(const QString timeline,const QByteArray data) |
---|
| |
---|
| | if (timeline != m_viewname) return; |
---|
| | QJsonArray json = QJsonDocument::fromJson(data).array(); |
---|
| | for (auto j:json) { |
---|
| | auto entry = new SaoriViewEntry(ui->scrollAreaWidgetContents); |
---|
| | connect(entry,&SaoriViewEntry::anchorClicked,this,&SaoriView::linkClicked); |
---|
| | entry->setObjectName(j.toObject()["id"].toString()); |
---|
| | entry->setContent(statusParser(j.toObject())); |
---|
| | ui->scrollAreaWidgetContents->layout()->addWidget(entry); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | void SaoriView::linkClicked(const QUrl &url) |
---|
| | { |
---|
| | if (url.toString().left(6) == "media:") { |
---|
| | qDebug() << url.toString().mid(6); |
---|
| | QUrl u(url.toString().mid(6)); |
---|
| | emit openMediaView(u); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |