• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.10.5 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 
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 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Fri Jul 12 2013 08:56:06 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdelibs-4.10.5 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