Merge pull request #215 from vedgy/exit-search-mode-before-creating-folder

Library: exit search mode before creating a folder
This commit is contained in:
Luis Ángel San Martín 2021-12-29 12:48:42 +01:00 committed by GitHub
commit 1cf4ef97ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View File

@ -1572,6 +1572,8 @@ void LibraryWindow::enableNeededActions()
void LibraryWindow::addFolderToCurrentIndex() void LibraryWindow::addFolderToCurrentIndex()
{ {
exitSearchMode(); // Creating a folder in search mode is broken => exit it.
QModelIndex currentIndex = getCurrentFolderIndex(); QModelIndex currentIndex = getCurrentFolderIndex();
bool ok; bool ok;
@ -2726,3 +2728,12 @@ void LibraryWindow::updateComicsView(quint64 libraryId, const ComicDB &comic)
comicsViewsManager->updateCurrentComicView(); comicsViewsManager->updateCurrentComicView();
} }
} }
bool LibraryWindow::exitSearchMode()
{
if (status != LibraryWindow::Searching)
return false;
searchEdit->clearText();
clearSearchFilter();
return true;
}

View File

@ -424,6 +424,10 @@ public slots:
void afterLaunchTasks(); void afterLaunchTasks();
private: private:
//! @brief Exits search mode if it is active.
//! @return true If the search mode was active when this function was called.
bool exitSearchMode();
// fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309 // fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
Qt::WindowFlags previousWindowFlags; Qt::WindowFlags previousWindowFlags;
QPoint previousPos; QPoint previousPos;

View File

@ -34,10 +34,8 @@ void YACReaderNavigationController::selectedFolder(const QModelIndex &mi)
// update history // update history
libraryWindow->historyController->updateHistory(YACReaderLibrarySourceContainer(modelIndex, YACReaderLibrarySourceContainer::Folder)); libraryWindow->historyController->updateHistory(YACReaderLibrarySourceContainer(modelIndex, YACReaderLibrarySourceContainer::Folder));
if (libraryWindow->status == LibraryWindow::Searching) { // when a folder is selected the search mode has to be reset
// when a folder is selected the search mode has to be reset if (libraryWindow->exitSearchMode()) {
libraryWindow->searchEdit->clearText();
libraryWindow->clearSearchFilter();
libraryWindow->foldersView->scrollTo(mi, QAbstractItemView::PositionAtTop); libraryWindow->foldersView->scrollTo(mi, QAbstractItemView::PositionAtTop);
libraryWindow->foldersView->setCurrentIndex(mi); libraryWindow->foldersView->setCurrentIndex(mi);
} }
@ -182,10 +180,9 @@ void YACReaderNavigationController::selectedList(const QModelIndex &mi)
// update history // update history
libraryWindow->historyController->updateHistory(YACReaderLibrarySourceContainer(modelIndex, YACReaderLibrarySourceContainer::List)); libraryWindow->historyController->updateHistory(YACReaderLibrarySourceContainer(modelIndex, YACReaderLibrarySourceContainer::List));
if (libraryWindow->status == LibraryWindow::Searching) { // when a list is selected the search mode has to be reset
// when a list is selected the search mode has to be reset if (libraryWindow->exitSearchMode()) {
libraryWindow->searchEdit->clearText();
libraryWindow->clearSearchFilter();
libraryWindow->listsView->scrollTo(mi, QAbstractItemView::PositionAtTop); libraryWindow->listsView->scrollTo(mi, QAbstractItemView::PositionAtTop);
libraryWindow->listsView->setCurrentIndex(mi); libraryWindow->listsView->setCurrentIndex(mi);
} }
@ -212,12 +209,8 @@ void YACReaderNavigationController::reselectCurrentSource()
void YACReaderNavigationController::selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer) void YACReaderNavigationController::selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer)
{ {
// TODO NO searching allowed, just disable backward/forward actions in searching mode // TODO NO searching allowed, just disable backward/forward actions in searching mode
if (libraryWindow->status == LibraryWindow::Searching) { // when a folder or a list is selected the search mode has to be reset
// when a folder is selected the search mode has to be reset libraryWindow->exitSearchMode();
libraryWindow->searchEdit->clearText();
libraryWindow->clearSearchFilter();
}
loadIndexFromHistory(sourceContainer); loadIndexFromHistory(sourceContainer);
libraryWindow->setToolbarTitle(sourceContainer.getSourceModelIndex()); libraryWindow->setToolbarTitle(sourceContainer.getSourceModelIndex());
} }