33 #include <config-kleopatra.h>
38 #include "libkleo/ui/filenamerequester.h"
43 #include <knuminput.h>
45 #include <QVBoxLayout>
49 #include <QPushButton>
52 static const char*
log_levels[] = {
"none",
"basic",
"advanced",
"expert",
"guru" };
75 setCaption( i18n(
"Configure KWatchGnuPG") );
76 setButtons(
Ok|Cancel );
77 setDefaultButton(
Ok );
90 group =
new QGroupBox( i18n(
"WatchGnuPG"), top );
100 mExeED =
new Kleo::FileNameRequester( group );
101 QLabel *label =
new QLabel( i18n(
"&Executable:"), group );
106 connect( mExeED, SIGNAL(fileNameChanged(
QString)), SLOT(slotChanged()) );
109 mSocketED =
new Kleo::FileNameRequester( group );
110 label =
new QLabel( i18n(
"&Socket:"), group );
115 connect( mSocketED, SIGNAL(fileNameChanged(
QString)), SLOT(slotChanged()) );
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 );
129 connect( mLogLevelCB, SIGNAL(activated(
int)), SLOT(slotChanged()) );
132 group =
new QGroupBox( i18n(
"Log Window"), top );
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 );
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()) );
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 ) );
182 const KConfigGroup logWindow( KGlobal::config(),
"LogWindow" );
183 mLoglenSB->setValue( logWindow.readEntry(
"MaxLogLen", 10000 ) );
184 mWordWrapCB->
setChecked( logWindow.readEntry(
"WordWrap",
false ) );
186 enableButtonOk(
false );
191 KConfigGroup watchGnuPG( KGlobal::config(),
"WatchGnuPG" );
192 watchGnuPG.writeEntry(
"Executable", mExeED->fileName() );
193 watchGnuPG.writeEntry(
"Socket", mSocketED->fileName() );
196 KConfigGroup logWindow( KGlobal::config(),
"LogWindow" );
197 logWindow.writeEntry(
"MaxLogLen", mLoglenSB->value() );
198 logWindow.writeEntry(
"WordWrap", mWordWrapCB->
isChecked() );
200 KGlobal::config()->sync();
202 enableButtonOk(
false );
205 void KWatchGnuPGConfig::slotChanged()
207 enableButtonOk(
true );
210 void KWatchGnuPGConfig::slotSave()
static int log_level_to_int(const QString &loglevel)
static const char * log_levels[]
void setSpacing(int spacing)
KWatchGnuPGConfig(QWidget *parent=0)
void addItem(const QString &text, const QVariant &userData)
void setBuddy(QWidget *buddy)
void setMargin(int margin)
void addStretch(int stretch)
void setColumnStretch(int column, int stretch)
void setCurrentIndex(int index)
void setSpacing(int spacing)