Change searchbar background color to red(ish) when no match found
This commit is contained in:
@@ -48,12 +48,13 @@ void HistorySearch::search() {
|
||||
} else {
|
||||
found = search(0, 0, m_startColumn, m_startLine) || search(m_startColumn, m_startLine, -1, m_emulation->lineCount());
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
emit matchFound(m_foundStartColumn, m_foundStartLine, m_foundEndColumn, m_foundEndLine);
|
||||
} else {
|
||||
emit noMatchFound();
|
||||
|
||||
if (found) {
|
||||
emit matchFound(m_foundStartColumn, m_foundStartLine, m_foundEndColumn, m_foundEndLine);
|
||||
}
|
||||
else {
|
||||
emit noMatchFound();
|
||||
}
|
||||
}
|
||||
|
||||
deleteLater();
|
||||
|
||||
+24
-2
@@ -67,6 +67,13 @@ void SearchBar::toggleShown()
|
||||
isHidden() ? show() : hide();
|
||||
}
|
||||
|
||||
void SearchBar::noMatchFound()
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(widget.searchTextEdit->backgroundRole(), QColor(255, 128, 128));
|
||||
widget.searchTextEdit->setPalette(palette);
|
||||
}
|
||||
|
||||
void SearchBar::searchTextChanged()
|
||||
{
|
||||
m_regExp = QRegExp(widget.searchTextEdit->text());
|
||||
@@ -77,8 +84,13 @@ void SearchBar::searchTextChanged()
|
||||
if (! m_matchCaseMenuEntry->isChecked()) {
|
||||
m_regExp.setCaseSensitivity(Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
emit search(m_regExp, true, false);
|
||||
|
||||
clearBackgroundColor();
|
||||
|
||||
if (!m_regExp.isEmpty())
|
||||
{
|
||||
emit search(m_regExp, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchBar::keyReleaseEvent(QKeyEvent* keyEvent)
|
||||
@@ -102,10 +114,20 @@ void SearchBar::keyReleaseEvent(QKeyEvent* keyEvent)
|
||||
|
||||
void SearchBar::findNext()
|
||||
{
|
||||
clearBackgroundColor();
|
||||
emit search(m_regExp, true, true);
|
||||
}
|
||||
|
||||
void SearchBar::findPrevious()
|
||||
{
|
||||
clearBackgroundColor();
|
||||
emit search(m_regExp, false, false);
|
||||
}
|
||||
|
||||
void SearchBar::clearBackgroundColor()
|
||||
{
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Base, Qt::white);
|
||||
widget.searchTextEdit->setPalette(p);
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void toggleShown();
|
||||
void noMatchFound();
|
||||
|
||||
signals:
|
||||
void search(QRegExp regexp, bool forwards, bool skip);
|
||||
@@ -45,6 +46,7 @@ private slots:
|
||||
void searchTextChanged();
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
void clearBackgroundColor();
|
||||
|
||||
private:
|
||||
QRegExp m_regExp;
|
||||
|
||||
@@ -148,6 +148,7 @@ void QTermWidget::search(QRegExp regexp, bool forwards, bool next)
|
||||
new HistorySearch(m_impl->m_session->emulation(), regexp, forwards, startColumn, startLine, this);
|
||||
connect(historySearch, SIGNAL(matchFound(int, int, int, int)), this, SLOT(matchFound(int, int, int, int)));
|
||||
connect(historySearch, SIGNAL(noMatchFound()), this, SLOT(noMatchFound()));
|
||||
connect(historySearch, SIGNAL(noMatchFound()), m_searchBar, SLOT(noMatchFound()));
|
||||
historySearch->search();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user