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

kleopatra

  • sources
  • kde-4.12
  • kdepim
  • kleopatra
  • dialogs
ownertrustdialog.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  dialogs/ownertrustdialog.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2008 Klarälvdalens Datakonsult AB
6 
7  Kleopatra is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  Kleopatra is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #include <config-kleopatra.h>
34 
35 #include "ownertrustdialog.h"
36 #include "ui_ownertrustdialog.h"
37 
38 #include <utils/formatting.h>
39 
40 #include <kpushbutton.h>
41 
42 #include <cassert>
43 
44 using namespace Kleo;
45 using namespace Kleo::Dialogs;
46 using namespace GpgME;
47 
48 
49 class OwnerTrustDialog::Private {
50  friend class ::Kleo::Dialogs::OwnerTrustDialog;
51  OwnerTrustDialog * const q;
52 public:
53  explicit Private( OwnerTrustDialog * qq )
54  : q( qq ),
55  formattedCertificateName( i18n("(unknown certificate)") ),
56  originalTrust( Key::Undefined ),
57  hasSecret( false ),
58  advancedMode( false ),
59  ui( qq )
60  {
61 
62  }
63 
64 private:
65  void slotTrustLevelChanged() {
66  enableDisableWidgets();
67  }
68 
69  void enableDisableWidgets();
70 
71 private:
72  QString formattedCertificateName;
73  Key::OwnerTrust originalTrust;
74  bool hasSecret : 1;
75  bool advancedMode : 1;
76 
77  struct UI : public Ui::OwnerTrustDialog {
78  explicit UI( Dialogs::OwnerTrustDialog * qq )
79  : Ui::OwnerTrustDialog(), q( qq )
80  {
81  setupUi( qq->mainWidget() );
82  qq->setButtons( KDialog::Ok | KDialog::Cancel );
83  }
84 
85  QPushButton * okPB() const {
86  return q->button( KDialog::Ok );
87  }
88 
89  Dialogs::OwnerTrustDialog *q;
90  } ui;
91 };
92 
93 OwnerTrustDialog::OwnerTrustDialog( QWidget * p, Qt::WindowFlags f )
94  : KDialog( p, f ), d( new Private( this ) )
95 {
96  connect( d->ui.unknownRB, SIGNAL(toggled(bool)), this, SLOT(slotTrustLevelChanged()) );
97  connect( d->ui.neverRB, SIGNAL(toggled(bool)), this, SLOT(slotTrustLevelChanged()) );
98  connect( d->ui.marginalRB, SIGNAL(toggled(bool)), this, SLOT(slotTrustLevelChanged()) );
99  connect( d->ui.fullRB, SIGNAL(toggled(bool)), this, SLOT(slotTrustLevelChanged()) );
100  connect( d->ui.ultimateRB, SIGNAL(toggled(bool)), this, SLOT(slotTrustLevelChanged()) );
101 }
102 
103 OwnerTrustDialog::~OwnerTrustDialog() {}
104 
105 void OwnerTrustDialog::setFormattedCertificateName( const QString & formatted ) {
106  if ( formatted.isEmpty() )
107  return;
108  d->formattedCertificateName = formatted;
109  setWindowTitle( i18nc( "@title", "Change Trust Level of %1", formatted ) );
110  d->ui.label->setText( i18nc( "@info", "How much do you trust certifications made by <b>%1</b> to correctly verify authenticity of certificates?", formatted ) );
111 }
112 
113 QString OwnerTrustDialog::formattedCertificateName() const {
114  return d->formattedCertificateName;
115 }
116 
117 void OwnerTrustDialog::setHasSecretKey( bool secret ) {
118  d->hasSecret = secret;
119  d->enableDisableWidgets();
120  setOwnerTrust( ownerTrust() );
121 }
122 
123 bool OwnerTrustDialog::hasSecretKey() const {
124  return d->hasSecret;
125 }
126 
127 void OwnerTrustDialog::setAdvancedMode( bool advanced ) {
128  d->advancedMode = advanced;
129  d->enableDisableWidgets();
130  setOwnerTrust( ownerTrust() );
131 }
132 
133 bool OwnerTrustDialog::isAdvancedMode() const {
134  return d->advancedMode;
135 }
136 
137 void OwnerTrustDialog::Private::enableDisableWidgets() {
138  ui.unknownRB ->setEnabled( !hasSecret || advancedMode );
139  ui.neverRB ->setEnabled( !hasSecret || advancedMode );
140  ui.marginalRB->setEnabled( !hasSecret || advancedMode );
141  ui.fullRB ->setEnabled( !hasSecret || advancedMode );
142  ui.ultimateRB->setEnabled( hasSecret || advancedMode );
143  ui.okPB()->setEnabled( q->ownerTrust() != Key::Undefined && q->ownerTrust() != originalTrust );
144 }
145 
146 static void force_set_checked( QAbstractButton * b, bool on ) {
147  // work around Qt bug (tested: 4.1.4, 4.2.3, 4.3.4)
148  const bool autoExclusive = b->autoExclusive();
149  b->setAutoExclusive( false );
150  b->setChecked( b->isEnabled() && on );
151  b->setAutoExclusive( autoExclusive );
152 }
153 
154 void OwnerTrustDialog::setOwnerTrust( Key::OwnerTrust trust ) {
155  d->originalTrust = trust;
156  force_set_checked( d->ui.unknownRB, trust == Key::Unknown );
157  force_set_checked( d->ui.neverRB, trust == Key::Never );
158  force_set_checked( d->ui.marginalRB,trust == Key::Marginal );
159  force_set_checked( d->ui.fullRB, trust == Key::Full );
160  force_set_checked( d->ui.ultimateRB,trust == Key::Ultimate );
161  d->enableDisableWidgets();
162 }
163 
164 Key::OwnerTrust OwnerTrustDialog::ownerTrust() const {
165  if ( d->ui.unknownRB->isChecked() )
166  return Key::Unknown;
167  if ( d->ui.neverRB->isChecked() )
168  return Key::Never;
169  if ( d->ui.marginalRB->isChecked() )
170  return Key::Marginal;
171  if ( d->ui.fullRB->isChecked() )
172  return Key::Full;
173  if ( d->ui.ultimateRB->isChecked() )
174  return Key::Ultimate;
175  return Key::Undefined;
176 }
177 
178 #include "moc_ownertrustdialog.cpp"
Kleo::Dialogs::OwnerTrustDialog::setOwnerTrust
void setOwnerTrust(GpgME::Key::OwnerTrust)
Definition: ownertrustdialog.cpp:154
Unknown
Definition: setinitialpindialog.cpp:55
Kleo::Dialogs::OwnerTrustDialog::isAdvancedMode
bool isAdvancedMode() const
Definition: ownertrustdialog.cpp:133
Kleo::Dialogs::OwnerTrustDialog::hasSecretKey
bool hasSecretKey() const
Definition: ownertrustdialog.cpp:123
QWidget
formatting.h
KDialog
Kleo::Dialogs::OwnerTrustDialog::setAdvancedMode
void setAdvancedMode(bool advanced)
Definition: ownertrustdialog.cpp:127
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Dialogs::OwnerTrustDialog
Definition: ownertrustdialog.h:45
force_set_checked
static void force_set_checked(QAbstractButton *b, bool on)
Definition: ownertrustdialog.cpp:146
Kleo::Dialogs::OwnerTrustDialog::formattedCertificateName
QString formattedCertificateName() const
Definition: ownertrustdialog.cpp:113
Kleo::Dialogs::OwnerTrustDialog::ownerTrust
GpgME::Key::OwnerTrust ownerTrust() const
Definition: ownertrustdialog.cpp:164
Kleo::Dialogs::OwnerTrustDialog::~OwnerTrustDialog
~OwnerTrustDialog()
Definition: ownertrustdialog.cpp:103
Ok
Definition: setinitialpindialog.cpp:59
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::Dialogs::OwnerTrustDialog::setFormattedCertificateName
void setFormattedCertificateName(const QString &formatted)
Definition: ownertrustdialog.cpp:105
Kleo::Dialogs::OwnerTrustDialog::setHasSecretKey
void setHasSecretKey(bool secret)
Definition: ownertrustdialog.cpp:117
Kleo::Formatting::OwnerTrust
Definition: formatting.h:79
ownertrustdialog.h
Kleo::Dialogs::OwnerTrustDialog::OwnerTrustDialog
OwnerTrustDialog(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: ownertrustdialog.cpp:93
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kleopatra

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

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