Falkon Develop
Cross-platform Qt-based web browser
autofillnotification.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2014 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* ============================================================ */
19#include "ui_autofillnotification.h"
20#include "mainapplication.h"
21#include "iconprovider.h"
22
23AutoFillNotification::AutoFillNotification(const QUrl &url, const PageFormData &formData, const PasswordEntry &updateData)
24 : AnimatedWidget(AnimatedWidget::Down, 300, nullptr)
25 , ui(new Ui::AutoFillNotification)
26 , m_url(url)
27 , m_formData(formData)
28 , m_updateData(updateData)
29{
30 setAutoFillBackground(true);
31 setAttribute(Qt::WA_DeleteOnClose);
32 ui->setupUi(widget());
33 ui->closeButton->setIcon(IconProvider::standardIcon(QStyle::SP_DialogCloseButton));
34
35 QString hostPart;
36 QString userPart;
37
38 if (!url.host().isEmpty()) {
39 hostPart = tr("on %1").arg(url.host());
40 }
41
42 if (!m_formData.username.isEmpty()) {
43 userPart = tr("for <b>%1</b>").arg(m_formData.username);
44 }
45
46 if (m_updateData.isValid()) {
47 ui->label->setText(tr("Do you want Falkon to update saved password %1?").arg(userPart));
48
49 ui->remember->setVisible(false);
50 ui->never->setVisible(false);
51 }
52 else {
53 ui->label->setText(tr("Do you want Falkon to remember the password %1 %2?").arg(userPart, hostPart));
54
55 ui->update->setVisible(false);
56 }
57
58 connect(ui->update, SIGNAL(clicked()), this, SLOT(update()));
59 connect(ui->remember, &QAbstractButton::clicked, this, &AutoFillNotification::remember);
60 connect(ui->never, &QAbstractButton::clicked, this, &AutoFillNotification::never);
61 connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
62 connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
63
65}
66
67void AutoFillNotification::update()
68{
69 mApp->autoFill()->updateEntry(m_updateData);
70 hide();
71}
72
73void AutoFillNotification::never()
74{
75 mApp->autoFill()->blockStoringforUrl(m_url);
76 hide();
77}
78
79void AutoFillNotification::remember()
80{
81 mApp->autoFill()->addEntry(m_url, m_formData);
82 hide();
83}
84
86{
87 delete ui;
88}
QWidget * widget()
AutoFillNotification(const QUrl &url, const PageFormData &formData, const PasswordEntry &updateData)
static QIcon standardIcon(QStyle::StandardPixmap icon)
#define mApp
QString username
Definition: autofill.h:37
bool isValid() const