• 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
  • crypto
  • gui
decryptverifyoperationwidget.cpp
Go to the documentation of this file.
1 /* -*- mode: c++; c-basic-offset:4 -*-
2  uiserver/decryptverifyoperationwidget.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2007 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 "decryptverifyoperationwidget.h"
36 
37 #include <utils/archivedefinition.h>
38 
39 #include "libkleo/ui/filenamerequester.h"
40 
41 #include <KLocale>
42 #include <KIcon>
43 
44 #include <QLayout>
45 #include <QLabel>
46 #include <QCheckBox>
47 #include <QToolButton>
48 #include <QStackedLayout>
49 #include <QComboBox>
50 
51 #include <boost/shared_ptr.hpp>
52 
53 using namespace Kleo;
54 using namespace Kleo::Crypto::Gui;
55 using namespace boost;
56 
57 class DecryptVerifyOperationWidget::Private {
58  friend class ::Kleo::Crypto::Gui::DecryptVerifyOperationWidget;
59  DecryptVerifyOperationWidget * const q;
60 public:
61  explicit Private( DecryptVerifyOperationWidget * qq );
62  ~Private();
63 
64  void enableDisableWidgets() {
65  const bool detached = ui.verifyDetachedCB.isChecked();
66  const bool archive = ui.archiveCB.isChecked();
67  ui.archiveCB.setEnabled( !detached );
68  ui.archivesCB.setEnabled( archive && !detached );
69  }
70 private:
71  struct UI {
72  QGridLayout glay;
73  QLabel inputLB;
74  QStackedLayout inputStack;
75  QLabel inputFileNameLB;
76  FileNameRequester inputFileNameRQ;
77  //------
78  QCheckBox verifyDetachedCB;
79  //------
80  QLabel signedDataLB;
81  QStackedLayout signedDataStack;
82  QLabel signedDataFileNameLB;
83  FileNameRequester signedDataFileNameRQ;
84  //------
85  QHBoxLayout hlay;
86  QCheckBox archiveCB;
87  QComboBox archivesCB;
88 
89  explicit UI( DecryptVerifyOperationWidget * q );
90  } ui;
91 };
92 
93 DecryptVerifyOperationWidget::Private::UI::UI( DecryptVerifyOperationWidget * q )
94  : glay( q ),
95  inputLB( i18n("Input file:"), q ),
96  inputStack(),
97  inputFileNameLB( q ),
98  inputFileNameRQ( q ),
99  verifyDetachedCB( i18n("&Input file is a detached signature"), q ),
100  signedDataLB( i18n("&Signed data:"), q ),
101  signedDataStack(),
102  signedDataFileNameLB( q ),
103  signedDataFileNameRQ( q ),
104  hlay(),
105  archiveCB( i18n("&Input file is an archive; unpack with:"), q ),
106  archivesCB( q )
107 {
108  KDAB_SET_OBJECT_NAME( glay );
109  KDAB_SET_OBJECT_NAME( inputLB );
110  KDAB_SET_OBJECT_NAME( inputStack );
111  KDAB_SET_OBJECT_NAME( inputFileNameLB );
112  KDAB_SET_OBJECT_NAME( inputFileNameRQ );
113  KDAB_SET_OBJECT_NAME( verifyDetachedCB );
114  KDAB_SET_OBJECT_NAME( signedDataLB );
115  KDAB_SET_OBJECT_NAME( signedDataStack );
116  KDAB_SET_OBJECT_NAME( signedDataFileNameLB );
117  KDAB_SET_OBJECT_NAME( signedDataFileNameRQ );
118  KDAB_SET_OBJECT_NAME( hlay );
119  KDAB_SET_OBJECT_NAME( archiveCB );
120  KDAB_SET_OBJECT_NAME( archivesCB );
121 
122  inputStack.setMargin( 0 );
123  signedDataStack.setMargin( 0 );
124 
125  signedDataLB.setEnabled( false );
126  signedDataFileNameLB.setEnabled( false );
127  signedDataFileNameRQ.setEnabled( false );
128  archivesCB.setEnabled( false );
129 
130  glay.setMargin( 0 );
131  glay.addWidget( &inputLB, 0, 0 );
132  glay.addLayout( &inputStack, 0, 1 );
133  inputStack.addWidget( &inputFileNameLB );
134  inputStack.addWidget( &inputFileNameRQ );
135 
136  glay.addWidget( &verifyDetachedCB, 1, 0, 1, 2 );
137 
138  glay.addWidget( &signedDataLB, 2, 0 );
139  glay.addLayout( &signedDataStack, 2, 1 );
140  signedDataStack.addWidget( &signedDataFileNameLB );
141  signedDataStack.addWidget( &signedDataFileNameRQ );
142 
143  glay.addLayout( &hlay, 3, 0, 1, 2 );
144  hlay.addWidget( &archiveCB );
145  hlay.addWidget( &archivesCB, 1 );
146 
147  connect( &verifyDetachedCB, SIGNAL(toggled(bool)),
148  &signedDataLB, SLOT(setEnabled(bool)) );
149  connect( &verifyDetachedCB, SIGNAL(toggled(bool)),
150  &signedDataFileNameLB, SLOT(setEnabled(bool)) );
151  connect( &verifyDetachedCB, SIGNAL(toggled(bool)),
152  &signedDataFileNameRQ, SLOT(setEnabled(bool)) );
153  connect( &verifyDetachedCB, SIGNAL(toggled(bool)),
154  q, SLOT(enableDisableWidgets()) );
155  connect( &archiveCB, SIGNAL(toggled(bool)),
156  q, SLOT(enableDisableWidgets()) );
157 }
158 
159 
160 DecryptVerifyOperationWidget::Private::Private( DecryptVerifyOperationWidget * qq )
161  : q( qq ),
162  ui( q )
163 {
164 
165 }
166 
167 DecryptVerifyOperationWidget::Private::~Private() {}
168 
169 DecryptVerifyOperationWidget::DecryptVerifyOperationWidget( QWidget * p )
170  : QWidget( p ), d( new Private( this ) )
171 {
172  setMode( DecryptVerifyOpaque );
173 }
174 
175 DecryptVerifyOperationWidget::~DecryptVerifyOperationWidget() {}
176 
177 void DecryptVerifyOperationWidget::setArchiveDefinitions( const std::vector< shared_ptr<ArchiveDefinition> > & archiveDefinitions ) {
178  d->ui.archivesCB.clear();
179  Q_FOREACH( const shared_ptr<ArchiveDefinition> & ad, archiveDefinitions )
180  d->ui.archivesCB.addItem( ad->label(), qVariantFromValue( ad ) );
181 }
182 
183 static const int Mutable = 1;
184 static const int Const = 0;
185 
186 void DecryptVerifyOperationWidget::setMode( Mode mode ) {
187  setMode( mode, shared_ptr<ArchiveDefinition>() );
188 }
189 
190 void DecryptVerifyOperationWidget::setMode( Mode mode, const shared_ptr<ArchiveDefinition> & ad ) {
191  d->ui.verifyDetachedCB.setChecked( mode != DecryptVerifyOpaque );
192 
193  QWidget * inputWidget;
194  QWidget * signedDataWidget;
195  if ( mode == VerifyDetachedWithSignedData ) {
196  inputWidget = &d->ui.inputFileNameRQ;
197  signedDataWidget = &d->ui.signedDataFileNameLB;
198  } else {
199  inputWidget = &d->ui.inputFileNameLB;
200  signedDataWidget = &d->ui.signedDataFileNameRQ;
201  }
202 
203  d->ui.inputStack.setCurrentWidget( inputWidget );
204  d->ui.signedDataStack.setCurrentWidget( signedDataWidget );
205 
206  d->ui.inputLB.setBuddy( inputWidget );
207  d->ui.signedDataLB.setBuddy( signedDataWidget );
208 
209  d->ui.archiveCB.setChecked( ad );
210  for ( int i = 0, end = d->ui.archivesCB.count() ; i != end ; ++i )
211  if ( ad == d->ui.archivesCB.itemData( i ).value< shared_ptr<ArchiveDefinition> >() ) {
212  d->ui.archivesCB.setCurrentIndex( i );
213  return;
214  }
215 }
216 
217 DecryptVerifyOperationWidget::Mode DecryptVerifyOperationWidget::mode() const {
218  if ( d->ui.verifyDetachedCB.isChecked() )
219  if ( d->ui.inputStack.currentIndex() == Const )
220  return VerifyDetachedWithSignature;
221  else
222  return VerifyDetachedWithSignedData;
223  else
224  return DecryptVerifyOpaque;
225 }
226 
227 void DecryptVerifyOperationWidget::setInputFileName( const QString & name ) {
228  d->ui.inputFileNameLB.setText( name );
229  d->ui.inputFileNameRQ.setFileName( name );
230 }
231 
232 QString DecryptVerifyOperationWidget::inputFileName() const {
233  if ( d->ui.inputStack.currentIndex() == Const )
234  return d->ui.inputFileNameLB.text();
235  else
236  return d->ui.inputFileNameRQ.fileName();
237 }
238 
239 void DecryptVerifyOperationWidget::setSignedDataFileName( const QString & name ) {
240  d->ui.signedDataFileNameLB.setText( name );
241  d->ui.signedDataFileNameRQ.setFileName( name );
242 }
243 
244 QString DecryptVerifyOperationWidget::signedDataFileName() const {
245  if ( d->ui.signedDataStack.currentIndex() == Const )
246  return d->ui.signedDataFileNameLB.text();
247  else
248  return d->ui.signedDataFileNameRQ.fileName();
249 }
250 
251 shared_ptr<ArchiveDefinition> DecryptVerifyOperationWidget::selectedArchiveDefinition() const {
252  if ( mode() == DecryptVerifyOpaque && d->ui.archiveCB.isChecked() )
253  return d->ui.archivesCB.itemData( d->ui.archivesCB.currentIndex() ).value< shared_ptr<ArchiveDefinition> >();
254  else
255  return shared_ptr<ArchiveDefinition>();
256 }
257 
258 #include "moc_decryptverifyoperationwidget.cpp"
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::DecryptVerifyOperationWidget
DecryptVerifyOperationWidget(QWidget *parent=0)
Definition: decryptverifyoperationwidget.cpp:169
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::Mode
Mode
Definition: decryptverifyoperationwidget.h:65
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::setSignedDataFileName
void setSignedDataFileName(const QString &name)
Definition: decryptverifyoperationwidget.cpp:239
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::inputFileName
QString inputFileName() const
QWidget
decryptverifyoperationwidget.h
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::setInputFileName
void setInputFileName(const QString &name)
Definition: decryptverifyoperationwidget.cpp:227
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::setArchiveDefinitions
void setArchiveDefinitions(const std::vector< boost::shared_ptr< ArchiveDefinition > > &ads)
Definition: decryptverifyoperationwidget.cpp:177
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::~DecryptVerifyOperationWidget
~DecryptVerifyOperationWidget()
Definition: decryptverifyoperationwidget.cpp:175
Mutable
static const int Mutable
Definition: decryptverifyoperationwidget.cpp:183
boost::shared_ptr
Definition: encryptemailcontroller.h:51
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::selectedArchiveDefinition
boost::shared_ptr< ArchiveDefinition > selectedArchiveDefinition() const
Definition: decryptverifyoperationwidget.cpp:251
KDAB_SET_OBJECT_NAME
#define KDAB_SET_OBJECT_NAME(x)
Definition: kdtoolsglobal.h:66
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::mode
Mode mode() const
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::VerifyDetachedWithSignature
Definition: decryptverifyoperationwidget.h:66
archivedefinition.h
Const
static const int Const
Definition: decryptverifyoperationwidget.cpp:184
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::DecryptVerifyOpaque
Definition: decryptverifyoperationwidget.h:68
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::setMode
void setMode(Mode mode, const boost::shared_ptr< ArchiveDefinition > &ad)
Definition: decryptverifyoperationwidget.cpp:190
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::signedDataFileName
QString signedDataFileName() const
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::Crypto::Gui::DecryptVerifyOperationWidget
Definition: decryptverifyoperationwidget.h:55
name
const char * name
Definition: uiserver/selectcertificatecommand.cpp:114
Kleo::Crypto::Gui::DecryptVerifyOperationWidget::VerifyDetachedWithSignedData
Definition: decryptverifyoperationwidget.h:67
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