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

kwallet

  • sources
  • kde-4.14
  • kdeutils
  • kwalletmanager
  • src
  • manager
kwalletpopup.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 George Staikos <staikos@kde.org>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 
21 #include "kwalletpopup.h"
22 #include <kstandardaction.h>
23 #include <kactioncollection.h>
24 #include <kaction.h>
25 #include <kdebug.h>
26 #include <klocale.h>
27 #include <kmessagebox.h>
28 #include <kwallet.h>
29 
30 KWalletPopup::KWalletPopup(const QString& wallet, QWidget *parent, const char *name)
31 : KMenu(parent), _walletName(wallet) {
32  addTitle(wallet);
33  setObjectName( QLatin1String( name ) );
34  KActionCollection *ac = new KActionCollection(this/*, "kwallet context actions"*/);
35  ac->setObjectName( QLatin1String("kwallet context actions" ));
36  QAction *act;
37 
38  act = ac->addAction(QLatin1String( "wallet_create" ));
39  act->setText(i18n("&New Wallet..."));
40  connect(act, SIGNAL(triggered(bool)), SLOT(createWallet()));
41  addAction( act );
42 
43  act= ac->addAction( QLatin1String( "wallet-open" ));
44  act->setText( i18n( "&Open..." ) );
45  connect(act, SIGNAL(triggered(bool)), SLOT(openWallet()));
46  act->setShortcut(QKeySequence(Qt::Key_Return));
47  addAction( act );
48 
49  act=ac->addAction( QLatin1String( "wallet_password" ) );
50  act->setText( i18n("Change &Password...") );
51  connect(act, SIGNAL(triggered(bool)), SLOT(changeWalletPassword()));
52  addAction( act );
53 
54  const QStringList ul = KWallet::Wallet::users(wallet);
55  if (!ul.isEmpty()) {
56  KMenu *pm = new KMenu(this);
57  pm->setObjectName( QLatin1String("Disconnect Apps" ));
58  int id = 7000;
59  for (QStringList::const_iterator it = ul.begin(); it != ul.end(); ++it) {
60  QAction *a = pm->addAction(*it, this, SLOT(disconnectApp()));
61  a->setData(*it);
62  id++;
63  }
64  QAction *act = addMenu( pm);
65  act->setText(i18n("Disconnec&t"));
66  }
67 
68  act = KStandardAction::close( this,
69  SLOT(closeWallet()), ac);
70  ac->addAction(QLatin1String( "wallet_close" ), act);
71  // FIXME: let's track this inside the manager so we don't need a dcop
72  // roundtrip here.
73  act->setEnabled(KWallet::Wallet::isOpen(wallet));
74  addAction( act );
75 
76  act = ac->addAction( QLatin1String( "wallet_delete" ) );
77  act->setText( i18n( "&Delete") );
78 
79  connect(act, SIGNAL(triggered(bool)), SLOT(deleteWallet()));
80  act->setShortcut(QKeySequence(Qt::Key_Delete));
81  addAction( act );
82 }
83 
84 
85 KWalletPopup::~KWalletPopup() {
86 }
87 
88 
89 void KWalletPopup::openWallet() {
90  emit walletOpened(_walletName);
91 }
92 
93 
94 void KWalletPopup::deleteWallet() {
95  emit walletDeleted(_walletName);
96 }
97 
98 
99 void KWalletPopup::closeWallet() {
100  emit walletClosed(_walletName);
101 }
102 
103 
104 void KWalletPopup::changeWalletPassword() {
105  emit walletChangePassword(_walletName);
106 }
107 
108 
109 void KWalletPopup::createWallet() {
110  emit walletCreated();
111 }
112 
113 
114 void KWalletPopup::disconnectApp() {
115  QAction *a = qobject_cast<QAction *>(sender());
116  Q_ASSERT(a);
117  if (a) {
118  KWallet::Wallet::disconnectApplication(_walletName, a->data().toString());
119  }
120 }
121 
122 #include "kwalletpopup.moc"
123 
QAction::setText
void setText(const QString &text)
QWidget
KWalletPopup::deleteWallet
void deleteWallet()
Definition: kwalletpopup.cpp:94
KWalletPopup::createWallet
void createWallet()
Definition: kwalletpopup.cpp:109
QAction::data
QVariant data() const
KMenu
KWalletPopup::walletChangePassword
void walletChangePassword(const QString &walletName)
QList::const_iterator
KWalletPopup::walletOpened
void walletOpened(const QString &walletName)
KWalletPopup::KWalletPopup
KWalletPopup(const QString &wallet, QWidget *parent=0, const char *name=0)
Definition: kwalletpopup.cpp:30
kwalletpopup.h
QList::isEmpty
bool isEmpty() const
KWalletPopup::disconnectApp
void disconnectApp()
Definition: kwalletpopup.cpp:114
KWalletPopup::closeWallet
void closeWallet()
Definition: kwalletpopup.cpp:99
QString
QStringList
QAction::setData
void setData(const QVariant &userData)
QList::end
iterator end()
KWalletPopup::walletCreated
void walletCreated()
QAction::setShortcut
void setShortcut(const QKeySequence &shortcut)
KWalletPopup::changeWalletPassword
void changeWalletPassword()
Definition: kwalletpopup.cpp:104
QLatin1String
QKeySequence
QAction
KWalletPopup::walletClosed
void walletClosed(const QString &walletName)
KWalletPopup::openWallet
void openWallet()
Definition: kwalletpopup.cpp:89
KWalletPopup::~KWalletPopup
virtual ~KWalletPopup()
Definition: kwalletpopup.cpp:85
KWalletPopup::walletDeleted
void walletDeleted(const QString &walletName)
QVariant::toString
QString toString() const
QList::begin
iterator begin()
QAction::setEnabled
void setEnabled(bool)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kwallet

Skip menu "kwallet"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

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