diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index abc76896..65c7c2ba 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -644,25 +644,21 @@ void LibraryWindow::createActions() setFolderAsNotCompletedAction = new QAction(this); setFolderAsNotCompletedAction->setText(tr("Set as uncompleted")); - setFolderAsNotCompletedAction->setVisible(false); setFolderAsNotCompletedAction->setData(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL); setFolderAsNotCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL)); setFolderAsCompletedAction = new QAction(this); setFolderAsCompletedAction->setText(tr("Set as completed")); - setFolderAsCompletedAction->setVisible(false); setFolderAsCompletedAction->setData(SET_FOLDER_AS_COMPLETED_ACTION_YL); setFolderAsCompletedAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_COMPLETED_ACTION_YL)); setFolderAsReadAction = new QAction(this); setFolderAsReadAction->setText(tr("Set as read")); - setFolderAsReadAction->setVisible(false); setFolderAsReadAction->setData(SET_FOLDER_AS_READ_ACTION_YL); setFolderAsReadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_READ_ACTION_YL)); setFolderAsUnreadAction = new QAction(this); setFolderAsUnreadAction->setText(tr("Set as unread")); - setFolderAsUnreadAction->setVisible(false); setFolderAsUnreadAction->setData(SET_FOLDER_AS_UNREAD_ACTION_YL); setFolderAsUnreadAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_FOLDER_AS_UNREAD_ACTION_YL)); @@ -831,14 +827,6 @@ void LibraryWindow::disableFoldersActions(bool disabled) openContainingFolderAction->setDisabled(disabled); updateFolderAction->setDisabled(disabled); - - if(disabled == false) - { - setFolderAsNotCompletedAction->setVisible(false); - setFolderAsCompletedAction->setVisible(false); - setFolderAsReadAction->setVisible(false); - setFolderAsUnreadAction->setVisible(false); - } } void LibraryWindow::disableAllActions() @@ -1111,6 +1099,7 @@ void LibraryWindow::createConnections() //drops in folders view connect(foldersView, SIGNAL(copyComicsToFolder(QList >,QModelIndex)), this, SLOT(copyAndImportComicsToFolder(QList >,QModelIndex))); connect(foldersView, SIGNAL(moveComicsToFolder(QList >,QModelIndex)), this, SLOT(moveAndImportComicsToFolder(QList >,QModelIndex))); + connect(foldersView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showFoldersContextMenu(QPoint))); //actions connect(createLibraryAction,SIGNAL(triggered()),this,SLOT(createLibrary())); @@ -1978,11 +1967,6 @@ void LibraryWindow::setRootIndex() foldersView->selectionModel()->clear(); } - - setFolderAsNotCompletedAction->setVisible(false); - setFolderAsCompletedAction->setVisible(false); - setFolderAsReadAction->setVisible(false); - setFolderAsUnreadAction->setVisible(false); } @@ -2520,7 +2504,33 @@ void LibraryWindow::deleteComics() if(thread != NULL) thread->start(); - } + } +} + +void LibraryWindow::showFoldersContextMenu(const QPoint &point) +{ + QModelIndex sourceMI = foldersModelProxy->mapToSource(foldersView->indexAt(point)); + + bool isCompleted = sourceMI.data(FolderModel::CompletedRole).toBool(); + bool isRead = sourceMI.data(FolderModel::FinishedRole).toBool(); + + QMenu menu; + //QMenu * folderMenu = new QMenu(tr("Folder")); + menu.addAction(openContainingFolderAction); + menu.addAction(updateFolderAction); + menu.addSeparator();//------------------------------- + if(isCompleted) + menu.addAction(setFolderAsNotCompletedAction); + else + menu.addAction(setFolderAsCompletedAction); + menu.addSeparator();//------------------------------- + if(isRead) + menu.addAction(setFolderAsUnreadAction); + else + menu.addAction(setFolderAsReadAction); + + menu.exec(foldersView->mapToGlobal(point)); + } /* @@ -2536,21 +2546,6 @@ void LibraryWindow::showSocial() socialDialog->setHidden(false); }*/ -void LibraryWindow::updateFoldersViewConextMenu(const QModelIndex &mi) -{ - if(!mi.isValid()) - return; - - bool isFinished = mi.data(FolderModel::FinishedRole).toBool(); - bool isCompleted = mi.data(FolderModel::CompletedRole).toBool(); - - setFolderAsReadAction->setVisible(!isFinished); - setFolderAsUnreadAction->setVisible(isFinished); - - setFolderAsCompletedAction->setVisible(!isCompleted); - setFolderAsNotCompletedAction->setVisible(isCompleted); -} - void LibraryWindow::libraryAlreadyExists(const QString & name) { QMessageBox::information(this,tr("Library name already exists"),tr("There is another library with the name '%1'.").arg(name)); diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 488a4d04..1e03a4e0 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -350,7 +350,7 @@ public slots: QModelIndexList getSelectedComics(); void deleteComics(); //void showSocial(); - void updateFoldersViewConextMenu(const QModelIndex & mi); + void showFoldersContextMenu(const QPoint & point); void libraryAlreadyExists(const QString & name); void importLibraryPackage(); void updateComicsView(quint64 libraryId, const ComicDB & comic); diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index d0bec71c..30830871 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -73,7 +73,7 @@ void YACReaderNavigationController::loadFolderInfo(const QModelIndex &modelIndex libraryWindow->disableComicsActions(true); } - libraryWindow->updateFoldersViewConextMenu(modelIndex); + //libraryWindow->updateFoldersViewConextMenu(modelIndex); //if a folder is selected, listsView selection must be cleared libraryWindow->listsView->clearSelection(); diff --git a/custom_widgets/yacreader_treeview.cpp b/custom_widgets/yacreader_treeview.cpp index f67cfbb4..6f36f16e 100644 --- a/custom_widgets/yacreader_treeview.cpp +++ b/custom_widgets/yacreader_treeview.cpp @@ -11,8 +11,8 @@ YACReaderTreeView::YACReaderTreeView(QWidget *parent) : /*viewport()->setAcceptDrops(true); setDropIndicatorShown(true);*/ - setContextMenuPolicy(Qt::ActionsContextMenu); - setContextMenuPolicy(Qt::ActionsContextMenu); + setContextMenuPolicy(Qt::CustomContextMenu); + header()->hide(); setUniformRowHeights(true); setSelectionBehavior(QAbstractItemView::SelectRows);