File indexing completed on 2025-01-19 03:50:45
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2002-16-10 0007 * Description : Item icon view interface - Search methods. 0008 * 0009 * SPDX-FileCopyrightText: 2002-2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2002-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2009-2011 by Johannes Wienke <languitar at semipol dot de> 0012 * SPDX-FileCopyrightText: 2010-2011 by Andi Clemens <andi dot clemens at gmail dot com> 0013 * SPDX-FileCopyrightText: 2011-2013 by Michael G. Hansen <mike at mghansen dot de> 0014 * SPDX-FileCopyrightText: 2014-2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com> 0015 * SPDX-FileCopyrightText: 2017 by Simon Frei <freisim93 at gmail dot com> 0016 * 0017 * SPDX-License-Identifier: GPL-2.0-or-later 0018 * 0019 * ============================================================ */ 0020 0021 #include "itemiconview_p.h" 0022 #include "progressmanager.h" 0023 0024 namespace Digikam 0025 { 0026 0027 void ItemIconView::slotNewKeywordSearch() 0028 { 0029 slotLeftSideBarActivate(d->searchSideBar); 0030 d->searchSideBar->newKeywordSearch(); 0031 } 0032 0033 void ItemIconView::slotNewAdvancedSearch() 0034 { 0035 slotLeftSideBarActivate(d->searchSideBar); 0036 d->searchSideBar->newAdvancedSearch(); 0037 } 0038 0039 void ItemIconView::slotNewDuplicatesSearch(const QList<PAlbum*>& albums) 0040 { 0041 slotLeftSideBarActivate(d->fuzzySearchSideBar); 0042 d->fuzzySearchSideBar->newDuplicatesSearch(albums); 0043 } 0044 0045 void ItemIconView::slotNewDuplicatesSearch(const QList<TAlbum*>& albums) 0046 { 0047 slotLeftSideBarActivate(d->fuzzySearchSideBar); 0048 d->fuzzySearchSideBar->newDuplicatesSearch(albums); 0049 } 0050 0051 0052 void ItemIconView::slotImageFindSimilar() 0053 { 0054 const ItemInfo current = currentInfo(); 0055 0056 if (!current.isNull()) 0057 { 0058 d->fuzzySearchSideBar->newSimilarSearch(current); 0059 slotLeftSideBarActivate(d->fuzzySearchSideBar); 0060 } 0061 } 0062 0063 void ItemIconView::slotImageScanForFaces() 0064 { 0065 0066 if (ProgressManager::instance()->findItembyId(i18n("FacesDetector"))) 0067 { 0068 QString message = i18n("A face recognition task is already running. " 0069 "Only one task can be running at a time. " 0070 "Please wait until it is finished."); 0071 d->errorWidget->setMessageType(DNotificationWidget::Information); 0072 d->errorWidget->setText(message); 0073 d->errorWidget->animatedShowTemporized(5000); 0074 0075 return; 0076 } 0077 0078 FaceScanSettings settings; 0079 0080 // TODO Faces engine : set K-nearest config 0081 0082 settings.accuracy = ApplicationSettings::instance()->getFaceDetectionAccuracy(); 0083 settings.useYoloV3 = ApplicationSettings::instance()->getFaceDetectionYoloV3(); 0084 settings.task = FaceScanSettings::Detect; 0085 settings.alreadyScannedHandling = FaceScanSettings::Rescan; 0086 0087 // Remove possible duplicate ItemInfos. 0088 0089 Q_FOREACH (const ItemInfo& info, selectedInfoList(ApplicationSettings::Tools)) 0090 { 0091 if (!settings.infos.contains(info)) 0092 { 0093 settings.infos << info; 0094 } 0095 } 0096 0097 FacesDetector* const tool = new FacesDetector(settings); 0098 0099 connect(tool, SIGNAL(signalComplete()), 0100 this, SLOT(slotRefreshImagePreview())); 0101 0102 tool->start(); 0103 } 0104 0105 void ItemIconView::slotImageRecognizeFaces() 0106 { 0107 0108 if (ProgressManager::instance()->findItembyId(i18n("FacesDetector"))) 0109 { 0110 QString message = i18n("A face recognition task is already running. " 0111 "Only one task can be running at a time. " 0112 "Please wait until it is finished."); 0113 d->errorWidget->setMessageType(DNotificationWidget::Information); 0114 d->errorWidget->setText(message); 0115 d->errorWidget->animatedShowTemporized(5000); 0116 0117 return; 0118 } 0119 0120 FaceScanSettings settings; 0121 0122 // TODO Faces engine : set K-nearest config 0123 0124 settings.accuracy = ApplicationSettings::instance()->getFaceDetectionAccuracy(); 0125 settings.useYoloV3 = ApplicationSettings::instance()->getFaceDetectionYoloV3(); 0126 settings.task = FaceScanSettings::RecognizeMarkedFaces; 0127 0128 // Remove possible duplicate ItemInfos. 0129 0130 Q_FOREACH (const ItemInfo& info, selectedInfoList(ApplicationSettings::Tools)) 0131 { 0132 if (!settings.infos.contains(info)) 0133 { 0134 settings.infos << info; 0135 } 0136 } 0137 0138 FacesDetector* const tool = new FacesDetector(settings); 0139 0140 connect(tool, SIGNAL(signalComplete()), 0141 this, SLOT(slotRefreshImagePreview())); 0142 0143 tool->start(); 0144 } 0145 0146 void ItemIconView::slotImageRemoveAllFaces() 0147 { 0148 const ItemInfoList& selected = selectedInfoList(ApplicationSettings::Metadata); 0149 MetadataRemover* const tool = new MetadataRemover(selected, MetadataRemover::Faces); 0150 tool->start(); 0151 } 0152 0153 } // namespace Digikam