From f6d389ff354afd35db46b51e7b159a768eec977c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 23 Apr 2018 19:22:51 +0200 Subject: [PATCH] Add current/next comic view to GridView. --- YACReaderLibrary/YACReaderLibrary.pro | 8 +- YACReaderLibrary/classic_comics_view.cpp | 5 + YACReaderLibrary/classic_comics_view.h | 1 + YACReaderLibrary/comics_view.h | 2 + .../current_comic_view_helper.cpp | 17 + YACReaderLibrary/current_comic_view_helper.h | 8 + YACReaderLibrary/db/comic_model.cpp | 7 +- YACReaderLibrary/db/comic_model.h | 3 + YACReaderLibrary/grid_comics_view.cpp | 65 ++- YACReaderLibrary/grid_comics_view.h | 15 +- YACReaderLibrary/info_comics_view.cpp | 5 + YACReaderLibrary/info_comics_view.h | 1 + YACReaderLibrary/library_window.cpp | 29 +- YACReaderLibrary/library_window.h | 1 + YACReaderLibrary/main.cpp | 2 +- YACReaderLibrary/qml.qrc | 2 +- YACReaderLibrary/qml/ComicInfoView.qml | 528 ++++++++++++++++++ YACReaderLibrary/qml/GridComicsView.qml | 248 +++++++- YACReaderLibrary/qml/InfoComicsView.qml | 2 +- .../qml/YACReaderScrollViewStyle.qml | 2 +- .../yacreader_comics_views_manager.cpp | 10 + .../yacreader_comics_views_manager.h | 2 + .../yacreader_navigation_controller.cpp | 2 +- 23 files changed, 933 insertions(+), 32 deletions(-) create mode 100644 YACReaderLibrary/current_comic_view_helper.cpp create mode 100644 YACReaderLibrary/current_comic_view_helper.h create mode 100644 YACReaderLibrary/qml/ComicInfoView.qml diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index f6c5c249..203107c0 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -148,7 +148,8 @@ HEADERS += comic_flow.h \ info_comics_view.h \ yacreader_comics_selection_helper.h \ yacreader_comic_info_helper.h \ - db/reading_list.h + db/reading_list.h \ + current_comic_view_helper.h !CONFIG(no_opengl) { HEADERS += ../common/gl/yacreader_flow_gl.h @@ -218,7 +219,8 @@ SOURCES += comic_flow.cpp \ info_comics_view.cpp \ yacreader_comics_selection_helper.cpp \ yacreader_comic_info_helper.cpp\ - db/reading_list.cpp + db/reading_list.cpp \ + current_comic_view_helper.cpp !CONFIG(no_opengl) { SOURCES += ../common/gl/yacreader_flow_gl.cpp @@ -316,4 +318,4 @@ translation.files = ../release/languages/yacreaderlibrary_* manpage.path = $$DATADIR/man/man1 manpage.files = ../YACReaderLibrary.1 -} \ No newline at end of file +} diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index 90a3736a..f65d2bdc 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -265,6 +265,11 @@ void ClassicComicsView::selectIndex(int index) tableView->selectRow(index); } +void ClassicComicsView::updateCurrentComicView() +{ + +} + void ClassicComicsView::selectAll() { tableView->selectAll(); diff --git a/YACReaderLibrary/classic_comics_view.h b/YACReaderLibrary/classic_comics_view.h index 27bb878f..c06a9429 100644 --- a/YACReaderLibrary/classic_comics_view.h +++ b/YACReaderLibrary/classic_comics_view.h @@ -31,6 +31,7 @@ public: void updateConfig(QSettings * settings); void enableFilterMode(bool enabled); void selectIndex(int index); + void updateCurrentComicView(); public slots: void setCurrentIndex(const QModelIndex &index); diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h index 1876343c..4a106c98 100644 --- a/YACReaderLibrary/comics_view.h +++ b/YACReaderLibrary/comics_view.h @@ -28,6 +28,7 @@ public: virtual void updateConfig(QSettings * settings) = 0; virtual void enableFilterMode(bool enabled) = 0; virtual void selectIndex(int index) = 0; + virtual void updateCurrentComicView() = 0; public slots: virtual void updateInfoForIndex(int index); @@ -36,6 +37,7 @@ public slots: signals: void selected(unsigned int); + void openComic(const ComicDB& comic); void comicRated(int,QModelIndex); //Context menus diff --git a/YACReaderLibrary/current_comic_view_helper.cpp b/YACReaderLibrary/current_comic_view_helper.cpp new file mode 100644 index 00000000..787b0ec6 --- /dev/null +++ b/YACReaderLibrary/current_comic_view_helper.cpp @@ -0,0 +1,17 @@ +#include "current_comic_view_helper.h" + +#include "comic_db.h" + +ComicDB currentComicFromModel(ComicModel *model, bool &found) { + auto comics = model->getAllComics(); + + foreach (auto comic, comics) { + if (comic.info.read == false) { + found = true; + return comic; + } + } + + found = false; + return ComicDB(); +} diff --git a/YACReaderLibrary/current_comic_view_helper.h b/YACReaderLibrary/current_comic_view_helper.h new file mode 100644 index 00000000..595a6332 --- /dev/null +++ b/YACReaderLibrary/current_comic_view_helper.h @@ -0,0 +1,8 @@ +#ifndef CURRENT_COMIC_VIEW_HELPER_H +#define CURRENT_COMIC_VIEW_HELPER_H + +#include "comic_model.h" + +ComicDB currentComicFromModel(ComicModel *model, bool &found); + +#endif // CURRENT_COMIC_VIEW_HELPER_H diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index fd6f1a6d..e4605689 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -295,7 +295,7 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const else if (role == RatingRole) return item->data(Rating); else if (role == CoverPathRole) - return QUrl("file:"+_databasePath+"/covers/"+item->data(Hash).toString()+".jpg"); + return getCoverUrlPathForComicHash(item->data(Hash).toString()); else if (role == NumPagesRole) return item->data(NumPages); else if (role == CurrentPageRole) @@ -994,6 +994,11 @@ void ComicModel::resetComicRating(const QModelIndex &mi) QSqlDatabase::removeDatabase(_databasePath); } +QUrl ComicModel::getCoverUrlPathForComicHash(const QString &hash) const +{ + return QUrl("file:"+_databasePath+"/covers/"+hash+".jpg"); +} + void ComicModel::addComicsToFavorites(const QList &comicIds) { addComicsToFavorites(getIndexesFromIds(comicIds)); diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index b23750c3..e8296e9f 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "yacreader_global_gui.h" @@ -70,6 +71,8 @@ public: void reload(const ComicDB & comic); void resetComicRating(const QModelIndex & mi); + Q_INVOKABLE QUrl getCoverUrlPathForComicHash(const QString& hash) const; + void addComicsToFavorites(const QList &comicsList); void addComicsToLabel(const QList &comicsList, qulonglong labelId); diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 7b35b600..680fc76c 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -11,6 +11,7 @@ #include "comic_db.h" #include "yacreader_comics_selection_helper.h" #include "yacreader_comic_info_helper.h" +#include "current_comic_view_helper.h" //values relative to visible cells const unsigned int YACREADER_MIN_GRID_ZOOM_WIDTH = 156; @@ -30,7 +31,7 @@ const unsigned int YACREADER_MIN_ITEM_WIDTH = YACREADER_MIN_COVER_WIDTH; GridComicsView::GridComicsView(QWidget *parent) : - ComicsView(parent) + ComicsView(parent), filterEnabled(false) { settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini", QSettings::IniFormat, this); settings->beginGroup("libraryConfig"); @@ -151,6 +152,7 @@ GridComicsView::GridComicsView(QWidget *parent) : ctxt->setContextProperty("dummyValue", true); ctxt->setContextProperty("dragManager", this); ctxt->setContextProperty("dropManager", this); + ctxt->setContextProperty("comicOpener", this); bool showInfo = settings->value(COMICS_GRID_SHOW_INFO, false).toBool(); ctxt->setContextProperty("showInfo", showInfo); @@ -237,6 +239,8 @@ void GridComicsView::setModel(ComicModel *model) ComicsView::setModel(model); + setCurrentComicIfNeeded(); + selectionHelper->setModel(model); comicInfoHelper->setModel(model); @@ -255,12 +259,18 @@ void GridComicsView::setModel(ComicModel *model) updateBackgroundConfig(); + selectionHelper->clear(); + if(model->rowCount()>0) { setCurrentIndex(model->index(0,0)); if(showInfoAction->isChecked()) updateInfoForIndex(0); } + + //If the currentComicView was hidden before showing it sometimes the scroll view doesn't show it + //this is a hacky solution... + QTimer::singleShot(0, this, SLOT(resetScroll())); } void GridComicsView::updateBackgroundConfig() @@ -360,7 +370,16 @@ void GridComicsView::updateConfig(QSettings *settings) void GridComicsView::enableFilterMode(bool enabled) { - Q_UNUSED(enabled); + filterEnabled = enabled; + + QQmlContext *ctxt = view->rootContext(); + + if (enabled) { + ctxt->setContextProperty("showCurrentComic", false); + ctxt->setContextProperty("currentComic", nullptr); + } else { + setCurrentComicIfNeeded(); + } } void GridComicsView::selectAll() @@ -373,6 +392,11 @@ void GridComicsView::selectIndex(int index) selectionHelper->selectIndex(index); } +void GridComicsView::triggerOpenCurrentComic() +{ + emit openComic(currentComic); +} + void GridComicsView::rate(int index, int rating) { model->updateRating(rating,model->index(index,0)); @@ -414,6 +438,36 @@ void GridComicsView::dummyUpdater() ctxt->setContextProperty("dummyValue", true); } +void GridComicsView::setCurrentComicIfNeeded() +{ + bool found; + currentComic = currentComicFromModel(model, found); + + QQmlContext *ctxt = view->rootContext(); + + if (found && filterEnabled == false) { + ctxt->setContextProperty("currentComic", ¤tComic); + ctxt->setContextProperty("currentComicInfo", &(currentComic.info)); + ctxt->setContextProperty("showCurrentComic", true); + } + else + { + ctxt->setContextProperty("currentComic", ¤tComic); + ctxt->setContextProperty("currentComicInfo", &(currentComic.info)); + ctxt->setContextProperty("showCurrentComic", false); + //ctxt->setContextProperty("currentComic", nullptr); + + } +} + +void GridComicsView::resetScroll() +{ + QObject *rootObject = dynamic_cast(view->rootObject()); + QObject *scrollView = rootObject->findChild("topScrollView", Qt::FindChildrenRecursively); + + QMetaObject::invokeMethod(scrollView, "scrollToOrigin"); +} + QSize GridComicsView::sizeHint() { return QSize(1280,768); @@ -431,6 +485,11 @@ QByteArray GridComicsView::getMimeDataFromSelection() return data; } +void GridComicsView::updateCurrentComicView() +{ + setCurrentComicIfNeeded(); +} + void GridComicsView::startDrag() { QDrag *drag = new QDrag(this); @@ -498,7 +557,7 @@ void GridComicsView::closeEvent(QCloseEvent *event) toolbar->removeAction(coverSizeSliderAction); QObject *rootObject = dynamic_cast(view->rootObject()); - QObject *infoContainer = rootObject->findChild("infoContainer"); + QObject *infoContainer = rootObject->findChild("infoContainer", Qt::FindChildrenRecursively); int infoWidth = QQmlProperty(infoContainer, "width").read().toInt(); diff --git a/YACReaderLibrary/grid_comics_view.h b/YACReaderLibrary/grid_comics_view.h index 8d3348ce..351a33ea 100644 --- a/YACReaderLibrary/grid_comics_view.h +++ b/YACReaderLibrary/grid_comics_view.h @@ -5,6 +5,7 @@ #include +#include "comic_db.h" class QAbstractListModel; @@ -17,7 +18,6 @@ class YACReaderComicsSelectionHelper; class YACReaderComicInfoHelper; - class GridComicsView : public ComicsView { Q_OBJECT @@ -36,12 +36,14 @@ public: void enableFilterMode(bool enabled); QSize sizeHint(); QByteArray getMimeDataFromSelection(); + void updateCurrentComicView(); public slots: //ComicsView void setShowMarks(bool show); void selectAll(); void selectIndex(int index); + void triggerOpenCurrentComic(); void updateBackgroundConfig(); @@ -68,6 +70,13 @@ protected slots: void dummyUpdater(); //TODO remove this + void setCurrentComicIfNeeded(); + + void resetScroll(); + +signals: + void onScrollToOrigin(); + private: QSettings * settings; QToolBar * toolbar; @@ -79,9 +88,13 @@ private: QAction * showInfoAction; QAction * showInfoSeparatorAction; + boolean filterEnabled; + YACReaderComicsSelectionHelper * selectionHelper; YACReaderComicInfoHelper * comicInfoHelper; + ComicDB currentComic; + bool dummy; void closeEvent ( QCloseEvent * event ); void createCoverSizeSliderWidget(); diff --git a/YACReaderLibrary/info_comics_view.cpp b/YACReaderLibrary/info_comics_view.cpp index 44af8dc3..86a65f69 100644 --- a/YACReaderLibrary/info_comics_view.cpp +++ b/YACReaderLibrary/info_comics_view.cpp @@ -201,6 +201,11 @@ void InfoComicsView::selectIndex(int index) selectionHelper->selectIndex(index); } +void InfoComicsView::updateCurrentComicView() +{ + +} + void InfoComicsView::setShowMarks(bool show) { QQmlContext *ctxt = view->rootContext(); diff --git a/YACReaderLibrary/info_comics_view.h b/YACReaderLibrary/info_comics_view.h index 53699148..e41d7620 100644 --- a/YACReaderLibrary/info_comics_view.h +++ b/YACReaderLibrary/info_comics_view.h @@ -29,6 +29,7 @@ public: void updateConfig(QSettings * settings); void enableFilterMode(bool enabled); void selectIndex(int index); + void updateCurrentComicView(); public slots: void setShowMarks(bool show); diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index a2263db6..3af8e8d0 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1792,14 +1792,12 @@ void LibraryWindow::checkEmptyFolder() } } -void LibraryWindow::openComic() +void LibraryWindow::openComic(const ComicDB &comic) { - if(!importedCovers) - { - ComicDB comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex()); + if(!importedCovers) { QList siblings = comicsModel->getAllComics(); - //TODO generate IDS for libraries... + //TODO generate IDS for libraries... quint64 libraryId = libraries.getId(selectedLibrary->currentText()); bool yacreaderFound = false; @@ -1822,26 +1820,36 @@ void LibraryWindow::openComic() #ifdef Q_OS_WIN QStringList parameters {currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId)}; - yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath()), parameters); + yacreaderFound = QProcess::startDetached(QDir::cleanPath(QCoreApplication::applicationDirPath()+"/YACReader.exe"), parameters); #endif #if defined Q_OS_UNIX && !defined Q_OS_MAC QStringList parameters {currentPath(), QString("--comicId=%1").arg(comic.id), QString("--libraryId=%1").arg(libraryId)}; - yacreaderFound = QProcess::startDetached(QStringLiteral("YACReader"), parameters); + yacreaderFound = QProcess::startDetached(QStringLiteral("YACReader"), parameters); #endif if(!yacreaderFound) { - #ifdef Q_OS_WIN +#ifdef Q_OS_WIN QMessageBox::critical(this,tr("YACReader not found"),tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary.")); - #else +#else QMessageBox::critical(this,tr("YACReader not found"),tr("YACReader not found. There might be a problem with your YACReader installation.")); - #endif +#endif } + } +} + +void LibraryWindow::openComic() +{ + if(!importedCovers) + { + ComicDB comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex()); + openComic(comic); } } void LibraryWindow::setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus) { comicsModel->setComicsRead(getSelectedComics(),readStatus); + comicsViewsManager->updateCurrentComicView(); } void LibraryWindow::setCurrentComicReaded() { @@ -2618,5 +2626,6 @@ void LibraryWindow::updateComicsView(quint64 libraryId, const ComicDB & comic) { if(libraryId == libraries.getId(selectedLibrary->currentText())) { comicsModel->reload(comic); + comicsViewsManager->updateCurrentComicView(); } } diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index df151749..3d27fe24 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -296,6 +296,7 @@ public slots: void selectSubfolder(const QModelIndex & mi, int child); void checkEmptyFolder(); void openComic(); + void openComic(const ComicDB & comic); void createLibrary(); void create(QString source,QString dest, QString name); void showAddLibrary(); diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 6113b300..5eac3207 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -101,7 +101,7 @@ int main( int argc, char ** argv ) QDir().mkpath(YACReader::getSettingsPath()); Logger& logger = Logger::instance(); - logger.setLoggingLevel(QsLogging::InfoLevel); + logger.setLoggingLevel(QsLogging::TraceLevel); DestinationPtr fileDestination(DestinationFactory::MakeFileDestination( destLog, EnableLogRotation, MaxSizeBytes(1048576), MaxOldLogCount(2))); diff --git a/YACReaderLibrary/qml.qrc b/YACReaderLibrary/qml.qrc index d3d279ea..ae0b04ff 100644 --- a/YACReaderLibrary/qml.qrc +++ b/YACReaderLibrary/qml.qrc @@ -15,7 +15,7 @@ qml/info-indicator-light@2x.png qml/info-shadow-light@2x.png qml/info-top-shadow.png - qml/ComicInfo.qml + qml/ComicInfoView.qml qml/info-favorites.png qml/info-favorites@2x.png qml/info-rating.png diff --git a/YACReaderLibrary/qml/ComicInfoView.qml b/YACReaderLibrary/qml/ComicInfoView.qml new file mode 100644 index 00000000..ea5b6ccb --- /dev/null +++ b/YACReaderLibrary/qml/ComicInfoView.qml @@ -0,0 +1,528 @@ +import QtQuick 2.6 + +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.2 + +import QtGraphicalEffects 1.0 + +import com.yacreader.ComicInfo 1.0 +import com.yacreader.ComicDB 1.0 + +Rectangle { + + color : "transparent" + id: mainContainer + + height: info.height + 2 * topMargin + + property string infoColor: infoTextColor + property font infoFont: Qt.font({ + + family: "Arial", + pixelSize: 14 + }); + + property int topMargin : 27 + + property bool compact : width <= 650 + + RowLayout + { + id:main_layout + anchors.fill: parent + + //READ------------------------------------------------------------ + ColumnLayout + { + Layout.topMargin: topMargin + Layout.maximumWidth: 61 + Layout.fillHeight: true + id: readStatus + + Layout.alignment: Qt.AlignTop | + Qt.AlignHCenter + + Rectangle { + color: "transparent" + width: 61 + height: 24 + + InfoTick { + x: 27 + y: 5 + + read: comicInfo.read + + onReadChangedByUser: { + comicInfo.read = read; + comicInfoHelper.setRead(comic_info_index, read); + } + } + } + + visible: !mainContainer.compact + } + + //INFO------------------------------------------------------------ + ColumnLayout + { + id: info + //width: parent.width + //Layout.fillWidth: true + + Layout.alignment: Qt.AlignTop | + Qt.AlignLeft + + Layout.maximumWidth: mainContainer.compact ? mainContainer.width : 960 + + Layout.leftMargin: mainContainer.compact ? 30 : 0 + + RowLayout + { + Layout.topMargin: topMargin + + InfoTick { + Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft + + read: comicInfo.read + + onReadChangedByUser: { + comicInfo.read = read; + comicInfoHelper.setRead(comic_info_index, read); + } + } + + Item { + Layout.fillWidth: true + } + + InfoFavorites { + Layout.topMargin: 1 + Layout.rightMargin: 17 + Layout.alignment: Qt.AlignTop + + active: comicInfo.isFavorite + + onActiveChangedByUser: { + if(active) + comicInfoHelper.addToFavorites(comic_info_index); + else + comicInfoHelper.removeFromFavorites(comic_info_index); + + comicInfo.isFavorite = active; + } + } + + InfoRating { + Layout.alignment: Qt.AlignTop + Layout.rightMargin: 30 + rating: comicInfo.rating + + onRatingChangedByUser: { + comicInfo.rating = rating; + comicInfoHelper.rate(comic_info_index, rating); + } + } + + visible: mainContainer.compact + } + + RowLayout + { + Text { + Layout.topMargin: mainContainer.compact ? 18 : topMargin + Layout.fillWidth: true + Layout.rightMargin: mainContainer.compact ? 30 : 0 + + id: title + + color: infoTitleColor + font.family: "Arial" + font.bold: true + font.pixelSize: mainContainer.compact ? 18 : 21; + wrapMode: Text.WordWrap + + text: comic.getTitleIncludingNumber() + } + + RowLayout + { + visible: !mainContainer.compact + + Layout.alignment: Qt.AlignTop + Layout.topMargin: topMargin + + InfoFavorites { + Layout.topMargin: 1 + Layout.rightMargin: 17 + Layout.alignment: Qt.AlignTop + + active: comicInfo.isFavorite + + onActiveChangedByUser: { + if(active) + comicInfoHelper.addToFavorites(comic_info_index); + else + comicInfoHelper.removeFromFavorites(comic_info_index); + + comicInfo.isFavorite = active; + } + } + + InfoRating { + Layout.alignment: Qt.AlignTop + Layout.rightMargin: 30 + rating: comicInfo.rating + + onRatingChangedByUser: { + comicInfo.rating = rating; + comicInfoHelper.rate(comic_info_index, rating); + } + } + } + } + + Flow { + spacing: 0 + + Layout.fillWidth: true + Text { + id: volume + color: infoColor + font: mainContainer.infoFont + text: comicInfo.volume + rightPadding: 20 + visible: comicInfo.volume + } + + Text { + id: numbering + color: infoColor + font: mainContainer.infoFont + text: comicInfo.number + "/" + comicInfo.count + rightPadding: 20 + visible : comicInfo.number + } + + Text { + id: genre + color: infoColor + font: mainContainer.infoFont + text: comicInfo.genere + rightPadding: 20 + visible: comicInfo.genere + } + + Text { + id: date + color: infoColor + font: mainContainer.infoFont + text: comicInfo.date + rightPadding: 20 + visible: comicInfo.date + } + + Text { + id: pages + color: infoColor + font: mainContainer.infoFont + text: comicInfo.numPages + " pages" + rightPadding: 20 + visible: comicInfo.numPages + } + + Text { + id: showInComicVine + font: mainContainer.infoFont + color: "#ffcc00" + text: "Show in Comic Vine" + visible: comicInfo.comicVineID + MouseArea { + anchors.fill: parent + onClicked: { + Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo.comicVineID)); + } + } + } + } + + Text { + Layout.topMargin: 22 + Layout.rightMargin: 30 + Layout.bottomMargin: 5 + Layout.fillWidth: true + + id: sinopsis + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignJustify + text: comicInfo.synopsis + visible: comicInfo.synopsis + } + + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: authors_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: "Authors" + + visible: comicInfo.getWriters().length + + comicInfo.getPencillers().length + + comicInfo.getInkers().length + + comicInfo.getColorists().length + + comicInfo.getLetterers().length + + comicInfo.getCoverArtists().length > 0 + } + + Flow { + Layout.fillWidth: true + spacing: 20 + Repeater { + id: writers + model: comicInfo.getWriters().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getWriters()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "writer" + } + } + } + + Repeater { + id: pencilllers + model: comicInfo.getPencillers().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getPencillers()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "penciller" + } + } + } + + Repeater { + id: inkers + model: comicInfo.getInkers().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getInkers()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "inker" + } + } + } + + Repeater { + id: colorist + model: comicInfo.getColorists().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getColorists()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "colorist" + } + } + } + + Repeater { + id: letterers + model: comicInfo.getLetterers().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getLetterers()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "letterer" + } + } + } + + Repeater { + id: cover_artist + model: comicInfo.getCoverArtists().length + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getCoverArtists()[index] + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: "cover artist" + } + } + } + } + + Text { + Layout.topMargin: 25 + + id: publisher_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: "Publisher" + + visible: publisher.visible || format.visible || color.visible || age_rating.visible + } + + Flow { + Layout.fillWidth: true + spacing: 20 + + Text { + id: publisher + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.publisher + + visible: comicInfo.publisher + } + + Text { + id: format + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.format + + visible: comicInfo.format + } + + Text { + id: color + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.color ? "color" : "b/w" + + visible: comicInfo.color + } + + Text { + id: age_rating + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.ageRating + + visible: comicInfo.ageRating + } + } + + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: characters_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: "Characters" + + visible: comicInfo.getCharacters().length > 0 + } + + Flow { + Layout.fillWidth: true + spacing: 20 + Repeater { + id: characters + model: comicInfo.getCharacters().length + + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo.getCharacters()[index] + } + } + } + } + + Item { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.minimumWidth: 0 + Layout.preferredWidth: 0 + } + } +} diff --git a/YACReaderLibrary/qml/GridComicsView.qml b/YACReaderLibrary/qml/GridComicsView.qml index 56b45fde..324f2ac0 100644 --- a/YACReaderLibrary/qml/GridComicsView.qml +++ b/YACReaderLibrary/qml/GridComicsView.qml @@ -1,13 +1,16 @@ -import QtQuick 2.3 +import QtQuick 2.9 import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.2 +import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import QtQuick.Controls.Styles 1.4 import com.yacreader.ComicModel 1.0 +import com.yacreader.ComicInfo 1.0 +import com.yacreader.ComicDB 1.0 + SplitView { anchors.fill: parent orientation: Qt.Horizontal @@ -171,7 +174,6 @@ Rectangle { } onPressed: { - var ci = grid.currentIndex; //save current index /*if(mouse.button != Qt.RightButton && !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier)) @@ -385,12 +387,18 @@ Rectangle { } } - YACReaderScrollView { - __wheelAreaScrollSpeed: grid.cellHeight * 0.30 + ScrollView { + __wheelAreaScrollSpeed: grid.cellHeight * 0.40 id: scrollView + objectName: "topScrollView" anchors.fill: parent anchors.margins: 0 + function scrollToOrigin() { + flickableItem.contentY = showCurrentComic ? -270 : -20 + flickableItem.contentX = 0 + } + style: YACReaderScrollViewStyle { transientScrollBars: false incrementControl: Item {} @@ -456,22 +464,244 @@ Rectangle { } } + Component { + id: currentComicView + Rectangle { + id: currentComicViewTopView + color: "#00000000" + + height: showCurrentComic ? 270 : 20 + + Rectangle { + color: "#88000000" + + id: currentComicVisualView + + width: main.width + height: 250 + + visible: showCurrentComic + + //cover + Image { + id: currentCoverElement + anchors.fill: parent + width: paintedWidth + + anchors.leftMargin: 15 + anchors.topMargin: 15 + anchors.bottomMargin: 15 + anchors.rightMargin: 15 + horizontalAlignment: Image.AlignLeft + anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 0} + source: comicsList.getCoverUrlPathForComicHash(currentComicInfo.hash.toString()) + fillMode: Image.PreserveAspectFit + smooth: true + mipmap: true + asynchronous : true + cache: false //TODO clear cache only when it is needed + } + + DropShadow { + anchors.fill: currentCoverElement + horizontalOffset: 0 + verticalOffset: 0 + radius: 8.0 + samples: 17 + color: "#FF000000" + source: currentCoverElement + visible: (Qt.platform.os === "osx") ? false : true; + } + + ColumnLayout + { + id: currentComicInfoView + + x: currentCoverElement.anchors.rightMargin + currentCoverElement.paintedWidth + currentCoverElement.anchors.rightMargin + //y: currentCoverElement.anchors.topMargin + + anchors.top: currentCoverElement.top + anchors.right: parent.right + anchors.left: readButton.left + + spacing: 9 + + Text { + Layout.topMargin: 7 + Layout.fillWidth: true + Layout.rightMargin: 20 + + Layout.alignment: Qt.AlignTop | Qt.AlignLeft + + id: currentComicInfoTitleView + + color: infoTitleColor + font.family: "Arial" + font.bold: true + font.pixelSize: 21 + wrapMode: Text.WordWrap + + text: currentComic.getTitleIncludingNumber() + } + + Flow { + spacing: 0 + Layout.alignment: Qt.AlignTop | Qt.AlignLeft + Layout.fillWidth: true + Layout.fillHeight: false + + id: currentComicDetailsFlowView + property font infoFont: Qt.font({ + family: "Arial", + pixelSize: 14 + }); + property string infoFlowTextColor: infoTextColor + + Text { + id: currentComicInfoVolume + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.volume + rightPadding: 20 + visible: currentComicInfo.volume + } + + Text { + id: currentComicInfoNumbering + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.number + "/" + currentComicInfo.count + rightPadding: 20 + visible : currentComicInfo.number + } + + Text { + id: currentComicInfoGenre + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.genere + rightPadding: 20 + visible: currentComicInfo.genere + } + + Text { + id: currentComicInfoDate + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.date + rightPadding: 20 + visible: currentComicInfo.date + } + + Text { + id: currentComicInfoPages + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.numPages + " pages" + rightPadding: 20 + visible: currentComicInfo.numPages + } + + Text { + id: currentComicInfoShowInComicVine + font: currentComicDetailsFlowView.infoFont + color: "#ffcc00" + text: "Show in Comic Vine" + visible: currentComicInfo.comicVineID + MouseArea { + anchors.fill: parent + onClicked: { + Qt.openUrlExternally("http://www.comicvine.com/comic/4000-%1/".arg(comicInfo.comicVineID)); + } + } + } + } + + Text { + Layout.topMargin: 6 + Layout.rightMargin: 30 + Layout.bottomMargin: 5 + Layout.fillWidth: true + Layout.maximumHeight: (currentComicVisualView.height * 0.32) + Layout.maximumWidth: 960 + + id: currentComicInfoSinopsis + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 14 + wrapMode: Text.WordWrap + elide: Text.ElideRight + horizontalAlignment: Text.AlignJustify + text: currentComicInfo.synopsis + visible: currentComicInfo.synopsis + } + } + + Button { + text: "Read" + id: readButton + x: currentCoverElement.anchors.rightMargin + currentCoverElement.paintedWidth + currentCoverElement.anchors.rightMargin + anchors.bottom: currentCoverElement.bottom + anchors.bottomMargin: 15 + + onClicked: comicOpener.triggerOpenCurrentComic() + + style: ButtonStyle { + background: Rectangle { + implicitWidth: 100 + implicitHeight: 30 + border.width: control.activeFocus ? 2 : 1 + border.color: "#FFCC00" + radius: height / 2 + color: "#FFCC00" + + } + label: Text { + renderType: Text.NativeRendering + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.family: "Arial" + font.pointSize: 12 + font.bold: true + color: "white" + text: control.text + } + } + } + + + DropShadow { + anchors.fill: readButton + horizontalOffset: 0 + verticalOffset: 0 + radius: 8.0 + samples: 17 + color: "#AA000000" + source: readButton + visible: ((Qt.platform.os === "osx") ? false : true) && !readButton.pressed + } + } + } + } + GridView { id:grid objectName: "grid" anchors.fill: parent cellHeight: cellCustomHeight + header: currentComicView //highlight: appHighlight focus: true model: comicsList delegate: appDelegate - anchors.topMargin: 20 + anchors.topMargin: 0 //showCurrentComic ? 0 : 20 anchors.bottomMargin: 20 - anchors.leftMargin: 10 - anchors.rightMargin: 10 + anchors.leftMargin: 0 + anchors.rightMargin: 0 pixelAligned: true //flickDeceleration: -2000 + currentIndex: 0 cacheBuffer: 0 @@ -620,7 +850,7 @@ Rectangle { } } - ComicInfo { + ComicInfoView { width: info_container.width } } diff --git a/YACReaderLibrary/qml/InfoComicsView.qml b/YACReaderLibrary/qml/InfoComicsView.qml index b6835de0..35bfe7c5 100644 --- a/YACReaderLibrary/qml/InfoComicsView.qml +++ b/YACReaderLibrary/qml/InfoComicsView.qml @@ -91,7 +91,7 @@ Rectangle { } } - ComicInfo { + ComicInfoView { width: info_container.width - 14 } } diff --git a/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml b/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml index e9a0e787..e756431e 100644 --- a/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml +++ b/YACReaderLibrary/qml/YACReaderScrollViewStyle.qml @@ -50,7 +50,7 @@ Style { id: root /*! The \l ScrollView this style is attached to. */ - readonly property YACReaderScrollView control: __control + readonly property ScrollView control: __control /*! This property controls the frame border padding of the scrollView. */ padding {left: 1; top: 1; right: 1; bottom: 1} diff --git a/YACReaderLibrary/yacreader_comics_views_manager.cpp b/YACReaderLibrary/yacreader_comics_views_manager.cpp index 21c9fb26..711216a9 100644 --- a/YACReaderLibrary/yacreader_comics_views_manager.cpp +++ b/YACReaderLibrary/yacreader_comics_views_manager.cpp @@ -70,6 +70,13 @@ QWidget * YACReaderComicsViewsManager::containerWidget() return comicsViewStack; } +void YACReaderComicsViewsManager::updateCurrentComicView() +{ + if (comicsViewStack->currentWidget() == comicsView) { + comicsView->updateCurrentComicView(); + } +} + void YACReaderComicsViewsManager::showComicsView() { comicsViewStack->setCurrentWidget(comicsView); @@ -123,6 +130,7 @@ void YACReaderComicsViewsManager::disconnectComicsViewConnections(ComicsView * w disconnect(widget, SIGNAL(comicRated(int,QModelIndex)), libraryWindow->comicsModel, SLOT(updateRating(int,QModelIndex))); disconnect(libraryWindow->showHideMarksAction,SIGNAL(toggled(bool)),widget,SLOT(setShowMarks(bool))); disconnect(widget,SIGNAL(selected(unsigned int)),libraryWindow,SLOT(openComic())); + disconnect(widget,SIGNAL(openComic(ComicDB)),libraryWindow,SLOT(openComic(ComicDB))); disconnect(libraryWindow->selectAllComicsAction,SIGNAL(triggered()),widget,SLOT(selectAll())); disconnect(comicsView, SIGNAL(copyComicsToCurrentFolder(QList >)), libraryWindow, SLOT(copyAndImportComicsToCurrentFolder(QList >))); disconnect(comicsView, SIGNAL(moveComicsToCurrentFolder(QList >)), libraryWindow, SLOT(moveAndImportComicsToCurrentFolder(QList >))); @@ -135,6 +143,8 @@ void YACReaderComicsViewsManager::doComicsViewConnections() connect(comicsView, SIGNAL(comicRated(int,QModelIndex)), libraryWindow->comicsModel, SLOT(updateRating(int,QModelIndex))); connect(libraryWindow->showHideMarksAction,SIGNAL(toggled(bool)),comicsView,SLOT(setShowMarks(bool))); connect(comicsView,SIGNAL(selected(unsigned int)),libraryWindow,SLOT(openComic())); + connect(comicsView,SIGNAL(openComic(ComicDB)),libraryWindow,SLOT(openComic(ComicDB))); + connect(libraryWindow->selectAllComicsAction,SIGNAL(triggered()),comicsView,SLOT(selectAll())); connect(comicsView,SIGNAL(customContextMenuViewRequested(QPoint)),libraryWindow,SLOT(showComicsViewContextMenu(QPoint))); diff --git a/YACReaderLibrary/yacreader_comics_views_manager.h b/YACReaderLibrary/yacreader_comics_views_manager.h index 62136ca9..bd4fa3c9 100644 --- a/YACReaderLibrary/yacreader_comics_views_manager.h +++ b/YACReaderLibrary/yacreader_comics_views_manager.h @@ -39,6 +39,8 @@ public: NoSearchResultsWidget * noSearchResultsWidget; + void updateCurrentComicView(); + protected: QStackedWidget * comicsViewStack; LibraryWindow * libraryWindow; diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index ab1afd33..a52366d7 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -60,12 +60,12 @@ void YACReaderNavigationController::loadFolderInfo(const QModelIndex &modelIndex //check comics in folder with id = folderId libraryWindow->comicsModel->setupFolderModelData(folderId,libraryWindow->foldersModel->getDatabase()); - comicsViewsManager->comicsView->setModel(libraryWindow->comicsModel); //configure views if(libraryWindow->comicsModel->rowCount() > 0) { //updateView + comicsViewsManager->comicsView->setModel(libraryWindow->comicsModel); comicsViewsManager->showComicsView(); libraryWindow->disableComicsActions(false); }