KHTML
storepassbar.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "storepassbar.h"
00022
00023 #include "khtmlviewbar.h"
00024 #include "khtml_part.h"
00025 #include "khtmlview.h"
00026 #include <kcolorscheme.h>
00027 #include <QPalette>
00028
00029 StorePassBar::StorePassBar( QWidget *parent ) :
00030 KHTMLViewBarWidget( true, parent )
00031 {
00032 setupUi( centralWidget() );
00033
00034 m_store->setIcon( KIcon( "document-save" ) );
00035
00036 m_neverForThisSite->setIcon( KIcon( "process-stop" ) );
00037 m_doNotStore->setIcon( KIcon( "dialog-cancel" ) );
00038 centralWidget()->setFocusProxy( m_store );
00039
00040 QPalette pal = palette();
00041 KColorScheme::adjustBackground(pal, KColorScheme::ActiveBackground);
00042 setPalette(pal);
00043 setBackgroundRole(QPalette::Base);
00044 setAutoFillBackground(true);
00045
00046 connect( m_store, SIGNAL(clicked()), this, SIGNAL(storeClicked()) );
00047 connect( m_neverForThisSite, SIGNAL(clicked()), this,
00048 SIGNAL(neverForThisSiteClicked()) );
00049 connect( m_doNotStore, SIGNAL(clicked()), this,
00050 SIGNAL(doNotStoreClicked()) );
00051
00052 m_store->setFocus();
00053 }
00054
00055
00056 void StorePassBar::setHost(const QString& host)
00057 {
00058 if(host.isEmpty())
00059 m_label->setText( i18n("Do you want to store this password?") );
00060 else
00061 m_label->setText( i18n("Do you want to store this password for %1?", host) );
00062 }
00063
00064
00065
00066 StorePass::StorePass( KHTMLPart *part ) :
00067 m_part( part )
00068 {
00069 connect( &m_storePassBar, SIGNAL(storeClicked()), this, SLOT(slotStoreClicked()) );
00070 connect( &m_storePassBar, SIGNAL(neverForThisSiteClicked()), this,
00071 SLOT(slotNeverForThisSiteClicked()) );
00072 connect( &m_storePassBar, SIGNAL(doNotStoreClicked()), this,
00073 SLOT(slotDoNotStoreClicked()) );
00074 }
00075
00076 StorePass::~StorePass()
00077 {
00078 }
00079
00080 void StorePass::saveLoginInformation(const QString& host, const QString& key,
00081 const QMap<QString, QString>& walletMap)
00082 {
00083 m_host = host;
00084 m_key = key;
00085 m_walletMap = walletMap;
00086 m_storePassBar.setHost(host);
00087
00088 m_part->pTopViewBar()->addBarWidget( &m_storePassBar );
00089 m_part->pTopViewBar()->showBarWidget( &m_storePassBar );
00090 }
00091
00092 void StorePass::removeBar()
00093 {
00094 m_part->pTopViewBar()->hideCurrentBarWidget();
00095 m_walletMap.clear();
00096 m_host = m_key = "";
00097 m_storePassBar.setHost(m_host);
00098 }
00099
00100 void StorePass::slotStoreClicked()
00101 {
00102 m_part->saveToWallet(m_key, m_walletMap);
00103 removeBar();
00104 }
00105
00106 void StorePass::slotNeverForThisSiteClicked()
00107 {
00108 m_part->view()->addNonPasswordStorableSite(m_host);
00109 removeBar();
00110 }
00111
00112 void StorePass::slotDoNotStoreClicked()
00113 {
00114 removeBar();
00115 }