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

kleopatra

  • sources
  • kde-4.14
  • 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 #ifndef Q_MOC_RUN
51 #include <boost/shared_ptr.hpp>
52 #endif
53 
54 using namespace Kleo;
55 using namespace Kleo::Config;
56 using namespace boost;
57 
58 class CryptoOperationsConfigWidget::Private {
59  friend class ::Kleo::Config::CryptoOperationsConfigWidget;
60  CryptoOperationsConfigWidget * const q;
61 public:
62  explicit Private( CryptoOperationsConfigWidget * qq )
63  : q( qq ), ui( q ) {}
64 
65 private:
66  struct UI : Ui_CryptoOperationsConfigWidget {
67 
68  explicit UI( CryptoOperationsConfigWidget * q )
69  : Ui_CryptoOperationsConfigWidget()
70  {
71  setupUi( q );
72 
73  if ( QLayout * const l = q->layout() )
74  l->setMargin( 0 );
75 
76  connect( quickSignCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
77  connect( quickEncryptCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
78  connect( checksumDefinitionCB, SIGNAL(currentIndexChanged(int)), q, SIGNAL(changed()) );
79  connect( pgpFileExtCB, SIGNAL(toggled(bool)), q, SIGNAL(changed()) );
80  }
81 
82  } ui;
83 
84 };
85 
86 CryptoOperationsConfigWidget::CryptoOperationsConfigWidget( QWidget * p, Qt::WindowFlags f )
87  : QWidget( p, f ), d( new Private( this ) )
88 {
89 // load();
90 }
91 
92 
93 CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget() {}
94 
95 void CryptoOperationsConfigWidget::defaults() {
96  EMailOperationsPreferences emailPrefs;
97  emailPrefs.setDefaults();
98  d->ui.quickSignCB->setChecked( emailPrefs.quickSignEMail() );
99  d->ui.quickEncryptCB->setChecked( emailPrefs.quickEncryptEMail() );
100 
101  FileOperationsPreferences filePrefs;
102  filePrefs.setDefaults();
103  d->ui.pgpFileExtCB->setChecked( filePrefs.usePGPFileExt() );
104 
105  if ( d->ui.checksumDefinitionCB->count() )
106  d->ui.checksumDefinitionCB->setCurrentIndex( 0 );
107 }
108 
109 Q_DECLARE_METATYPE( boost::shared_ptr<Kleo::ChecksumDefinition> )
110 
111 void CryptoOperationsConfigWidget::load() {
112 
113  const EMailOperationsPreferences emailPrefs;
114  d->ui.quickSignCB ->setChecked( emailPrefs.quickSignEMail() );
115  d->ui.quickEncryptCB->setChecked( emailPrefs.quickEncryptEMail() );
116 
117  const FileOperationsPreferences filePrefs;
118  d->ui.pgpFileExtCB->setChecked( filePrefs.usePGPFileExt() );
119 
120  const std::vector< shared_ptr<ChecksumDefinition> > cds = ChecksumDefinition::getChecksumDefinitions();
121  const shared_ptr<ChecksumDefinition> default_cd = ChecksumDefinition::getDefaultChecksumDefinition( cds );
122 
123  d->ui.checksumDefinitionCB->clear();
124 
125  Q_FOREACH( const shared_ptr<ChecksumDefinition> & cd, cds ) {
126  d->ui.checksumDefinitionCB->addItem( cd->label(), qVariantFromValue( cd ) );
127  if ( cd == default_cd )
128  d->ui.checksumDefinitionCB->setCurrentIndex( d->ui.checksumDefinitionCB->count() - 1 );
129  }
130 }
131 
132 void CryptoOperationsConfigWidget::save() {
133 
134  EMailOperationsPreferences emailPrefs;
135  emailPrefs.setQuickSignEMail ( d->ui.quickSignCB ->isChecked() );
136  emailPrefs.setQuickEncryptEMail( d->ui.quickEncryptCB->isChecked() );
137  emailPrefs.writeConfig();
138 
139  FileOperationsPreferences filePrefs;
140  filePrefs.setUsePGPFileExt( d->ui.pgpFileExtCB->isChecked() );
141  filePrefs.writeConfig();
142 
143  const int idx = d->ui.checksumDefinitionCB->currentIndex();
144  if ( idx < 0 )
145  return; // ### pick first?
146  const shared_ptr<ChecksumDefinition> cd = qvariant_cast< shared_ptr<ChecksumDefinition> >( d->ui.checksumDefinitionCB->itemData( idx ) );
147  ChecksumDefinition::setDefaultChecksumDefinition( cd );
148 
149 }
150 
QWidget::layout
QLayout * layout() const
QWidget
Kleo::Config::CryptoOperationsConfigWidget::defaults
void defaults()
Definition: cryptooperationsconfigwidget.cpp:95
QLayout
Kleo::Config::CryptoOperationsConfigWidget::~CryptoOperationsConfigWidget
~CryptoOperationsConfigWidget()
Definition: cryptooperationsconfigwidget.cpp:93
cryptooperationsconfigwidget.h
boost::shared_ptr
Definition: encryptemailcontroller.h:51
d
#define d
Definition: adduseridcommand.cpp:89
Kleo::Config::CryptoOperationsConfigWidget::CryptoOperationsConfigWidget
CryptoOperationsConfigWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Definition: cryptooperationsconfigwidget.cpp:86
Kleo::Config::CryptoOperationsConfigWidget::save
void save()
Definition: cryptooperationsconfigwidget.cpp:132
Kleo::Config::CryptoOperationsConfigWidget
Definition: cryptooperationsconfigwidget.h:43
q
#define q
Definition: adduseridcommand.cpp:90
Qt::WindowFlags
typedef WindowFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:33:10 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
  • pimprint

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