diff --git a/saori.pro b/saori.pro index b0f39d0..64e08b5 100644 --- a/saori.pro +++ b/saori.pro @@ -30,7 +30,8 @@ saoriaddaccountdialog.cpp \ saoriaccount.cpp \ saoriapplication.cpp \ - saoricache.cpp + saoricache.cpp \ + saoriviewentry.cpp HEADERS += \ saoriwindow.h \ @@ -40,7 +41,8 @@ saoridef.h \ saoriaccount.h \ saoriapplication.h \ - saoricache.h + saoricache.h \ + saoriviewentry.h FORMS += \ saoriwindow.ui \ diff --git a/saori.qrc b/saori.qrc index 67759cc..e708696 100644 --- a/saori.qrc +++ b/saori.qrc @@ -32,4 +32,7 @@ ionicons/load-a.svg ionicons/alert-circled.svg + + saoristyle.css + diff --git a/saori_ja.qm b/saori_ja.qm new file mode 100644 index 0000000..4ac4e00 --- /dev/null +++ b/saori_ja.qm Binary files differ diff --git a/saori_ja.ts b/saori_ja.ts index 7e676a5..352e142 100644 --- a/saori_ja.ts +++ b/saori_ja.ts @@ -6,47 +6,47 @@ Add new Account - + アカウントを追加 Instance URL: - + インスタンスURL: Get Access token: - + アクセストークンを取得: Open Authorize page: - + 認証ページを開く: Check - + 確認 Get! - + 取得! Authorize Code: - + 認証コード: Open WebBrowser - + ブラウザを開く Account: - + アカウント: @@ -57,145 +57,166 @@ - + Pin - + Notify - + Auto reload - + Newest - + Reload - + Toot + + + following: + フォロー: + + + + followers: + フォロワー: + SaoriWindow - SaoriWindow + Saori + SaoriWindow - + &File ファイル(&F) - + &View 表示(&V) - + &Edit 編集(&E) - + &Help ヘルプ(&H) - + Timeline &list タイムラインリスト(&l) - + Auto reload Interval (minutes) - + List リスト - + Account - + Instance - + &Quit - + Show/Hide Timeline &List - + &Open Timeline - + &Add Account - + &Remove Account - + + &TabbedView mode + + + + + T&iled + + + + Accounts アカウント - + home ホーム - + local ローカルタイムライン - + public 連合タイムライン - + notifications 通知 - + Instances インスタンス - + Infomation 情報 diff --git a/saoristyle.css b/saoristyle.css new file mode 100644 index 0000000..558840f --- /dev/null +++ b/saoristyle.css @@ -0,0 +1,16 @@ +div.user_info { + font-size:small; +} + +span.display_name { + font-size:large; +} + +span.acct { + color:gray; +} + +img.avatar { + float:left; +} + diff --git a/saoriview.cpp b/saoriview.cpp index a730d49..2883196 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -28,6 +28,9 @@ #include "ui_saoriview.h" #include #include +#include +#include +#include #include #include @@ -63,9 +66,51 @@ return nullptr; } +const QString SaoriView::statusParser(const QJsonObject json) +{ + QString result; + if (json.isEmpty()) return QString(); + result += "
"; + result += accountParser(json["account"].toObject()); + result += "
"; + result += json["content"].toString(); + result += "
"; + result += "
"; + return result; +} + +const QString SaoriView::accountParser(const QJsonObject json) +{ + QString result; + if (json.isEmpty()) return QString(); + result += "
"; + result += "
"; + result += "
"; + result += ""; + result += json["display_name"].toString(); + result += ""; + result += json["acct"].toString(); + result += ""; + result += "
"; + result += tr(" following: "); + result += QString::number(json["following_count"].toInt()); + result += tr(" followers: "); + result += QString::number(json["followers_count"].toInt()); + result += "
"; + result += "
"; + return result; +} + void SaoriView::recived(const QString timeline,const QByteArray data) { - if (timeline == m_viewname) { - qDebug() << QString::fromUtf8(data); + if (timeline != m_viewname) return; + QJsonArray json = QJsonDocument::fromJson(data).array(); + for (auto j:json) { + auto entry = new SaoriViewEntry(ui->scrollAreaWidgetContents); + entry->setObjectName(j.toObject()["id"].toString()); + entry->setContent(statusParser(j.toObject())); + ui->scrollAreaWidgetContents->layout()->addWidget(entry); } } diff --git a/saoriview.h b/saoriview.h index d15652d..d7c5887 100644 --- a/saoriview.h +++ b/saoriview.h @@ -28,7 +28,10 @@ #define SAORIVIEW_H #include -#include +#include +#include +#include +#include namespace Ui { class SaoriView; @@ -46,9 +49,15 @@ protected: QString m_viewname; QString m_account; + QList m_entries; static QList m_viewList; +protected: + const QString statusParser(const QJsonObject json); + const QString accountParser(const QJsonObject json); + const QString notificationParser(const QJsonObject json); + public slots: void recived(const QString timeline,const QByteArray data); diff --git a/saoriview.ui b/saoriview.ui index e4b2987..96650f4 100644 --- a/saoriview.ui +++ b/saoriview.ui @@ -16,18 +16,42 @@ + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAsNeeded + + + QAbstractScrollArea::AdjustIgnored + true + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + 0 0 - 307 + 293 316 + + + 0 + 0 + + diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp new file mode 100644 index 0000000..e00c47f --- /dev/null +++ b/saoriviewentry.cpp @@ -0,0 +1,85 @@ +/*** + +The MIT License + +Copyright (c) 2018 Teppei Tamra (TAM) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +***/ + +#include "saoriviewentry.h" +#include "saoriapplication.h" +#include "saoricache.h" +#include +#include + +SaoriViewEntry::SaoriViewEntry(QWidget *parent) : + QLabel(parent) +{ + setWordWrap(true); + setSizePolicy(QSizePolicy::Expanding,QSizePolicy::MinimumExpanding); + setTextFormat(Qt::RichText); + connect(SaoriApplication::saori()->cache(),&SaoriCache::downloaded,this,&SaoriViewEntry::downloaded); +} + +void SaoriViewEntry::setContent(const QString content) +{ + m_original = content; + QStringList imgs; + for(int i = 0;(i = m_original.indexOf("cache()->fileCache(QUrl(i)); + } + setText(designedText()); + qDebug() << text(); +} + +const QString SaoriViewEntry::designedText() +{ + QString result; + result += ""; + result += ""; + result += imageReplacer(); + result += ""; + return result; +} + +const QString SaoriViewEntry::imageReplacer() +{ + QString result = m_original; + for (auto k:m_urlmap.keys()) { + result.replace(QString("cache()->fileCache(url); + setText(designedText()); + for (auto i:m_urlmap) { + if (i.indexOf(":/")) return; + } + disconnect(SaoriApplication::saori()->cache(),&SaoriCache::downloaded,this,&SaoriViewEntry::downloaded); +} diff --git a/saoriviewentry.h b/saoriviewentry.h new file mode 100644 index 0000000..4d6c718 --- /dev/null +++ b/saoriviewentry.h @@ -0,0 +1,55 @@ +/*** + +The MIT License + +Copyright (c) 2018 Teppei Tamra (TAM) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +***/ + +#ifndef SAORIVIEWENTRY_H +#define SAORIVIEWENTRY_H + +#include +#include +#include + +class SaoriViewEntry : public QLabel +{ + Q_OBJECT + +public: + SaoriViewEntry(QWidget *parent = nullptr); + void setContent(const QString content); + +protected: + const QString designedText(); + const QString imageReplacer(); + +protected: + QString m_original; + QMap m_urlmap; + +protected slots: + void downloaded(const QUrl url); + +}; + +#endif // SAORIVIEWENTRY_H