• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • khtml
  • ui
  • passwordbar
storepassbar.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2009 Eduardo Robles Elvira <edulix at gmail dot com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "storepassbar.h"
22
23#include "khtmlviewbar.h"
24#include "khtml_part.h"
25#include "khtmlview.h"
26#include <kcolorscheme.h>
27#include <QPalette>
28
29StorePassBar::StorePassBar( QWidget *parent ) :
30 KHTMLViewBarWidget( true, parent )
31{
32 setupUi( centralWidget() );
33
34 m_store->setIcon( KIcon( "document-save" ) );
35 // Same as KStandardGuiItem::no()
36 m_neverForThisSite->setIcon( KIcon( "process-stop" ) );
37 m_doNotStore->setIcon( KIcon( "dialog-cancel" ) );
38 centralWidget()->setFocusProxy( m_store );
39
40 QPalette pal = palette();
41 KColorScheme::adjustBackground(pal, KColorScheme::ActiveBackground);
42 setPalette(pal);
43 setBackgroundRole(QPalette::Base);
44 setAutoFillBackground(true);
45
46 connect( m_store, SIGNAL(clicked()), this, SIGNAL(storeClicked()) );
47 connect( m_neverForThisSite, SIGNAL(clicked()), this,
48 SIGNAL(neverForThisSiteClicked()) );
49 connect( m_doNotStore, SIGNAL(clicked()), this,
50 SIGNAL(doNotStoreClicked()) );
51
52 m_store->setFocus();
53}
54
55
56void StorePassBar::setHost(const QString& host)
57{
58 if(host.isEmpty())
59 m_label->setText( i18n("Do you want to store this password?") );
60 else
61 m_label->setText( i18n("Do you want to store this password for %1?", host) );
62}
63
64
65
66StorePass::StorePass( KHTMLPart *part ) :
67 m_part( part )
68{
69 connect( &m_storePassBar, SIGNAL(storeClicked()), this, SLOT(slotStoreClicked()) );
70 connect( &m_storePassBar, SIGNAL(neverForThisSiteClicked()), this,
71 SLOT(slotNeverForThisSiteClicked()) );
72 connect( &m_storePassBar, SIGNAL(doNotStoreClicked()), this,
73 SLOT(slotDoNotStoreClicked()) );
74}
75
76StorePass::~StorePass()
77{
78}
79
80void StorePass::saveLoginInformation(const QString& host, const QString& key,
81 const QMap<QString, QString>& walletMap)
82{
83 KConfigGroup config( KGlobal::config(), "HTML Settings" );
84 if (!config.readEntry("OfferToSaveWebsitePassword", true))
85 return;
86
87 m_host = host;
88 m_key = key;
89 m_walletMap = walletMap;
90 m_storePassBar.setHost(host);
91
92 m_part->pTopViewBar()->addBarWidget( &m_storePassBar );
93 m_part->pTopViewBar()->showBarWidget( &m_storePassBar );
94}
95
96void StorePass::removeBar()
97{
98 m_part->pTopViewBar()->hideCurrentBarWidget();
99 m_walletMap.clear();
100 m_host = m_key = "";
101 m_storePassBar.setHost(m_host);
102}
103
104void StorePass::slotStoreClicked()
105{
106 m_part->saveToWallet(m_key, m_walletMap);
107 removeBar();
108}
109
110void StorePass::slotNeverForThisSiteClicked()
111{
112 m_part->view()->addNonPasswordStorableSite(m_host);
113 removeBar();
114}
115
116void StorePass::slotDoNotStoreClicked()
117{
118 removeBar();
119}
KColorScheme::ActiveBackground
ActiveBackground
KColorScheme::adjustBackground
static void adjustBackground(QPalette &, BackgroundRole newRole=NormalBackground, QPalette::ColorRole color=QPalette::Base, ColorSet set=View, KSharedConfigPtr=KSharedConfigPtr())
KConfigGroup
KHTMLPart
This class is khtml's main class.
Definition: khtml_part.h:207
KHTMLPart::view
KHTMLView * view() const
Returns a pointer to the HTML document's view.
Definition: khtml_part.cpp:1059
KHTMLViewBarWidget
Definition: khtmlviewbarwidget.h:26
KHTMLViewBarWidget::centralWidget
QWidget * centralWidget()
Definition: khtmlviewbarwidget.h:35
KHTMLViewBar::hideCurrentBarWidget
void hideCurrentBarWidget()
Hides currently shown bar widget.
Definition: khtmlviewbar.cpp:110
KHTMLViewBar::addBarWidget
void addBarWidget(KHTMLViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: khtmlviewbar.cpp:42
KHTMLViewBar::showBarWidget
void showBarWidget(KHTMLViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: khtmlviewbar.cpp:91
KIcon
QMap
QWidget
StorePassBar::storeClicked
void storeClicked()
StorePassBar::StorePassBar
StorePassBar(QWidget *parent=0)
Definition: storepassbar.cpp:29
StorePassBar::neverForThisSiteClicked
void neverForThisSiteClicked()
StorePassBar::doNotStoreClicked
void doNotStoreClicked()
StorePassBar::setHost
void setHost(const QString &host)
Definition: storepassbar.cpp:56
StorePass::StorePass
StorePass(KHTMLPart *part)
Definition: storepassbar.cpp:66
StorePass::saveLoginInformation
void saveLoginInformation(const QString &host, const QString &key, const QMap< QString, QString > &walletMap)
Definition: storepassbar.cpp:80
StorePass::removeBar
void removeBar()
Definition: storepassbar.cpp:96
StorePass::~StorePass
~StorePass()
Definition: storepassbar.cpp:76
kcolorscheme.h
khtml_part.h
khtmlview.h
khtmlviewbar.h
i18n
QString i18n(const char *text)
config
KSharedConfigPtr config()
storepassbar.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal