diff --git a/saoriaccount.cpp b/saoriaccount.cpp index c1c62da..776a9f6 100644 --- a/saoriaccount.cpp +++ b/saoriaccount.cpp @@ -108,7 +108,12 @@ void SaoriAccount::getTimelineData(const QString timeline, const QUrlQuery query) { // TODO max_id、since_id、limitの処理を追加すべし。 - QUrl url = instance()->timelineUrl(timeline); + QUrl url; + if (timeline.left(8) == "accounts") { + url = QUrl(instance()->timelineUrl(timeline.left(8)).toString() + "/" + timeline.mid(9) + "/statuses"); + } else { + url = instance()->timelineUrl(timeline); + } int limit = SaoriApplication::saori()->setting()->value(SAORI_SETTING_GETLIMIT,SAORI_SETTING_GETLIMIT_DEFAULT).toInt(); if (url.isEmpty()) return; QNetworkRequest request = createHearder(); diff --git a/saoridon.cpp b/saoridon.cpp index dd99481..fa03362 100644 --- a/saoridon.cpp +++ b/saoridon.cpp @@ -161,6 +161,7 @@ m_timelineMap["local"] = QUrl(instance().url() + SAORI_MASTODON_APIPATH_TIMELINE + "/public?local=1"); m_timelineMap["public"] = QUrl(instance().url() + SAORI_MASTODON_APIPATH_TIMELINE + "/public"); m_timelineMap["notifications"] = QUrl(instance().url() + SAORI_MASTODON_APIPATH_NOTIFICATION + "/"); + m_timelineMap["accounts"] = QUrl(instance().url() + SAORI_MASTODON_APIPATH_ACCOUNTS); return; } diff --git a/saoristyle.css b/saoristyle.css index ad238e3..631bdd1 100644 --- a/saoristyle.css +++ b/saoristyle.css @@ -67,3 +67,11 @@ line-height:64px; font-weight:bold; } + +div.accounts { + text-align:center; +} + +div.accounts_display_name { + font-size:large; +} diff --git a/saoriview.cpp b/saoriview.cpp index 7fef693..0918ac1 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -51,7 +51,9 @@ m_viewList.append(this); m_maxid = 0; - auto footter = new SaoriViewEntry(0,ui->scrollAreaWidgetContents); + ui->header->hide(); + + auto footter = new SaoriViewEntry(ui->scrollAreaWidgetContents); footter->setFrameStyle(QFrame::NoFrame); footter->setContent(htmlDiv("more",tr("more..."))); ui->scrollAreaWidgetContents->layout()->addWidget(footter); @@ -122,6 +124,20 @@ saoriaccount->getTimelineData(m_viewname,query); } +const QString SaoriView::headerParser(const QJsonObject json) +{ + QString result; + result += QString(htmlDiv("accounts_icon", + htmlImg("avatar",json["avatar"].toString()))); + result += QString(htmlDiv("accounts_display_name", + json["display_name"].toString())); + result += QString(htmlDiv("accounts_acct", + "@" + json["acct"].toString())); + result += QString(htmlDiv("accounts_note", + json["note"].toString())); + return htmlDiv("accounts",result); +} + const QString SaoriView::instanceInfoParser(const QString instance) { auto i = SaoriApplication::findInstance(QUrl(instance)); @@ -152,6 +168,12 @@ QDateTime dt = QDateTime::fromString(json["created_at"].toString(),"yyyy-MM-ddTHH:mm:ss.zzzZ"); dt.setTimeSpec(Qt::UTC); + //FIXME デバッグ用。 + if (ui->header->isHidden() && (m_viewname.left(8) == "accounts")) { + ui->header->setContent(headerParser(json["account"].toObject())); + ui->header->show(); + } + result = (!json["reblog"].isNull()) ? (statusParser(json["reblog"].toObject()) + htmlDiv("reblogger",htmlHr() + @@ -165,7 +187,6 @@ ); if (json["reblog"].isNull()) { QString media; - // TODO 設定でNSFWぼかし無効にできるよう。 bool sensitive = json["sensitive"].toBool(); for (auto j:json["media_attachments"].toArray()) { media += mediaParser(j.toObject(),sensitive); @@ -183,10 +204,12 @@ htmlSpan("avatar", htmlHr() + htmlImg("avatar",json["avatar"].toString())) + - htmlSpan("display_name", - json["display_name"].toString()) + - " " + - htmlSpan("acct","@" + json["acct"].toString()) + + htmlAnc("accounts:" + json["id"].toString(), + htmlSpan("display_name", + json["display_name"].toString()) + + " " + + htmlSpan("acct","@" + json["acct"].toString()) + ) + htmlDiv("user_info", tr(" following: ") + QString::number(json["following_count"].toInt()) + @@ -341,6 +364,11 @@ QUrl u(url.toString().mid(6)); emit openMediaView(u); } + if (url.toString().left(9) == "accounts:") { + QStringList v; + v << m_account << url.toString().mid(9); + emit openAccountView(v); + } } void SaoriView::on_pushButton_newest_clicked() diff --git a/saoriview.h b/saoriview.h index 7f4bd1c..45a37e1 100644 --- a/saoriview.h +++ b/saoriview.h @@ -56,6 +56,7 @@ protected: void reload(); + const QString headerParser(const QJsonObject json); const QString instanceInfoParser(const QString instance); const QString statusParser(const QJsonObject json); const QString accountParser(const QJsonObject json); @@ -79,6 +80,8 @@ signals: void openMediaView(const QUrl); + void openAccountView(const QStringList view); + private slots: void on_pushButton_newest_clicked(); void on_pushButton_reload_clicked(); diff --git a/saoriview.ui b/saoriview.ui index 6f6ea3a..f3a845b 100644 --- a/saoriview.ui +++ b/saoriview.ui @@ -15,6 +15,16 @@ + + + + 0 + 0 + + + + + @@ -43,7 +53,7 @@ 0 0 297 - 379 + 363 @@ -187,6 +197,12 @@
saoritootwidget.h
1 + + SaoriViewEntry + QWidget +
saoriviewentry.h
+ 1 +
diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp index 63732f7..b953e74 100644 --- a/saoriviewentry.cpp +++ b/saoriviewentry.cpp @@ -33,6 +33,11 @@ #include #include +SaoriViewEntry::SaoriViewEntry(QWidget *parent) +{ + SaoriViewEntry(0,parent); +} + SaoriViewEntry::SaoriViewEntry(qlonglong id, QWidget *parent) : QTextBrowser(parent) { diff --git a/saoriviewentry.h b/saoriviewentry.h index 87c7941..e3baeb6 100644 --- a/saoriviewentry.h +++ b/saoriviewentry.h @@ -36,6 +36,7 @@ Q_OBJECT public: + SaoriViewEntry(QWidget *parent = nullptr); SaoriViewEntry(qlonglong id,QWidget *parent = nullptr); void setContent(const QString content); qlonglong id(); diff --git a/saoriwindow.cpp b/saoriwindow.cpp index 72d6a20..7a0f333 100644 --- a/saoriwindow.cpp +++ b/saoriwindow.cpp @@ -55,7 +55,7 @@ // trick for translation. QStringList trtl; QString tlText,icon; - trtl << "home" << "local" << "public" << "notifications" << "instance"; + trtl << "home" << "local" << "public" << "notifications" << "instance" << "accounts"; switch (trtl.indexOf(timeline)) { case 0: tlText = tr("home"); @@ -77,6 +77,10 @@ tlText = tr("instance"); icon = ":/icons/ionicons/earth.svg"; break; + case 5: + tlText = tr("accounts"); + icon = ":/icons/ionicons/person.svg"; + break; default: tlText = timeline; break; @@ -96,6 +100,7 @@ auto view = new SaoriView(viewName.at(1),viewName.at(0)); auto sub = ui->mdiArea->addSubWindow(view); connect(view,&SaoriView::openMediaView,this,&SaoriWindow::openMediaView); + connect(view,&SaoriView::openAccountView,this,&SaoriWindow::openAccountView); sub->setWindowTitle(title); sub->setWindowIcon(QIcon(getTimelineTitle(viewName.at(1)).second)); sub->show(); @@ -121,7 +126,21 @@ sub->resize(view->pixmap()->size()); } - +void SaoriWindow::openAccountView(const QStringList viewName) +{ + if (auto view = SaoriView::findView("accounts:" + viewName.at(1),viewName.at(0))) { + ui->mdiArea->setActiveSubWindow(qobject_cast(view->parent())); + return; + } + QString title = getTimelineTitle("accounts").first + " " + viewName.at(1) + ":" + viewName.at(0); + auto view = new SaoriView("accounts:" + viewName.at(1),viewName.at(0)); + auto sub = ui->mdiArea->addSubWindow(view); + connect(view,&SaoriView::openMediaView,this,&SaoriWindow::openMediaView); + connect(view,&SaoriView::openAccountView,this,&SaoriWindow::openAccountView); + sub->setWindowTitle(title); + sub->setWindowIcon(QIcon(getTimelineTitle("accounts").second)); + sub->show(); +} void SaoriWindow::openAccountDialog() { @@ -173,6 +192,7 @@ auto instance = SaoriApplication::findInstance(QUrl(item->text(0))); if (instance) { openView(QStringList() << instance->instance().toString() << "instance"); + return; } } diff --git a/saoriwindow.h b/saoriwindow.h index 674c7a2..c3a8cb3 100644 --- a/saoriwindow.h +++ b/saoriwindow.h @@ -51,6 +51,7 @@ public slots: void openMediaView(const QUrl url); + void openAccountView(const QStringList viewName); protected slots: void openAccountDialog();