Kate
docwordcompletion_config.cpp
Go to the documentation of this file.00001
00021 #include "docwordcompletion_config.h"
00022 #include "docwordcompletion.h"
00023
00024 #include <QtGui/QBoxLayout>
00025 #include <QtGui/QLabel>
00026 #include <QtGui/QCheckBox>
00027 #include <QtGui/QSpinBox>
00028
00029 #include <khbox.h>
00030 #include <kdialog.h>
00031 #include <klocale.h>
00032 #include <kgenericfactory.h>
00033
00034 #ifndef KDE_USE_FINAL
00035 K_PLUGIN_FACTORY_DECLARATION(DocWordCompletionFactory)
00036 #endif
00037
00038 DocWordCompletionConfig::DocWordCompletionConfig(QWidget *parent, const QVariantList &args)
00039 : KCModule(DocWordCompletionFactory::componentData(), parent, args)
00040 {
00041 QVBoxLayout *lo = new QVBoxLayout( this );
00042 lo->setSpacing( KDialog::spacingHint() );
00043
00044 cbAutoPopup = new QCheckBox( i18n("Automatically &show completion list"), this );
00045 lo->addWidget( cbAutoPopup );
00046
00047 KHBox *hb = new KHBox( this );
00048 hb->setSpacing( KDialog::spacingHint() );
00049 lo->addWidget( hb );
00050 QLabel *l = new QLabel( i18nc(
00051 "Translators: This is the first part of two strings which will comprise the "
00052 "sentence 'Show completions when a word is at least N characters'. The first "
00053 "part is on the right side of the N, which is represented by a spinbox "
00054 "widget, followed by the second part: 'characters long'. Characters is a "
00055 "integer number between and including 1 and 30. Feel free to leave the "
00056 "second part of the sentence blank if it suits your language better. ",
00057 "Show completions &when a word is at least"), hb );
00058 sbAutoPopup = new QSpinBox( hb );
00059 sbAutoPopup->setRange( 1, 30 );
00060 sbAutoPopup->setSingleStep( 1 );
00061 l->setBuddy( sbAutoPopup );
00062 lSbRight = new QLabel( i18nc(
00063 "This is the second part of two strings that will comprise the sentence "
00064 "'Show completions when a word is at least N characters'",
00065 "characters long."), hb );
00066
00067 cbAutoPopup->setWhatsThis(i18n(
00068 "Enable the automatic completion list popup as default. The popup can "
00069 "be disabled on a view basis from the 'Tools' menu.") );
00070 sbAutoPopup->setWhatsThis(i18n(
00071 "Define the length a word should have before the completion list "
00072 "is displayed.") );
00073
00074 lo->addStretch();
00075
00076 QObject::connect(cbAutoPopup, SIGNAL(stateChanged(int)), this, SLOT(slotChanged()));
00077
00078 QObject::connect(sbAutoPopup, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
00079
00080 load();
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 QMetaObject::invokeMethod(this, "changed", Qt::QueuedConnection);
00100 }
00101
00102 DocWordCompletionConfig::~DocWordCompletionConfig()
00103 {
00104 }
00105
00106 void DocWordCompletionConfig::save()
00107 {
00108 if (DocWordCompletionPlugin::self())
00109 {
00110 DocWordCompletionPlugin::self()->setTreshold(sbAutoPopup->value());
00111 DocWordCompletionPlugin::self()->setAutoPopupEnabled(cbAutoPopup->isChecked());
00112 DocWordCompletionPlugin::self()->writeConfig();
00113 }
00114 else
00115 {
00116 KConfigGroup cg(KGlobal::config(), "DocWordCompletion Plugin");
00117 cg.writeEntry("treshold", sbAutoPopup->value());
00118 cg.writeEntry("autopopup", cbAutoPopup->isChecked());
00119 }
00120
00121 emit changed(false);
00122 }
00123
00124 void DocWordCompletionConfig::load()
00125 {
00126 if (DocWordCompletionPlugin::self())
00127 {
00128 DocWordCompletionPlugin::self()->readConfig();
00129 sbAutoPopup->setValue(DocWordCompletionPlugin::self()->treshold());
00130 cbAutoPopup->setChecked(DocWordCompletionPlugin::self()->autoPopupEnabled());
00131 }
00132 else
00133 {
00134 KConfigGroup cg(KGlobal::config(), "DocWordCompletion Plugin");
00135 sbAutoPopup->setValue(cg.readEntry("treshold", 3));
00136 cbAutoPopup->setChecked(cg.readEntry("autopopup", true));
00137 }
00138
00139 emit changed(false);
00140 }
00141
00142 void DocWordCompletionConfig::defaults()
00143 {
00144 cbAutoPopup->setChecked(true);
00145 sbAutoPopup->setValue(3);
00146
00147 emit changed(true);
00148 }
00149
00150 void DocWordCompletionConfig::slotChanged()
00151 {
00152 emit changed(true);
00153 }
00154
00155 #include "docwordcompletion_config.moc"