forked from qt-creator/qt-creator
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 <orgads@gmail.com>
This commit is contained in:
@@ -48,7 +48,7 @@ class FadingIndicatorPrivate : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FadingIndicatorPrivate(QWidget *parent = 0)
|
||||
FadingIndicatorPrivate(QWidget *parent, FadingIndicator::TextSize size)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_effect = new QGraphicsOpacityEffect(this);
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
m_label = new QLabel;
|
||||
QFont font = m_label->font();
|
||||
font.setPixelSize(45);
|
||||
font.setPixelSize(size == FadingIndicator::LargeText ? 45 : 22);
|
||||
m_label->setFont(font);
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Foreground, pal.color(QPalette::Background));
|
||||
@@ -126,16 +126,16 @@ private:
|
||||
|
||||
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->run(1000); // deletes itself
|
||||
indicator->run(2500); // deletes itself
|
||||
}
|
||||
|
||||
void showPixmap(QWidget *parent, const QString &pixmap)
|
||||
{
|
||||
auto indicator = new Internal::FadingIndicatorPrivate(parent);
|
||||
auto indicator = new Internal::FadingIndicatorPrivate(parent, LargeText);
|
||||
indicator->setPixmap(pixmap);
|
||||
indicator->run(300); // deletes itself
|
||||
}
|
||||
|
||||
@@ -40,7 +40,13 @@
|
||||
namespace Utils {
|
||||
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);
|
||||
|
||||
} // FadingIndicator
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/fadingindicator.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -134,7 +136,12 @@ bool CurrentDocumentFind::replaceStep(const QString &before, const QString &afte
|
||||
int CurrentDocumentFind::replaceAll(const QString &before, const QString &after, FindFlags findFlags)
|
||||
{
|
||||
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()
|
||||
|
||||
@@ -42,9 +42,10 @@
|
||||
#include <coreplugin/find/ifindsupport.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/refactoringchanges.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fadingindicator.h>
|
||||
#include <utils/filesearch.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
@@ -208,6 +209,9 @@ void BaseFileFind::doReplace(const QString &text,
|
||||
{
|
||||
QStringList files = replaceAll(text, items, preserveCase);
|
||||
if (!files.isEmpty()) {
|
||||
Utils::FadingIndicator::showText(ICore::mainWindow(),
|
||||
tr("%1 occurrences replaced.").arg(items.size()),
|
||||
Utils::FadingIndicator::SmallText);
|
||||
DocumentManager::notifyFilesChangedInternally(files);
|
||||
SearchResultWindow::instance()->hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user