kspread

kspread_dlg_preference.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
00003              (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
00004              (C) 2002-2003 Norbert Andres <nandres@web.de>
00005              (C) 2000-2005 Laurent Montel <montel@kde.org>
00006              (C) 2002 John Dailey <dailey@vt.edu>
00007              (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
00008              (C) 2001-2002 David Faure <faure@kde.org>
00009              (C) 2001 Werner Trobin <trobin@kde.org>
00010              (C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
00011 
00012    This library is free software; you can redistribute it and/or
00013    modify it under the terms of the GNU Library General Public
00014    License as published by the Free Software Foundation; either
00015    version 2 of the License, or (at your option) any later version.
00016 
00017    This library is distributed in the hope that it will be useful,
00018    but WITHOUT ANY WARRANTY; without even the implied warranty of
00019    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020    Library General Public License for more details.
00021 
00022    You should have received a copy of the GNU Library General Public License
00023    along with this library; see the file COPYING.LIB.  If not, write to
00024    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00025  * Boston, MA 02110-1301, USA.
00026 */
00027 
00028 #include <qvbox.h>
00029 #include <qlayout.h>
00030 #include <qcheckbox.h>
00031 #include <qcombobox.h>
00032 #include <qvgroupbox.h>
00033 #include <qwhatsthis.h>
00034 
00035 #include <kconfig.h>
00036 #include <kstatusbar.h>
00037 #include <knuminput.h>
00038 #include <kspell.h>
00039 #include <kmessagebox.h>
00040 #include <kdeversion.h>
00041 #include <kcolorbutton.h>
00042 
00043 #include <KoTabBar.h>
00044 #include <KoSpeaker.h>
00045 
00046 #include "kspread_sheet.h"
00047 #include "kspread_sheetprint.h"
00048 #include "kspread_doc.h"
00049 #include "kspread_canvas.h"
00050 #include "kspread_view.h"
00051 #include "kspread_locale.h"
00052 #include "kspread_editors.h"
00053 
00054 #include "kspread_dlg_preference.h"
00055 
00056 using namespace KSpread;
00057 
00058 PreferenceDialog::PreferenceDialog( View* parent, const char* /*name*/)
00059   : KDialogBase(KDialogBase::IconList,i18n("Configure KSpread") ,
00060         KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
00061         KDialogBase::Ok)
00062 
00063 {
00064   m_pView=parent;
00065 
00066   connect(this, SIGNAL(okClicked()),this,SLOT(slotApply()));
00067 
00068   QVBox *page2=addVBoxPage(i18n("Locale Settings"), QString::null,BarIcon("gohome",KIcon::SizeMedium));
00069  _localePage=new parameterLocale(parent,page2 );
00070 
00071   QVBox *page3=addVBoxPage(i18n("Interface"), QString::null,BarIcon("signature", KIcon::SizeMedium) );
00072   _configure = new  configure(parent,page3 );
00073 
00074   QVBox * page4=addVBoxPage(i18n("Misc"), QString::null,BarIcon("misc",KIcon::SizeMedium) );
00075   _miscParameter = new  miscParameters(parent,page4 );
00076 
00077   QVBox *page5=addVBoxPage(i18n("Color"), QString::null,BarIcon("colorize",KIcon::SizeMedium) );
00078   _colorParameter=new colorParameters(parent,page5 );
00079 
00080   QVBox *page6=addVBoxPage(i18n("Page Layout"), QString::null,BarIcon("edit",KIcon::SizeMedium) );
00081   _layoutPage=new configureLayoutPage(parent,page6 );
00082 
00083   QVBox *page7 = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
00084                           BarIcon("spellcheck", KIcon::SizeMedium) );
00085   _spellPage=new configureSpellPage(parent,page7);
00086 
00087   if (KoSpeaker::isKttsdInstalled()) {
00088       QVBox *page8 = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"),
00089           i18n("Text-to-Speech Settings"), BarIcon("access", KIcon::SizeMedium) );
00090       _ttsPage=new configureTTSPage(parent, page8);
00091   } else _ttsPage = 0;
00092 
00093 }
00094 
00095 void PreferenceDialog::openPage(int flags)
00096 {
00097     if(flags & KS_LOCALE)
00098         showPage( 0 );
00099     else if(flags & KS_INTERFACE)
00100         showPage( 1 );
00101     else if(flags & KS_MISC)
00102         showPage( 2 );
00103     else if(flags & KS_COLOR)
00104         showPage( 3 );
00105     else if(flags & KS_LAYOUT)
00106         showPage( 4 );
00107     else if(flags & KS_SPELLING)
00108         showPage( 5 );
00109 }
00110 
00111 void PreferenceDialog::slotApply()
00112 {
00113   m_pView->doc()->emitBeginOperation( false );
00114   _configure->apply();
00115   _miscParameter->apply();
00116   _colorParameter->apply();
00117   _layoutPage->apply();
00118   _spellPage->apply();
00119   _localePage->apply();
00120   if (_ttsPage) _ttsPage->apply();
00121   m_pView->doc()->refreshInterface();
00122   m_pView->slotUpdateView( m_pView->activeSheet() );
00123 }
00124 
00125 void PreferenceDialog::slotDefault()
00126 {
00127     switch(activePageIndex())
00128     {
00129         case 1:
00130             _configure->slotDefault();
00131             break;
00132         case 2:
00133             _miscParameter->slotDefault();
00134             break;
00135         case 3:
00136             _colorParameter->slotDefault();
00137             break;
00138         case 4:
00139             _layoutPage->slotDefault();
00140             break;
00141         case 5:
00142             _spellPage->slotDefault();
00143             break;
00144         case 6:
00145             _ttsPage->slotDefault();
00146             break;
00147         default:
00148             break;
00149     }
00150 }
00151 
00152 
00153 parameterLocale::parameterLocale( View* _view, QVBox *box , char *name )
00154  :QObject ( box->parent(),name)
00155 {
00156     m_pView = _view;
00157     m_bUpdateLocale=false;
00158   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Settings"), box, "GroupBox" );
00159 
00160   KLocale* locale=_view->doc()->locale();
00161 
00162   m_language=new QLabel( tmpQGroupBox,"label");
00163   m_number=new QLabel( tmpQGroupBox,"label6");
00164   m_date=new QLabel( tmpQGroupBox,"label1");
00165   m_shortDate=new QLabel( tmpQGroupBox,"label5");
00166   m_time=new QLabel( tmpQGroupBox,"label2");
00167   m_money=new QLabel( tmpQGroupBox,"label3");
00168 
00169   updateToMatchLocale(locale);
00170   
00171   m_updateButton=new QPushButton ( i18n("&Update Locale Settings"), tmpQGroupBox);
00172   connect(m_updateButton, SIGNAL(clicked()),this,SLOT(updateDefaultSystemConfig()));
00173 }
00174 
00175 void parameterLocale::apply()
00176 {
00177     if (m_bUpdateLocale)
00178     {
00179         m_pView->doc()->emitBeginOperation( false );
00180         m_pView->doc()->refreshLocale();
00181         m_pView->slotUpdateView( m_pView->activeSheet() );
00182     }
00183 }
00184 
00185 void parameterLocale::updateDefaultSystemConfig()
00186 {
00187     m_bUpdateLocale=true;
00188     static_cast<Locale*>(m_pView->doc()->locale())->defaultSystemConfig( );
00189     KLocale* locale=m_pView->doc()->locale();
00190     updateToMatchLocale( locale );
00191 }
00192 
00193 void parameterLocale::updateToMatchLocale(KLocale* locale)
00194 {
00195   m_language->setText( i18n("Language: %1").arg( locale->language() ));
00196   m_number->setText( i18n("Default number format: %1").arg( locale->formatNumber(12.55) ));
00197   m_date->setText( i18n("Long date format: %1").arg( locale->formatDate( QDate::currentDate() )));
00198   m_shortDate->setText( i18n("Short date format: %1").arg( locale->formatDate( QDate::currentDate() ,true) ));
00199   m_time->setText( i18n("Time format: %1").arg( locale->formatTime( QTime::currentTime() ) ));
00200   m_money->setText( i18n("Currency format: %1").arg( locale->formatMoney(12.55) ));
00201 }
00202 
00203 configure::configure( View* _view, QVBox *box , char *name )
00204  :QObject ( box->parent(),name)
00205  {
00206   m_pView = _view;
00207 
00208   bool vertical=true;
00209   bool horizontal=true;
00210   bool rowHeader=true;
00211   bool colHeader=true;
00212   bool tabbar=true;
00213   bool formulaBar=true;
00214   bool statusBar=true;
00215   m_oldBackupFile = true;
00216 
00217   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Settings"), box, "GroupBox" );
00218 
00219   config = Factory::global()->config();
00220   int _page=1;
00221 
00222   oldRecent=10;
00223   oldAutoSaveValue=KoDocument::defaultAutoSave()/60;
00224 
00225   if( config->hasGroup("Parameters" ))
00226         {
00227         config->setGroup( "Parameters" );
00228         _page=config->readNumEntry( "NbPage" ,1) ;
00229         horizontal=config->readBoolEntry("Horiz ScrollBar",true);
00230         vertical=config->readBoolEntry("Vert ScrollBar",true);
00231         colHeader=config->readBoolEntry("Column Header",true);
00232         rowHeader=config->readBoolEntry("Row Header",true);
00233     tabbar=config->readBoolEntry("Tabbar",true);
00234     formulaBar=config->readBoolEntry("Formula bar",true);
00235         statusBar=config->readBoolEntry("Status bar",true);
00236         oldRecent=config->readNumEntry( "NbRecentFile" ,10);
00237         oldAutoSaveValue=config->readNumEntry("AutoSave",KoDocument::defaultAutoSave()/60);
00238         m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
00239         }
00240   nbPage=new KIntNumInput(_page, tmpQGroupBox , 10);
00241   nbPage->setRange(1, 10, 1);
00242   nbPage->setLabel(i18n("Number of sheets open at the &beginning:"));
00243   QWhatsThis::add(nbPage, i18n( "Controls how many worksheets will be created if the option Start with an empty document is chosen when KSpread is started." ) );
00244 
00245   nbRecentFile=new KIntNumInput(oldRecent, tmpQGroupBox , 10);
00246   nbRecentFile->setRange(1, 20, 1);
00247   nbRecentFile->setLabel(i18n("&Number of files to show in Recent Files list:"));
00248   QWhatsThis::add(nbRecentFile, i18n( "Controls the maximum number of filenames that are shown when you select File-> Open Recent." ) );
00249 
00250   autoSaveDelay=new KIntNumInput(oldAutoSaveValue, tmpQGroupBox , 10);
00251   autoSaveDelay->setRange(0, 60, 1);
00252   autoSaveDelay->setLabel(i18n("Au&tosave delay (minutes):"));
00253   autoSaveDelay->setSpecialValueText(i18n("Do not save automatically"));
00254   autoSaveDelay->setSuffix(i18n("min"));
00255   QWhatsThis::add(autoSaveDelay, i18n( "Here you can select the time between autosaves, or disable this feature altogether by choosing Do not save automatically (drag the slider to the far left)." ) );
00256 
00257   m_createBackupFile = new QCheckBox( i18n("Create backup files"), tmpQGroupBox );
00258   m_createBackupFile->setChecked( m_oldBackupFile );
00259   QWhatsThis::add(m_createBackupFile, i18n( "Check this box if you want some backup files created. This is checked per default." ) );
00260 
00261   showVScrollBar=new QCheckBox(i18n("Show &vertical scrollbar"),tmpQGroupBox);
00262   showVScrollBar->setChecked(vertical);
00263   QWhatsThis::add(showVScrollBar, i18n( "Check or uncheck this box to show or hide the vertical scrollbar in all sheets." ) );
00264 
00265   showHScrollBar=new QCheckBox(i18n("Show &horizontal scrollbar"),tmpQGroupBox);
00266   showHScrollBar->setChecked(horizontal);
00267   QWhatsThis::add(showHScrollBar, i18n( "Check or uncheck this box to show or hide the horizontal scrollbar in all sheets." ) );
00268 
00269   showColHeader=new QCheckBox(i18n("Show c&olumn header"),tmpQGroupBox);
00270   showColHeader->setChecked(colHeader);
00271   QWhatsThis::add(showColHeader, i18n( "Check this box to show the column letters across the top of each worksheet." ) );
00272   showRowHeader=new QCheckBox(i18n("Show &row header"),tmpQGroupBox);
00273   showRowHeader->setChecked(rowHeader);
00274   QWhatsThis::add(showRowHeader, i18n( "Check this box to show the row numbers down the left side." ) );
00275 
00276   showTabBar =new QCheckBox(i18n("Show ta&bs"),tmpQGroupBox);
00277   showTabBar->setChecked(tabbar);
00278   QWhatsThis::add(showTabBar, i18n( "This check box controls whether the sheet tabs are shown at the bottom of the worksheet." ) );
00279 
00280   showFormulaBar =new QCheckBox(i18n("Sho&w formula toolbar"),tmpQGroupBox);
00281   showFormulaBar->setChecked(formulaBar);
00282   QWhatsThis::add(showFormulaBar, i18n( "Here is where you can choose to show or hide the Formula bar." ) );
00283 
00284   showStatusBar =new QCheckBox(i18n("Show stat&us bar"),tmpQGroupBox);
00285   showStatusBar->setChecked(statusBar);
00286   QWhatsThis::add(showStatusBar, i18n( "Uncheck this box if you want to hide the status bar." ) );
00287 }
00288 
00289 
00290 void configure::slotDefault()
00291 {
00292   showHScrollBar->setChecked(true);
00293   showRowHeader->setChecked(true);
00294   showVScrollBar->setChecked(true);
00295   showColHeader->setChecked(true);
00296   showTabBar->setChecked(true);
00297   showFormulaBar->setChecked(true);
00298   showStatusBar->setChecked(true);
00299   nbPage->setValue(1);
00300   nbRecentFile->setValue(10);
00301   autoSaveDelay->setValue(KoDocument::defaultAutoSave()/60);
00302   m_createBackupFile->setChecked( true );
00303 }
00304 
00305 
00306 void configure::apply()
00307 {
00308     m_pView->doc()->emitBeginOperation( false );
00309     config->setGroup( "Parameters" );
00310     config->writeEntry( "NbPage", nbPage->value());
00311     Doc *doc =m_pView->doc();
00312     bool active=true;
00313     active=showHScrollBar->isChecked();
00314     if( m_pView->horzScrollBar()->isVisible()!=active)
00315     {
00316         config->writeEntry( "Horiz ScrollBar",active);
00317         if( active)
00318             m_pView->horzScrollBar()->show();
00319         else
00320             m_pView->horzScrollBar()->hide();
00321         doc->setShowHorizontalScrollBar(active);
00322     }
00323     active=showVScrollBar->isChecked();
00324     if( m_pView->vertScrollBar()->isVisible()!=active)
00325     {
00326         config->writeEntry( "Vert ScrollBar", active);
00327         if(active)
00328             m_pView->vertScrollBar()->show();
00329         else
00330             m_pView->vertScrollBar()->hide();
00331         doc->setShowVerticalScrollBar(active);
00332 
00333     }
00334     active=showColHeader->isChecked();
00335     if( m_pView->hBorderWidget()->isVisible()!=active)
00336     {
00337         config->writeEntry( "Column Header", active);
00338         if( active)
00339             m_pView->hBorderWidget()->show();
00340         else
00341             m_pView->hBorderWidget()->hide();
00342         doc->setShowColHeader(active);
00343     }
00344 
00345     active=showRowHeader->isChecked();
00346     if( m_pView->vBorderWidget()->isVisible()!=active)
00347     {
00348         config->writeEntry( "Row Header", active);
00349         if( active)
00350             m_pView->vBorderWidget()->show();
00351         else
00352             m_pView->vBorderWidget()->hide();
00353         doc->setShowRowHeader(active);
00354     }
00355 
00356     active=showTabBar->isChecked();
00357     if(m_pView->tabBar()->isVisible()!=active)
00358     {
00359         config->writeEntry( "Tabbar", active);
00360         if(active)
00361             m_pView->tabBar()->show();
00362         else
00363             m_pView->tabBar()->hide();
00364         doc->setShowTabBar(active);
00365     }
00366 
00367     active=showFormulaBar->isChecked();
00368     if(m_pView->posWidget()->isVisible()!=active)
00369     {
00370         config->writeEntry( "Formula bar",active);
00371         m_pView->editWidget()->showEditWidget(active);
00372         if(active)
00373             m_pView->posWidget()->show();
00374         else
00375             m_pView->posWidget()->hide();
00376         doc->setShowFormulaBar(active);
00377     }
00378 
00379     active=showStatusBar->isChecked();
00380     config->writeEntry( "Status bar",active);
00381     m_pView->showStatusBar( active );
00382 
00383     int val=nbRecentFile->value();
00384     if( oldRecent!= val)
00385     {
00386        config->writeEntry( "NbRecentFile",val);
00387        m_pView->changeNbOfRecentFiles(val);
00388     }
00389     val=autoSaveDelay->value();
00390     if(val!=oldAutoSaveValue)
00391     {
00392         config->writeEntry( "AutoSave", val );
00393         doc->setAutoSave(val*60);
00394     }
00395 
00396     bool state =m_createBackupFile->isChecked();
00397     if(state!=m_oldBackupFile)
00398     {
00399         config->writeEntry( "BackupFile", state );
00400         doc->setBackupFile( state);
00401         m_oldBackupFile=state;
00402     }
00403 
00404     m_pView->slotUpdateView( m_pView->activeSheet() );
00405 }
00406 
00407 
00408 miscParameters::miscParameters( View* _view,QVBox *box, char *name )
00409  :QObject ( box->parent(),name)
00410  {
00411   m_pView = _view;
00412 
00413 
00414   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Misc"), box, "GroupBox" );
00415 
00416   config = Factory::global()->config();
00417   indentUnit = _view->doc()->unit();
00418   double _indent = KoUnit::toUserValue( 10.0, indentUnit);
00419   bool m_bMsgError=false;
00420   if( config->hasGroup("Parameters" ))
00421         {
00422         config->setGroup( "Parameters" );
00423         _indent = config->readDoubleNumEntry( "Indent" , _indent ) ;
00424         m_bMsgError=config->readBoolEntry( "Msg error" ,false) ;
00425         }
00426 
00427   if( config->hasGroup("Misc") )
00428   {
00429    config->setGroup( "Misc" );
00430    m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
00431   }
00432 
00433   m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpQGroupBox );
00434   m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
00435   m_undoRedoLimit->setRange(10, 60, 1);
00436 
00437 
00438   QLabel *label=new QLabel(i18n("&Completion mode:"), tmpQGroupBox);
00439 
00440   typeCompletion=new QComboBox(tmpQGroupBox);
00441   label->setBuddy(typeCompletion);
00442   QWhatsThis::add(typeCompletion, i18n( "Lets you choose the (auto) text completion mode from a range of options in the drop down selection box." ) );
00443   QStringList listType;
00444   listType+=i18n("None");
00445   listType+=i18n("Manual");
00446   listType+=i18n("Popup");
00447   listType+=i18n("Automatic");
00448   listType+=i18n("Semi-Automatic");
00449   typeCompletion->insertStringList(listType);
00450   typeCompletion->setCurrentItem(0);
00451   comboChanged=false;
00452   connect(typeCompletion,SIGNAL(activated( const QString & )),this,SLOT(slotTextComboChanged(const QString &)));
00453 
00454   label=new QLabel(i18n("&Pressing enter moves cell cursor:"), tmpQGroupBox);
00455   typeOfMove=new QComboBox( tmpQGroupBox);
00456   label->setBuddy(typeOfMove);
00457   listType.clear();
00458   listType+=i18n("Down");
00459   listType+=i18n("Up");
00460   listType+=i18n("Right");
00461   listType+=i18n("Left");
00462   listType+=i18n("Down, First Column");
00463   typeOfMove->insertStringList(listType);
00464   typeOfMove->setCurrentItem(0);
00465   QWhatsThis::add(typeOfMove, i18n( "When you have selected a cell, pressing the Enter key will move the cell cursor one cell left, right, up or down, as determined by this setting." ) );
00466 
00467   label=new QLabel(i18n("&Method of calc:"), tmpQGroupBox);
00468 
00469   typeCalc=new QComboBox( tmpQGroupBox);
00470   label->setBuddy(typeCalc);
00471   QStringList listTypeCalc;
00472   listTypeCalc+=i18n("Sum");
00473   listTypeCalc+=i18n("Min");
00474   listTypeCalc+=i18n("Max");
00475   listTypeCalc+=i18n("Average");
00476   listTypeCalc+=i18n("Count");
00477   listTypeCalc+=i18n("CountA");
00478   listTypeCalc+=i18n("None");
00479   typeCalc->insertStringList(listTypeCalc);
00480   typeCalc->setCurrentItem(0);
00481   QWhatsThis::add(typeCalc, i18n( "This drop down selection box can be used to choose the calculation performed by the Statusbar Summary  function." ) );
00482 
00483 //   valIndent = new KDoubleNumInput( _indent, tmpQGroupBox , 10.0 );
00484   valIndent = new KDoubleNumInput( tmpQGroupBox );
00485   valIndent->setRange( KoUnit::toUserValue( 0.0, indentUnit ),
00486                        KoUnit::toUserValue( 400.0, indentUnit ),
00487                        KoUnit::toUserValue( 10.0, indentUnit) );
00488 //   valIndent->setRange( 0.0, 100.0, 10.0 );
00489   valIndent->setValue ( KoUnit::toUserValue( _indent, indentUnit ) );
00490   QWhatsThis::add(valIndent, i18n( "Lets you define the amount of indenting used by the Increase Indent and Decrease Indent option in the Format menu." ) );
00491   valIndent->setLabel(i18n("&Indentation step (%1):").arg(KoUnit::unitName(indentUnit)));
00492 
00493   msgError= new QCheckBox(i18n("&Show error message for invalid formulae"),tmpQGroupBox);
00494   msgError->setChecked(m_bMsgError);
00495   QWhatsThis::add(msgError, i18n( "If this box is checked a message box will pop up when what you have entered into a cell cannot be understood by KSpread." ) );
00496 
00497   initComboBox();
00498 }
00499 
00500 void miscParameters::slotTextComboChanged(const QString &)
00501 {
00502   comboChanged=true;
00503 }
00504 
00505 void miscParameters::initComboBox()
00506 {
00507   KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionAuto;
00508   if( config->hasGroup("Parameters" ))
00509     {
00510       config->setGroup( "Parameters" );
00511       tmpCompletion=( KGlobalSettings::Completion)config->readNumEntry( "Completion Mode" ,KGlobalSettings::CompletionAuto) ;
00512       config->writeEntry( "Completion Mode", (int)tmpCompletion);
00513     }
00514 switch(tmpCompletion )
00515         {
00516         case  KGlobalSettings::CompletionNone:
00517                 typeCompletion->setCurrentItem(0);
00518                 break;
00519         case  KGlobalSettings::CompletionAuto:
00520                 typeCompletion->setCurrentItem(3);
00521                 break;
00522         case  KGlobalSettings::CompletionMan:
00523                 typeCompletion->setCurrentItem(4);
00524                 break;
00525         case  KGlobalSettings::CompletionShell:
00526                 typeCompletion->setCurrentItem(1);
00527                 break;
00528         case  KGlobalSettings::CompletionPopup:
00529                 typeCompletion->setCurrentItem(2);
00530                 break;
00531         default :
00532                 typeCompletion->setCurrentItem(0);
00533                 break;
00534         }
00535 switch( m_pView->doc()->getMoveToValue( ))
00536         {
00537         case  Bottom:
00538                 typeOfMove->setCurrentItem(0);
00539                 break;
00540         case  Left:
00541                 typeOfMove->setCurrentItem(3);
00542                 break;
00543         case  Top:
00544                 typeOfMove->setCurrentItem(1);
00545                 break;
00546         case  Right:
00547                 typeOfMove->setCurrentItem(2);
00548                 break;
00549         case  BottomFirst:
00550                 typeOfMove->setCurrentItem(4);
00551                 break;
00552         default :
00553                 typeOfMove->setCurrentItem(0);
00554                 break;
00555         }
00556 
00557 switch( m_pView->doc()->getTypeOfCalc())
00558         {
00559         case  SumOfNumber:
00560                 typeCalc->setCurrentItem(0);
00561                 break;
00562         case  Min:
00563                 typeCalc->setCurrentItem(1);
00564                 break;
00565         case  Max:
00566                 typeCalc->setCurrentItem(2);
00567                 break;
00568         case  Average:
00569                 typeCalc->setCurrentItem(3);
00570                 break;
00571         case  Count:
00572             typeCalc->setCurrentItem(4);
00573                 break;
00574         case  CountA:
00575             typeCalc->setCurrentItem(5);
00576                 break;
00577         case  NoneCalc:
00578             typeCalc->setCurrentItem(6);
00579                 break;
00580         default :
00581                 typeCalc->setCurrentItem(0);
00582                 break;
00583         }
00584 
00585 }
00586 
00587 void miscParameters::slotDefault()
00588 {
00589   m_undoRedoLimit->setValue(30);
00590   valIndent->setValue( KoUnit::toUserValue( 10.0, indentUnit) );
00591   typeCompletion->setCurrentItem(3);
00592   typeOfMove->setCurrentItem(0);
00593   msgError->setChecked(false);
00594   typeCalc->setCurrentItem(0);
00595 }
00596 
00597 
00598 void miscParameters::apply()
00599 {
00600     kdDebug() << "Applying misc preferences" << endl;
00601 
00602     config->setGroup( "Misc" );
00603     int const newUndo=m_undoRedoLimit->value();
00604     if( newUndo!=m_oldNbRedo )
00605     {
00606         config->writeEntry("UndoRedo",newUndo);
00607         m_pView->doc()->setUndoRedoLimit(newUndo);
00608         m_oldNbRedo=newUndo;
00609     }
00610 
00611     config->setGroup( "Parameters" );
00612     KGlobalSettings::Completion tmpCompletion=KGlobalSettings::CompletionNone;
00613 
00614     switch(typeCompletion->currentItem())
00615     {
00616         case 0:
00617             tmpCompletion=KGlobalSettings::CompletionNone;
00618             break;
00619         case 1:
00620             tmpCompletion=KGlobalSettings::CompletionShell;
00621             break;
00622         case 2:
00623             tmpCompletion=KGlobalSettings::CompletionPopup;
00624             break;
00625         case 3:
00626             tmpCompletion=KGlobalSettings::CompletionAuto;
00627             break;
00628         case 4:
00629             tmpCompletion=KGlobalSettings::CompletionMan;
00630             break;
00631     }
00632 
00633 
00634     if(comboChanged)
00635     {
00636         m_pView->doc()->setCompletionMode(tmpCompletion);
00637         config->writeEntry( "Completion Mode", (int)tmpCompletion);
00638     }
00639 
00640     KSpread::MoveTo tmpMoveTo=Bottom;
00641     switch(typeOfMove->currentItem())
00642     {
00643         case 0:
00644             tmpMoveTo=Bottom;
00645             break;
00646         case 1:
00647             tmpMoveTo=Top;
00648             break;
00649         case 2:
00650             tmpMoveTo=Right;
00651             break;
00652         case 3:
00653             tmpMoveTo=Left;
00654             break;
00655         case 4:
00656             tmpMoveTo=BottomFirst;
00657             break;
00658     }
00659     if(tmpMoveTo!=m_pView->doc()->getMoveToValue())
00660     {
00661         m_pView->doc()->setMoveToValue(tmpMoveTo);
00662         config->writeEntry( "Move", (int)tmpMoveTo);
00663     }
00664 
00665     MethodOfCalc tmpMethodCalc=SumOfNumber;
00666     switch(typeCalc->currentItem())
00667     {
00668         case 0:
00669             tmpMethodCalc =SumOfNumber;
00670             break;
00671         case 1:
00672             tmpMethodCalc=Min;
00673             break;
00674         case 2:
00675             tmpMethodCalc=Max;
00676             break;
00677         case 3:
00678             tmpMethodCalc=Average;
00679             break;
00680         case 4:
00681             tmpMethodCalc=Count;
00682             break;
00683         case 5:
00684             tmpMethodCalc=CountA;
00685             break;
00686         case 6:
00687             tmpMethodCalc=NoneCalc;
00688             break;
00689 
00690     }
00691     if(tmpMethodCalc!=m_pView->doc()->getTypeOfCalc())
00692     {
00693         m_pView->doc()->setTypeOfCalc(tmpMethodCalc);
00694         config->writeEntry( "Method of Calc", (int)tmpMethodCalc);
00695         m_pView->calcStatusBarOp();
00696         m_pView->initCalcMenu();
00697     }
00698 
00699     double val = valIndent->value();
00700     if( val != m_pView->doc()->getIndentValue() )
00701     {
00702         KoUnit::Unit oldUnit = m_pView->doc()->unit();
00703         m_pView->doc()->setUnit(indentUnit);
00704         m_pView->doc()->setIndentValue( val );
00705         m_pView->doc()->setUnit(oldUnit);
00706         config->writeEntry( "Indent", KoUnit::fromUserValue( val, indentUnit ) );
00707     }
00708 
00709     bool active=msgError->isChecked();
00710     if(active!=m_pView->doc()->getShowMessageError())
00711     {
00712         m_pView->doc()->setShowMessageError( active);
00713         config->writeEntry( "Msg error" ,(int)active);
00714     }
00715 }
00716 
00717 
00718 
00719 colorParameters::colorParameters( View* _view,QVBox *box , char *name )
00720  :QObject ( box->parent(),name)
00721 {
00722   m_pView = _view;
00723   config = Factory::global()->config();
00724 
00725   QColor _gridColor(Qt::lightGray);
00726 
00727   if ( config->hasGroup("KSpread Color" ) )
00728   {
00729     config->setGroup( "KSpread Color" );
00730     _gridColor = config->readColorEntry("GridColor",&_gridColor);
00731   }
00732 
00733   QGroupBox* tmpQGroupBox = new QVGroupBox( i18n("Color"), box, "GroupBox" );
00734 
00735   QLabel *label = new QLabel(i18n("&Grid color:"), tmpQGroupBox,"label20" );
00736 
00737   gridColor = new KColorButton( _gridColor,
00738                                 Qt::lightGray,
00739                                 tmpQGroupBox );
00740   QWhatsThis::add(gridColor, i18n( "Click here to change the grid color ie the color of the borders of each cell." ) );
00741   label->setBuddy(gridColor);
00742 
00743   QColor _pbColor(Qt::red);
00744   if ( config->hasGroup("KSpread Color" ) )
00745   {
00746     config->setGroup( "KSpread Color" );
00747     _pbColor = config->readColorEntry("PageBorderColor", &_pbColor);
00748   }
00749 
00750   QLabel * label2 = new QLabel( i18n("&Page borders:"), tmpQGroupBox, "label21" );
00751 
00752   pageBorderColor = new KColorButton( _pbColor,
00753                                 Qt::red,
00754                                 tmpQGroupBox );
00755   QWhatsThis::add(pageBorderColor, i18n( "When the View ->Show Page Borders menu item is checked, the page borders are displayed. Click here to choose another color for the borders than the default red." ) );
00756 
00757   label2->setBuddy(pageBorderColor);
00758 }
00759 
00760 void colorParameters::apply()
00761 {
00762   QColor _col = gridColor->color();
00763   if ( m_pView->doc()->gridColor() != _col )
00764   {
00765     m_pView->doc()->setGridColor( _col );
00766     config->setGroup( "KSpread Color" );
00767     config->writeEntry( "GridColor", _col );
00768   }
00769 
00770   QColor _pbColor = pageBorderColor->color();
00771   if ( m_pView->doc()->pageBorderColor() != _pbColor )
00772   {
00773     m_pView->doc()->changePageBorderColor( _pbColor );
00774     config->setGroup( "KSpread Color" );
00775     config->writeEntry( "PageBorderColor", _pbColor );
00776   }
00777 }
00778 
00779 void colorParameters::slotDefault()
00780 {
00781   gridColor->setColor( lightGray );
00782   pageBorderColor->setColor( red );
00783 }
00784 
00785 
00786 
00787 configureLayoutPage::configureLayoutPage( View* _view,QVBox *box , char *name )
00788  :QObject ( box->parent(),name)
00789 {
00790   m_pView = _view;
00791 
00792   QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Default Parameters"), box, "GroupBox" );
00793   tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint());
00794   tmpQGroupBox->layout()->setMargin(KDialog::marginHint());
00795 
00796   QGridLayout *grid1 = new QGridLayout(tmpQGroupBox->layout(),8,1);
00797   grid1->addRowSpacing( 0, KDialog::marginHint()  );
00798   grid1->setRowStretch( 7, 10 );
00799 
00800   config = Factory::global()->config();
00801 
00802   QLabel *label=new QLabel(i18n("Default page &size:"), tmpQGroupBox);
00803 
00804   grid1->addWidget(label,0,0);
00805 
00806   defaultSizePage=new QComboBox( tmpQGroupBox);
00807   label->setBuddy(defaultSizePage);
00808   defaultSizePage->insertStringList( KoPageFormat::allFormats() );
00809   defaultSizePage->setCurrentItem(1);
00810   QWhatsThis::add(defaultSizePage, i18n( "Choose the default page size for your worksheet among all the most common page sizes.\nNote that you can overwrite the page size for the current sheet using the Format -> Page Layout... dialog." ) );
00811   grid1->addWidget(defaultSizePage,1,0);
00812 
00813   label=new QLabel(i18n("Default page &orientation:"), tmpQGroupBox);
00814   grid1->addWidget(label,2,0);
00815 
00816   defaultOrientationPage=new QComboBox( tmpQGroupBox);
00817   label->setBuddy(defaultOrientationPage);
00818   
00819   QStringList listType;
00820   listType+=i18n( "Portrait" );
00821   listType+=i18n( "Landscape" );
00822   defaultOrientationPage->insertStringList(listType);
00823   defaultOrientationPage->setCurrentItem(0);
00824   QWhatsThis::add(defaultOrientationPage, i18n( "Choose the sheet orientation: portrait or lanscape.\nNote that you can overwrite the orientation for the current sheet using the Format -> Page Layout... dialog." ) );
00825   grid1->addWidget(defaultOrientationPage,3,0);
00826 
00827   label=new QLabel(tmpQGroupBox);
00828   label->setText(i18n("Default page &unit:"));
00829   grid1->addWidget(label,4,0);
00830   defaultUnit=new QComboBox( tmpQGroupBox);
00831   label->setBuddy(defaultUnit);
00832   
00833   defaultUnit->insertStringList(KoUnit::listOfUnitName());
00834   defaultUnit->setCurrentItem(0);
00835   QWhatsThis::add(defaultUnit, i18n( "Choose the default unit that will be used in your sheet.\nNote that you can overwrite the unit for the current sheet using the Format -> Page Layout... dialog." ) );
00836   grid1->addWidget(defaultUnit,5,0);
00837   initCombo();
00838 
00839 }
00840 
00841 void configureLayoutPage::slotDefault()
00842 {
00843   defaultSizePage->setCurrentItem(1);
00844   defaultOrientationPage->setCurrentItem(0);
00845   defaultUnit->setCurrentItem(0);
00846 }
00847 
00848 void configureLayoutPage::initCombo()
00849 {
00850     paper=1;
00851     orientation=0;
00852     unit=0;
00853     if( config->hasGroup("KSpread Page Layout" ))
00854     {
00855         config->setGroup( "KSpread Page Layout" );
00856         paper=config->readNumEntry( "Default size page" ,1);
00857         orientation=config->readNumEntry( "Default orientation page" ,0);
00858         unit=config->readNumEntry( "Default unit page" ,0);
00859     }
00860 
00861     defaultUnit->setCurrentItem(m_pView->doc()->unit());
00862     defaultSizePage->setCurrentItem(paper);
00863     defaultOrientationPage->setCurrentItem(orientation);
00864 }
00865 
00866 
00867 void configureLayoutPage::apply()
00868 {
00869   m_pView->doc()->emitBeginOperation( false );
00870   config->setGroup( "KSpread Page Layout" );
00871 
00872   if( paper != defaultSizePage->currentItem() )
00873   {
00874      unsigned int sizePage = defaultSizePage->currentItem();
00875      config->writeEntry( "Default size page", sizePage );
00876      m_pView->activeSheet()->print()->setPaperFormat( (KoFormat)sizePage );
00877   }
00878   if( orientation != defaultOrientationPage->currentItem() )
00879   {
00880      unsigned int orientationPage = defaultOrientationPage->currentItem();
00881      config->writeEntry( "Default orientation page", orientationPage );
00882      m_pView->activeSheet()->print()->setPaperOrientation( (KoOrientation)orientationPage );
00883   }
00884   if( unit != defaultUnit->currentItem() )
00885   {
00886      unsigned int unitPage = defaultUnit->currentItem();
00887      config->writeEntry( "Default unit page", unitPage );
00888      m_pView->doc()->setUnit( (KoUnit::Unit)unitPage );
00889   }
00890   m_pView->slotUpdateView( m_pView->activeSheet() );
00891 }
00892 
00893 configureSpellPage::configureSpellPage( View* _view,QVBox *box , char *name )
00894  :QObject ( box->parent(),name)
00895 {
00896   m_pView = _view;
00897 
00898   config = Factory::global()->config();
00899 
00900 
00901   m_spellConfigWidget = new KSpellConfig( box, "spell_check",m_pView->doc()->getKSpellConfig()/*, false*/);
00902   dontCheckUpperWord = new QCheckBox( i18n("Skip all uppercase words"),box);
00903   QWhatsThis::add(dontCheckUpperWord, i18n( "If checked, the words written in uppercase letters are not spell checked. This might be useful if you have a lot of acronyms such as KDE for example." ) );
00904   dontCheckTitleCase = new QCheckBox( i18n("Do not check title case"),box);
00905   QWhatsThis::add(dontCheckTitleCase, i18n( "Check this box if you want the spellchecker to ignore the title case, for example My Own Spreadsheet or My own spreadsheet. If this is unchecked, the spell checker will ask for a uppercase letter in the title nouns." ) );
00906 
00907   QWidget* spacer = new QWidget( box );
00908   spacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
00909 
00910     if( config->hasGroup("KSpell kspread") )
00911     {
00912         config->setGroup( "KSpell kspread" );
00913 
00914         dontCheckUpperWord->setChecked(config->readBoolEntry("KSpell_dont_check_upper_word",false));
00915         dontCheckTitleCase->setChecked(config->readBoolEntry("KSpell_dont_check_title_case",false));
00916     }
00917     //m_spellConfigWidget->addIgnoreList( m_pView->doc()->spellListIgnoreAll() );
00918 }
00919 
00920 
00921 void configureSpellPage::apply()
00922 {
00923   m_pView->doc()->emitBeginOperation( false );
00924 
00925   KSpellConfig *_spellConfig = m_spellConfigWidget;
00926   config->setGroup( "KSpell kspread" );
00927   config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
00928   config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
00929   config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
00930   config->writeEntry ("KSpell_DictFromList",(int)  _spellConfig->dictFromList());
00931   config->writeEntry ("KSpell_Encoding", (int)  _spellConfig->encoding());
00932   config->writeEntry ("KSpell_Client",  _spellConfig->client());
00933 //  m_spellConfigWidget->saveDictionary();
00934   Doc* doc = m_pView->doc();
00935   doc->setKSpellConfig(*_spellConfig);
00936 
00937     bool state=dontCheckUpperWord->isChecked();
00938   config->writeEntry ("KSpell_dont_check_upper_word",(int)state);
00939   doc->setDontCheckUpperWord(state);
00940 
00941   state=dontCheckTitleCase->isChecked();
00942   config->writeEntry("KSpell_dont_check_title_case",(int)state);
00943   doc->setDontCheckTitleCase(state);
00944 
00945   //m_pView->doc()->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
00946 
00947   m_pView->slotUpdateView( m_pView->activeSheet() );
00948 }
00949 
00950 void configureSpellPage::slotDefault()
00951 {
00952     //FIXME
00953     //m_spellConfigWidget->setDefault();
00954 }
00955 
00957 
00958 configureTTSPage::configureTTSPage( View *_view, QVBox *box, char *name )
00959  : QObject( box->parent(), name )
00960 {
00961     Q_UNUSED(_view);
00962 
00963     m_cbSpeakPointerWidget = new QCheckBox(i18n("Speak widget under &mouse pointer"), box);
00964     m_cbSpeakFocusWidget = new QCheckBox(i18n("Speak widget with &focus"), box);
00965     m_gbScreenReaderOptions = new QVGroupBox("", box);
00966     m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
00967     m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
00968     m_cbSpeakTooltips = new QCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
00969     m_cbSpeakWhatsThis = new QCheckBox(i18n("Speak &What's This"), m_gbScreenReaderOptions);
00970     m_cbSpeakDisabled = new QCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
00971         "&Say whether disabled"), m_gbScreenReaderOptions);
00972     m_cbSpeakAccelerators = new QCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
00973     QHBox* hbAcceleratorPrefix = new QHBox(m_gbScreenReaderOptions);
00974     QWidget* spacer = new QWidget(hbAcceleratorPrefix);
00975     spacer->setMinimumWidth(2 * KDialog::marginHint());
00976     m_lblAcceleratorPrefix = 
00977         new QLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
00978         hbAcceleratorPrefix);
00979     m_leAcceleratorPrefixWord = new QLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
00980         hbAcceleratorPrefix);
00981     m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
00982     QHBox* hbPollingInterval = new QHBox(m_gbScreenReaderOptions);
00983     hbPollingInterval->setMargin( 0 );
00984     QLabel* lblPollingInterval = new QLabel(i18n("&Polling interval:"), hbPollingInterval);
00985     m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
00986     m_iniPollingInterval->setSuffix(" ms");
00987     m_iniPollingInterval->setRange(100, 5000, 100, true);
00988     lblPollingInterval->setBuddy(m_iniPollingInterval);
00989 
00990     config = Factory::global()->config();
00991     config->setGroup("TTS");
00992     m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
00993     m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
00994     m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
00995     m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
00996     m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
00997     m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
00998     m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
00999         i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
01000     m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
01001 
01002     screenReaderOptionChanged();
01003     connect(m_cbSpeakPointerWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
01004     connect(m_cbSpeakFocusWidget, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
01005     connect(m_cbSpeakAccelerators, SIGNAL(toggled(bool)), this, SLOT(screenReaderOptionChanged()));
01006 }
01007 
01008 void configureTTSPage::slotDefault()
01009 {
01010     m_cbSpeakPointerWidget->setChecked(false);
01011     m_cbSpeakFocusWidget->setChecked(false);
01012     m_cbSpeakTooltips->setChecked(true);
01013     m_cbSpeakWhatsThis->setChecked(false);
01014     m_cbSpeakDisabled->setChecked(true);
01015     m_cbSpeakAccelerators->setChecked(true);
01016     m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
01017     m_iniPollingInterval->setValue(600);
01018 }
01019 
01020 void configureTTSPage::apply()
01021 {
01022     config->setGroup("TTS");
01023     config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
01024     config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
01025     config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
01026     config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
01027     config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
01028     config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
01029     config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
01030     config->writeEntry("PollingInterval", m_iniPollingInterval->value());
01031     if (kospeaker) kospeaker->readConfig(config);
01032 }
01033 
01034 void configureTTSPage::screenReaderOptionChanged()
01035 {
01036     m_gbScreenReaderOptions->setEnabled(
01037         m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked());
01038     m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
01039     m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
01040 }
01041 
01042 #include "kspread_dlg_preference.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys