• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

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     hbTreshold = new KHBox( this );
00048     hbTreshold->setSpacing( KDialog::spacingHint() );
00049     lo->addWidget( hbTreshold );
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"), hbTreshold );
00058     sbAutoPopup = new QSpinBox( hbTreshold );
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."), hbTreshold );
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     // The reason for emitting the changed signal here is that this plugin adds a menu
00083     // entry "[x] Auto pop up completion list". As this setting is on the plugin
00084     // configuration dialog too, the behavior is the next:
00085     //
00086     // 1. This dialog is not going to show when opened the properties of the view.
00087     //    It is going to show the properties that will be applied to new views,
00088     //    and the properties that are going to be applied when opening Kate/Kwrite
00089     //    again.
00090     //
00091     // 2. If we go to the plugin configuration dialog and the state of this property
00092     //    is different than the one on the menu of the view, set the property view to this
00093     //    dialog property value only if we hit "OK". If this signal weren't emitted,
00094     //    KPluginSelector would just ignore the saving of the settings (because
00095     //    it considers that no changes were made to this dialog. Probably nobody
00096     //    clicked on any widget of this config dialog, but the properties values of this dialog
00097     //    and the view menu ones are different).
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     hbTreshold->setEnabled(cbAutoPopup->isChecked());
00153     emit changed(true);
00154 }
00155 
00156 #include "docwordcompletion_config.moc"

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal