File indexing completed on 2024-05-12 04:58:08
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2018 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 LOCATIONBAR_H 0019 #define LOCATIONBAR_H 0020 0021 #include "qzcommon.h" 0022 #include "lineedit.h" 0023 #include "searchenginesmanager.h" 0024 #include "loadrequest.h" 0025 0026 class QStringListModel; 0027 0028 class BrowserWindow; 0029 class LocationCompleter; 0030 class ClickableLabel; 0031 class TabbedWebView; 0032 class BookmarksIcon; 0033 class SiteIcon; 0034 class GoIcon; 0035 class AutoFillIcon; 0036 class BookmarkItem; 0037 class ZoomLabel; 0038 0039 class FALKON_EXPORT LocationBar : public LineEdit 0040 { 0041 Q_OBJECT 0042 0043 public: 0044 explicit LocationBar(QWidget *parent = nullptr); 0045 0046 struct LoadAction { 0047 enum Type { 0048 Invalid = 0, 0049 Search, 0050 Bookmark, 0051 Url 0052 }; 0053 Type type = Invalid; 0054 SearchEngine searchEngine; 0055 BookmarkItem *bookmark = nullptr; 0056 LoadRequest loadRequest; 0057 }; 0058 0059 // BrowserWindow can be null! 0060 BrowserWindow *browserWindow() const; 0061 void setBrowserWindow(BrowserWindow *window); 0062 0063 TabbedWebView* webView() const; 0064 void setWebView(TabbedWebView* view); 0065 0066 static QString convertUrlToText(const QUrl &url); 0067 static SearchEngine searchEngine(); 0068 static LoadAction loadAction(const QString &text); 0069 0070 public Q_SLOTS: 0071 void setText(const QString &text); 0072 void showUrl(const QUrl &url); 0073 void loadRequest(const LoadRequest &request); 0074 0075 private Q_SLOTS: 0076 void textEdited(const QString &text); 0077 void requestLoadUrl(); 0078 void pasteAndGo(); 0079 0080 void updateSiteIcon(); 0081 void updatePlaceHolderText(); 0082 0083 void setPrivacyState(bool state); 0084 void setGoIconVisible(bool state); 0085 0086 void showCompletion(const QString &completion, bool completeDomain); 0087 void showDomainCompletion(const QString &completion); 0088 void clearCompletion(); 0089 0090 void loadStarted(); 0091 void loadProgress(int progress); 0092 void loadFinished(); 0093 void hideProgress(); 0094 0095 void loadSettings(); 0096 0097 private: 0098 enum ProgressStyle { 0099 ProgressFilled, 0100 ProgressBottom, 0101 ProgressTop 0102 }; 0103 0104 void contextMenuEvent(QContextMenuEvent* event) override; 0105 void showEvent(QShowEvent* event) override; 0106 void focusInEvent(QFocusEvent* event) override; 0107 void focusOutEvent(QFocusEvent* event) override; 0108 void keyPressEvent(QKeyEvent* event) override; 0109 void dropEvent(QDropEvent* event) override; 0110 void paintEvent(QPaintEvent* event) override; 0111 0112 void refreshTextFormat(); 0113 0114 LocationCompleter* m_completer; 0115 QStringListModel* m_domainCompleterModel; 0116 0117 BookmarksIcon* m_bookmarkIcon; 0118 GoIcon* m_goIcon; 0119 SiteIcon* m_siteIcon; 0120 AutoFillIcon* m_autofillIcon; 0121 ZoomLabel* m_zoomlabel; 0122 0123 BrowserWindow* m_window; 0124 TabbedWebView* m_webView; 0125 0126 bool m_holdingAlt; 0127 int m_oldTextLength; 0128 int m_currentTextLength; 0129 0130 int m_loadProgress; 0131 bool m_progressVisible; 0132 ProgressStyle m_progressStyle; 0133 QColor m_progressColor; 0134 QTimer *m_progressTimer; 0135 }; 0136 0137 #endif // LOCATIONBAR_H