• 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
  • conf
cryptooperationsconfigwidget.cpp
Go to the documentation of this file.
1 /*
2  cryptooperationsconfigwidget.cpp
3 
4  This file is part of kleopatra, the KDE key manager
5  Copyright (c) 2010 Klarälvdalens Datakonsult AB
6 
7  Libkleopatra is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of the
10  License, or (at your option) any later version.
11 
12  Libkleopatra 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 "cryptooperationsconfigwidget.h"
36 #include "ui_cryptooperationsconfigwidget.h"
37 
38 #include "emailoperationspreferences.h"
39 #include "fileoperationspreferences.h"
40 
41 #include <kleo/checksumdefinition.h>
42 
43 #include <kconfig.h>
44 #include <kglobal.h>
45 #include <klocale.h>
46 #include <kconfiggroup.h>
47 
48 #include <QLayout>
49 
50 #include <boost/shared_ptr.hpp>
51 
52 using namespace Kleo;
53 using namespace Kleo::Config;
54 using namespace boost;
55 
56 class CryptoOperationsConfigWidget::Private {
57  friend class ::Kleo::Config::CryptoOperationsConfigWidget;
58  CryptoOperationsConfigWidget * const q;
59 public:
60  explicit Private( CryptoOperationsConfigWidget * qq )
61  : q( qq ), ui( q ) {}
62 
63 private:
64  struct UI : Ui_CryptoOperationsConfigWidget {
65 
66  explicit UI( CryptoOperationsConfigWidget * q )
67  : Ui_CryptoOperationsConfigWidget()
68  {
69  setupUi( q );
70 
71  if ( QLayout * const l = q->layout() )
72  l->setMargin( 0 );
73 
74  connect( quickSignCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
75  connect( quickEncryptCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
76  connect( checksumDefinitionCB, SIGNAL(currentIndexChanged(int)), q, SIGNAL(changed()) );
77  connect( pgpFileExtCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
78  }
79 
80  } ui;
81 
82 };
83 
84 CryptoOperationsConfigWidget::CryptoOperationsConfigWidget( QWidget * p, Qt::WindowFlags f )
85  : QWidget( p, f ), d( new Private( this ) )
86 {
87 // load();
88 }
89 
90 
91 CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget() {}
92 
93 void CryptoOperationsConfigWidget::defaults() {
94  EMailOperationsPreferences emailPrefs;
95  emailPrefs.setDefaults();
96  d->ui.quickSignCB->setChecked( emailPrefs.quickSignEMail() );
97  d->ui.quickEncryptCB->setChecked( emailPrefs.quickEncryptEMail() );
98 
99  FileOperationsPreferences filePrefs;
100  filePrefs.setDefaults();
101  d->ui.pgpFileExtCB->setChecked( filePrefs.usePGPFileExt() );
102 
103  if ( d->ui.checksumDefinitionCB->count() )
104  d->ui.checksumDefinitionCB->setCurrentIndex( 0 );
105 }
106 
107 Q_DECLARE_METATYPE( boost::shared_ptr<Kleo::ChecksumDefinition> )
108 
109 void CryptoOperationsConfigWidget::load() {
110 
111  const EMailOperationsPreferences emailPrefs;
112  d->ui.quickSignCB ->setChecked( emailPrefs.quickSignEMail() );
113  d->ui.quickEncryptCB->setChecked( emailPrefs.quickEncryptEMail() );
114 
115  const FileOperationsPreferences filePrefs;
116  d->ui.pgpFileExtCB->setChecked( filePrefs.usePGPFileExt() );
117 
118  const std::vector< shared_ptr<ChecksumDefinition> > cds = ChecksumDefinition::getChecksumDefinitions();
119  const shared_ptr<ChecksumDefinition> default_cd = ChecksumDefinition::getDefaultChecksumDefinition( cds );
120 
121  d->ui.checksumDefinitionCB->clear();
122 
123  Q_FOREACH( const shared_ptr<ChecksumDefinition> & cd, cds ) {
124  d->ui.checksumDefinitionCB->addItem( cd->label(), qVariantFromValue( cd ) );
125  if ( cd == default_cd )
126  d->ui.checksumDefinitionCB->setCurrentIndex( d->ui.checksumDefinitionCB->count() - 1 );
127  }
128 }
129 
130 void CryptoOperationsConfigWidget::save() {
131 
132  EMailOperationsPreferences emailPrefs;
133  emailPrefs.setQuickSignEMail ( d->ui.quickSignCB ->isChecked() );
134  emailPrefs.setQuickEncryptEMail( d->ui.quickEncryptCB->isChecked() );
135  emailPrefs.writeConfig();
136 
137  FileOperationsPreferences filePrefs;
138  filePrefs.setUsePGPFileExt( d->ui.pgpFileExtCB->isChecked() );
139  filePrefs.writeConfig();
140 
141  const int idx = d->ui.checksumDefinitionCB->currentIndex();
142  if ( idx < 0 )
143  return; // ### pick first?
144  const shared_ptr<ChecksumDefinition> cd = qvariant_cast< shared_ptr<ChecksumDefinition> >( d->ui.checksumDefinitionCB->itemData( idx ) );
145  ChecksumDefinition::setDefaultChecksumDefinition( cd );
146 
147 }
148 
149 #include "moc_cryptooperationsconfigwidget.cpp"
emailoperationspreferences.h
Kleo::FileOperationsPreferences::setUsePGPFileExt
void setUsePGPFileExt(bool v)
Set Use pgp as the default extension for generated OpenPGP files.
Definition: fileoperationspreferences.h:22
Kleo::Config::CryptoOperationsConfigWidget::defaults
void defaults()
Definition: cryptooperationsconfigwidget.cpp:93
QWidget
fileoperationspreferences.h
Kleo::Config::CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget
~CryptoOperationsConfigWidget()
Definition: cryptooperationsconfigwidget.cpp:91
cryptooperationsconfigwidget.h
boost::shared_ptr
Definition: encryptemailcontroller.h:51
d
#define d
Definition: adduseridcommand.cpp:90
Kleo::Config::CryptoOperationsConfigWidget::CryptoOperationsConfigWidget
CryptoOperationsConfigWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: cryptooperationsconfigwidget.cpp:84
Kleo::EMailOperationsPreferences
Definition: emailoperationspreferences.h:12
Kleo::EMailOperationsPreferences::setQuickEncryptEMail
void setQuickEncryptEMail(bool v)
Set Quick Encrypt EMail.
Definition: emailoperationspreferences.h:39
Kleo::EMailOperationsPreferences::quickSignEMail
bool quickSignEMail() const
Get Quick Sign EMail.
Definition: emailoperationspreferences.h:31
Kleo::EMailOperationsPreferences::setQuickSignEMail
void setQuickSignEMail(bool v)
Set Quick Sign EMail.
Definition: emailoperationspreferences.h:22
Kleo::Config::CryptoOperationsConfigWidget::save
void save()
Definition: cryptooperationsconfigwidget.cpp:130
Kleo::FileOperationsPreferences
Definition: fileoperationspreferences.h:12
Kleo::Config::CryptoOperationsConfigWidget
Definition: cryptooperationsconfigwidget.h:43
Kleo::FileOperationsPreferences::usePGPFileExt
bool usePGPFileExt() const
Get Use pgp as the default extension for generated OpenPGP files.
Definition: fileoperationspreferences.h:31
q
#define q
Definition: adduseridcommand.cpp:91
Kleo::EMailOperationsPreferences::quickEncryptEMail
bool quickEncryptEMail() const
Get Quick Encrypt EMail.
Definition: emailoperationspreferences.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:40 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