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/saorimediaview.cpp b/saorimediaview.cpp new file mode 100644 index 0000000..72d0ae7 --- /dev/null +++ b/saorimediaview.cpp @@ -0,0 +1,51 @@ +/*** + +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" + +SaoriMediaView::SaoriMediaView(QWidget *parent) : + QWidget(parent), + ui(new Ui::SaoriMediaView) +{ + ui->setupUi(this); +} + +SaoriMediaView::~SaoriMediaView() +{ + delete ui; +} + +void SaoriMediaView::setImage(QImage image) +{ + ui->media->setPixmap(QPixmap::fromImage(image)); +} + +void SaoriMediaView::setUrls(QList urls, uint current) +{ + m_mediaList = urls; + m_currentMedia = current; +} diff --git a/saorimediaview.h b/saorimediaview.h new file mode 100644 index 0000000..80186ef --- /dev/null +++ b/saorimediaview.h @@ -0,0 +1,58 @@ +/*** + +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 + +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: + QList m_mediaList; + uint m_currentMedia; + +private: + Ui::SaoriMediaView *ui; +}; + +#endif // SAORIMEDIAVIEW_H diff --git a/saorimediaview.ui b/saorimediaview.ui new file mode 100644 index 0000000..92079bb --- /dev/null +++ b/saorimediaview.ui @@ -0,0 +1,83 @@ + + + SaoriMediaView + + + + 0 + 0 + 534 + 452 + + + + Form + + + + + + true + + + + + 0 + 0 + 514 + 389 + + + + + + + + + + + + + + + + + + + + + + + + + + :/icons/ionicons-md/md-arrow-round-up.svg:/icons/ionicons-md/md-arrow-round-up.svg + + + Prev + + + + + + :/icons/ionicons-md/md-arrow-round-down.svg:/icons/ionicons-md/md-arrow-round-down.svg + + + Next + + + + + + :/icons/ionicons-md/md-save.svg:/icons/ionicons-md/md-save.svg + + + Save + + + + + + + + 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)