diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index d454d218..4ac749b7 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -85,6 +85,7 @@ HEADERS += comic_flow.h \ library_creator.h \ library_window.h \ add_library_dialog.h \ + recent_visibility_coordinator.h \ rename_library_dialog.h \ properties_dialog.h \ options_dialog.h \ @@ -171,6 +172,7 @@ SOURCES += comic_flow.cpp \ library_window.cpp \ main.cpp \ add_library_dialog.cpp \ + recent_visibility_coordinator.cpp \ rename_library_dialog.cpp \ properties_dialog.cpp \ options_dialog.cpp \ diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index 9d3c3603..1121074a 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -120,9 +120,7 @@ void ClassicComicsView::setToolBar(QToolBar *toolBar) static_cast(comics->layout())->insertWidget(0, toolBar); this->toolbar = toolBar; - toolBarStretch = new YACReaderToolBarStretch(this); - - toolBarStretchAction = toolBar->addWidget(toolBarStretch); + startSeparatorAction = toolBar->addSeparator(); toolBar->addAction(hideFlowViewAction); } @@ -343,7 +341,7 @@ void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, void ClassicComicsView::closeEvent(QCloseEvent *event) { - toolbar->removeAction(toolBarStretchAction); + toolbar->removeAction(startSeparatorAction); toolbar->removeAction(hideFlowViewAction); saveTableHeadersStatus(); diff --git a/YACReaderLibrary/classic_comics_view.h b/YACReaderLibrary/classic_comics_view.h index 98bb02ef..6307b4bb 100644 --- a/YACReaderLibrary/classic_comics_view.h +++ b/YACReaderLibrary/classic_comics_view.h @@ -54,8 +54,6 @@ protected slots: private: YACReaderTableView *tableView; - YACReaderToolBarStretch *toolBarStretch; - QAction *toolBarStretchAction; QToolBar *toolbar; QWidget *comics; QSplitter *sVertical; @@ -63,6 +61,7 @@ private: QSettings *settings; void closeEvent(QCloseEvent *event) override; QAction *hideFlowViewAction; + QAction *startSeparatorAction; QStackedWidget *stack; diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index 34f6c1eb..08216740 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -17,12 +17,13 @@ #include "QsLog.h" ComicModel::ComicModel(QObject *parent) - : QAbstractItemModel(parent) + : QAbstractItemModel(parent), showRecent(false) + { } ComicModel::ComicModel(QSqlQuery &sqlquery, QObject *parent) - : QAbstractItemModel(parent) + : QAbstractItemModel(parent), showRecent(false) { setupModelData(sqlquery); } @@ -239,7 +240,9 @@ QHash ComicModel::roleNames() const roles[CoverPathRole] = "cover_path"; roles[PublicationDate] = "date"; roles[ReadableTitle] = "readable_title"; - roles[Added] = "added_date"; + roles[AddedRole] = "added_date"; + roles[TypeRole] = "type"; + roles[ShowRecentRole] = "show_recent"; return roles; } @@ -306,6 +309,8 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const return item->data(Added); else if (role == TypeRole) return item->data(Type); + else if (role == ShowRecentRole) + return showRecent; if (role != Qt::DisplayRole) return QVariant(); @@ -1129,6 +1134,16 @@ bool ComicModel::isFavorite(const QModelIndex &index) return isFavorite; } +void ComicModel::setShowRecent(bool showRecent) +{ + if (this->showRecent == showRecent) + return; + + this->showRecent = showRecent; + + emit dataChanged(index(0, 0), index(rowCount() - 1, 0), { ComicModel::ShowRecentRole }); +} + void ComicModel::updateRating(int rating, QModelIndex mi) { ComicDB comic = getComic(mi); diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index b4b5eeda..62e582d0 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -59,6 +59,7 @@ public: ReadableTitle, AddedRole, TypeRole, + ShowRecentRole, }; enum Mode { @@ -139,6 +140,8 @@ public: ComicModel::Mode getMode() { return mode; } unsigned long long int getSourceId() { return sourceId; } + void setShowRecent(bool visible); + QHash roleNames() const override; public slots: @@ -168,6 +171,8 @@ private: qulonglong sourceId; QString localizedDate(const QString &dbDate) const; + bool showRecent; + signals: void isEmpty(); void searchNumResults(int); diff --git a/YACReaderLibrary/db/folder_model.cpp b/YACReaderLibrary/db/folder_model.cpp index 0b0abbee..73bd9a88 100644 --- a/YACReaderLibrary/db/folder_model.cpp +++ b/YACReaderLibrary/db/folder_model.cpp @@ -52,12 +52,12 @@ void drawMacOSXFinishedFolderIcon() #define ROOT 1 FolderModel::FolderModel(QObject *parent) - : QAbstractItemModel(parent), isSubfolder(false), rootItem(nullptr), folderIcon(YACReader::noHighlightedIcon(":/images/sidebar/folder.svg")), folderFinishedIcon(YACReader::noHighlightedIcon(":/images/sidebar/folder_finished.svg")) + : QAbstractItemModel(parent), isSubfolder(false), rootItem(nullptr), folderIcon(YACReader::noHighlightedIcon(":/images/sidebar/folder.svg")), folderFinishedIcon(YACReader::noHighlightedIcon(":/images/sidebar/folder_finished.svg")), showRecent(false) { } FolderModel::FolderModel(QSqlQuery &sqlquery, QObject *parent) - : QAbstractItemModel(parent), isSubfolder(false), rootItem(nullptr) + : QAbstractItemModel(parent), isSubfolder(false), rootItem(nullptr), showRecent(false) { QList rootData; rootData << "root"; // id 1, parent 1, title "root" @@ -99,6 +99,7 @@ QHash FolderModel::roleNames() const roles[TypeRole] = "type"; roles[AddedRole] = "added"; roles[UpdatedRole] = "updated"; + roles[ShowRecentRole] = "show_recent"; return roles; } @@ -181,6 +182,9 @@ QVariant FolderModel::data(const QModelIndex &index, int role) const if (role == FolderModel::UpdatedRole) return item->data(Updated); + if (role == FolderModel::ShowRecentRole) + return showRecent; + if (role != Qt::DisplayRole) return QVariant(); @@ -195,7 +199,8 @@ Qt::ItemFlags FolderModel::flags(const QModelIndex &index) const return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled; } -QVariant FolderModel::headerData(int section, Qt::Orientation orientation, +QVariant FolderModel::headerData(int section, + Qt::Orientation orientation, int role) const { if (rootItem == nullptr) { @@ -401,7 +406,7 @@ void FolderModel::updateFolderCompletedStatus(const QModelIndexList &list, bool } QSqlDatabase::removeDatabase(connectionName); - emit dataChanged(index(list.first().row(), FolderModel::Name), index(list.last().row(), FolderModel::FirstChildHash)); + emit dataChanged(index(list.first().row(), FolderModel::Name), index(list.last().row(), FolderModel::Updated)); } void FolderModel::updateFolderFinishedStatus(const QModelIndexList &list, bool status) @@ -640,6 +645,16 @@ QUrl FolderModel::getCoverUrlPathForComicHash(const QString &hash) const return QUrl("file:" + _databasePath + "/covers/" + hash + ".jpg"); } +void FolderModel::setShowRecent(bool showRecent) +{ + if (this->showRecent == showRecent) + return; + + this->showRecent = showRecent; + + emit dataChanged(index(0, 0), index(rowCount() - 1, 0), { FolderModel::ShowRecentRole }); +} + void FolderModel::deleteFolder(const QModelIndex &mi) { beginRemoveRows(mi.parent(), mi.row(), mi.row()); diff --git a/YACReaderLibrary/db/folder_model.h b/YACReaderLibrary/db/folder_model.h index 6dae78c5..11238b0c 100644 --- a/YACReaderLibrary/db/folder_model.h +++ b/YACReaderLibrary/db/folder_model.h @@ -81,6 +81,8 @@ public: Q_INVOKABLE QUrl getCoverUrlPathForComicHash(const QString &hash) const; + void setShowRecent(bool showRecent); + enum Columns { Name = 0, Path, @@ -106,6 +108,7 @@ public: TypeRole, AddedRole, UpdatedRole, + ShowRecentRole, }; bool isSubfolder; @@ -125,6 +128,8 @@ private: QIcon folderIcon; QIcon folderFinishedIcon; + + bool showRecent; }; #endif diff --git a/YACReaderLibrary/folder_content_view.cpp b/YACReaderLibrary/folder_content_view.cpp index db8eb460..69e31770 100644 --- a/YACReaderLibrary/folder_content_view.cpp +++ b/YACReaderLibrary/folder_content_view.cpp @@ -13,7 +13,7 @@ using namespace YACReader; -FolderContentView::FolderContentView(QWidget *parent) +FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWidget *parent) : QWidget { parent }, parent(QModelIndex()), comicModel(new ComicModel()), folderModel(new FolderModel()) { qmlRegisterType("com.yacreader.FolderModel", 1, 0, "FolderModel"); @@ -60,6 +60,8 @@ FolderContentView::FolderContentView(QWidget *parent) toolbar = new QToolBar(); toolbar->addWidget(new YACReaderToolBarStretch); + toolbar->addAction(toogleRecentVisibilityAction); + toolbar->addSeparator(); toolbar->addWidget(coverSizeSliderWidget); auto l = new QVBoxLayout; @@ -205,6 +207,11 @@ void FolderContentView::reloadContinueReadingModel() } } +void FolderContentView::setShowRecent(bool visible) +{ + folderModel->setShowRecent(visible); +} + void FolderContentView::openFolder(int index) { emit subfolderSelected(this->parent, index); diff --git a/YACReaderLibrary/folder_content_view.h b/YACReaderLibrary/folder_content_view.h index 22de2413..865534aa 100644 --- a/YACReaderLibrary/folder_content_view.h +++ b/YACReaderLibrary/folder_content_view.h @@ -19,10 +19,11 @@ class FolderContentView : public QWidget { Q_OBJECT public: - explicit FolderContentView(QWidget *parent = nullptr); + explicit FolderContentView(QAction *toogleRecentVisibilityAction, QWidget *parent = nullptr); void setModel(const QModelIndex &parent, FolderModel *model); void setContinueReadingModel(ComicModel *model); void reloadContinueReadingModel(); + void setShowRecent(bool visible); FolderModel *currentFolderModel() { return folderModel; } signals: diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index c7e9b6fd..4f3548d6 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -170,7 +170,6 @@ GridComicsView::~GridComicsView() void GridComicsView::createCoverSizeSliderWidget() { - toolBarStretch = new YACReaderToolBarStretch(this); coverSizeSliderWidget = new QWidget(this); coverSizeSliderWidget->setFixedWidth(200); coverSizeSlider = new QSlider(); @@ -206,7 +205,7 @@ void GridComicsView::setToolBar(QToolBar *toolBar) createCoverSizeSliderWidget(); - toolBarStretchAction = toolBar->addWidget(toolBarStretch); + startSeparatorAction = toolBar->addSeparator(); toolBar->addAction(showInfoAction); showInfoSeparatorAction = toolBar->addSeparator(); coverSizeSliderAction = toolBar->addWidget(coverSizeSliderWidget); @@ -553,7 +552,7 @@ void GridComicsView::setShowMarks(bool show) void GridComicsView::closeEvent(QCloseEvent *event) { - toolbar->removeAction(toolBarStretchAction); + toolbar->removeAction(startSeparatorAction); toolbar->removeAction(showInfoAction); toolbar->removeAction(showInfoSeparatorAction); toolbar->removeAction(coverSizeSliderAction); diff --git a/YACReaderLibrary/grid_comics_view.h b/YACReaderLibrary/grid_comics_view.h index 158ebc6a..6b47c3a3 100644 --- a/YACReaderLibrary/grid_comics_view.h +++ b/YACReaderLibrary/grid_comics_view.h @@ -97,13 +97,12 @@ signals: private: QSettings *settings; QToolBar *toolbar; - YACReaderToolBarStretch *toolBarStretch; - QAction *toolBarStretchAction; QWidget *coverSizeSliderWidget; QSlider *coverSizeSlider; QAction *coverSizeSliderAction; QAction *showInfoAction; QAction *showInfoSeparatorAction; + QAction *startSeparatorAction; bool filterEnabled; diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index a9e66602..b6c66320 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -25,6 +25,7 @@ ../images/comics_view_toolbar/show_comic_info.svg ../images/comics_view_toolbar/setManga.svg ../images/comics_view_toolbar/setNormal.svg + ../images/comics_view_toolbar/showRecentIndicator.svg ../images/defaultCover.png ../images/edit.png ../images/empty_current_readings.png diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b91c85df..d5cd63a2 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1,5 +1,4 @@ #include "library_window.h" -#include "custom_widgets.h" #include "folder_item.h" #include @@ -43,6 +42,7 @@ #include "help_about_dialog.h" #include "server_config_dialog.h" #include "comic_model.h" +#include "yacreader_tool_bar_stretch.h" #include "yacreader_titled_toolbar.h" #include "yacreader_main_toolbar.h" @@ -83,6 +83,8 @@ #include "library_comic_opener.h" +#include "recent_visibility_coordinator.h" + #include "QsLog.h" #include "yacreader_http_server.h" @@ -200,6 +202,8 @@ void LibraryWindow::setupUI() createToolBars(); createMenus(); + setupCoordinators(); + navigationController = new YACReaderNavigationController(this, contentViewsManager); createConnections(); @@ -218,24 +222,6 @@ void LibraryWindow::setupUI() trayIconController = new TrayIconController(settings, this); } -/*void LibraryWindow::changeEvent(QEvent *event) -{ - QMainWindow::changeEvent(event); - - if (event->type() == QEvent::WindowStateChange && isMinimized() && - trayIcon.isVisible()) { -#ifdef Q_OS_MACOS - OSXHideDockIcon(); -#endif - hide(); - } else if (event->type() == QEvent::WindowStateChange) { -#ifdef Q_OS_MACOS - OSXShowDockIcon(); -#endif - show(); - } -}*/ - void LibraryWindow::doLayout() { // LAYOUT ELEMENTS------------------------------------------------------------ @@ -457,6 +443,7 @@ void LibraryWindow::setUpShortcutsManagement() editShortcutsDialog->addActionsGroup("Visualization", QIcon(":/images/shortcuts_group_visualization.svg"), tmpList = QList() << showHideMarksAction + << toogleShowRecentIndicatorAction #ifndef Q_OS_MAC << toggleFullScreenAction #endif @@ -481,6 +468,11 @@ void LibraryWindow::doModels() listsModelProxy = new ReadingListModelProxy(this); } +void LibraryWindow::setupCoordinators() +{ + recentVisibilityCoordinator = new RecentVisibilityCoordinator(settings, foldersModel, contentViewsManager->folderContentView, comicsModel); +} + void LibraryWindow::createActions() { backAction = new QAction(this); @@ -612,14 +604,6 @@ void LibraryWindow::createActions() setYonkomaAction->setData(SET_AS_YONKOMA_ACTION_YL); setYonkomaAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_AS_YONKOMA_ACTION_YL)); - /*setAllAsReadAction = new QAction(tr("Set all as read"),this); - setAllAsReadAction->setToolTip(tr("Set all comics as read")); - setAllAsReadAction->setIcon(QIcon(":/images/comics_view_toolbar/setAllRead.png")); - - setAllAsNonReadAction = new QAction(tr("Set all as unread"),this); - setAllAsNonReadAction->setToolTip(tr("Set all comics as unread")); - setAllAsNonReadAction->setIcon(QIcon(":/images/comics_view_toolbar/setAllUnread.png"));*/ - showHideMarksAction = new QAction(tr("Show/Hide marks"), this); showHideMarksAction->setToolTip(tr("Show or hide read marks")); showHideMarksAction->setData(SHOW_HIDE_MARKS_ACTION_YL); @@ -627,6 +611,15 @@ void LibraryWindow::createActions() showHideMarksAction->setCheckable(true); showHideMarksAction->setIcon(QIcon(":/images/comics_view_toolbar/showMarks.svg")); showHideMarksAction->setChecked(true); + + toogleShowRecentIndicatorAction = new QAction(tr("Show/Hide recent indicator"), this); + toogleShowRecentIndicatorAction->setToolTip(tr("Show or hide recent indicator")); + toogleShowRecentIndicatorAction->setData(SHOW_HIDE_RECENT_INDICATOR_ACTION_YL); + toogleShowRecentIndicatorAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_HIDE_RECENT_INDICATOR_ACTION_YL)); + toogleShowRecentIndicatorAction->setCheckable(true); + toogleShowRecentIndicatorAction->setIcon(QIcon(":/images/comics_view_toolbar/showRecentIndicator.svg")); + toogleShowRecentIndicatorAction->setChecked(settings->value(DISPLAY_RECENTLY_INDICATOR, true).toBool()); + #ifndef Q_OS_MAC toggleFullScreenAction = new QAction(tr("Fullscreen mode on/off"), this); toggleFullScreenAction->setToolTip(tr("Fullscreen mode on/off")); @@ -1035,9 +1028,7 @@ void LibraryWindow::createToolBars() editInfoToolBar->addSeparator(); editInfoToolBar->addAction(setAsReadAction); - // editInfoToolBar->addAction(setAllAsReadAction); editInfoToolBar->addAction(setAsNonReadAction); - // editInfoToolBar->addAction(setAllAsNonReadAction); editInfoToolBar->addAction(showHideMarksAction); @@ -1057,6 +1048,11 @@ void LibraryWindow::createToolBars() editInfoToolBar->addAction(deleteComicsAction); + auto toolBarStretch = new YACReaderToolBarStretch(this); + editInfoToolBar->addWidget(toolBarStretch); + + editInfoToolBar->addAction(toogleShowRecentIndicatorAction); + contentViewsManager->comicsView->setToolBar(editInfoToolBar); } @@ -1361,6 +1357,8 @@ void LibraryWindow::createConnections() // upgrade library connect(this, &LibraryWindow::libraryUpgraded, this, &LibraryWindow::loadLibrary, Qt::QueuedConnection); connect(this, &LibraryWindow::errorUpgradingLibrary, this, &LibraryWindow::showErrorUpgradingLibrary, Qt::QueuedConnection); + + connect(toogleShowRecentIndicatorAction, &QAction::toggled, recentVisibilityCoordinator, &RecentVisibilityCoordinator::toggleVisibility); } void LibraryWindow::showErrorUpgradingLibrary(const QString &path) diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index f2917e0a..3e300caf 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -81,6 +81,7 @@ class YACReaderHistoryController; class EmptyLabelWidget; class EmptySpecialListWidget; class EmptyReadingListWidget; +class RecentVisibilityCoordinator; namespace YACReader { class TrayIconController; @@ -214,12 +215,12 @@ public: QAction *setWebComicAction; QAction *setYonkomaAction; - // QAction * setAllAsReadAction; - // QAction * setAllAsNonReadAction; QAction *showHideMarksAction; QAction *getInfoAction; // comic vine QAction *resetComicRatingAction; + QAction *toogleShowRecentIndicatorAction; + // edit info actions QAction *selectAllComicsAction; QAction *editSelectedComicsAction; @@ -266,10 +267,6 @@ public: QString _lastAdded; QString _sourceLastAdded; - // QModelIndex _rootIndex; - // QModelIndex _rootIndexCV; - // QModelIndex updateDestination; - quint64 _comicIdEdited; enum NavigationStatus { @@ -290,6 +287,7 @@ public: void doDialogs(); void setUpShortcutsManagement(); void doModels(); + void setupCoordinators(); // ACTIONS MANAGEMENT void disableComicsActions(bool disabled); @@ -298,9 +296,6 @@ public: void disableFoldersActions(bool disabled); void disableAllActions(); - // void disableActions(); - // void enableActions(); - // void enableLibraryActions(); QString currentPath(); QString currentFolderPath(); @@ -455,6 +450,8 @@ private: TrayIconController *trayIconController; ComicQueryResultProcessor comicQueryResultProcessor; std::unique_ptr folderQueryResultProcessor; + + RecentVisibilityCoordinator *recentVisibilityCoordinator; }; #endif diff --git a/YACReaderLibrary/qml/FolderContentView.qml b/YACReaderLibrary/qml/FolderContentView.qml index c9cf14e6..47aadd51 100644 --- a/YACReaderLibrary/qml/FolderContentView.qml +++ b/YACReaderLibrary/qml/FolderContentView.qml @@ -131,6 +131,16 @@ Rectangle { } } + //is new + Rectangle { + width: 10 + height: 10 + radius: 5 + anchors { left: coverElement.left; top: coverElement.top; topMargin: 10; leftMargin: 10; } + color: "#FFFFCC00" + visible: (((new Date() / 1000) - added) < 86400 || ((new Date() / 1000) - updated) < 86400) && show_recent + } + //border Rectangle { width: coverElement.width diff --git a/YACReaderLibrary/qml/FolderContentView6.qml b/YACReaderLibrary/qml/FolderContentView6.qml index 49662ff0..1e925c08 100644 --- a/YACReaderLibrary/qml/FolderContentView6.qml +++ b/YACReaderLibrary/qml/FolderContentView6.qml @@ -133,6 +133,16 @@ Rectangle { } } + //is new + Rectangle { + width: 10 + height: 10 + radius: 5 + anchors { left: coverElement.left; top: coverElement.top; topMargin: 10; leftMargin: 10; } + color: "#FFFFCC00" + visible: (((new Date() / 1000) - added) < 86400 || ((new Date() / 1000) - updated) < 86400) && show_recent + } + //border Rectangle { width: coverElement.width diff --git a/YACReaderLibrary/qml/GridComicsView.qml b/YACReaderLibrary/qml/GridComicsView.qml index 4d2072c8..d5ec996c 100644 --- a/YACReaderLibrary/qml/GridComicsView.qml +++ b/YACReaderLibrary/qml/GridComicsView.qml @@ -280,6 +280,16 @@ SplitView { } + //is new + Rectangle { + width: 10 + height: 10 + radius: 5 + anchors { left: coverElement.left; top: coverElement.top; topMargin: 5; leftMargin: 5; } + color: "#FFFFCC00" + visible: (((new Date() / 1000) - added_date) < 86400) && show_recent + } + //border Rectangle { width: coverElement.width diff --git a/YACReaderLibrary/qml/GridComicsView6.qml b/YACReaderLibrary/qml/GridComicsView6.qml index 4cb7c1ce..d410a9fb 100644 --- a/YACReaderLibrary/qml/GridComicsView6.qml +++ b/YACReaderLibrary/qml/GridComicsView6.qml @@ -283,6 +283,16 @@ SplitView { } + //is new + Rectangle { + width: 10 + height: 10 + radius: 5 + anchors { left: coverElement.left; top: coverElement.top; topMargin: 5; leftMargin: 5; } + color: "#FFFFCC00" + visible: (((new Date() / 1000) - added_date) < 86400) && show_recent + } + //border Rectangle { width: coverElement.width diff --git a/YACReaderLibrary/recent_visibility_coordinator.cpp b/YACReaderLibrary/recent_visibility_coordinator.cpp new file mode 100644 index 00000000..6670224f --- /dev/null +++ b/YACReaderLibrary/recent_visibility_coordinator.cpp @@ -0,0 +1,30 @@ + +#include "recent_visibility_coordinator.h" + +#include "yacreader_global_gui.h" + +RecentVisibilityCoordinator::RecentVisibilityCoordinator(QSettings *settings, FolderModel *folderModel, FolderContentView *folderContentView, ComicModel *comicModel) + : QObject(), settings(settings), folderModel(folderModel), folderContentView(folderContentView), comicModel(comicModel) +{ + updateVisibility(); +} + +void RecentVisibilityCoordinator::toggleVisibility(bool visibility) +{ + settings->setValue(DISPLAY_RECENTLY_INDICATOR, visibility); + + updateVisibility(); +} + +void RecentVisibilityCoordinator::setTimeRangeInDays(int days) +{ +} + +void RecentVisibilityCoordinator::updateVisibility() +{ + auto visibility = settings->value(DISPLAY_RECENTLY_INDICATOR, true).toBool(); + + folderModel->setShowRecent(visibility); + folderContentView->setShowRecent(visibility); + comicModel->setShowRecent(visibility); +} diff --git a/YACReaderLibrary/recent_visibility_coordinator.h b/YACReaderLibrary/recent_visibility_coordinator.h new file mode 100644 index 00000000..b1254953 --- /dev/null +++ b/YACReaderLibrary/recent_visibility_coordinator.h @@ -0,0 +1,30 @@ + +#ifndef RECENT_VISIBILITY_COORDINATOR_H +#define RECENT_VISIBILITY_COORDINATOR_H + +#include + +#include "folder_model.h" +#include "comic_model.h" +#include "folder_content_view.h" + +class RecentVisibilityCoordinator : public QObject +{ + Q_OBJECT +public: + explicit RecentVisibilityCoordinator(QSettings *settings, FolderModel *folderModel, FolderContentView *folderContentView, ComicModel *comicModel); + +public slots: + void toggleVisibility(bool visibility); + void setTimeRangeInDays(int days); + +private: + QSettings *settings; + FolderModel *folderModel; + FolderContentView *folderContentView; + ComicModel *comicModel; + + void updateVisibility(); +}; + +#endif // RECENT_VISIBILITY_COORDINATOR_H diff --git a/YACReaderLibrary/yacreader_content_views_manager.cpp b/YACReaderLibrary/yacreader_content_views_manager.cpp index f61c23f1..3ab8b05b 100644 --- a/YACReaderLibrary/yacreader_content_views_manager.cpp +++ b/YACReaderLibrary/yacreader_content_views_manager.cpp @@ -45,7 +45,7 @@ YACReaderContentViewsManager::YACReaderContentViewsManager(QSettings *settings, doComicsViewConnections(); comicsViewStack->addWidget(comicsViewTransition = new ComicsViewTransition()); - comicsViewStack->addWidget(folderContentView = new FolderContentView()); + comicsViewStack->addWidget(folderContentView = new FolderContentView(parent->toogleShowRecentIndicatorAction)); comicsViewStack->addWidget(emptyLabelWidget = new EmptyLabelWidget()); comicsViewStack->addWidget(emptySpecialList = new EmptySpecialListWidget()); comicsViewStack->addWidget(emptyReadingList = new EmptyReadingListWidget()); diff --git a/YACReaderLibrary/yacreader_folders_view.cpp b/YACReaderLibrary/yacreader_folders_view.cpp index f8b29b86..f4f6ee92 100644 --- a/YACReaderLibrary/yacreader_folders_view.cpp +++ b/YACReaderLibrary/yacreader_folders_view.cpp @@ -91,4 +91,25 @@ void YACReaderFoldersViewItemDeletegate::paint(QPainter *painter, const QStyleOp } QStyledItemDelegate::paint(painter, option, index); + + auto showRecent = index.data(FolderModel::ShowRecentRole).toBool(); + + if (showRecent) { + auto now = QDateTime::currentSecsSinceEpoch(); + auto added = index.data(FolderModel::AddedRole).toLongLong(); + auto updated = index.data(FolderModel::UpdatedRole).toLongLong(); + auto dayInSeconds = 86400; + + if (now - added < dayInSeconds || now - updated < dayInSeconds) { + painter->save(); +#ifdef Q_OS_MAC + painter->setBrush(QBrush(QColor(85, 95, 127))); +#else + painter->setBrush(QBrush(QColor(237, 197, 24))); +#endif + painter->setPen(QPen(QBrush(), 0)); + painter->drawEllipse(option.rect.x() + 13, option.rect.y() + 2, 7, 7); + painter->restore(); + } + } } diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index 55b7a441..9aed6620 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -71,6 +71,7 @@ #define BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW "BLUR_RADIUS_BACKGROUND_IMAGE_IN_GRID_VIEW" #define USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW "USE_SELECTED_COMIC_COVER_AS_BACKGROUND_IMAGE_IN_GRID_VIEW" #define DISPLAY_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_CONTINUE_READING_IN_GRID_VIEW" +#define DISPLAY_RECENTLY_INDICATOR "DISPLAY_RECENTLY_INDICATOR" namespace YACReader { diff --git a/images/comics_view_toolbar/showRecentIndicator.svg b/images/comics_view_toolbar/showRecentIndicator.svg new file mode 100644 index 00000000..411f24e0 --- /dev/null +++ b/images/comics_view_toolbar/showRecentIndicator.svg @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/shortcuts_management/shortcuts_manager.h b/shortcuts_management/shortcuts_manager.h index 0e568355..cb201c88 100644 --- a/shortcuts_management/shortcuts_manager.h +++ b/shortcuts_management/shortcuts_manager.h @@ -97,6 +97,7 @@ public: #define RENAME_LIST_ACTION_YL "RENAME_LIST_ACTION_YL" #define ADD_TO_FAVORITES_ACTION_YL "ADD_TO_FAVORITES_ACTION_YL" #define SAVE_COVERS_TO_ACTION_YL "SAVE_COVERS_TO_ACTION_YL" +#define SHOW_HIDE_RECENT_INDICATOR_ACTION_YL "SHOW_HIDE_RECENT_INDICATOR_ACTION_YL" // COMMANDS YACReaderLibrary // ACTION NAMES YACReader