diff --git a/saoriview.cpp b/saoriview.cpp index e934099..81f9d80 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -160,8 +160,10 @@ ); if (json["reblog"].isNull()) { QString media; + // TODO 設定でNSFWぼかし無効にできるよう。 + bool sensitive = json["sensitive"].toBool(); for (auto j:json["media_attachments"].toArray()) { - media += mediaParser(j.toObject()); + media += mediaParser(j.toObject(),sensitive); } result += htmlDiv("media",media); } @@ -189,13 +191,15 @@ return result; } -const QString SaoriView::mediaParser(const QJsonObject json) +const QString SaoriView::mediaParser(const QJsonObject json, bool sensitive) { - QString result; + QString result,media; + if (sensitive) media = "nsfwmedia"; + else media = "media"; result = htmlSpan("media_preview", json["type"].toString() == "image" ? - htmlAnc("media:" + json["url"].toString(),htmlImg("media",json["preview_url"].toString())) : - htmlImg("media",json["preview_url"].toString())); + htmlAnc("media:" + json["url"].toString(),htmlImg(media,json["preview_url"].toString())) : + htmlImg(media,json["preview_url"].toString())); return result; } diff --git a/saoriview.h b/saoriview.h index 60540f0..7f4bd1c 100644 --- a/saoriview.h +++ b/saoriview.h @@ -59,7 +59,7 @@ const QString instanceInfoParser(const QString instance); const QString statusParser(const QJsonObject json); const QString accountParser(const QJsonObject json); - const QString mediaParser(const QJsonObject json); + const QString mediaParser(const QJsonObject json,bool sensitive = false); const QString contentParser(const QString content); const QString notificationParser(const QJsonObject json); diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp index 64265d4..f75b7ce 100644 --- a/saoriviewentry.cpp +++ b/saoriviewentry.cpp @@ -64,7 +64,6 @@ imageurl = i.mid(p + 1); } m_urlmap[i] = imageurl; - //qDebug() << imageurl; QImage img(imageurl); imageResizer(i.left(p),img); document()->addResource(QTextDocument::ImageResource,QUrl("img:" + imageurl),QVariant(img)); @@ -110,7 +109,7 @@ void SaoriViewEntry::imageResizer(const QString type, QImage &image) { QStringList c; - c << "avatar" << "mavatar" << "media"; + c << "avatar" << "mavatar" << "media" << "nsfwmedia"; switch (c.indexOf(type)) { case 0: image = image.scaled(64,64,Qt::KeepAspectRatio,Qt::SmoothTransformation); @@ -121,6 +120,10 @@ case 2: image = image.scaledToWidth(200,Qt::SmoothTransformation); break; + case 3: + image = image.scaledToWidth(10,Qt::SmoothTransformation); + image = image.scaledToWidth(200,Qt::SmoothTransformation); + break; default: break; }