From 1f46098349bb62088ace6226b54b6bbae145b51c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 29 Mar 2019 15:05:31 +0100 Subject: [PATCH] Use new progress subtitle API for search result count Change-Id: Ie40f44a3bdb7621c48560cb560ccc2622d59ba4a Reviewed-by: David Schulz --- src/plugins/texteditor/basefilefind.cpp | 33 ++++++------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index eb449251c16..bdcc9ca5a55 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -293,10 +293,6 @@ void BaseFileFind::runNewSearch(const QString &txt, FindFlags findFlags, void BaseFileFind::runSearch(SearchResult *search) { const FileFindParameters parameters = search->userData().value(); - auto label = new CountingLabel; - connect(search, &SearchResult::countChanged, label, &CountingLabel::updateCount); - auto statusLabel = new CountingLabel; - connect(search, &SearchResult::countChanged, statusLabel, &CountingLabel::updateCount); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch|IOutputPane::WithFocus)); auto watcher = new QFutureWatcher(); watcher->setPendingResultsLimit(1); @@ -316,10 +312,13 @@ void BaseFileFind::runSearch(SearchResult *search) search->finishSearch(watcher->isCanceled()); }); watcher->setFuture(executeSearch(parameters)); - FutureProgress *progress = - ProgressManager::addTask(watcher->future(), tr("Searching"), Constants::TASK_SEARCH); - progress->setWidget(label); - progress->setStatusBarWidget(statusLabel); + FutureProgress *progress = ProgressManager::addTask(watcher->future(), + tr("Searching"), + Constants::TASK_SEARCH); + connect(search, &SearchResult::countChanged, progress, [progress](int c) { + progress->setSubtitle(BaseFileFind::tr("%n found.", nullptr, c)); + }); + progress->setSubtitleVisibleInStatusBar(true); connect(progress, &FutureProgress::clicked, search, &SearchResult::popup); } @@ -566,23 +565,5 @@ QFuture BaseFileFind::executeSearch(const FileFindParamete namespace Internal { -CountingLabel::CountingLabel() -{ - setAlignment(Qt::AlignCenter); - // ### TODO this setup should be done by style - QFont f = font(); - f.setBold(true); - f.setPointSizeF(StyleHelper::sidebarFontSize()); - setFont(f); - setPalette(StyleHelper::sidebarFontPalette(palette())); - setProperty("_q_custom_style_disabled", QVariant(true)); - updateCount(0); -} - -void CountingLabel::updateCount(int count) -{ - setText(BaseFileFind::tr("%n found.", nullptr, count)); -} - } // namespace Internal } // namespace TextEditor