Falkon Develop
Cross-platform Qt-based web browser
locationbar.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef LOCATIONBAR_H
19#define LOCATIONBAR_H
20
21#include "qzcommon.h"
22#include "lineedit.h"
24#include "loadrequest.h"
25
26class QStringListModel;
27
28class BrowserWindow;
30class ClickableLabel;
31class TabbedWebView;
32class BookmarksIcon;
33class SiteIcon;
34class GoIcon;
35class AutoFillIcon;
36class BookmarkItem;
37class ZoomLabel;
38
40{
41 Q_OBJECT
42
43public:
44 explicit LocationBar(QWidget *parent = nullptr);
45
46 struct LoadAction {
47 enum Type {
48 Invalid = 0,
51 Url
52 };
53 Type type = Invalid;
55 BookmarkItem *bookmark = nullptr;
57 };
58
59 // BrowserWindow can be null!
60 BrowserWindow *browserWindow() const;
61 void setBrowserWindow(BrowserWindow *window);
62
63 TabbedWebView* webView() const;
64 void setWebView(TabbedWebView* view);
65
66 static QString convertUrlToText(const QUrl &url);
67 static SearchEngine searchEngine();
68 static LoadAction loadAction(const QString &text);
69
70public Q_SLOTS:
71 void setText(const QString &text);
72 void showUrl(const QUrl &url);
73 void loadRequest(const LoadRequest &request);
74
75private Q_SLOTS:
76 void textEdited(const QString &text);
77 void requestLoadUrl();
78 void pasteAndGo();
79
80 void updateSiteIcon();
81 void updatePlaceHolderText();
82
83 void setPrivacyState(bool state);
84 void setGoIconVisible(bool state);
85
86 void showCompletion(const QString &completion, bool completeDomain);
87 void showDomainCompletion(const QString &completion);
88 void clearCompletion();
89
90 void loadStarted();
91 void loadProgress(int progress);
92 void loadFinished();
93 void hideProgress();
94
95 void loadSettings();
96
97private:
98 enum ProgressStyle {
99 ProgressFilled,
100 ProgressBottom,
101 ProgressTop
102 };
103
104 void contextMenuEvent(QContextMenuEvent* event) override;
105 void showEvent(QShowEvent* event) override;
106 void focusInEvent(QFocusEvent* event) override;
107 void focusOutEvent(QFocusEvent* event) override;
108 void keyPressEvent(QKeyEvent* event) override;
109 void dropEvent(QDropEvent* event) override;
110 void paintEvent(QPaintEvent* event) override;
111
112 void refreshTextFormat();
113
114 LocationCompleter* m_completer;
115 QStringListModel* m_domainCompleterModel;
116
117 BookmarksIcon* m_bookmarkIcon;
118 GoIcon* m_goIcon;
119 SiteIcon* m_siteIcon;
120 AutoFillIcon* m_autofillIcon;
121 ZoomLabel* m_zoomlabel;
122
123 BrowserWindow* m_window;
124 TabbedWebView* m_webView;
125
126 bool m_holdingAlt;
127 int m_oldTextLength;
128 int m_currentTextLength;
129
130 int m_loadProgress;
131 bool m_progressVisible;
132 ProgressStyle m_progressStyle;
133 QColor m_progressColor;
134 QTimer *m_progressTimer;
135};
136
137#endif // LOCATIONBAR_H
Definition: goicon.h:25
void focusInEvent(QFocusEvent *event) override
Definition: lineedit.cpp:362
State state
#define FALKON_EXPORT
Definition: qzcommon.h:28
SearchEngine searchEngine
Definition: locationbar.h:54
LoadRequest loadRequest
Definition: locationbar.h:56