Falkon Develop
Cross-platform Qt-based web browser
autofillicon.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-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#include "autofillicon.h"
19#include "autofillwidget.h"
20
21#include <QContextMenuEvent>
22
24 : ClickableLabel(parent)
25 , m_view(nullptr)
26{
27 setObjectName(QSL("locationbar-autofillicon"));
28 setCursor(Qt::PointingHandCursor);
29 setToolTip(AutoFillWidget::tr("Choose username to login"));
30 setFocusPolicy(Qt::ClickFocus);
31
32 connect(this, &ClickableLabel::clicked, this, &AutoFillIcon::iconClicked);
33}
34
36{
37 m_view = view;
38}
39
40void AutoFillIcon::setUsernames(const QStringList &usernames)
41{
42 m_usernames = usernames;
43}
44
45void AutoFillIcon::iconClicked()
46{
47 if (!m_view) {
48 return;
49 }
50
51 auto* widget = new AutoFillWidget(m_view, this);
52 widget->setUsernames(m_usernames);
53 widget->showAt(parentWidget());
54}
55
56void AutoFillIcon::contextMenuEvent(QContextMenuEvent* ev)
57{
58 // Prevent propagating to LocationBar
59 ev->accept();
60}
61
62void AutoFillIcon::mousePressEvent(QMouseEvent* ev)
63{
64 ClickableLabel::mousePressEvent(ev);
65
66 // Prevent propagating to LocationBar
67 ev->accept();
68}
AutoFillIcon(QWidget *parent=nullptr)
void setWebView(WebView *view)
void setUsernames(const QStringList &usernames)
void clicked(QPoint)
#define QSL(x)
Definition: qzcommon.h:40