mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Show the current type as checked in the context menu
This commit is contained in:
parent
9ae4911b78
commit
abdf5bda4f
@ -1030,6 +1030,12 @@ void ComicModel::setComicsType(QList<QModelIndex> list, FileType type)
|
|||||||
connectionName = db.connectionName();
|
connectionName = db.connectionName();
|
||||||
}
|
}
|
||||||
QSqlDatabase::removeDatabase(connectionName);
|
QSqlDatabase::removeDatabase(connectionName);
|
||||||
|
|
||||||
|
foreach (QModelIndex mi, list) {
|
||||||
|
_data.value(mi.row())->setData(ComicModel::Type, QVariant::fromValue(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
emit dataChanged(index(list.first().row(), ComicModel::Type), index(list.last().row(), ComicModel::Type), QVector<int>() << TypeRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 ComicModel::asignNumbers(QList<QModelIndex> list, int startingNumber)
|
qint64 ComicModel::asignNumbers(QList<QModelIndex> list, int startingNumber)
|
||||||
|
@ -1901,6 +1901,71 @@ void LibraryWindow::addSelectedComicsToFavorites()
|
|||||||
|
|
||||||
void LibraryWindow::showComicsViewContextMenu(const QPoint &point)
|
void LibraryWindow::showComicsViewContextMenu(const QPoint &point)
|
||||||
{
|
{
|
||||||
|
showComicsContextMenu(point, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::showComicsItemContextMenu(const QPoint &point)
|
||||||
|
{
|
||||||
|
showComicsContextMenu(point, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibraryWindow::showComicsContextMenu(const QPoint &point, bool showFullScreenAction)
|
||||||
|
{
|
||||||
|
auto selection = this->getSelectedComics();
|
||||||
|
|
||||||
|
auto setNormalAction = new QAction();
|
||||||
|
setNormalAction->setText(tr("comic"));
|
||||||
|
|
||||||
|
auto setMangaAction = new QAction();
|
||||||
|
setMangaAction->setText(tr("manga"));
|
||||||
|
|
||||||
|
auto setWesternMangaAction = new QAction();
|
||||||
|
setWesternMangaAction->setText(tr("western manga (left to right)"));
|
||||||
|
|
||||||
|
auto setWebComicAction = new QAction();
|
||||||
|
setWebComicAction->setText(tr("web comic"));
|
||||||
|
|
||||||
|
auto setYonkomaAction = new QAction();
|
||||||
|
setYonkomaAction->setText(tr("4koma (top to botom)"));
|
||||||
|
|
||||||
|
setNormalAction->setCheckable(true);
|
||||||
|
setMangaAction->setCheckable(true);
|
||||||
|
setWesternMangaAction->setCheckable(true);
|
||||||
|
setWebComicAction->setCheckable(true);
|
||||||
|
setYonkomaAction->setCheckable(true);
|
||||||
|
|
||||||
|
connect(setNormalAction, &QAction::triggered, this->setNormalAction, &QAction::trigger);
|
||||||
|
connect(setMangaAction, &QAction::triggered, this->setMangaAction, &QAction::trigger);
|
||||||
|
connect(setWesternMangaAction, &QAction::triggered, this->setWesternMangaAction, &QAction::trigger);
|
||||||
|
connect(setWebComicAction, &QAction::triggered, this->setWebComicAction, &QAction::trigger);
|
||||||
|
connect(setYonkomaAction, &QAction::triggered, this->setYonkomaAction, &QAction::trigger);
|
||||||
|
|
||||||
|
auto setupActions = [=](FileType type) {
|
||||||
|
switch (type) {
|
||||||
|
case YACReader::FileType::Comic:
|
||||||
|
setNormalAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::Manga:
|
||||||
|
setMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::WesternManga:
|
||||||
|
setWesternMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::WebComic:
|
||||||
|
setWebComicAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case YACReader::FileType::Yonkoma:
|
||||||
|
setYonkomaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (selection.size() == 1) {
|
||||||
|
QModelIndex index = selection.at(0);
|
||||||
|
auto type = index.data(ComicModel::TypeRole).value<YACReader::FileType>();
|
||||||
|
setupActions(type);
|
||||||
|
}
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
menu.addAction(openComicAction);
|
menu.addAction(openComicAction);
|
||||||
@ -1937,51 +2002,15 @@ void LibraryWindow::showComicsViewContextMenu(const QPoint &point)
|
|||||||
setupAddToSubmenu(subMenu);
|
setupAddToSubmenu(subMenu);
|
||||||
|
|
||||||
#ifndef Q_OS_MACOS
|
#ifndef Q_OS_MACOS
|
||||||
menu.addSeparator();
|
if (showFullScreenAction) {
|
||||||
menu.addAction(toggleFullScreenAction);
|
menu.addSeparator();
|
||||||
|
menu.addAction(toggleFullScreenAction);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
menu.exec(contentViewsManager->comicsView->mapToGlobal(point));
|
menu.exec(contentViewsManager->comicsView->mapToGlobal(point));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::showComicsItemContextMenu(const QPoint &point)
|
|
||||||
{
|
|
||||||
QMenu menu;
|
|
||||||
|
|
||||||
menu.addAction(openComicAction);
|
|
||||||
menu.addAction(saveCoversToAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(openContainingFolderComicAction);
|
|
||||||
menu.addAction(updateCurrentFolderAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(resetComicRatingAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(editSelectedComicsAction);
|
|
||||||
menu.addAction(getInfoAction);
|
|
||||||
menu.addAction(asignOrderAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(setAsReadAction);
|
|
||||||
menu.addAction(setAsNonReadAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
auto typeMenu = new QMenu(tr("Set type"));
|
|
||||||
menu.addMenu(typeMenu);
|
|
||||||
typeMenu->addAction(setNormalAction);
|
|
||||||
typeMenu->addAction(setMangaAction);
|
|
||||||
typeMenu->addAction(setWesternMangaAction);
|
|
||||||
typeMenu->addAction(setWebComicAction);
|
|
||||||
typeMenu->addAction(setYonkomaAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(deleteMetadataAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(deleteComicsAction);
|
|
||||||
menu.addSeparator();
|
|
||||||
menu.addAction(addToMenuAction);
|
|
||||||
QMenu subMenu;
|
|
||||||
setupAddToSubmenu(subMenu);
|
|
||||||
|
|
||||||
menu.exec(contentViewsManager->comicsView->mapToGlobal(point));
|
|
||||||
}
|
|
||||||
|
|
||||||
void LibraryWindow::showGridFoldersContextMenu(QPoint point, Folder folder)
|
void LibraryWindow::showGridFoldersContextMenu(QPoint point, Folder folder)
|
||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
@ -2014,13 +2043,13 @@ void LibraryWindow::showGridFoldersContextMenu(QPoint point, Folder folder)
|
|||||||
setFolderAsNormalAction->setText(tr("comic"));
|
setFolderAsNormalAction->setText(tr("comic"));
|
||||||
|
|
||||||
auto setFolderAsWesternMangaAction = new QAction();
|
auto setFolderAsWesternMangaAction = new QAction();
|
||||||
setFolderAsWesternMangaAction->setText(tr("manga (or left to right)"));
|
setFolderAsWesternMangaAction->setText(tr("western manga (left to right)"));
|
||||||
|
|
||||||
auto setFolderAsWebComicAction = new QAction();
|
auto setFolderAsWebComicAction = new QAction();
|
||||||
setFolderAsWebComicAction->setText(tr("web comic"));
|
setFolderAsWebComicAction->setText(tr("web comic"));
|
||||||
|
|
||||||
auto setFolderAs4KomaAction = new QAction();
|
auto setFolderAs4KomaAction = new QAction();
|
||||||
setFolderAs4KomaAction->setText(tr("4koma (or top to botom"));
|
setFolderAs4KomaAction->setText(tr("4koma (top to botom"));
|
||||||
|
|
||||||
menu.addAction(openContainingFolderAction);
|
menu.addAction(openContainingFolderAction);
|
||||||
menu.addAction(updateFolderAction);
|
menu.addAction(updateFolderAction);
|
||||||
@ -2038,6 +2067,30 @@ void LibraryWindow::showGridFoldersContextMenu(QPoint point, Folder folder)
|
|||||||
menu.addAction(setFolderAsReadAction);
|
menu.addAction(setFolderAsReadAction);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
setFolderAsNormalAction->setCheckable(true);
|
||||||
|
setFolderAsMangaAction->setCheckable(true);
|
||||||
|
setFolderAsWesternMangaAction->setCheckable(true);
|
||||||
|
setFolderAsWebComicAction->setCheckable(true);
|
||||||
|
setFolderAs4KomaAction->setCheckable(true);
|
||||||
|
|
||||||
|
switch (folder.type) {
|
||||||
|
case FileType::Comic:
|
||||||
|
setFolderAsNormalAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::Manga:
|
||||||
|
setFolderAsMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::WesternManga:
|
||||||
|
setFolderAsWesternMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::WebComic:
|
||||||
|
setFolderAsWebComicAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::Yonkoma:
|
||||||
|
setFolderAs4KomaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
auto typeMenu = new QMenu(tr("Set type"));
|
auto typeMenu = new QMenu(tr("Set type"));
|
||||||
menu.addMenu(typeMenu);
|
menu.addMenu(typeMenu);
|
||||||
typeMenu->addAction(setFolderAsNormalAction);
|
typeMenu->addAction(setFolderAsNormalAction);
|
||||||
@ -3046,6 +3099,37 @@ void LibraryWindow::showFoldersContextMenu(const QPoint &point)
|
|||||||
|
|
||||||
bool isCompleted = sourceMI.data(FolderModel::CompletedRole).toBool();
|
bool isCompleted = sourceMI.data(FolderModel::CompletedRole).toBool();
|
||||||
bool isRead = sourceMI.data(FolderModel::FinishedRole).toBool();
|
bool isRead = sourceMI.data(FolderModel::FinishedRole).toBool();
|
||||||
|
auto type = sourceMI.data(FolderModel::TypeRole).value<YACReader::FileType>();
|
||||||
|
|
||||||
|
setFolderAsNormalAction->setCheckable(true);
|
||||||
|
setFolderAsMangaAction->setCheckable(true);
|
||||||
|
setFolderAsWesternMangaAction->setCheckable(true);
|
||||||
|
setFolderAsWebComicAction->setCheckable(true);
|
||||||
|
setFolderAsYonkomaAction->setCheckable(true);
|
||||||
|
|
||||||
|
setFolderAsNormalAction->setChecked(false);
|
||||||
|
setFolderAsMangaAction->setChecked(false);
|
||||||
|
setFolderAsWesternMangaAction->setChecked(false);
|
||||||
|
setFolderAsWebComicAction->setChecked(false);
|
||||||
|
setFolderAsYonkomaAction->setChecked(false);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case FileType::Comic:
|
||||||
|
setFolderAsNormalAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::Manga:
|
||||||
|
setFolderAsMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::WesternManga:
|
||||||
|
setFolderAsWesternMangaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::WebComic:
|
||||||
|
setFolderAsWebComicAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FileType::Yonkoma:
|
||||||
|
setFolderAsYonkomaAction->setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
|
@ -425,6 +425,7 @@ public slots:
|
|||||||
void addSelectedComicsToFavorites();
|
void addSelectedComicsToFavorites();
|
||||||
void showComicsViewContextMenu(const QPoint &point);
|
void showComicsViewContextMenu(const QPoint &point);
|
||||||
void showComicsItemContextMenu(const QPoint &point);
|
void showComicsItemContextMenu(const QPoint &point);
|
||||||
|
void showComicsContextMenu(const QPoint &point, bool showFullScreenAction);
|
||||||
void setupAddToSubmenu(QMenu &menu);
|
void setupAddToSubmenu(QMenu &menu);
|
||||||
void onAddComicsToLabel();
|
void onAddComicsToLabel();
|
||||||
void setToolbarTitle(const QModelIndex &modelIndex);
|
void setToolbarTitle(const QModelIndex &modelIndex);
|
||||||
|
Loading…
Reference in New Issue
Block a user