Commit ca41c24c authored by Eike Ziller's avatar Eike Ziller
Browse files

Find: Show number of replaced items after replace all



Show a fading indicator over the editor, or over the main window in case
of global search & replace.

Change-Id: I84a982bcfed558c0f84c08c3625a0cad4c5409d6
Task-number: QTCREATORBUG-3494
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent a320daff
...@@ -48,7 +48,7 @@ class FadingIndicatorPrivate : public QWidget ...@@ -48,7 +48,7 @@ class FadingIndicatorPrivate : public QWidget
Q_OBJECT Q_OBJECT
public: public:
FadingIndicatorPrivate(QWidget *parent = 0) FadingIndicatorPrivate(QWidget *parent, FadingIndicator::TextSize size)
: QWidget(parent) : QWidget(parent)
{ {
m_effect = new QGraphicsOpacityEffect(this); m_effect = new QGraphicsOpacityEffect(this);
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
m_label = new QLabel; m_label = new QLabel;
QFont font = m_label->font(); QFont font = m_label->font();
font.setPixelSize(45); font.setPixelSize(size == FadingIndicator::LargeText ? 45 : 22);
m_label->setFont(font); m_label->setFont(font);
QPalette pal = palette(); QPalette pal = palette();
pal.setColor(QPalette::Foreground, pal.color(QPalette::Background)); pal.setColor(QPalette::Foreground, pal.color(QPalette::Background));
...@@ -126,16 +126,16 @@ private: ...@@ -126,16 +126,16 @@ private:
namespace FadingIndicator { namespace FadingIndicator {
void showText(QWidget *parent, const QString &text) void showText(QWidget *parent, const QString &text, TextSize size)
{ {
auto indicator = new Internal::FadingIndicatorPrivate(parent); auto indicator = new Internal::FadingIndicatorPrivate(parent, size);
indicator->setText(text); indicator->setText(text);
indicator->run(1000); // deletes itself indicator->run(2500); // deletes itself
} }
void showPixmap(QWidget *parent, const QString &pixmap) void showPixmap(QWidget *parent, const QString &pixmap)
{ {
auto indicator = new Internal::FadingIndicatorPrivate(parent); auto indicator = new Internal::FadingIndicatorPrivate(parent, LargeText);
indicator->setPixmap(pixmap); indicator->setPixmap(pixmap);
indicator->run(300); // deletes itself indicator->run(300); // deletes itself
} }
......
...@@ -40,7 +40,13 @@ ...@@ -40,7 +40,13 @@
namespace Utils { namespace Utils {
namespace FadingIndicator { namespace FadingIndicator {
QTCREATOR_UTILS_EXPORT void showText(QWidget *parent, const QString &text); enum TextSize {
SmallText,
LargeText
};
QTCREATOR_UTILS_EXPORT void showText(QWidget *parent, const QString &text,
TextSize size = LargeText);
QTCREATOR_UTILS_EXPORT void showPixmap(QWidget *parent, const QString &pixmap); QTCREATOR_UTILS_EXPORT void showPixmap(QWidget *parent, const QString &pixmap);
} // FadingIndicator } // FadingIndicator
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#include <aggregation/aggregate.h> #include <aggregation/aggregate.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <utils/fadingindicator.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QDebug> #include <QDebug>
...@@ -134,7 +136,12 @@ bool CurrentDocumentFind::replaceStep(const QString &before, const QString &afte ...@@ -134,7 +136,12 @@ bool CurrentDocumentFind::replaceStep(const QString &before, const QString &afte
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags) int CurrentDocumentFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
{ {
QTC_ASSERT(m_currentFind, return 0); QTC_ASSERT(m_currentFind, return 0);
return m_currentFind->replaceAll(before, after, findFlags); QTC_CHECK(m_currentWidget);
int count = m_currentFind->replaceAll(before, after, findFlags);
Utils::FadingIndicator::showText(m_currentWidget,
tr("%1 occurrences replaced.").arg(count),
Utils::FadingIndicator::SmallText);
return count;
} }
void CurrentDocumentFind::defineFindScope() void CurrentDocumentFind::defineFindScope()
......
...@@ -42,9 +42,10 @@ ...@@ -42,9 +42,10 @@
#include <coreplugin/find/ifindsupport.h> #include <coreplugin/find/ifindsupport.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <texteditor/refactoringchanges.h> #include <texteditor/refactoringchanges.h>
#include <utils/stylehelper.h> #include <utils/fadingindicator.h>
#include <utils/qtcassert.h>
#include <utils/filesearch.h> #include <utils/filesearch.h>
#include <utils/qtcassert.h>
#include <utils/stylehelper.h>
#include <QDebug> #include <QDebug>
#include <QSettings> #include <QSettings>
...@@ -208,6 +209,9 @@ void BaseFileFind::doReplace(const QString &text, ...@@ -208,6 +209,9 @@ void BaseFileFind::doReplace(const QString &text,
{ {
QStringList files = replaceAll(text, items, preserveCase); QStringList files = replaceAll(text, items, preserveCase);
if (!files.isEmpty()) { if (!files.isEmpty()) {
Utils::FadingIndicator::showText(ICore::mainWindow(),
tr("%1 occurrences replaced.").arg(items.size()),
Utils::FadingIndicator::SmallText);
DocumentManager::notifyFilesChangedInternally(files); DocumentManager::notifyFilesChangedInternally(files);
SearchResultWindow::instance()->hide(); SearchResultWindow::instance()->hide();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment