diff --git a/saoriview.cpp b/saoriview.cpp
index f9236f1..c8b8d29 100644
--- a/saoriview.cpp
+++ b/saoriview.cpp
@@ -135,9 +135,12 @@
{
QString result;
result += "";
+ result += "";
result += "";
+ result += ") width=200>";
return result;
}
@@ -147,8 +150,18 @@
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);
+ }
+}
diff --git a/saoriview.h b/saoriview.h
index e33bfc4..e981a63 100644
--- a/saoriview.h
+++ b/saoriview.h
@@ -61,9 +61,13 @@
public slots:
void recived(const QString timeline,const QByteArray data);
+ void linkClicked(const QUrl &url);
private:
Ui::SaoriView *ui;
+
+signals:
+ void openMediaView(const QUrl);
};
#endif // SAORIVIEW_H
diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp
index b51bb90..8ce51f1 100644
--- a/saoriviewentry.cpp
+++ b/saoriviewentry.cpp
@@ -38,10 +38,10 @@
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
- setMinimumHeight(100);
+ setOpenLinks(false);
+ setOpenExternalLinks(false);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- //setTextFormat(Qt::RichText);
connect(SaoriApplication::saori()->cache(),&SaoriCache::downloaded,this,&SaoriViewEntry::downloaded);
}
diff --git a/saoriwindow.cpp b/saoriwindow.cpp
index cb3e30e..7f20df7 100644
--- a/saoriwindow.cpp
+++ b/saoriwindow.cpp
@@ -25,6 +25,7 @@
***/
#include
+#include
#include "saoriwindow.h"
#include "ui_saoriwindow.h"
#include "saoriapplication.h"
@@ -86,11 +87,28 @@
QString title = getTimelineTitle(viewName.at(1)).first + ":" + viewName.at(0);
auto view = new SaoriView(viewName.at(1),viewName.at(0));
auto sub = ui->mdiArea->addSubWindow(view);
+ connect(view,&SaoriView::openMediaView,this,&SaoriWindow::openMediaView);
sub->setWindowTitle(title);
sub->setWindowIcon(QIcon(getTimelineTitle(viewName.at(1)).second));
sub->show();
}
+void SaoriWindow::openMediaView(const QUrl url)
+{
+ auto view = new QLabel();
+ auto sub = ui->mdiArea->addSubWindow(view);
+ sub->setWindowTitle(url.toString());
+ QString image = SaoriApplication::saori()->cache()->fileCache(url);
+ if (image.mid(0,2) == ":/")
+ connect(SaoriApplication::saori()->cache(),&SaoriCache::downloaded,this,[=](const QUrl i){
+ if (i.toString() == url.toString())
+ view->setPixmap(SaoriApplication::saori()->cache()->fileCache(url));
+ });
+ view->setPixmap(image);
+ view->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
+ sub->show();
+}
+
void SaoriWindow::openAccountDialog()
diff --git a/saoriwindow.h b/saoriwindow.h
index 6b3cdfe..da84032 100644
--- a/saoriwindow.h
+++ b/saoriwindow.h
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
namespace Ui {
class SaoriWindow;
@@ -47,6 +48,9 @@
protected:
void openView(const QStringList viewName);
+public slots:
+ void openMediaView(const QUrl url);
+
protected slots:
void openAccountDialog();
void updateTimelineList();