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

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • 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 
29 StorePassBar::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 
56 void 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 
66 StorePass::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 
76 StorePass::~StorePass()
77 {
78 }
79 
80 void 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 
96 void 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 
104 void StorePass::slotStoreClicked()
105 {
106  m_part->saveToWallet(m_key, m_walletMap);
107  removeBar();
108 }
109 
110 void StorePass::slotNeverForThisSiteClicked()
111 {
112  m_part->view()->addNonPasswordStorableSite(m_host);
113  removeBar();
114 }
115 
116 void StorePass::slotDoNotStoreClicked()
117 {
118  removeBar();
119 }
i18n
QString i18n(const char *text)
StorePassBar::setHost
void setHost(const QString &host)
Definition: storepassbar.cpp:56
StorePassBar::doNotStoreClicked
void doNotStoreClicked()
KHTMLViewBar::showBarWidget
void showBarWidget(KHTMLViewBarWidget *barWidget)
Shows barWidget that was previously added with addBarWidget.
Definition: khtmlviewbar.cpp:91
KColorScheme::ActiveBackground
khtml_part.h
KHTMLViewBarWidget
Definition: khtmlviewbarwidget.h:25
storepassbar.h
QWidget
KHTMLViewBar::addBarWidget
void addBarWidget(KHTMLViewBarWidget *newBarWidget)
Adds a widget to this viewbar.
Definition: khtmlviewbar.cpp:42
KHTMLPart
This class is khtml's main class.
Definition: khtml_part.h:206
StorePassBar::neverForThisSiteClicked
void neverForThisSiteClicked()
QString
StorePass::~StorePass
~StorePass()
Definition: storepassbar.cpp:76
StorePassBar::StorePassBar
StorePassBar(QWidget *parent=0)
Definition: storepassbar.cpp:29
config
KSharedConfigPtr config()
khtmlviewbar.h
KHTMLPart::view
KHTMLView * view() const
Returns a pointer to the HTML document's view.
Definition: khtml_part.cpp:1056
KHTMLViewBar::hideCurrentBarWidget
void hideCurrentBarWidget()
Hides currently shown bar widget.
Definition: khtmlviewbar.cpp:110
KIcon
khtmlview.h
KConfigGroup
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
KColorScheme::adjustBackground
static void adjustBackground(QPalette &, BackgroundRole newRole=NormalBackground, QPalette::ColorRole color=QPalette::Base, ColorSet set=View, KSharedConfigPtr=KSharedConfigPtr())
StorePass::removeBar
void removeBar()
Definition: storepassbar.cpp:96
KHTMLViewBarWidget::centralWidget
QWidget * centralWidget()
Definition: khtmlviewbarwidget.h:35
KConfigGroup::readEntry
T readEntry(const QString &key, const T &aDefault) const
kcolorscheme.h
StorePassBar::storeClicked
void storeClicked()
QMap< QString, QString >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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