diff --git a/ionicons-md/md-arrow-round-back.svg b/ionicons-md/md-arrow-round-back.svg new file mode 100644 index 0000000..d6d667d --- /dev/null +++ b/ionicons-md/md-arrow-round-back.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/ionicons-md/md-arrow-round-forward.svg b/ionicons-md/md-arrow-round-forward.svg new file mode 100644 index 0000000..7ea9e8c --- /dev/null +++ b/ionicons-md/md-arrow-round-forward.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/ionicons-md/md-play.svg b/ionicons-md/md-play.svg new file mode 100644 index 0000000..c3307da --- /dev/null +++ b/ionicons-md/md-play.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/ionicons-md/md-resize.svg b/ionicons-md/md-resize.svg new file mode 100644 index 0000000..437f722 --- /dev/null +++ b/ionicons-md/md-resize.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/saori.pro b/saori.pro index ec4d807..be741e5 100644 --- a/saori.pro +++ b/saori.pro @@ -35,7 +35,8 @@ saoriconfiguredialog.cpp \ saoritootwidget.cpp \ saoridownloader.cpp \ - saorisystemtray.cpp + saorisystemtray.cpp \ + saorimediaview.cpp HEADERS += \ saoriwindow.h \ @@ -50,14 +51,16 @@ saoriconfiguredialog.h \ saoritootwidget.h \ saoridownloader.h \ - saorisystemtray.h + saorisystemtray.h \ + saorimediaview.h FORMS += \ saoriwindow.ui \ saoriview.ui \ saoriaddaccountdialog.ui \ saoriconfiguredialog.ui \ - saoritootwidget.ui + saoritootwidget.ui \ + saorimediaview.ui TRANSLATIONS += \ saori_ja.ts diff --git a/saori.qrc b/saori.qrc index b7f4825..7a01f1d 100644 --- a/saori.qrc +++ b/saori.qrc @@ -59,6 +59,10 @@ ionicons-md/md-pin.svg ionicons-md/md-trending-up.svg ionicons-md/md-arrow-round-down.svg + ionicons-md/md-arrow-round-forward.svg + ionicons-md/md-arrow-round-back.svg + ionicons-md/md-resize.svg + ionicons-md/md-play.svg saoristyle.css diff --git a/saorimediaview.cpp b/saorimediaview.cpp new file mode 100644 index 0000000..231156f --- /dev/null +++ b/saorimediaview.cpp @@ -0,0 +1,79 @@ +/*** + +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 "saorimediaview.h" +#include "ui_saorimediaview.h" +#include +#include + +SaoriMediaView::SaoriMediaView(QWidget *parent) : + QWidget(parent), + ui(new Ui::SaoriMediaView) +{ + ui->setupUi(this); +} + +SaoriMediaView::~SaoriMediaView() +{ + delete ui; +} + +void SaoriMediaView::setImage(QImage image) +{ + m_image = image; + ui->media->setPixmap(QPixmap::fromImage(m_image)); + ui->scrollArea->setWidgetResizable(true); + ui->media->adjustSize(); + if (ui->actionFit->isChecked()) fit(); +} + +void SaoriMediaView::setUrls(QList urls, uint current) +{ + m_mediaList = urls; + m_currentMedia = current; +} + +void SaoriMediaView::fit() +{ + // FIXME この式正しいか? + QSize s = ui->scrollArea->size() - ui->scrollArea->sizeHint(); + ui->media->setPixmap(QPixmap::fromImage((m_image.scaled(s,Qt::KeepAspectRatio,Qt::SmoothTransformation)))); + ui->media->adjustSize(); + qDebug () << ui->scrollArea->size(); + qDebug () << ui->scrollArea->frameWidth(); +} + +void SaoriMediaView::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + if (ui->actionFit->isChecked()) fit(); +} + +void SaoriMediaView::on_actionFit_changed() +{ + setImage(m_image); + if (ui->actionFit->isChecked()) fit(); +} diff --git a/saorimediaview.h b/saorimediaview.h new file mode 100644 index 0000000..3d62f16 --- /dev/null +++ b/saorimediaview.h @@ -0,0 +1,68 @@ +/*** + +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 SAORIMEDIAVIEW_H +#define SAORIMEDIAVIEW_H + +#include +#include +#include +#include +#include + +namespace Ui { +class SaoriMediaView; +} + +class SaoriMediaView : public QWidget +{ + Q_OBJECT + +public: + explicit SaoriMediaView(QWidget *parent = nullptr); + ~SaoriMediaView(); + + void setImage(QImage image); + void setUrls(QList urls,uint current); + +protected: + void fit(); + virtual void resizeEvent(QResizeEvent *event); + +protected: + QList m_mediaList; + uint m_currentMedia; + bool m_fit; + QImage m_image; + +private slots: + void on_actionFit_changed(); + +private: + Ui::SaoriMediaView *ui; +}; + +#endif // SAORIMEDIAVIEW_H diff --git a/saorimediaview.ui b/saorimediaview.ui new file mode 100644 index 0000000..95c8344 --- /dev/null +++ b/saorimediaview.ui @@ -0,0 +1,115 @@ + + + SaoriMediaView + + + + 0 + 0 + 534 + 452 + + + + Form + + + + + + QAbstractScrollArea::AdjustIgnored + + + true + + + + + 0 + 0 + 514 + 389 + + + + + + + + + + + + + + + + + + + + + + + + + + + + :/icons/ionicons-md/md-arrow-round-back.svg:/icons/ionicons-md/md-arrow-round-back.svg + + + Prev + + + + + + :/icons/ionicons-md/md-arrow-round-forward.svg:/icons/ionicons-md/md-arrow-round-forward.svg + + + Next + + + + + + :/icons/ionicons-md/md-save.svg:/icons/ionicons-md/md-save.svg + + + Save + + + + + true + + + + :/icons/ionicons-md/md-resize.svg:/icons/ionicons-md/md-resize.svg + + + Fit + + + Fit + + + + + true + + + + :/icons/ionicons-md/md-play.svg:/icons/ionicons-md/md-play.svg + + + Play + + + + + + + + diff --git a/saoriviewentry.cpp b/saoriviewentry.cpp index 2b34cc8..adbbb20 100644 --- a/saoriviewentry.cpp +++ b/saoriviewentry.cpp @@ -192,7 +192,6 @@ void SaoriViewEntry::downloaded(const QUrl url) { - setContent(m_original,m_cw); for (auto i = m_urlmap.begin();i != m_urlmap.end();i ++) { if (i.key().mid(i.key().indexOf(':') + 1, -1) == url.toString()) { setContent(m_original,m_cw); diff --git a/saoriwindow.cpp b/saoriwindow.cpp index 01111b5..d421555 100644 --- a/saoriwindow.cpp +++ b/saoriwindow.cpp @@ -34,6 +34,7 @@ #include "saoriaddaccountdialog.h" #include "saoriview.h" #include "saoriaccount.h" +#include "saorimediaview.h" SaoriWindow::SaoriWindow(QWidget *parent) : QMainWindow(parent), @@ -183,21 +184,23 @@ void SaoriWindow::openMediaView(const QUrl url) { // TODO 専用のwidget作った方がいいでしょう。 - auto view = new QLabel(); + auto view = new SaoriMediaView(); auto sub = ui->mdiArea->addSubWindow(view); + // TODO 以下、SaoriMediaWidgetに実装し直す。 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)); - sub->resize(view->pixmap()->size()); + view->setImage(QImage(SaoriApplication::saori()->cache()->fileCache(url))); + //sub->resize(view->pixmap()->size()); } }); - view->setPixmap(image); + view->setImage(QImage(image)); view->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); sub->show(); - sub->resize(view->pixmap()->size()); + // TODO 以下とりあえず。 + sub->resize(400,400); } void SaoriWindow::closeEvent(QCloseEvent *event)