Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/editor/dtextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,10 +1055,12 @@ void TextEdit::nextLine()
if (m_wrapper != nullptr) {
qDebug() << "Updating highlighter";
m_wrapper->OnUpdateHighlighter();
if ((m_wrapper->window()->findBarIsVisiable() || m_wrapper->window()->replaceBarIsVisiable()) &&
(QString::compare(m_wrapper->window()->getKeywordForSearchAll(), m_wrapper->window()->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
Window *win = m_wrapper->window();
const QString keyword = win->getKeywordForSearchAll();
if ((win->findBarIsVisiable() || win->replaceBarIsVisiable()) &&
(QString::compare(keyword, win->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "Highlighting keyword in view";
highlightKeywordInView(m_wrapper->window()->getKeywordForSearchAll());
highlightKeywordInView(keyword, win->getSearchCaseFlag());
}

qDebug() << "Marking all keyword in view";
Expand Down Expand Up @@ -1090,10 +1092,12 @@ void TextEdit::prevLine()
if (m_wrapper != nullptr) {
qDebug() << "Updating highlighter";
m_wrapper->OnUpdateHighlighter();
if ((m_wrapper->window()->findBarIsVisiable() || m_wrapper->window()->replaceBarIsVisiable()) &&
(QString::compare(m_wrapper->window()->getKeywordForSearchAll(), m_wrapper->window()->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
Window *win = m_wrapper->window();
const QString keyword = win->getKeywordForSearchAll();
if ((win->findBarIsVisiable() || win->replaceBarIsVisiable()) &&
(QString::compare(keyword, win->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "Highlighting keyword in view";
highlightKeywordInView(m_wrapper->window()->getKeywordForSearchAll());
highlightKeywordInView(keyword, win->getSearchCaseFlag());
}

qDebug() << "Marking all keyword in view";
Expand Down Expand Up @@ -1302,10 +1306,12 @@ void TextEdit::scrollUp()
if (m_wrapper != nullptr) {
qDebug() << "Updating highlighter";
m_wrapper->OnUpdateHighlighter();
if ((m_wrapper->window()->findBarIsVisiable() || m_wrapper->window()->replaceBarIsVisiable()) &&
(QString::compare(m_wrapper->window()->getKeywordForSearchAll(), m_wrapper->window()->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
Window *win = m_wrapper->window();
const QString keyword = win->getKeywordForSearchAll();
if ((win->findBarIsVisiable() || win->replaceBarIsVisiable()) &&
(QString::compare(keyword, win->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "Highlighting keyword in view";
highlightKeywordInView(m_wrapper->window()->getKeywordForSearchAll());
highlightKeywordInView(keyword, win->getSearchCaseFlag());
}

markAllKeywordInView();
Expand Down Expand Up @@ -1336,10 +1342,12 @@ void TextEdit::scrollDown()
if (m_wrapper != nullptr) {
qDebug() << "Updating highlighter";
m_wrapper->OnUpdateHighlighter();
if ((m_wrapper->window()->findBarIsVisiable() || m_wrapper->window()->replaceBarIsVisiable()) &&
(QString::compare(m_wrapper->window()->getKeywordForSearchAll(), m_wrapper->window()->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
Window *win = m_wrapper->window();
const QString keyword = win->getKeywordForSearchAll();
if ((win->findBarIsVisiable() || win->replaceBarIsVisiable()) &&
(QString::compare(keyword, win->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "Highlighting keyword in view";
highlightKeywordInView(m_wrapper->window()->getKeywordForSearchAll());
highlightKeywordInView(keyword, win->getSearchCaseFlag());
}

markAllKeywordInView();
Expand Down
2 changes: 1 addition & 1 deletion src/editor/editwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ EditWrapper::EditWrapper(Window *window, QWidget *parent)
if ((m_pWindow->findBarIsVisiable() || m_pWindow->replaceBarIsVisiable()) &&
(QString::compare(m_pWindow->getKeywordForSearchAll(), m_pWindow->getKeywordForSearch(), Qt::CaseInsensitive) == 0)) {
qDebug() << "EditWrapper connect verticalScrollBar valueChanged, highlightKeywordInView";
m_pTextEdit->highlightKeywordInView(m_pWindow->getKeywordForSearchAll());
m_pTextEdit->highlightKeywordInView(m_pWindow->getKeywordForSearchAll(), m_pWindow->getSearchCaseFlag());
}

m_pTextEdit->markAllKeywordInView();
Expand Down
21 changes: 17 additions & 4 deletions src/widgets/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
#include <DAnchors>
#include <DSettingsWidgetFactory>
#include <DSettingsGroup>
#include <DSettings>

Check warning on line 11 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DSettings> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSettings> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <DSettingsOption>

Check warning on line 12 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DSettingsOption> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DSettingsOption> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QApplication>

Check warning on line 13 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

Check warning on line 14 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 14 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPrintDialog>

Check warning on line 15 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QPrintDialog> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 15 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPrintDialog> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPrintPreviewDialog>

Check warning on line 16 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QPrintPreviewDialog> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 16 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPrintPreviewDialog> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPrinter>

Check warning on line 17 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QPrinter> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 17 in src/widgets/window.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPrinter> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>
#include <QStyleFactory>
#include <QEvent>
Expand Down Expand Up @@ -294,7 +295,7 @@
connect(m_replaceBar, &ReplaceBar::replaceRest, this, &Window::handleReplaceRest, Qt::QueuedConnection);
connect(m_replaceBar, &ReplaceBar::replaceSkip, this, &Window::handleReplaceSkip, Qt::QueuedConnection);
connect(m_replaceBar, &ReplaceBar::updateSearchKeyword, this, [ = ](QString file, QString keyword) {
handleUpdateSearchKeyword(m_replaceBar, file, keyword);
handleUpdateSearchKeyword(m_replaceBar, file, keyword, Qt::CaseSensitive);
});
connect(m_replaceBar, &ReplaceBar::sigReplacebarClose, this, &Window::slotReplacebarClose, Qt::QueuedConnection);

Expand Down Expand Up @@ -1730,8 +1731,9 @@
int scrollOffset = wrapper->textEditor()->getScrollOffset();

m_findBar->activeInput(text, tabPath, row, column, scrollOffset);
// highlight keyword when findbar show
wrapper->textEditor()->highlightKeywordInView(text);
// highlight keyword when findbar show (find bar uses case-insensitive by default)
m_searchCaseFlag = Qt::CaseInsensitive;
wrapper->textEditor()->highlightKeywordInView(text, m_searchCaseFlag);
// set keywords
m_keywordForSearchAll = m_keywordForSearch = text;

Expand Down Expand Up @@ -1794,6 +1796,8 @@
int scrollOffset = wrapper->textEditor()->getScrollOffset();

m_replaceBar->activeInput(text, tabPath, row, column, scrollOffset);
// replace bar uses case-sensitive search by default
m_searchCaseFlag = Qt::CaseSensitive;

QTimer::singleShot(10, this, [ = ] { m_replaceBar->focus(); });
qDebug() << "Popup replace bar completed";
Expand Down Expand Up @@ -3288,7 +3292,7 @@
wrapper->textEditor()->clearFindMatchSelections();
} else {
qDebug() << "m_keywordForSearchAll is equal to m_keywordForSearch, highlight it";
wrapper->textEditor()->highlightKeywordInView(m_keywordForSearchAll);
wrapper->textEditor()->highlightKeywordInView(m_keywordForSearchAll, m_searchCaseFlag);
}

wrapper->textEditor()->markAllKeywordInView();
Expand Down Expand Up @@ -3406,6 +3410,7 @@
Q_UNUSED(file);
m_keywordForSearch = replaceText;
m_keywordForSearchAll = replaceText;
m_searchCaseFlag = Qt::CaseSensitive;
EditWrapper *wrapper = currentWrapper();
wrapper->textEditor()->replaceNext(replaceText, withText);
qDebug() << "handleReplaceNext end";
Expand Down Expand Up @@ -3466,6 +3471,7 @@
bool findKeyword = wrapper->textEditor()->highlightKeyword(keyword, wrapper->textEditor()->getPosition(), caseFlag);
m_keywordForSearchAll = keyword;
m_keywordForSearch = keyword;
m_searchCaseFlag = caseFlag;
bool emptyKeyword = keyword.trimmed().isEmpty();

auto *findBarWidget = qobject_cast<FindBar *>(widget);
Expand Down Expand Up @@ -3966,6 +3972,8 @@
DMainWindow::resizeEvent(e);
}



void Window::closeEvent(QCloseEvent *e)
{
qDebug() << "close event";
Expand Down Expand Up @@ -4302,6 +4310,11 @@
return m_keywordForSearch;
}

Qt::CaseSensitivity Window::getSearchCaseFlag()
{
return m_searchCaseFlag;
}

void Window::setPrintEnabled(bool enabled)
{
qDebug() << "set print enabled";
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class Window : public DMainWindow
bool findBarIsVisiable();
QString getKeywordForSearchAll();
QString getKeywordForSearch();
Qt::CaseSensitivity getSearchCaseFlag();
void setPrintEnabled(bool enabled);
QStackedWidget *getStackedWgt();

Expand Down Expand Up @@ -280,6 +281,7 @@ public Q_SLOTS:

QString m_keywordForSearch;
QString m_keywordForSearchAll;
Qt::CaseSensitivity m_searchCaseFlag = Qt::CaseInsensitive;

QString m_themePath;
QString m_tabbarActiveColor;
Expand Down
Loading