+ 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;
+
+ bool const dark_mode = guiApp && guiApp->isInDarkMode();
+ qreal dpr = 1.0;
+ // Consider device/pixel ratio (HiDPI)
+ if (guiApp && guiApp->currentView())
+ dpr = guiApp->currentView()->devicePixelRatio();
+ QString imagedir = "images/";
+ QPixmap bpixmap = getPixmap("images/", "search-options", "svgz,png");
+ QPixmap pm = bpixmap;
+
+ if (pms > 0) {
+ int const gap = 3;
+ QPixmap scaled_pm = QPixmap(bpixmap.size() * dpr);
+ pm = QPixmap(pms * scaled_pm.width() + ((pms - 1) * gap),
+ scaled_pm.height());
+ pm.fill(Qt::transparent);
+ QPainter painter(&pm);
+ int x = 0;
+
+ tip = qt_("Active options:");
+ tip += "<ul>";
+ if (caseCB->isChecked()) {
+ tip += "<li>" + qt_("Case sensitive search");
+ QPixmap spixmap = getPixmap("images/", "search-case-sensitive", "svgz,png");
+ // We render SVG directly for HiDPI scalability
+ FileName fname = imageLibFileSearch(imagedir, "search-case-sensitive", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid())
+ svgRenderer.render(&painter, QRectF(0, 0, spixmap.width() * dpr,
+ spixmap.height() * dpr));
+ }
+ x += (spixmap.width() * dpr) + gap;
+ }
+ if (wordsCB->isChecked()) {
+ tip += "<li>" + qt_("Whole words only");
+ QPixmap spixmap = getPixmap("images/", "search-whole-words", "svgz,png");
+ FileName fname = imageLibFileSearch(imagedir, "search-whole-words", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid())
+ svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr,
+ spixmap.height() * dpr));
+ }
+ x += (spixmap.width() * dpr) + gap;
+ }
+ if (selectionCB->isChecked()) {
+ tip += "<li>" + qt_("Search only in selection");
+ QPixmap spixmap = getPixmap("images/", "search-selection", "svgz,png");
+ FileName fname = imageLibFileSearch(imagedir, "search-selection", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid())
+ svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr,
+ spixmap.height() * dpr));
+ }
+ x += (spixmap.width() * dpr) + gap;
+ }
+ if (instantSearchCB->isChecked()) {
+ tip += "<li>" + qt_("Search as you type");
+ QPixmap spixmap = getPixmap("images/", "search-instant", "svgz,png");
+ FileName fname = imageLibFileSearch(imagedir, "search-instant", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid())
+ svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr,
+ spixmap.height() * dpr));
+ }
+ x += (spixmap.width() * dpr) + gap;
+ }
+ if (wrapCB->isChecked()) {
+ tip += "<li>" + qt_("Wrap search");
+ QPixmap spixmap = getPixmap("images/", "search-wrap", "svgz,png");
+ FileName fname = imageLibFileSearch(imagedir, "search-wrap", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid())
+ svgRenderer.render(&painter, QRectF(x, 0, spixmap.width() * dpr,
+ spixmap.height() * dpr));
+ }
+ x += (spixmap.width() * dpr) + gap;
+ }
+ tip += "</ul>";
+ pm.setDevicePixelRatio(dpr);
+ painter.end();
+ } else {
+ tip = qt_("Click here to change search options");
+ // We render SVG directly for HiDPI scalability
+ FileName fname = imageLibFileSearch(imagedir, "search-options", "svgz,png");
+ QString fpath = toqstr(fname.absFileName());
+ if (!fpath.isEmpty()) {
+ QSvgRenderer svgRenderer(fpath);
+ if (svgRenderer.isValid()) {
+ pm = QPixmap(bpixmap.size() * dpr);
+ pm.fill(Qt::transparent);
+ QPainter painter(&pm);
+ svgRenderer.render(&painter);
+ pm.setDevicePixelRatio(dpr);
+ }
+ }
+ }
+ if (dark_mode) {
+ QImage img = pm.toImage();
+ img.invertPixels();
+ pm.convertFromImage(img);
+ }
+ findLE_->setButtonPixmap(FancyLineEdit::Right, pm);
+ }
+ findLE_->setButtonToolTip(FancyLineEdit::Right, tip);