• 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
  • kwatchgnupg
kwatchgnupgconfig.cpp
Go to the documentation of this file.
1 /*
2  kwatchgnupgconfig.cpp
3 
4  This file is part of Kleopatra, the KDE keymanager
5  Copyright (c) 2001,2002,2004 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 "kwatchgnupgconfig.h"
36 #include "kwatchgnupg.h"
37 
38 #include "libkleo/ui/filenamerequester.h"
39 
40 #include <klocale.h>
41 #include <kconfig.h>
42 #include <kglobal.h>
43 #include <knuminput.h>
44 
45 #include <QLayout>
46 #include <QLabel>
47 #include <QCheckBox>
48 #include <QComboBox>
49 #include <QPushButton>
50 #include <QGroupBox>
51 
52 static const char* log_levels[] = { "none", "basic", "advanced", "expert", "guru" };
53 
54 static int log_level_to_int( const QString& loglevel )
55 {
56  if( loglevel == QLatin1String("none") ) {
57  return 0;
58  } else if( loglevel == QLatin1String("basic") ) {
59  return 1;
60  } else if( loglevel == QLatin1String("advanced") ) {
61  return 2;
62  } else if( loglevel == QLatin1String("expert") ) {
63  return 3;
64  } else if( loglevel == QLatin1String("guru") ) {
65  return 4;
66  } else {
67  // default
68  return 1;
69  }
70 }
71 
72 KWatchGnuPGConfig::KWatchGnuPGConfig( QWidget* parent )
73  : KDialog( parent )
74 {
75  setCaption( i18n("Configure KWatchGnuPG") );
76  setButtons( Ok|Cancel );
77  setDefaultButton( Ok );
78 
79  // tmp vars:
80  QGridLayout * glay;
81  QGroupBox * group;
82 
83  QWidget * top = new QWidget;
84  setMainWidget( top );
85 
86  QVBoxLayout * vlay = new QVBoxLayout( top );
87  vlay->setSpacing( spacingHint() );
88  vlay->setMargin( 0 );
89 
90  group = new QGroupBox( i18n("WatchGnuPG"), top );
91  vlay->addWidget(group);
92 
93  glay = new QGridLayout( group );
94  glay->setSpacing( spacingHint() );
95  glay->setColumnStretch( 1, 1 );
96 
97  int row = -1;
98 
99  ++row;
100  mExeED = new Kleo::FileNameRequester( group );
101  QLabel *label = new QLabel( i18n("&Executable:"), group );
102  label->setBuddy( mExeED );
103  glay->addWidget( label, row, 0 );
104  glay->addWidget( mExeED, row, 1 );
105 
106  connect( mExeED, SIGNAL(fileNameChanged(QString)), SLOT(slotChanged()) );
107 
108  ++row;
109  mSocketED = new Kleo::FileNameRequester( group );
110  label = new QLabel( i18n("&Socket:"), group );
111  label->setBuddy( mSocketED );
112  glay->addWidget( label, row, 0 );
113  glay->addWidget( mSocketED, row, 1 );
114 
115  connect( mSocketED, SIGNAL(fileNameChanged(QString)), SLOT(slotChanged()) );
116 
117  ++row;
118  mLogLevelCB = new QComboBox( group );
119  mLogLevelCB->addItem( i18n("None") );
120  mLogLevelCB->addItem( i18n("Basic") );
121  mLogLevelCB->addItem( i18n("Advanced") );
122  mLogLevelCB->addItem( i18n("Expert") );
123  mLogLevelCB->addItem( i18n("Guru") );
124  label = new QLabel( i18n("Default &log level:"), group );
125  label->setBuddy( mLogLevelCB );
126  glay->addWidget( label, row, 0 );
127  glay->addWidget( mLogLevelCB, row, 1 );
128 
129  connect( mLogLevelCB, SIGNAL(activated(int)), SLOT(slotChanged()) );
130 
131  /******************* Log Window group *******************/
132  group = new QGroupBox( i18n("Log Window"), top );
133  vlay->addWidget(group);
134 
135  glay = new QGridLayout( group );
136  glay->setSpacing( spacingHint() );
137  glay->setColumnStretch( 1, 1 );
138 
139  row = -1;
140 
141  ++row;
142  mLoglenSB = new KIntSpinBox( group );
143  mLoglenSB->setRange( 0, 1000000 );
144  mLoglenSB->setSingleStep( 100 );
145  mLoglenSB->setSuffix( ki18ncp("history size spinbox suffix", " line", " lines") );
146  mLoglenSB->setSpecialValueText( i18n("unlimited") );
147  label = new QLabel( i18n("&History size:"), group );
148  label->setBuddy( mLoglenSB );
149  glay->addWidget( label, row, 0 );
150  glay->addWidget( mLoglenSB, row, 1 );
151  QPushButton * button = new QPushButton( i18n("Set &Unlimited"), group );
152  glay->addWidget( button, row, 2 );
153 
154  connect( mLoglenSB, SIGNAL(valueChanged(int)), SLOT(slotChanged()) );
155  connect( button, SIGNAL(clicked()), SLOT(slotSetHistorySizeUnlimited()) );
156 
157  ++row;
158  mWordWrapCB = new QCheckBox( i18n("Enable &word wrapping"), group );
159  mWordWrapCB->hide(); // QTextEdit doesn't support word wrapping in LogText mode
160  glay->addWidget( mWordWrapCB, row, 0, 1, 3 );
161 
162  connect( mWordWrapCB, SIGNAL(clicked()), SLOT(slotChanged()) );
163 
164  vlay->addStretch( 1 );
165 
166  connect( this, SIGNAL(okClicked()), SLOT(slotSave()) );
167 }
168 
169 KWatchGnuPGConfig::~KWatchGnuPGConfig() {}
170 
171 void KWatchGnuPGConfig::slotSetHistorySizeUnlimited() {
172  mLoglenSB->setValue( 0 );
173 }
174 
175 void KWatchGnuPGConfig::loadConfig()
176 {
177  const KConfigGroup watchGnuPG( KGlobal::config(), "WatchGnuPG" );
178  mExeED->setFileName( watchGnuPG.readEntry( "Executable", WATCHGNUPGBINARY ) );
179  mSocketED->setFileName( watchGnuPG.readEntry( "Socket", WATCHGNUPGSOCKET ) );
180  mLogLevelCB->setCurrentIndex( log_level_to_int( watchGnuPG.readEntry( "LogLevel", "basic" ) ) );
181 
182  const KConfigGroup logWindow( KGlobal::config(), "LogWindow" );
183  mLoglenSB->setValue( logWindow.readEntry( "MaxLogLen", 10000 ) );
184  mWordWrapCB->setChecked( logWindow.readEntry("WordWrap", false ) );
185 
186  enableButtonOk( false );
187  enableButtonApply( false );
188 }
189 
190 void KWatchGnuPGConfig::saveConfig()
191 {
192  KConfigGroup watchGnuPG( KGlobal::config(), "WatchGnuPG" );
193  watchGnuPG.writeEntry( "Executable", mExeED->fileName() );
194  watchGnuPG.writeEntry( "Socket", mSocketED->fileName() );
195  watchGnuPG.writeEntry( "LogLevel", log_levels[mLogLevelCB->currentIndex()] );
196 
197  KConfigGroup logWindow( KGlobal::config(), "LogWindow" );
198  logWindow.writeEntry( "MaxLogLen", mLoglenSB->value() );
199  logWindow.writeEntry( "WordWrap", mWordWrapCB->isChecked() );
200 
201  KGlobal::config()->sync();
202 
203  enableButtonOk( false );
204  enableButtonApply( false );
205 }
206 
207 void KWatchGnuPGConfig::slotChanged()
208 {
209  enableButtonOk( true );
210  enableButtonApply( true );
211 }
212 
213 void KWatchGnuPGConfig::slotSave()
214 {
215  saveConfig();
216  emit reconfigure();
217 }
218 
219 #include "kwatchgnupgconfig.moc"
KWatchGnuPGConfig::loadConfig
void loadConfig()
Definition: kwatchgnupgconfig.cpp:175
kwatchgnupgconfig.h
QWidget
KDialog
log_level_to_int
static int log_level_to_int(const QString &loglevel)
Definition: kwatchgnupgconfig.cpp:54
log_levels
static const char * log_levels[]
Definition: kwatchgnupgconfig.cpp:52
KWatchGnuPGConfig::KWatchGnuPGConfig
KWatchGnuPGConfig(QWidget *parent=0)
Definition: kwatchgnupgconfig.cpp:72
kwatchgnupg.h
WATCHGNUPGSOCKET
#define WATCHGNUPGSOCKET
Definition: kwatchgnupg.h:39
WATCHGNUPGBINARY
#define WATCHGNUPGBINARY
Definition: kwatchgnupg.h:38
Ok
Definition: setinitialpindialog.cpp:59
KWatchGnuPGConfig::reconfigure
void reconfigure()
KWatchGnuPGConfig::saveConfig
void saveConfig()
Definition: kwatchgnupgconfig.cpp:190
KWatchGnuPGConfig::~KWatchGnuPGConfig
~KWatchGnuPGConfig()
Definition: kwatchgnupgconfig.cpp:169
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