33 #include <config-kleopatra.h>
38 #include "libkleo/ui/filenamerequester.h"
43 #include <knuminput.h>
49 #include <QPushButton>
52 static const char*
log_levels[] = {
"none",
"basic",
"advanced",
"expert",
"guru" };
56 if( loglevel == QLatin1String(
"none") ) {
58 }
else if( loglevel == QLatin1String(
"basic") ) {
60 }
else if( loglevel == QLatin1String(
"advanced") ) {
62 }
else if( loglevel == QLatin1String(
"expert") ) {
64 }
else if( loglevel == QLatin1String(
"guru") ) {
75 setCaption( i18n(
"Configure KWatchGnuPG") );
76 setButtons(
Ok|Cancel );
77 setDefaultButton(
Ok );
86 QVBoxLayout * vlay =
new QVBoxLayout( top );
87 vlay->setSpacing( spacingHint() );
90 group =
new QGroupBox( i18n(
"WatchGnuPG"), top );
91 vlay->addWidget(group);
93 glay =
new QGridLayout( group );
94 glay->setSpacing( spacingHint() );
95 glay->setColumnStretch( 1, 1 );
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 );
106 connect( mExeED, SIGNAL(fileNameChanged(QString)), SLOT(slotChanged()) );
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 );
115 connect( mSocketED, SIGNAL(fileNameChanged(QString)), SLOT(slotChanged()) );
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 );
129 connect( mLogLevelCB, SIGNAL(activated(
int)), SLOT(slotChanged()) );
132 group =
new QGroupBox( i18n(
"Log Window"), top );
133 vlay->addWidget(group);
135 glay =
new QGridLayout( group );
136 glay->setSpacing( spacingHint() );
137 glay->setColumnStretch( 1, 1 );
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 );
154 connect( mLoglenSB, SIGNAL(valueChanged(
int)), SLOT(slotChanged()) );
155 connect( button, SIGNAL(clicked()), SLOT(slotSetHistorySizeUnlimited()) );
158 mWordWrapCB =
new QCheckBox( i18n(
"Enable &word wrapping"), group );
160 glay->addWidget( mWordWrapCB, row, 0, 1, 3 );
162 connect( mWordWrapCB, SIGNAL(clicked()), SLOT(slotChanged()) );
164 vlay->addStretch( 1 );
166 connect(
this, SIGNAL(okClicked()), SLOT(slotSave()) );
171 void KWatchGnuPGConfig::slotSetHistorySizeUnlimited() {
172 mLoglenSB->setValue( 0 );
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" ) ) );
182 const KConfigGroup logWindow( KGlobal::config(),
"LogWindow" );
183 mLoglenSB->setValue( logWindow.readEntry(
"MaxLogLen", 10000 ) );
184 mWordWrapCB->setChecked( logWindow.readEntry(
"WordWrap",
false ) );
186 enableButtonOk(
false );
187 enableButtonApply(
false );
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()] );
197 KConfigGroup logWindow( KGlobal::config(),
"LogWindow" );
198 logWindow.writeEntry(
"MaxLogLen", mLoglenSB->value() );
199 logWindow.writeEntry(
"WordWrap", mWordWrapCB->isChecked() );
201 KGlobal::config()->sync();
203 enableButtonOk(
false );
204 enableButtonApply(
false );
207 void KWatchGnuPGConfig::slotChanged()
209 enableButtonOk(
true );
210 enableButtonApply(
true );
213 void KWatchGnuPGConfig::slotSave()
219 #include "kwatchgnupgconfig.moc"
static int log_level_to_int(const QString &loglevel)
static const char * log_levels[]
KWatchGnuPGConfig(QWidget *parent=0)