• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdespell2
 

tdespell2

configwidget.cpp
00001 /*
00002  * configwidget.cpp
00003  *
00004  * Copyright (C)  2004  Zack Rusin <zack@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00019  * 02110-1301  USA
00020  */
00021 #include "configwidget.h"
00022 #include "configui.h"
00023 
00024 #include "broker.h"
00025 #include "settings.h"
00026 
00027 #include <keditlistbox.h>
00028 #include <kcombobox.h>
00029 #include <tdelocale.h>
00030 
00031 #include <tqcheckbox.h>
00032 #include <tqlayout.h>
00033 
00034 using namespace KSpell2;
00035 
00036 class ConfigWidget::Private
00037 {
00038 public:
00039     Broker::Ptr broker;
00040     KSpell2ConfigUI *ui;
00041 };
00042 
00043 ConfigWidget::ConfigWidget( Broker *broker, TQWidget *parent, const char *name )
00044     : TQWidget( parent, name )
00045 {
00046     init( broker );
00047 }
00048 
00049 ConfigWidget::~ConfigWidget()
00050 {
00051     delete d; d = 0;
00052 }
00053 
00054 void ConfigWidget::init( Broker *broker )
00055 {
00056     d = new Private;
00057     d->broker = broker;
00058 
00059     TQVBoxLayout *layout = new TQVBoxLayout( this, 0, 0, "KSpell2ConfigUILayout");
00060     d->ui = new KSpell2ConfigUI( this );
00061 
00062     TQStringList langs = d->broker->languages();
00063     //TQStringList clients = d->broker->clients();
00064     d->ui->m_langCombo->insertStringList( langs );
00065     setCorrectLanguage( langs );
00066     //d->ui->m_clientCombo->insertStringList( clients );
00067     d->ui->m_skipUpperCB->setChecked( !d->broker->settings()->checkUppercase() );
00068     d->ui->m_skipRunTogetherCB->setChecked( d->broker->settings()->skipRunTogether() );
00069     TQStringList ignoreList = d->broker->settings()->currentIgnoreList();
00070     ignoreList.sort();
00071     d->ui->m_ignoreListBox->insertStringList( ignoreList );
00072     d->ui->m_bgSpellCB->setChecked( d->broker->settings()->backgroundCheckerEnabled() );
00073     d->ui->m_bgSpellCB->hide();//hidden by default
00074     connect( d->ui->m_ignoreListBox, TQT_SIGNAL(changed()), TQT_SLOT(slotChanged()) );
00075 
00076     layout->addWidget( d->ui );
00077 }
00078 
00079 void KSpell2::ConfigWidget::save()
00080 {
00081     setFromGUI();
00082     d->broker->settings()->save();
00083 }
00084 
00085 void ConfigWidget::setFromGUI()
00086 {
00087     d->broker->settings()->setDefaultLanguage(
00088         d->ui->m_langCombo->currentText() );
00089     d->broker->settings()->setCheckUppercase(
00090         !d->ui->m_skipUpperCB->isChecked() );
00091     d->broker->settings()->setSkipRunTogether(
00092         d->ui->m_skipRunTogetherCB->isChecked() );
00093     d->broker->settings()->setBackgroundCheckerEnabled(
00094         d->ui->m_bgSpellCB->isChecked() );
00095 }
00096 
00097 void ConfigWidget::slotChanged()
00098 {
00099     d->broker->settings()->setCurrentIgnoreList(
00100         d->ui->m_ignoreListBox->items() );
00101 }
00102 
00103 void ConfigWidget::setCorrectLanguage( const TQStringList& langs)
00104 {
00105     int idx = 0;
00106     for ( TQStringList::const_iterator itr = langs.begin();
00107           itr != langs.end(); ++itr, ++idx ) {
00108         if ( *itr == d->broker->settings()->defaultLanguage() )
00109             d->ui->m_langCombo->setCurrentItem( idx );
00110     }
00111 }
00112 
00113 void ConfigWidget::setBackgroundCheckingButtonShown( bool b )
00114 {
00115     d->ui->m_bgSpellCB->setShown( b );
00116 }
00117 
00118 bool ConfigWidget::backgroundCheckingButtonShown() const
00119 {
00120     return d->ui->m_bgSpellCB->isShown();
00121 }
00122 
00123 void ConfigWidget::slotDefault()
00124 {
00125     d->ui->m_skipUpperCB->setChecked( false );
00126     d->ui->m_skipRunTogetherCB->setChecked( false );
00127     d->ui->m_bgSpellCB->setChecked( true );
00128     d->ui->m_ignoreListBox->clear();
00129 }
00130 
00131 #include "configwidget.moc"

tdespell2

Skip menu "tdespell2"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

tdespell2

Skip menu "tdespell2"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdespell2 by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.