From a7e6dcc31dc8b49ad27c16558c8634880a1f6002 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 18 Feb 2021 07:33:26 +0100 Subject: [PATCH] GuiSearch: make search options visible/accessible in minimal mode --- lib/Makefile.am | 6 + lib/images/search-case-sensitive.svgz | Bin 0 -> 1542 bytes lib/images/search-instant.svgz | Bin 0 -> 848 bytes lib/images/search-options.svgz | Bin 0 -> 929 bytes lib/images/search-selection.svgz | Bin 0 -> 1660 bytes lib/images/search-whole-words.svgz | Bin 0 -> 1566 bytes lib/images/search-wrap.svgz | Bin 0 -> 1071 bytes src/frontends/qt/GuiSearch.cpp | 152 ++++++++++++++++++++++++++ src/frontends/qt/GuiSearch.h | 23 ++++ 9 files changed, 181 insertions(+) create mode 100644 lib/images/search-case-sensitive.svgz create mode 100644 lib/images/search-instant.svgz create mode 100644 lib/images/search-options.svgz create mode 100644 lib/images/search-selection.svgz create mode 100644 lib/images/search-whole-words.svgz create mode 100644 lib/images/search-wrap.svgz diff --git a/lib/Makefile.am b/lib/Makefile.am index 18761f0438..038b33c752 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -658,6 +658,12 @@ dist_images_DATA1X = \ images/paste.svgz \ images/redo.svgz \ images/reload.svgz \ + images/search-case-sensitive.svgz \ + images/search-instant.svgz \ + images/search-options.svgz \ + images/search-selection.svgz \ + images/search-whole-words.svgz \ + images/search-wrap.svgz \ images/script-insert_subscript.svgz \ images/script-insert_superscript.svgz \ images/specialchar-insert_latex.svgz \ diff --git a/lib/images/search-case-sensitive.svgz b/lib/images/search-case-sensitive.svgz new file mode 100644 index 0000000000000000000000000000000000000000..4d76a011c897c36094dd3f28c57fa65cae00e750 GIT binary patch literal 1542 zcmV+h2Ko6PiwFP!000000PR=Hj@vdA-RCO=WswH8C|ay)Sw}`tw{_5`4e0*HJilPX{-B{GsB3^sHEz)%RFtn^6R%u&mX>p9EsQW6o zhsc#fwN9#Xbjj$tu?c-(F!;Q;K5SfE&IS|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EHx(nkqASn zlJ7>g-E-yVhijW}wohXU1A1gj3nKupd*drFX(8 zK`~M9CT$;xvrmrV2^xIZHNZdzET#meo-pM2^u8)v|nAZZPk<@=tZ z^feBj_qP}W{Q>rVgBR)j$+;!=wJGZqrju<)bm+U3Oe1o0%-q8~@PMz+NX3*fsx)5# zHwrU}CHjP9j0M()G4zPwW|9h1^tXRvL}F?}zPZ#MQJi4L3?Nc+C5Xp3fg15yqC}Y< zGLrLNZNwln11aR7=NAgvPO??7D7j|gTq-3tGJt{@MlL`KPI96RM|cGWD3e-IgFu5* z1IGhq45xz85fdhul2n5pfv_~CY>9y$qgVhN801)KEj05!L-`v_K+XjnDv(M7$8*0& z7=|fbc`p^yn4v#_LBTYU;PR)LWAqpL?77uUfC&>5%s~s7#oh;vu~AqAnw2n8s1O!c zN@3okSP^*N8X;-MiU2Z!$r&DG*If7vVtL~x7=Tn<;cgS;Dz z74zkRp?=K7UqCd}$7+h#r-MN0%*dFn1wlhLHM&YVln7a1i#&t^A`1G`^of*O@}My! za>{NnHP*r4%_Z13{7^eSn{stgTzz%k#O8Yajt<}{_GhlvBGz0A2C9#U#{_gJI1Svz z6hkci@dmTL$NGNiyT0$Ip-2NSV=sbl8ZH5Og;AqPPo?tU;V?GDglRKTX;!Qo9odlvolGg^n?Hc!N1NM2xy3896@hGF`M zhUxnW=~x5Xgu-xPG0X4J+4a;-2@&AR~z4{05=&b}n G4*&q)J}8|4 literal 0 HcmV?d00001 diff --git a/lib/images/search-whole-words.svgz b/lib/images/search-whole-words.svgz new file mode 100644 index 0000000000000000000000000000000000000000..858dae91b5198c8a0741c4bdc161198539fcf533 GIT binary patch literal 1566 zcmV+(2I2W1iwFP!000000L@n0j@w2OefL)o^g}j?NcR0gOJgK33@;Er?8eyudE<~R zi8e(lBsH4x*Y9bH7tL4!f<+#dg8|g1s;jF`UAotA9}iXV;M%Ti>P<*v5(ci$o1(0D zoAB39?;{fiU7yuORyDQTgmn|Xy?eFp9(J#SAi(CjON)FH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Moit^ZMlsxl1q0kgU9|{ZOfti6PTn-nSMwTcpel^mh{*0x_{AHeovReCB Q_uZ@i0$DlxJu?mf083&LKL7v# literal 0 HcmV?d00001 diff --git a/lib/images/search-wrap.svgz b/lib/images/search-wrap.svgz new file mode 100644 index 0000000000000000000000000000000000000000..e5379b7c45ae94bf6d32d65590fdae2063dbbf9b GIT binary patch literal 1071 zcmV+~1kn2*iwFP!000000Hs#hZsRr-ea}}2%EPp1Nr|+)NU=RY5e%k4`_fF?XNIJ0 zHWDe2^p>xmOKo->4ccO4*b(nJcfTaF{CKL$=pe0AMz3Om(>Riv8=>@e7619=6I#TP z^Gpj?8ZB3`Hu1;x-O?SlcTp69vUY{wt9a*qT_j1pw;n_(JCw zI=7N}b&%XtmC>%z)b9R@Y{h0^ACE_ToHQho=XsLSgi-_ys~8e!(LS0&7#_?6B$?$qbhNC-KznUEA=nf@5BL2Fq_&jj-DTqYOb4cVV-c`@3WwX$u{=#&ax zsi2fRc~zFb1}AZp+!$59lDUDsl_nYR4Tj1GPA#D%Mn&%B7G(@3@*G**ZXs@O?Y>Q#zMQ!d{2*1}1N zN_LjE+qKjG{x>sx_< zEoNB=6NPL+Rm*osQx3QQN+sT5%{DCV;l5}g4;#jXqv^_&u?k{n_(i2oQar%cs3oeI z2sbSRr@(lNv%NPDKtj)@)B;sT$UdKn*%xUWyIr69GXT7IlBOWXZrfyU#T! +#include #include #include #include @@ -82,6 +83,36 @@ GuiSearchWidget::GuiSearchWidget(QWidget * parent) setFocusProxy(findCO); + // Use a FancyLineEdit due to the indicator icons + findLE_ = new FancyLineEdit(this); + findCO->setLineEdit(findLE_); + + // And a menu in minimal mode + menu_ = new QMenu(); + act_casesense_ = new QAction(qt_("&Case sensitive[[search]]"), this); + act_casesense_->setCheckable(true); + act_wholewords_ = new QAction(qt_("Wh&ole words"), this); + act_wholewords_->setCheckable(true); + act_selection_ = new QAction(qt_("Selection onl&y"), this); + act_selection_->setCheckable(true); + act_immediate_ = new QAction(qt_("Search as yo&u type"), this); + act_immediate_->setCheckable(true); + act_wrap_ = new QAction(qt_("&Wrap"), this); + act_wrap_->setCheckable(true); + + menu_->addAction(act_casesense_); + menu_->addAction(act_wholewords_); + menu_->addAction(act_selection_); + menu_->addAction(act_immediate_); + menu_->addAction(act_wrap_); + findLE_->setButtonMenu(FancyLineEdit::Right, menu_); + + connect(act_casesense_, SIGNAL(triggered()), this, SLOT(caseSenseActTriggered())); + connect(act_wholewords_, SIGNAL(triggered()), this, SLOT(wholeWordsActTriggered())); + connect(act_selection_, SIGNAL(triggered()), this, SLOT(searchSelActTriggered())); + connect(act_immediate_, SIGNAL(triggered()), this, SLOT(immediateActTriggered())); + connect(act_wrap_, SIGNAL(triggered()), this, SLOT(wrapActTriggered())); + findCO->setCompleter(nullptr); replaceCO->setCompleter(nullptr); @@ -148,9 +179,18 @@ void GuiSearchWidget::minimizeClicked(bool const toggle) replacePrevPB->setHidden(minimized_); replaceallPB->setHidden(minimized_); CBFrame->setHidden(minimized_); + if (minimized_) { minimizePB->setText(qt_("Ex&pand")); minimizePB->setToolTip(qt_("Show replace and option widgets")); + // update menu items + blockSignals(true); + act_casesense_->setChecked(caseCB->isChecked()); + act_immediate_->setChecked(instantSearchCB->isChecked()); + act_selection_->setChecked(selectionCB->isChecked()); + act_wholewords_->setChecked(wordsCB->isChecked()); + act_wrap_->setChecked(wrapCB->isChecked()); + blockSignals(false); } else { minimizePB->setText(qt_("&Minimize")); minimizePB->setToolTip(qt_("Hide replace and option widgets")); @@ -158,6 +198,113 @@ void GuiSearchWidget::minimizeClicked(bool const toggle) Q_EMIT needSizeUpdate(); Q_EMIT needTitleBarUpdate(); + handleIndicators(); +} + + +void GuiSearchWidget::handleIndicators() +{ + findLE_->setButtonVisible(FancyLineEdit::Right, minimized_); + + QString tip; + + if (minimized_) { + int pms = 0; + if (caseCB->isChecked()) + ++pms; + if (wordsCB->isChecked()) + ++pms; + if (selectionCB->isChecked()) + ++pms; + if (instantSearchCB->isChecked()) + ++pms; + if (wrapCB->isChecked()) + ++pms; + + QPixmap bpixmap = getPixmap("images/", "search-options", "svgz,png"); + + if (pms > 0) { + int const gap = 3; + QPixmap tpixmap(pms * (bpixmap.width() + gap), bpixmap.height()); + tpixmap.fill(); + QPainter painter(&tpixmap); + int x = 0; + + tip = qt_("Active options:"); + tip += "

    "; + if (caseCB->isChecked()) { + tip += "
  • " + qt_("Case sensitive search"); + QPixmap spixmap = getPixmap("images/", "search-case-sensitive", "svgz,png"); + painter.drawPixmap(x, 0, spixmap); + x += spixmap.width() + gap; + } + if (wordsCB->isChecked()) { + tip += "
  • " + qt_("Whole words only"); + QPixmap spixmap = getPixmap("images/", "search-whole-words", "svgz,png"); + painter.drawPixmap(x, 0, spixmap); + x += spixmap.width() + gap; + } + if (selectionCB->isChecked()) { + tip += "
  • " + qt_("Search only in selection"); + QPixmap spixmap = getPixmap("images/", "search-selection", "svgz,png"); + painter.drawPixmap(x, 0, spixmap); + x += spixmap.width() + gap; + } + if (instantSearchCB->isChecked()) { + tip += "
  • " + qt_("Search as you type"); + QPixmap spixmap = getPixmap("images/", "search-instant", "svgz,png"); + painter.drawPixmap(x, 0, spixmap); + x += spixmap.width() + gap; + } + if (wrapCB->isChecked()) { + tip += "
  • " + qt_("Wrap search"); + QPixmap spixmap = getPixmap("images/", "search-wrap", "svgz,png"); + painter.drawPixmap(x, 0, spixmap); + x += spixmap.width() + gap; + } + tip += "
"; + findLE_->setButtonPixmap(FancyLineEdit::Right, tpixmap); + } else { + tip = qt_("Click here to change search options"); + findLE_->setButtonPixmap(FancyLineEdit::Right, bpixmap); + } + } + findLE_->setButtonToolTip(FancyLineEdit::Right, tip); +} + + +void GuiSearchWidget::caseSenseActTriggered() +{ + caseCB->setChecked(act_casesense_->isChecked()); + handleIndicators(); +} + + +void GuiSearchWidget::wholeWordsActTriggered() +{ + wordsCB->setChecked(act_wholewords_->isChecked()); + handleIndicators(); +} + + +void GuiSearchWidget::searchSelActTriggered() +{ + selectionCB->setChecked(act_selection_->isChecked()); + handleIndicators(); +} + + +void GuiSearchWidget::immediateActTriggered() +{ + instantSearchCB->setChecked(act_immediate_->isChecked()); + handleIndicators(); +} + + +void GuiSearchWidget::wrapActTriggered() +{ + wrapCB->setChecked(act_wrap_->isChecked()); + handleIndicators(); } @@ -293,10 +440,15 @@ void GuiSearchWidget::restoreSession(QString const & session_key) { QSettings settings; caseCB->setChecked(settings.value(session_key + "/casesensitive", false).toBool()); + 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()); wrapCB->setChecked(settings.value(session_key + "/wrap", false).toBool()); + act_wrap_->setChecked(settings.value(session_key + "/wrap", false).toBool()); selectionCB->setChecked(settings.value(session_key + "/selection", false).toBool()); + act_selection_->setChecked(settings.value(session_key + "/selection", false).toBool()); minimized_ = settings.value(session_key + "/minimized", false).toBool(); // initialize hidings minimizeClicked(false); diff --git a/src/frontends/qt/GuiSearch.h b/src/frontends/qt/GuiSearch.h index 440e2770fa..a6d1fd85bb 100644 --- a/src/frontends/qt/GuiSearch.h +++ b/src/frontends/qt/GuiSearch.h @@ -15,7 +15,9 @@ #include "GuiDialog.h" #include "DockView.h" +#include "FancyLineEdit.h" +#include #include #include "ui_SearchUi.h" @@ -51,6 +53,11 @@ private Q_SLOTS: void replacePrevClicked(); void replaceallClicked(); void minimizeClicked(bool const toggle = true); + void caseSenseActTriggered(); + void wholeWordsActTriggered(); + void searchSelActTriggered(); + void immediateActTriggered(); + void wrapActTriggered(); Q_SIGNALS: void needTitleBarUpdate() const; void needSizeUpdate() const; @@ -74,9 +81,25 @@ private: bool casesensitive, bool matchword, bool forward, bool all, bool wrap, bool onlysel); /// + void handleIndicators(); + /// BufferView const * bv_ = nullptr; /// bool minimized_ = false; + /// contains the search box + FancyLineEdit * findLE_; + /// The options menu + QMenu * menu_; + /// And its actions + QAction * act_casesense_ = new QAction(this); + /// + QAction * act_wholewords_ = new QAction(this); + /// + QAction * act_selection_ = new QAction(this); + /// + QAction * act_immediate_ = new QAction(this); + /// + QAction * act_wrap_ = new QAction(this); };