File indexing completed on 2025-01-26 04:57:23
0001 /* SPDX-FileCopyrightText: 2010 Torgny Nyblom <nyblom@kde.org> 0002 * SPDX-FileCopyrightText: 2010-2024 Laurent Montel <montel@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "webengineviewer_export.h" 0010 #include <QWidget> 0011 class QAction; 0012 class QPushButton; 0013 class QMenu; 0014 class QLabel; 0015 namespace PimCommon 0016 { 0017 class LineEditWithCompleterNg; 0018 } 0019 namespace WebEngineViewer 0020 { 0021 /** 0022 * @brief The FindBarBase class 0023 */ 0024 class WEBENGINEVIEWER_EXPORT FindBarBase : public QWidget 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit FindBarBase(QWidget *parent = nullptr); 0029 ~FindBarBase() override; 0030 0031 [[nodiscard]] QString text() const; 0032 void setText(const QString &text); 0033 void focusAndSetCursor(); 0034 0035 protected: 0036 bool event(QEvent *e) override; 0037 virtual void clearSelections(); 0038 virtual void updateHighLight(bool); 0039 virtual void searchText(bool backward, bool isAutoSearch); 0040 virtual void updateSensitivity(bool); 0041 0042 void setFoundMatch(bool match); 0043 QMenu *optionsMenu() const; 0044 0045 public Q_SLOTS: 0046 void findNext(); 0047 void findPrev(); 0048 void autoSearch(const QString &str); 0049 void slotSearchText(bool backward = false, bool isAutoSearch = true); 0050 void closeBar(); 0051 0052 Q_SIGNALS: 0053 void hideFindBar(); 0054 0055 protected Q_SLOTS: 0056 void caseSensitivityChanged(bool); 0057 void slotHighlightAllChanged(bool); 0058 void slotClearSearch(); 0059 0060 protected: 0061 void updatePalette(); 0062 QString mNotFoundString; 0063 QString mPositiveBackground; 0064 QString mNegativeBackground; 0065 QString mLastSearchStr; 0066 PimCommon::LineEditWithCompleterNg *mSearch = nullptr; 0067 QAction *mCaseSensitiveAct = nullptr; 0068 0069 QPushButton *mFindPrevBtn = nullptr; 0070 QPushButton *mFindNextBtn = nullptr; 0071 QMenu *mOptionsMenu = nullptr; 0072 QLabel *mStatus = nullptr; 0073 void addToCompletion(const QString &text); 0074 }; 0075 }