From 97c7723b17284b1b1d8595ba85c6b11bd0011afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 16 Jan 2021 14:25:47 +0100 Subject: [PATCH] Add support for setting issues as manga/normal in the comics view --- YACReaderLibrary/db/comic_model.cpp | 18 +++++++++ YACReaderLibrary/db/comic_model.h | 1 + YACReaderLibrary/images.qrc | 4 ++ YACReaderLibrary/library_window.cpp | 39 ++++++++++++++++++++ YACReaderLibrary/library_window.h | 6 +++ images/comics_view_toolbar/setManga.png | Bin 0 -> 217 bytes images/comics_view_toolbar/setManga@2x.png | Bin 0 -> 334 bytes images/comics_view_toolbar/setNormal.png | Bin 0 -> 205 bytes images/comics_view_toolbar/setNormal@2x.png | Bin 0 -> 315 bytes shortcuts_management/shortcuts_manager.h | 2 + 10 files changed, 70 insertions(+) create mode 100644 images/comics_view_toolbar/setManga.png create mode 100644 images/comics_view_toolbar/setManga@2x.png create mode 100644 images/comics_view_toolbar/setNormal.png create mode 100644 images/comics_view_toolbar/setNormal@2x.png diff --git a/YACReaderLibrary/db/comic_model.cpp b/YACReaderLibrary/db/comic_model.cpp index ea03a617..eb6bc40a 100644 --- a/YACReaderLibrary/db/comic_model.cpp +++ b/YACReaderLibrary/db/comic_model.cpp @@ -778,6 +778,24 @@ QVector ComicModel::setComicsRead(QList l return getReadList(); } + +void ComicModel::setComicsManga(QList list, bool isManga) +{ + QString connectionName = ""; + { + QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath); + db.transaction(); + foreach (QModelIndex mi, list) { + ComicDB c = DBHelper::loadComic(_data.value(mi.row())->data(ComicModel::Id).toULongLong(), db); + c.info.manga = isManga; + DBHelper::update(&(c.info), db); + } + db.commit(); + connectionName = db.connectionName(); + } + QSqlDatabase::removeDatabase(connectionName); +} + qint64 ComicModel::asignNumbers(QList list, int startingNumber) { qint64 idFirst; diff --git a/YACReaderLibrary/db/comic_model.h b/YACReaderLibrary/db/comic_model.h index 40f14517..5d7f95bc 100644 --- a/YACReaderLibrary/db/comic_model.h +++ b/YACReaderLibrary/db/comic_model.h @@ -105,6 +105,7 @@ public: //setComicInfoForAllComics(); --> inserta la información común a todos los cómics de una sola vez. //setComicInfoForSelectedComis(QList list); -->inserta la información común para los comics seleccionados QVector setComicsRead(QList list, YACReaderComicReadStatus read); + void setComicsManga(QList list, bool isManga); qint64 asignNumbers(QList list, int startingNumber); //void remove(ComicDB * comic, int row); void removeInTransaction(int row); diff --git a/YACReaderLibrary/images.qrc b/YACReaderLibrary/images.qrc index 07aa91bc..09366f1b 100644 --- a/YACReaderLibrary/images.qrc +++ b/YACReaderLibrary/images.qrc @@ -38,6 +38,10 @@ ../images/comics_view_toolbar/trash@2x.png ../images/comics_view_toolbar/show_comic_info.png ../images/comics_view_toolbar/show_comic_info@2x.png + ../images/comics_view_toolbar/setManga.png + ../images/comics_view_toolbar/setManga@2x.png + ../images/comics_view_toolbar/setNormal.png + ../images/comics_view_toolbar/setNormal@2x.png ../images/coversPackage.png ../images/db.png ../images/defaultCover.png diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 65f66b61..89288735 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -324,6 +324,8 @@ void LibraryWindow::setUpShortcutsManagement() << saveCoversToAction << setAsReadAction << setAsNonReadAction + << setMangaAction + << setNormalAction << openContainingFolderComicAction << resetComicRatingAction << selectAllComicsAction @@ -508,6 +510,18 @@ void LibraryWindow::createActions() setAsNonReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_AS_NON_READ_ACTION_YL)); setAsNonReadAction->setIcon(QIcon(":/images/comics_view_toolbar/setUnread.png")); + setMangaAction = new QAction(tr("Set as manga"), this); + setMangaAction->setToolTip(tr("Set issue as manga")); + setMangaAction->setData(SET_AS_MANGA_ACTION_YL); + setMangaAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_AS_MANGA_ACTION_YL)); + setMangaAction->setIcon(QIcon(":/images/comics_view_toolbar/setManga.png")); + + setNormalAction = new QAction(tr("Set as normal"), this); + setNormalAction->setToolTip(tr("Set issue as normal")); + setNormalAction->setData(SET_AS_NORMAL_ACTION_YL); + setNormalAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_AS_NORMAL_ACTION_YL)); + setNormalAction->setIcon(QIcon(":/images/comics_view_toolbar/setNormal.png")); + /*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")); @@ -753,6 +767,8 @@ void LibraryWindow::disableComicsActions(bool disabled) asignOrderAction->setDisabled(disabled); setAsReadAction->setDisabled(disabled); setAsNonReadAction->setDisabled(disabled); + setNormalAction->setDisabled(disabled); + setMangaAction->setDisabled(disabled); //setAllAsReadAction->setDisabled(disabled); //setAllAsNonReadAction->setDisabled(disabled); showHideMarksAction->setDisabled(disabled); @@ -870,6 +886,11 @@ void LibraryWindow::createToolBars() editInfoToolBar->addSeparator(); + editInfoToolBar->addAction(setNormalAction); + editInfoToolBar->addAction(setMangaAction); + + editInfoToolBar->addSeparator(); + editInfoToolBar->addAction(deleteComicsAction); comicsViewsManager->comicsView->setToolBar(editInfoToolBar); @@ -1019,6 +1040,8 @@ void LibraryWindow::createConnections() connect(openLibraryAction, SIGNAL(triggered()), this, SLOT(showAddLibrary())); connect(setAsReadAction, SIGNAL(triggered()), this, SLOT(setCurrentComicReaded())); connect(setAsNonReadAction, SIGNAL(triggered()), this, SLOT(setCurrentComicUnreaded())); + connect(setNormalAction, &QAction::triggered, this, &LibraryWindow::setSelectedComicsAsNormal); + connect(setMangaAction, &QAction::triggered, this, &LibraryWindow::setSelectedComicsAsManga); //connect(setAllAsReadAction,SIGNAL(triggered()),this,SLOT(setComicsReaded())); //connect(setAllAsNonReadAction,SIGNAL(triggered()),this,SLOT(setComicsUnreaded())); @@ -1594,6 +1617,9 @@ void LibraryWindow::showComicsViewContextMenu(const QPoint &point) menu.addAction(setAsReadAction); menu.addAction(setAsNonReadAction); menu.addSeparator(); + menu.addAction(setNormalAction); + menu.addAction(setMangaAction); + menu.addSeparator(); menu.addAction(deleteComicsAction); menu.addSeparator(); menu.addAction(addToMenuAction); @@ -1627,6 +1653,9 @@ void LibraryWindow::showComicsItemContextMenu(const QPoint &point) menu.addAction(setAsReadAction); menu.addAction(setAsNonReadAction); menu.addSeparator(); + menu.addAction(setNormalAction); + menu.addAction(setMangaAction); + menu.addSeparator(); menu.addAction(deleteComicsAction); menu.addSeparator(); menu.addAction(addToMenuAction); @@ -1793,6 +1822,16 @@ void LibraryWindow::setCurrentComicUnreaded() this->setCurrentComicsStatusReaded(YACReader::Unread); } +void LibraryWindow::setSelectedComicsAsNormal() +{ + comicsModel->setComicsManga(getSelectedComics(), false); +} + +void LibraryWindow::setSelectedComicsAsManga() +{ + comicsModel->setComicsManga(getSelectedComics(), true); +} + void LibraryWindow::createLibrary() { checkMaxNumLibraries(); diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 4e626cf3..72f983cd 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -193,6 +193,10 @@ public: QAction *openContainingFolderComicAction; QAction *setAsReadAction; QAction *setAsNonReadAction; + + QAction *setMangaAction; + QAction *setNormalAction; + //QAction * setAllAsReadAction; //QAction * setAllAsNonReadAction; QAction *showHideMarksAction; @@ -339,6 +343,8 @@ public slots: void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus); void setCurrentComicReaded(); void setCurrentComicUnreaded(); + void setSelectedComicsAsNormal(); + void setSelectedComicsAsManga(); void showExportComicsInfo(); void showImportComicsInfo(); void asignNumbers(); diff --git a/images/comics_view_toolbar/setManga.png b/images/comics_view_toolbar/setManga.png new file mode 100644 index 0000000000000000000000000000000000000000..01b4631d0f2003b295ba5ac45d6be7521f403fe6 GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|&H|6fVg?3opai!Ne3C)x1^plZnN8d@lalE8DpqPWrLdMU+Dmwld=;^qo?U4 z2k-R!Z>@D@VvOvUZ;#H(hB_MDkdE!WR@rz*rk1T&UNZXr`G3j`+-LfAn=Bkl>VVE- N@O1TaS?83{1OQxKOl<%F literal 0 HcmV?d00001 diff --git a/images/comics_view_toolbar/setManga@2x.png b/images/comics_view_toolbar/setManga@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..aaf105969f9fca3a6d33a70c2d04f24f7ef12390 GIT binary patch literal 334 zcmV-U0kQsxP)1~&^ExB&(% z1luAlrbkKo{A_@GavzkEbzO&;I7MZXgd8~AE+L{DfC|9X^+C*>se65zvIS5w^K)D< zGNfc0ADKVsV>BwJT}Wj{n#w9fL>HmV=u9!=9(!hf?Wgh~y%^WnDpbcLR5SBEfXjfd zP*53o3I&(J(q3l4kQw(bouzf1r9ICjLn4_OIpo+EMD!4F8F1~PUJCQl={>OVd&t12 zWFndJ?V;dOt|gl@lrI!pr>uxgC>Tj-jY9~vJ9tbnZ9=82%XdseNF8f)p-lBL^7&CZ g{U2H*3H=1X8*}tarW7KxWB>pF07*qoM6N<$f_|lef&c&j literal 0 HcmV?d00001 diff --git a/images/comics_view_toolbar/setNormal.png b/images/comics_view_toolbar/setNormal.png new file mode 100644 index 0000000000000000000000000000000000000000..a7e8ae38600c979098fd7c60562bb3dd61ac9eb8 GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|&H|6fVg?3opai!Nlu}$Ec{6!b^YzjcC5Lv4wDwKO7|YTz|gYFeUkg!J8o<5^sK2~ z`ToV5?A*sjn-ugWuzqYhvxmvc&+X>#oAoRS?5Dyt6*ONZOanTF!PC{xWt~$(69DUj BOAr76 literal 0 HcmV?d00001 diff --git a/images/comics_view_toolbar/setNormal@2x.png b/images/comics_view_toolbar/setNormal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..8cafb93045cfe8a0936793a834e124f92cf5eb25 GIT binary patch literal 315 zcmV-B0mS}^P)}bzwlw7eU}WaU>&7Ob z3^TXD{GjA9XU{TFPR3f(9*{*cRZm~`k{n2q1<<`KAZEU{K$%Qg3zS(8X`zbWvaf+c zqj9x9K@m~9ywqyUSDBQQzlVtEwl`&B4{7%|wf)e#rz99yCZvIZ6_6GN7CEt@)*`fY5zYY$$@qS;0a%AM??UMlfM7} N002ovPDHLkV1f@td({8{ literal 0 HcmV?d00001 diff --git a/shortcuts_management/shortcuts_manager.h b/shortcuts_management/shortcuts_manager.h index 2aee76a5..e831822f 100644 --- a/shortcuts_management/shortcuts_manager.h +++ b/shortcuts_management/shortcuts_manager.h @@ -48,6 +48,8 @@ public: #define OPEN_COMIC_ACTION_YL "OPEN_COMIC_ACTION_YL" #define SET_AS_READ_ACTION_YL "SET_AS_READ_ACTION_YL" #define SET_AS_NON_READ_ACTION_YL "SET_AS_NON_READ_ACTION_YL" +#define SET_AS_MANGA_ACTION_YL "SET_AS_MANGA_ACTION_YL" +#define SET_AS_NORMAL_ACTION_YL "SET_AS_MANGA_ACTION_YL" #define SHOW_HIDE_MARKS_ACTION_YL "SHOW_HIDE_MARKS_ACTION_YL" #define TOGGLE_FULL_SCREEN_ACTION_YL "TOGGLE_FULL_SCREEN_ACTION_YL" #define HELP_ABOUT_ACTION_YL "HELP_ABOUT_ACTION_YL"