File indexing completed on 2024-05-19 04:58:52
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef WEBSEARCHBAR_H 0019 #define WEBSEARCHBAR_H 0020 0021 #include <QPointer> 0022 0023 #include "qzcommon.h" 0024 #include "lineedit.h" 0025 #include "buttonwithmenu.h" 0026 #include "searchenginesmanager.h" 0027 #include "clickablelabel.h" 0028 0029 class QStringListModel; 0030 0031 class BrowserWindow; 0032 class LineEdit; 0033 class ClickableLabel; 0034 class SearchEnginesManager; 0035 class SearchEnginesDialog; 0036 class OpenSearchEngine; 0037 0038 class FALKON_EXPORT WebSearchBar_Button : public ClickableLabel 0039 { 0040 public: 0041 explicit WebSearchBar_Button(QWidget* parent = nullptr); 0042 0043 private: 0044 void contextMenuEvent(QContextMenuEvent* event) override; 0045 }; 0046 0047 class FALKON_EXPORT WebSearchBar : public LineEdit 0048 { 0049 Q_OBJECT 0050 0051 public: 0052 explicit WebSearchBar(BrowserWindow* window); 0053 0054 private Q_SLOTS: 0055 void searchChanged(const ButtonWithMenu::Item &item); 0056 void setupEngines(); 0057 0058 void search(); 0059 void searchInNewTab(); 0060 0061 void aboutToShowMenu(); 0062 void openSearchEnginesDialog(); 0063 0064 void enableSearchSuggestions(bool enable); 0065 void addSuggestions(const QStringList &list); 0066 0067 void addEngineFromAction(); 0068 void pasteAndGo(); 0069 void instantSearchChanged(bool); 0070 0071 private: 0072 void focusOutEvent(QFocusEvent* e) override; 0073 void dropEvent(QDropEvent* event) override; 0074 void keyPressEvent(QKeyEvent* event) override; 0075 0076 void contextMenuEvent(QContextMenuEvent* event) override; 0077 0078 void updateOpenSearchEngine(); 0079 0080 QCompleter* m_completer; 0081 QStringListModel* m_completerModel; 0082 0083 OpenSearchEngine* m_openSearchEngine; 0084 SearchEngine m_activeEngine; 0085 0086 BrowserWindow* m_window; 0087 0088 WebSearchBar_Button* m_buttonSearch; 0089 ButtonWithMenu* m_boxSearchType; 0090 SearchEnginesManager* m_searchManager; 0091 QPointer<SearchEnginesDialog> m_searchDialog; 0092 0093 bool m_reloadingEngines; 0094 }; 0095 0096 #endif // WEBSEARCHBAR_H