From 713264ae2b82f23e80ed6369b19ae6c9b030b6e4 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 7 Feb 2023 14:48:09 +0100 Subject: [PATCH] Disable "search in selection only" with instant search These two do not go well together. Making it work requires some major overhaul of selection while searching (see #12655) --- src/frontends/qt/GuiSearch.cpp | 30 ++++++++++++++++++++++++++---- src/frontends/qt/GuiSearch.h | 1 + 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt/GuiSearch.cpp b/src/frontends/qt/GuiSearch.cpp index 8ac62c68a7..b824bfeee4 100644 --- a/src/frontends/qt/GuiSearch.cpp +++ b/src/frontends/qt/GuiSearch.cpp @@ -79,6 +79,7 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent, GuiView & view) connect(replacePB, SIGNAL(clicked()), this, SLOT(replaceClicked())); connect(replacePrevPB, SIGNAL(clicked()), this, SLOT(replacePrevClicked())); connect(replaceallPB, SIGNAL(clicked()), this, SLOT(replaceallClicked())); + connect(instantSearchCB, SIGNAL(clicked()), this, SLOT(immediateClicked())); connect(findCO, SIGNAL(editTextChanged(QString)), this, SLOT(findChanged())); if(qApp->clipboard()->supportsFindBuffer()) { @@ -196,6 +197,7 @@ void GuiSearchWidget::minimizeClicked(bool const toggle) act_casesense_->setChecked(caseCB->isChecked()); act_immediate_->setChecked(instantSearchCB->isChecked()); act_selection_->setChecked(selectionCB->isChecked()); + act_selection_->setEnabled(!instantSearchCB->isChecked()); act_wholewords_->setChecked(wordsCB->isChecked()); act_wrap_->setChecked(wrapCB->isChecked()); blockSignals(false); @@ -368,11 +370,29 @@ void GuiSearchWidget::searchSelActTriggered() void GuiSearchWidget::immediateActTriggered() { - instantSearchCB->setChecked(act_immediate_->isChecked()); + bool const immediate = act_immediate_->isChecked(); + instantSearchCB->setChecked(immediate); + // FIXME: make these two work together eventually. + selectionCB->setEnabled(!immediate); + act_selection_->setEnabled(!immediate); + if (immediate) { + selectionCB->setChecked(false); + act_selection_->setChecked(false); + } handleIndicators(); } +void GuiSearchWidget::immediateClicked() +{ + // FIXME: make these two work together eventually. + bool const immediate = instantSearchCB->isChecked(); + selectionCB->setEnabled(!immediate); + if (immediate) + selectionCB->setChecked(false); +} + + void GuiSearchWidget::wrapActTriggered() { wrapCB->setChecked(act_wrap_->isChecked()); @@ -525,11 +545,13 @@ void GuiSearchWidget::restoreSession(QString const & session_key) act_casesense_->setChecked(settings.value(session_key + "/casesensitive", false).toBool()); wordsCB->setChecked(settings.value(session_key + "/words", false).toBool()); act_wholewords_->setChecked(settings.value(session_key + "/words", false).toBool()); - instantSearchCB->setChecked(settings.value(session_key + "/instant", false).toBool()); - act_immediate_->setChecked(settings.value(session_key + "/instant", false).toBool()); + bool const immediate = settings.value(session_key + "/instant", false).toBool(); + instantSearchCB->setChecked(immediate); + act_immediate_->setChecked(immediate); wrapCB->setChecked(settings.value(session_key + "/wrap", true).toBool()); act_wrap_->setChecked(settings.value(session_key + "/wrap", true).toBool()); - selectionCB->setChecked(settings.value(session_key + "/selection", false).toBool()); + selectionCB->setChecked(settings.value(session_key + "/selection", false).toBool() && !immediate); + selectionCB->setEnabled(!immediate); act_selection_->setChecked(settings.value(session_key + "/selection", false).toBool()); minimized_ = settings.value(session_key + "/minimized", false).toBool(); // initialize hidings diff --git a/src/frontends/qt/GuiSearch.h b/src/frontends/qt/GuiSearch.h index 2fbc8c7ac2..89234fe444 100644 --- a/src/frontends/qt/GuiSearch.h +++ b/src/frontends/qt/GuiSearch.h @@ -57,6 +57,7 @@ private Q_SLOTS: void wholeWordsActTriggered(); void searchSelActTriggered(); void immediateActTriggered(); + void immediateClicked(); void wrapActTriggered(); Q_SIGNALS: void needTitleBarUpdate() const;