diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd54853..5aa12d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ Version counting is based on semantic versioning (Major.Feature.Patch) * Enable dropping content on the FolderContentView. * Fix `open containing folder...` shortcut for comics. * Add a dialog to show information about a library, it includes the number of folders and comics and the number of read comics. -* Fix ocasional crashes when using automatic library updates. +* Fix ocasional crashes when using automatic library updates. +* Add setting to hide the "Continue Reading..." banner from the home view. ### YACReaderLibraryServer * New command --system-info to print information about the execution environment and available resources (including what image formats are supported and what libraries are used by the app). diff --git a/YACReaderLibrary/folder_content_view.cpp b/YACReaderLibrary/folder_content_view.cpp index 356f9237..a3cfc1de 100644 --- a/YACReaderLibrary/folder_content_view.cpp +++ b/YACReaderLibrary/folder_content_view.cpp @@ -163,7 +163,8 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid ctxt->setContextProperty("comicsList", comicModel.get()); ctxt->setContextProperty("foldersList", folderModel); - ctxt->setContextProperty("showCurrentComic", QVariant(false)); + auto showContinueReading = settings->value(DISPLAY_GLOBAL_CONTINUE_READING_IN_GRID_VIEW, true).toBool(); + ctxt->setContextProperty("showContinueReading", QVariant(showContinueReading)); ctxt->setContextProperty("openHelper", this); ctxt->setContextProperty("dropManager", this); @@ -229,6 +230,14 @@ void FolderContentView::setRecentRange(int days) folderModel->setRecentRange(days); } +void FolderContentView::updateSettings() +{ + QQmlContext *ctxt = view->rootContext(); + + auto showContinueReading = settings->value(DISPLAY_GLOBAL_CONTINUE_READING_IN_GRID_VIEW, true).toBool(); + ctxt->setContextProperty("showContinueReading", QVariant(showContinueReading)); +} + 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 842ea045..f199491b 100644 --- a/YACReaderLibrary/folder_content_view.h +++ b/YACReaderLibrary/folder_content_view.h @@ -28,6 +28,9 @@ public: void setRecentRange(int days); FolderModel *currentFolderModel() { return folderModel; } +public slots: + void updateSettings(); + signals: void subfolderSelected(QModelIndex, int); void openComic(const ComicDB &comic, const ComicModel::Mode mode); diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 1b613353..f834e612 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -381,6 +381,12 @@ void GridComicsView::triggerOpenCurrentComic() emit openComic(currentComic, model->getMode()); } +void GridComicsView::updateSettings() +{ + updateBackgroundConfig(); + setCurrentComicIfNeeded(); +} + void GridComicsView::rate(int index, int rating) { model->updateRating(rating, model->index(index, 0)); @@ -442,16 +448,9 @@ void GridComicsView::setCurrentComicIfNeeded() (mode == ComicModel::Mode::Folder || mode == ComicModel::Mode::ReadingList) && settings->value(DISPLAY_CONTINUE_READING_IN_GRID_VIEW, true).toBool(); - if (showCurrentComic) { - ctxt->setContextProperty("currentComic", ¤tComic); - ctxt->setContextProperty("currentComicInfo", &(currentComic.info)); - ctxt->setContextProperty("showCurrentComic", QVariant(true)); - } else { - ctxt->setContextProperty("currentComic", ¤tComic); - ctxt->setContextProperty("currentComicInfo", &(currentComic.info)); - ctxt->setContextProperty("showCurrentComic", QVariant(false)); - // ctxt->setContextProperty("currentComic", nullptr); - } + ctxt->setContextProperty("currentComic", ¤tComic); + ctxt->setContextProperty("currentComicInfo", &(currentComic.info)); + ctxt->setContextProperty("showCurrentComic", QVariant(showCurrentComic)); } void GridComicsView::resetScroll() diff --git a/YACReaderLibrary/grid_comics_view.h b/YACReaderLibrary/grid_comics_view.h index 6ae460a7..50d3c03c 100644 --- a/YACReaderLibrary/grid_comics_view.h +++ b/YACReaderLibrary/grid_comics_view.h @@ -59,9 +59,8 @@ public slots: void selectAll() override; void selectIndex(int index) override; void triggerOpenCurrentComic(); - + void updateSettings(); void updateBackgroundConfig(); - void showInfo(); protected slots: diff --git a/YACReaderLibrary/options_dialog.cpp b/YACReaderLibrary/options_dialog.cpp index 32a7df27..dd702675 100644 --- a/YACReaderLibrary/options_dialog.cpp +++ b/YACReaderLibrary/options_dialog.cpp @@ -75,6 +75,7 @@ void OptionsDialog::restoreOptions(QSettings *settings) blurLabel->setVisible(useBackgroundImage); useCurrentComicCoverCheck->setVisible(useBackgroundImage); + displayGlobalContinueReadingBannerCheck->setChecked(settings->value(DISPLAY_GLOBAL_CONTINUE_READING_IN_GRID_VIEW, true).toBool()); displayContinueReadingBannerCheck->setChecked(settings->value(DISPLAY_CONTINUE_READING_IN_GRID_VIEW, true).toBool()); updateLibrariesAtStartupCheck->setChecked(settings->value(UPDATE_LIBRARIES_AT_STARTUP, false).toBool()); @@ -384,9 +385,11 @@ QWidget *OptionsDialog::createGridTab() auto gridBackgroundGroup = new QGroupBox(tr("Background")); gridBackgroundGroup->setLayout(gridBackgroundLayout); - displayContinueReadingBannerCheck = new QCheckBox(tr("Display continue reading banner")); + displayGlobalContinueReadingBannerCheck = new QCheckBox(tr("Display continue reading banner")); + displayContinueReadingBannerCheck = new QCheckBox(tr("Display current comic banner")); auto continueReadingLayout = new QVBoxLayout(); + continueReadingLayout->addWidget(displayGlobalContinueReadingBannerCheck); continueReadingLayout->addWidget(displayContinueReadingBannerCheck); auto continueReadingGroup = new QGroupBox(tr("Continue reading")); @@ -399,6 +402,12 @@ QWidget *OptionsDialog::createGridTab() connect(resetButton, &QPushButton::clicked, this, &OptionsDialog::resetToDefaults); // end grid view background config + connect(displayGlobalContinueReadingBannerCheck, &QCheckBox::clicked, this, [this]() { + this->settings->setValue(DISPLAY_GLOBAL_CONTINUE_READING_IN_GRID_VIEW, this->displayGlobalContinueReadingBannerCheck->isChecked()); + + emit optionsChanged(); + }); + connect(displayContinueReadingBannerCheck, &QCheckBox::clicked, this, [this]() { this->settings->setValue(DISPLAY_CONTINUE_READING_IN_GRID_VIEW, this->displayContinueReadingBannerCheck->isChecked()); diff --git a/YACReaderLibrary/options_dialog.h b/YACReaderLibrary/options_dialog.h index 54b9254f..ccf8a2ff 100644 --- a/YACReaderLibrary/options_dialog.h +++ b/YACReaderLibrary/options_dialog.h @@ -30,6 +30,7 @@ private slots: private: // General tabs + QCheckBox *displayGlobalContinueReadingBannerCheck; QCheckBox *displayContinueReadingBannerCheck; QCheckBox *trayIconCheckbox; QCheckBox *startToTrayCheckbox; diff --git a/YACReaderLibrary/qml/FolderContentView.qml b/YACReaderLibrary/qml/FolderContentView.qml index 27139f05..d49d42d1 100644 --- a/YACReaderLibrary/qml/FolderContentView.qml +++ b/YACReaderLibrary/qml/FolderContentView.qml @@ -191,7 +191,7 @@ Rectangle { id: continueReadingTopView color: "#00000000" - height: list.count > 0 ? main.continuReadingHeight : main.topContentMargin + height: list.count > 0 && showContinueReading ? main.continuReadingHeight : main.topContentMargin Rectangle { color: continueReadingBackgroundColor @@ -201,7 +201,7 @@ Rectangle { width: main.width height: main.continuReadingHeight - main.topContentMargin - visible: list.count > 0 + visible: list.count > 0 && showContinueReading Text { id: continueReadingText diff --git a/YACReaderLibrary/qml/FolderContentView6.qml b/YACReaderLibrary/qml/FolderContentView6.qml index 18471fa2..190dd981 100644 --- a/YACReaderLibrary/qml/FolderContentView6.qml +++ b/YACReaderLibrary/qml/FolderContentView6.qml @@ -193,7 +193,7 @@ Rectangle { id: continueReadingTopView color: "#00000000" - height: list.count > 0 ? main.continuReadingHeight : main.topContentMargin + height: list.count > 0 && showContinueReading ? main.continuReadingHeight : main.topContentMargin Rectangle { color: continueReadingBackgroundColor @@ -203,7 +203,7 @@ Rectangle { width: main.width height: main.continuReadingHeight - main.topContentMargin - visible: list.count > 0 + visible: list.count > 0 && showContinueReading Text { id: continueReadingText diff --git a/YACReaderLibrary/yacreader_content_views_manager.cpp b/YACReaderLibrary/yacreader_content_views_manager.cpp index a82462e7..294a072c 100644 --- a/YACReaderLibrary/yacreader_content_views_manager.cpp +++ b/YACReaderLibrary/yacreader_content_views_manager.cpp @@ -38,6 +38,7 @@ YACReaderContentViewsManager::YACReaderContentViewsManager(QSettings *settings, default: comicsView = gridComicsView = new GridComicsView(); connect(libraryWindow->optionsDialog, &YACReaderOptionsDialog::optionsChanged, gridComicsView, &GridComicsView::updateBackgroundConfig); + connect(libraryWindow->optionsDialog, &YACReaderOptionsDialog::finished, gridComicsView, &GridComicsView::updateSettings); // TODO: we can link constante changes to updateSettings because of bad performance comicsViewStatus = Grid; break; } @@ -58,6 +59,7 @@ YACReaderContentViewsManager::YACReaderContentViewsManager(QSettings *settings, // connections connect(folderContentView, &FolderContentView::copyComicsToCurrentFolder, libraryWindow, &LibraryWindow::copyAndImportComicsToCurrentFolder); connect(folderContentView, &FolderContentView::moveComicsToCurrentFolder, libraryWindow, &LibraryWindow::moveAndImportComicsToCurrentFolder); + connect(libraryWindow->optionsDialog, &YACReaderOptionsDialog::optionsChanged, folderContentView, &FolderContentView::updateSettings); } QWidget *YACReaderContentViewsManager::containerWidget() @@ -245,6 +247,7 @@ void YACReaderContentViewsManager::_toggleComicsView() switchToComicsView(classicComicsView, gridComicsView); connect(libraryWindow->optionsDialog, &YACReaderOptionsDialog::optionsChanged, gridComicsView, &GridComicsView::updateBackgroundConfig); + connect(libraryWindow->optionsDialog, &YACReaderOptionsDialog::finished, gridComicsView, &GridComicsView::updateSettings); // TODO: we can link constante changes to updateSettings because of bad performance comicsViewStatus = Grid; break; diff --git a/common/yacreader_global_gui.h b/common/yacreader_global_gui.h index d9fb58ad..9e9b3b66 100644 --- a/common/yacreader_global_gui.h +++ b/common/yacreader_global_gui.h @@ -71,6 +71,7 @@ #define OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW "OPACITY_BACKGROUND_IMAGE_IN_GRID_VIEW" #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_GLOBAL_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_GLOBAL_CONTINUE_READING_IN_GRID_VIEW" #define DISPLAY_CONTINUE_READING_IN_GRID_VIEW "DISPLAY_CONTINUE_READING_IN_GRID_VIEW" #define DISPLAY_RECENTLY_INDICATOR "DISPLAY_RECENTLY_INDICATOR" #define NUM_DAYS_TO_CONSIDER_RECENT "NUM_DAYS_TO_CONSIDER_RECENT"