Skip to content

Commit

Permalink
fix issue #36: Find should indicate visually, if symbol wasn't found.
Browse files Browse the repository at this point in the history
Signed-off-by: zdenop <zdenop@gmail.com>
  • Loading branch information
zdenop committed Apr 14, 2014
1 parent c4d75d5 commit db92bcf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
27 changes: 25 additions & 2 deletions dialogs/FindDialog.cpp
Expand Up @@ -4,7 +4,7 @@
* Author: Zdenko Podobny
* Created: 2011-09-23
*
* (C) Copyright 2011, Zdenko Podobny
* (C) Copyright 2011-2014, Zdenko Podobny
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,8 @@

#include "dialogs/FindDialog.h"
#include "Settings.h"
#include <unistd.h>
#include <QDebug>

FindDialog::FindDialog(QWidget* parent, QString title)
: QDialog(parent) {
Expand Down Expand Up @@ -50,7 +52,9 @@ FindDialog::FindDialog(QWidget* parent, QString title)
connect(findPrevButton, SIGNAL(clicked()), this, SLOT(findPrev()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
connect(checkBox_Mc, SIGNAL(toggled(bool)), this, SLOT(changed_Mc(bool)));

connect(parent, SIGNAL(blinkFindDialog()), this, SLOT(blinkFindDialog()));
timerBlink = new QTimeLine(10);
originalBackColor = this->palette().color(QPalette::Background);;
getSettings();
}

Expand Down Expand Up @@ -81,6 +85,25 @@ void FindDialog::changed_Mc(bool status) {
settings.setValue("Find/MatchCase", status);
}

void FindDialog::blinkFindDialog() {
QApplication::beep();
if(timerBlink->state() == QTimeLine::NotRunning)
{
timerBlink->resume();
connect(timerBlink, SIGNAL(finished()), this, SLOT(blinkFinished()));
}
QPalette pal = this->palette();
pal.setColor(QPalette::Background, Qt::red);
this->setPalette(pal);
}

void FindDialog::blinkFinished() {
disconnect(timerBlink, SIGNAL(finished()), this, SLOT(blinkFinished()));
QPalette pal = this->palette();
pal.setColor(QPalette::Background, originalBackColor);
this->setPalette(pal);
}

void FindDialog::closeEvent(QCloseEvent* event) {
writeGeometry();
event->accept();
Expand Down
9 changes: 8 additions & 1 deletion dialogs/FindDialog.h
Expand Up @@ -4,7 +4,7 @@
* Author: Zdenko Podobny
* Created: 2011-09-23
*
* (C) Copyright 2011, Zdenko Podobny
* (C) Copyright 2011-2014, Zdenko Podobny
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
Expand All @@ -27,6 +27,7 @@
#include <QCloseEvent>
#include <QPushButton>
#include <QDialog>
#include <QTimeLine>

#include "ui_FindDialog.h"

Expand All @@ -36,6 +37,9 @@ class FindDialog : public QDialog, public Ui::Find {
public:
explicit FindDialog(QWidget* parent = 0, QString title = "");

public slots:
void blinkFindDialog();

signals:
void findNext(const QString &smbl, Qt::CaseSensitivity mc);
void findPrev(const QString &smbl, Qt::CaseSensitivity mc);
Expand All @@ -47,13 +51,16 @@ class FindDialog : public QDialog, public Ui::Find {
QPushButton *findNextButton;
QPushButton *findPrevButton;
QPushButton *closeButton;
QTimeLine *timerBlink;
QColor originalBackColor;

void writeGeometry();

private slots:
void on_lineEdit_textChanged();
void findNext();
void findPrev();
void blinkFinished();
void changed_Mc(bool status);
void getSettings();
};
Expand Down
6 changes: 4 additions & 2 deletions src/ChildWidget.cpp
Expand Up @@ -2673,7 +2673,8 @@ void ChildWidget::findNext(const QString &symbol, Qt::CaseSensitivity mc) {
}
++row;
}
QApplication::beep();
emit blinkFindDialog();
emit statusBarMessage(tr("End of search!"));
}

void ChildWidget::findPrev(const QString &symbol,
Expand All @@ -2690,7 +2691,8 @@ void ChildWidget::findPrev(const QString &symbol,
}
--row;
}
QApplication::beep();
emit blinkFindDialog();
emit statusBarMessage(tr("End of found!"));
}

bool ChildWidget::isUndoAvailable() {
Expand Down
1 change: 1 addition & 0 deletions src/ChildWidget.h
Expand Up @@ -303,6 +303,7 @@ class ChildWidget : public QSplitter {
signals:
void boxChanged();
void modifiedChanged();
void blinkFindDialog();
void zoomRatioChanged(qreal);
void statusBarMessage(QString);

Expand Down

0 comments on commit db92bcf

Please sign in to comment.