kspread

kspread_dlg_preference.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
3 (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
4 (C) 2002-2003 Norbert Andres <nandres@web.de>
5 (C) 2000-2005 Laurent Montel <montel@kde.org>
6 (C) 2002 John Dailey <dailey@vt.edu>
7 (C) 2002 Philipp Mueller <philipp.mueller@gmx.de>
8 (C) 2001-2002 David Faure <faure@kde.org>
9 (C) 2001 Werner Trobin <trobin@kde.org>
10 (C) 2000 Bernd Johannes Wuebben <wuebben@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Library General Public License for more details.
21
22 You should have received a copy of the GNU Library General Public License
23 along with this library; see the file COPYING.LIB. If not, write to
24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 * Boston, MA 02110-1301, USA.
26*/
27
28#include <tqvbox.h>
29#include <tqlayout.h>
30#include <tqcheckbox.h>
31#include <tqcombobox.h>
32#include <tqvgroupbox.h>
33#include <tqwhatsthis.h>
34
35#include <tdeconfig.h>
36#include <kstatusbar.h>
37#include <knuminput.h>
38#include <tdespell.h>
39#include <tdemessagebox.h>
40#include <tdeversion.h>
41#include <kcolorbutton.h>
42
43#include <KoTabBar.h>
44#include <KoSpeaker.h>
45
46#include "kspread_sheet.h"
47#include "kspread_sheetprint.h"
48#include "kspread_doc.h"
49#include "kspread_canvas.h"
50#include "kspread_view.h"
51#include "kspread_locale.h"
52#include "kspread_editors.h"
53
54#include "kspread_dlg_preference.h"
55
56using namespace KSpread;
57
58PreferenceDialog::PreferenceDialog( View* parent, const char* /*name*/)
59 : KDialogBase(KDialogBase::IconList,i18n("Configure KSpread") ,
60 KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
61 KDialogBase::Ok)
62
63{
64 m_pView=parent;
65
66 connect(this, TQ_SIGNAL(okClicked()),this,TQ_SLOT(slotApply()));
67
68 TQVBox *page2=addVBoxPage(i18n("Locale Settings"), TQString(),BarIcon("go-home",TDEIcon::SizeMedium));
69 _localePage=new parameterLocale(parent,page2 );
70
71 TQVBox *page3=addVBoxPage(i18n("Interface"), TQString(),BarIcon("signature", TDEIcon::SizeMedium) );
72 _configure = new configure(parent,page3 );
73
74 TQVBox * page4=addVBoxPage(i18n("Misc"), TQString(),BarIcon("misc",TDEIcon::SizeMedium) );
75 _miscParameter = new miscParameters(parent,page4 );
76
77 TQVBox *page5=addVBoxPage(i18n("Color"), TQString(),BarIcon("colorize",TDEIcon::SizeMedium) );
78 _colorParameter=new colorParameters(parent,page5 );
79
80 TQVBox *page6=addVBoxPage(i18n("Page Layout"), TQString(),BarIcon("edit",TDEIcon::SizeMedium) );
81 _layoutPage=new configureLayoutPage(parent,page6 );
82
83 TQVBox *page7 = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
84 BarIcon("tools-check-spelling", TDEIcon::SizeMedium) );
85 _spellPage=new configureSpellPage(parent,page7);
86
87 if (KoSpeaker::isKttsdInstalled()) {
88 TQVBox *page8 = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"),
89 i18n("Text-to-Speech Settings"), BarIcon("access", TDEIcon::SizeMedium) );
90 _ttsPage=new configureTTSPage(parent, page8);
91 } else _ttsPage = 0;
92
93}
94
95void PreferenceDialog::openPage(int flags)
96{
97 if(flags & KS_LOCALE)
98 showPage( 0 );
99 else if(flags & KS_INTERFACE)
100 showPage( 1 );
101 else if(flags & KS_MISC)
102 showPage( 2 );
103 else if(flags & KS_COLOR)
104 showPage( 3 );
105 else if(flags & KS_LAYOUT)
106 showPage( 4 );
107 else if(flags & KS_SPELLING)
108 showPage( 5 );
109}
110
111void PreferenceDialog::slotApply()
112{
113 m_pView->doc()->emitBeginOperation( false );
114 _configure->apply();
115 _miscParameter->apply();
116 _colorParameter->apply();
117 _layoutPage->apply();
118 _spellPage->apply();
119 _localePage->apply();
120 if (_ttsPage) _ttsPage->apply();
121 m_pView->doc()->refreshInterface();
122 m_pView->slotUpdateView( m_pView->activeSheet() );
123}
124
125void PreferenceDialog::slotDefault()
126{
127 switch(activePageIndex())
128 {
129 case 1:
130 _configure->slotDefault();
131 break;
132 case 2:
133 _miscParameter->slotDefault();
134 break;
135 case 3:
136 _colorParameter->slotDefault();
137 break;
138 case 4:
139 _layoutPage->slotDefault();
140 break;
141 case 5:
142 _spellPage->slotDefault();
143 break;
144 case 6:
145 _ttsPage->slotDefault();
146 break;
147 default:
148 break;
149 }
150}
151
152
153parameterLocale::parameterLocale( View* _view, TQVBox *box , char *name )
154 :TQObject ( box->parent(),name)
155{
156 m_pView = _view;
157 m_bUpdateLocale=false;
158 TQGroupBox* tmpTQGroupBox = new TQVGroupBox( i18n("Settings"), box, "GroupBox" );
159
160 TDELocale* locale=_view->doc()->locale();
161
162 m_language=new TQLabel( tmpTQGroupBox,"label");
163 m_number=new TQLabel( tmpTQGroupBox,"label6");
164 m_date=new TQLabel( tmpTQGroupBox,"label1");
165 m_shortDate=new TQLabel( tmpTQGroupBox,"label5");
166 m_time=new TQLabel( tmpTQGroupBox,"label2");
167 m_money=new TQLabel( tmpTQGroupBox,"label3");
168
169 updateToMatchLocale(locale);
170
171 m_updateButton=new TQPushButton ( i18n("&Update Locale Settings"), tmpTQGroupBox);
172 connect(m_updateButton, TQ_SIGNAL(clicked()),this,TQ_SLOT(updateDefaultSystemConfig()));
173}
174
175void parameterLocale::apply()
176{
177 if (m_bUpdateLocale)
178 {
179 m_pView->doc()->emitBeginOperation( false );
180 m_pView->doc()->refreshLocale();
181 m_pView->slotUpdateView( m_pView->activeSheet() );
182 }
183}
184
185void parameterLocale::updateDefaultSystemConfig()
186{
187 m_bUpdateLocale=true;
188 static_cast<Locale*>(m_pView->doc()->locale())->defaultSystemConfig( );
189 TDELocale* locale=m_pView->doc()->locale();
190 updateToMatchLocale( locale );
191}
192
193void parameterLocale::updateToMatchLocale(TDELocale* locale)
194{
195 m_language->setText( i18n("Language: %1").arg( locale->language() ));
196 m_number->setText( i18n("Default number format: %1").arg( locale->formatNumber(12.55) ));
197 m_date->setText( i18n("Long date format: %1").arg( locale->formatDate( TQDate::currentDate() )));
198 m_shortDate->setText( i18n("Short date format: %1").arg( locale->formatDate( TQDate::currentDate() ,true) ));
199 m_time->setText( i18n("Time format: %1").arg( locale->formatTime( TQTime::currentTime() ) ));
200 m_money->setText( i18n("Currency format: %1").arg( locale->formatMoney(12.55) ));
201}
202
203configure::configure( View* _view, TQVBox *box , char *name )
204 :TQObject ( box->parent(),name)
205 {
206 m_pView = _view;
207
208 bool vertical=true;
209 bool horizontal=true;
210 bool rowHeader=true;
211 bool colHeader=true;
212 bool tabbar=true;
213 bool formulaBar=true;
214 bool statusBar=true;
215 m_oldBackupFile = true;
216
217 TQGroupBox* tmpTQGroupBox = new TQVGroupBox( i18n("Settings"), box, "GroupBox" );
218
219 config = Factory::global()->config();
220 int _page=1;
221
222 oldRecent=10;
223 oldAutoSaveValue=KoDocument::defaultAutoSave()/60;
224
225 if( config->hasGroup("Parameters" ))
226 {
227 config->setGroup( "Parameters" );
228 _page=config->readNumEntry( "NbPage" ,1) ;
229 horizontal=config->readBoolEntry("Horiz ScrollBar",true);
230 vertical=config->readBoolEntry("Vert ScrollBar",true);
231 colHeader=config->readBoolEntry("Column Header",true);
232 rowHeader=config->readBoolEntry("Row Header",true);
233 tabbar=config->readBoolEntry("Tabbar",true);
234 formulaBar=config->readBoolEntry("Formula bar",true);
235 statusBar=config->readBoolEntry("Status bar",true);
236 oldRecent=config->readNumEntry( "NbRecentFile" ,10);
237 oldAutoSaveValue=config->readNumEntry("AutoSave",KoDocument::defaultAutoSave()/60);
238 m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
239 }
240 nbPage=new KIntNumInput(_page, tmpTQGroupBox , 10);
241 nbPage->setRange(1, 10, 1);
242 nbPage->setLabel(i18n("Number of sheets open at the &beginning:"));
243 TQWhatsThis::add(nbPage, i18n( "Controls how many worksheets will be created if the option Start with an empty document is chosen when KSpread is started." ) );
244
245 nbRecentFile=new KIntNumInput(oldRecent, tmpTQGroupBox , 10);
246 nbRecentFile->setRange(1, 20, 1);
247 nbRecentFile->setLabel(i18n("&Number of files to show in Recent Files list:"));
248 TQWhatsThis::add(nbRecentFile, i18n( "Controls the maximum number of filenames that are shown when you select File-> Open Recent." ) );
249
250 autoSaveDelay=new KIntNumInput(oldAutoSaveValue, tmpTQGroupBox , 10);
251 autoSaveDelay->setRange(0, 60, 1);
252 autoSaveDelay->setLabel(i18n("Au&tosave delay (minutes):"));
253 autoSaveDelay->setSpecialValueText(i18n("Do not save automatically"));
254 autoSaveDelay->setSuffix(i18n("min"));
255 TQWhatsThis::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)." ) );
256
257 m_createBackupFile = new TQCheckBox( i18n("Create backup files"), tmpTQGroupBox );
258 m_createBackupFile->setChecked( m_oldBackupFile );
259 TQWhatsThis::add(m_createBackupFile, i18n( "Check this box if you want some backup files created. This is checked per default." ) );
260
261 showVScrollBar=new TQCheckBox(i18n("Show &vertical scrollbar"),tmpTQGroupBox);
262 showVScrollBar->setChecked(vertical);
263 TQWhatsThis::add(showVScrollBar, i18n( "Check or uncheck this box to show or hide the vertical scrollbar in all sheets." ) );
264
265 showHScrollBar=new TQCheckBox(i18n("Show &horizontal scrollbar"),tmpTQGroupBox);
266 showHScrollBar->setChecked(horizontal);
267 TQWhatsThis::add(showHScrollBar, i18n( "Check or uncheck this box to show or hide the horizontal scrollbar in all sheets." ) );
268
269 showColHeader=new TQCheckBox(i18n("Show c&olumn header"),tmpTQGroupBox);
270 showColHeader->setChecked(colHeader);
271 TQWhatsThis::add(showColHeader, i18n( "Check this box to show the column letters across the top of each worksheet." ) );
272 showRowHeader=new TQCheckBox(i18n("Show &row header"),tmpTQGroupBox);
273 showRowHeader->setChecked(rowHeader);
274 TQWhatsThis::add(showRowHeader, i18n( "Check this box to show the row numbers down the left side." ) );
275
276 showTabBar =new TQCheckBox(i18n("Show ta&bs"),tmpTQGroupBox);
277 showTabBar->setChecked(tabbar);
278 TQWhatsThis::add(showTabBar, i18n( "This check box controls whether the sheet tabs are shown at the bottom of the worksheet." ) );
279
280 showFormulaBar =new TQCheckBox(i18n("Sho&w formula toolbar"),tmpTQGroupBox);
281 showFormulaBar->setChecked(formulaBar);
282 TQWhatsThis::add(showFormulaBar, i18n( "Here is where you can choose to show or hide the Formula bar." ) );
283
284 showStatusBar =new TQCheckBox(i18n("Show stat&us bar"),tmpTQGroupBox);
285 showStatusBar->setChecked(statusBar);
286 TQWhatsThis::add(showStatusBar, i18n( "Uncheck this box if you want to hide the status bar." ) );
287}
288
289
290void configure::slotDefault()
291{
292 showHScrollBar->setChecked(true);
293 showRowHeader->setChecked(true);
294 showVScrollBar->setChecked(true);
295 showColHeader->setChecked(true);
296 showTabBar->setChecked(true);
297 showFormulaBar->setChecked(true);
298 showStatusBar->setChecked(true);
299 nbPage->setValue(1);
300 nbRecentFile->setValue(10);
301 autoSaveDelay->setValue(KoDocument::defaultAutoSave()/60);
302 m_createBackupFile->setChecked( true );
303}
304
305
306void configure::apply()
307{
308 m_pView->doc()->emitBeginOperation( false );
309 config->setGroup( "Parameters" );
310 config->writeEntry( "NbPage", nbPage->value());
311 Doc *doc =m_pView->doc();
312 bool active=true;
313 active=showHScrollBar->isChecked();
314 if( m_pView->horzScrollBar()->isVisible()!=active)
315 {
316 config->writeEntry( "Horiz ScrollBar",active);
317 if( active)
318 m_pView->horzScrollBar()->show();
319 else
320 m_pView->horzScrollBar()->hide();
321 doc->setShowHorizontalScrollBar(active);
322 }
323 active=showVScrollBar->isChecked();
324 if( m_pView->vertScrollBar()->isVisible()!=active)
325 {
326 config->writeEntry( "Vert ScrollBar", active);
327 if(active)
328 m_pView->vertScrollBar()->show();
329 else
330 m_pView->vertScrollBar()->hide();
331 doc->setShowVerticalScrollBar(active);
332
333 }
334 active=showColHeader->isChecked();
335 if( m_pView->hBorderWidget()->isVisible()!=active)
336 {
337 config->writeEntry( "Column Header", active);
338 if( active)
339 m_pView->hBorderWidget()->show();
340 else
341 m_pView->hBorderWidget()->hide();
342 doc->setShowColHeader(active);
343 }
344
345 active=showRowHeader->isChecked();
346 if( m_pView->vBorderWidget()->isVisible()!=active)
347 {
348 config->writeEntry( "Row Header", active);
349 if( active)
350 m_pView->vBorderWidget()->show();
351 else
352 m_pView->vBorderWidget()->hide();
353 doc->setShowRowHeader(active);
354 }
355
356 active=showTabBar->isChecked();
357 if(m_pView->tabBar()->isVisible()!=active)
358 {
359 config->writeEntry( "Tabbar", active);
360 if(active)
361 m_pView->tabBar()->show();
362 else
363 m_pView->tabBar()->hide();
364 doc->setShowTabBar(active);
365 }
366
367 active=showFormulaBar->isChecked();
368 if(m_pView->posWidget()->isVisible()!=active)
369 {
370 config->writeEntry( "Formula bar",active);
371 m_pView->editWidget()->showEditWidget(active);
372 if(active)
373 m_pView->posWidget()->show();
374 else
375 m_pView->posWidget()->hide();
376 doc->setShowFormulaBar(active);
377 }
378
379 active=showStatusBar->isChecked();
380 config->writeEntry( "Status bar",active);
381 m_pView->showStatusBar( active );
382
383 int val=nbRecentFile->value();
384 if( oldRecent!= val)
385 {
386 config->writeEntry( "NbRecentFile",val);
387 m_pView->changeNbOfRecentFiles(val);
388 }
389 val=autoSaveDelay->value();
390 if(val!=oldAutoSaveValue)
391 {
392 config->writeEntry( "AutoSave", val );
393 doc->setAutoSave(val*60);
394 }
395
396 bool state =m_createBackupFile->isChecked();
397 if(state!=m_oldBackupFile)
398 {
399 config->writeEntry( "BackupFile", state );
400 doc->setBackupFile( state);
401 m_oldBackupFile=state;
402 }
403
404 m_pView->slotUpdateView( m_pView->activeSheet() );
405}
406
407
408miscParameters::miscParameters( View* _view,TQVBox *box, char *name )
409 :TQObject ( box->parent(),name)
410 {
411 m_pView = _view;
412
413
414 TQGroupBox* tmpTQGroupBox = new TQVGroupBox( i18n("Misc"), box, "GroupBox" );
415
416 config = Factory::global()->config();
417 indentUnit = _view->doc()->unit();
418 double _indent = KoUnit::toUserValue( 10.0, indentUnit);
419 bool m_bMsgError=false;
420 if( config->hasGroup("Parameters" ))
421 {
422 config->setGroup( "Parameters" );
423 _indent = config->readDoubleNumEntry( "Indent" , _indent ) ;
424 m_bMsgError=config->readBoolEntry( "Msg error" ,false) ;
425 }
426
427 if( config->hasGroup("Misc") )
428 {
429 config->setGroup( "Misc" );
430 m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
431 }
432
433 m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpTQGroupBox );
434 m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
435 m_undoRedoLimit->setRange(10, 60, 1);
436
437
438 TQLabel *label=new TQLabel(i18n("&Completion mode:"), tmpTQGroupBox);
439
440 typeCompletion=new TQComboBox(tmpTQGroupBox);
441 label->setBuddy(typeCompletion);
442 TQWhatsThis::add(typeCompletion, i18n( "Lets you choose the (auto) text completion mode from a range of options in the drop down selection box." ) );
443 TQStringList listType;
444 listType+=i18n("None");
445 listType+=i18n("Manual");
446 listType+=i18n("Popup");
447 listType+=i18n("Automatic");
448 listType+=i18n("Semi-Automatic");
449 typeCompletion->insertStringList(listType);
450 typeCompletion->setCurrentItem(0);
451 comboChanged=false;
452 connect(typeCompletion,TQ_SIGNAL(activated( const TQString & )),this,TQ_SLOT(slotTextComboChanged(const TQString &)));
453
454 label=new TQLabel(i18n("&Pressing enter moves cell cursor:"), tmpTQGroupBox);
455 typeOfMove=new TQComboBox( tmpTQGroupBox);
456 label->setBuddy(typeOfMove);
457 listType.clear();
458 listType+=i18n("Down");
459 listType+=i18n("Up");
460 listType+=i18n("Right");
461 listType+=i18n("Left");
462 listType+=i18n("Down, First Column");
463 typeOfMove->insertStringList(listType);
464 typeOfMove->setCurrentItem(0);
465 TQWhatsThis::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." ) );
466
467 label=new TQLabel(i18n("&Method of calc:"), tmpTQGroupBox);
468
469 typeCalc=new TQComboBox( tmpTQGroupBox);
470 label->setBuddy(typeCalc);
471 TQStringList listTypeCalc;
472 listTypeCalc+=i18n("Sum");
473 listTypeCalc+=i18n("Min");
474 listTypeCalc+=i18n("Max");
475 listTypeCalc+=i18n("Average");
476 listTypeCalc+=i18n("Count");
477 listTypeCalc+=i18n("CountA");
478 listTypeCalc+=i18n("None");
479 typeCalc->insertStringList(listTypeCalc);
480 typeCalc->setCurrentItem(0);
481 TQWhatsThis::add(typeCalc, i18n( "This drop down selection box can be used to choose the calculation performed by the Statusbar Summary function." ) );
482
483// valIndent = new KDoubleNumInput( _indent, tmpTQGroupBox , 10.0 );
484 valIndent = new KDoubleNumInput( tmpTQGroupBox );
485 valIndent->setRange( KoUnit::toUserValue( 0.0, indentUnit ),
486 KoUnit::toUserValue( 400.0, indentUnit ),
487 KoUnit::toUserValue( 10.0, indentUnit) );
488// valIndent->setRange( 0.0, 100.0, 10.0 );
489 valIndent->setValue ( KoUnit::toUserValue( _indent, indentUnit ) );
490 TQWhatsThis::add(valIndent, i18n( "Lets you define the amount of indenting used by the Increase Indent and Decrease Indent option in the Format menu." ) );
491 valIndent->setLabel(i18n("&Indentation step (%1):").arg(KoUnit::unitName(indentUnit)));
492
493 msgError= new TQCheckBox(i18n("&Show error message for invalid formulae"),tmpTQGroupBox);
494 msgError->setChecked(m_bMsgError);
495 TQWhatsThis::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." ) );
496
497 initComboBox();
498}
499
500void miscParameters::slotTextComboChanged(const TQString &)
501{
502 comboChanged=true;
503}
504
505void miscParameters::initComboBox()
506{
507 TDEGlobalSettings::Completion tmpCompletion=TDEGlobalSettings::CompletionAuto;
508 if( config->hasGroup("Parameters" ))
509 {
510 config->setGroup( "Parameters" );
511 tmpCompletion=( TDEGlobalSettings::Completion)config->readNumEntry( "Completion Mode" ,TDEGlobalSettings::CompletionAuto) ;
512 config->writeEntry( "Completion Mode", (int)tmpCompletion);
513 }
514switch(tmpCompletion )
515 {
516 case TDEGlobalSettings::CompletionNone:
517 typeCompletion->setCurrentItem(0);
518 break;
519 case TDEGlobalSettings::CompletionAuto:
520 typeCompletion->setCurrentItem(3);
521 break;
522 case TDEGlobalSettings::CompletionMan:
523 typeCompletion->setCurrentItem(4);
524 break;
525 case TDEGlobalSettings::CompletionShell:
526 typeCompletion->setCurrentItem(1);
527 break;
528 case TDEGlobalSettings::CompletionPopup:
529 typeCompletion->setCurrentItem(2);
530 break;
531 default :
532 typeCompletion->setCurrentItem(0);
533 break;
534 }
535switch( m_pView->doc()->getMoveToValue( ))
536 {
537 case KSpread::Bottom:
538 typeOfMove->setCurrentItem(0);
539 break;
540 case KSpread::Left:
541 typeOfMove->setCurrentItem(3);
542 break;
543 case KSpread::Top:
544 typeOfMove->setCurrentItem(1);
545 break;
546 case KSpread::Right:
547 typeOfMove->setCurrentItem(2);
548 break;
549 case KSpread::BottomFirst:
550 typeOfMove->setCurrentItem(4);
551 break;
552 default :
553 typeOfMove->setCurrentItem(0);
554 break;
555 }
556
557switch( m_pView->doc()->getTypeOfCalc())
558 {
559 case SumOfNumber:
560 typeCalc->setCurrentItem(0);
561 break;
562 case Min:
563 typeCalc->setCurrentItem(1);
564 break;
565 case Max:
566 typeCalc->setCurrentItem(2);
567 break;
568 case Average:
569 typeCalc->setCurrentItem(3);
570 break;
571 case Count:
572 typeCalc->setCurrentItem(4);
573 break;
574 case CountA:
575 typeCalc->setCurrentItem(5);
576 break;
577 case NoneCalc:
578 typeCalc->setCurrentItem(6);
579 break;
580 default :
581 typeCalc->setCurrentItem(0);
582 break;
583 }
584
585}
586
587void miscParameters::slotDefault()
588{
589 m_undoRedoLimit->setValue(30);
590 valIndent->setValue( KoUnit::toUserValue( 10.0, indentUnit) );
591 typeCompletion->setCurrentItem(3);
592 typeOfMove->setCurrentItem(0);
593 msgError->setChecked(false);
594 typeCalc->setCurrentItem(0);
595}
596
597
598void miscParameters::apply()
599{
600 kdDebug() << "Applying misc preferences" << endl;
601
602 config->setGroup( "Misc" );
603 int const newUndo=m_undoRedoLimit->value();
604 if( newUndo!=m_oldNbRedo )
605 {
606 config->writeEntry("UndoRedo",newUndo);
607 m_pView->doc()->setUndoRedoLimit(newUndo);
608 m_oldNbRedo=newUndo;
609 }
610
611 config->setGroup( "Parameters" );
612 TDEGlobalSettings::Completion tmpCompletion=TDEGlobalSettings::CompletionNone;
613
614 switch(typeCompletion->currentItem())
615 {
616 case 0:
617 tmpCompletion=TDEGlobalSettings::CompletionNone;
618 break;
619 case 1:
620 tmpCompletion=TDEGlobalSettings::CompletionShell;
621 break;
622 case 2:
623 tmpCompletion=TDEGlobalSettings::CompletionPopup;
624 break;
625 case 3:
626 tmpCompletion=TDEGlobalSettings::CompletionAuto;
627 break;
628 case 4:
629 tmpCompletion=TDEGlobalSettings::CompletionMan;
630 break;
631 }
632
633
634 if(comboChanged)
635 {
636 m_pView->doc()->setCompletionMode(tmpCompletion);
637 config->writeEntry( "Completion Mode", (int)tmpCompletion);
638 }
639
640 KSpread::MoveTo tmpMoveTo=KSpread::Bottom;
641 switch(typeOfMove->currentItem())
642 {
643 case 0:
644 tmpMoveTo=KSpread::Bottom;
645 break;
646 case 1:
647 tmpMoveTo=KSpread::Top;
648 break;
649 case 2:
650 tmpMoveTo=KSpread::Right;
651 break;
652 case 3:
653 tmpMoveTo=KSpread::Left;
654 break;
655 case 4:
656 tmpMoveTo=KSpread::BottomFirst;
657 break;
658 }
659 if(tmpMoveTo!=m_pView->doc()->getMoveToValue())
660 {
661 m_pView->doc()->setMoveToValue(tmpMoveTo);
662 config->writeEntry( "Move", (int)tmpMoveTo);
663 }
664
665 MethodOfCalc tmpMethodCalc=SumOfNumber;
666 switch(typeCalc->currentItem())
667 {
668 case 0:
669 tmpMethodCalc =SumOfNumber;
670 break;
671 case 1:
672 tmpMethodCalc=Min;
673 break;
674 case 2:
675 tmpMethodCalc=Max;
676 break;
677 case 3:
678 tmpMethodCalc=Average;
679 break;
680 case 4:
681 tmpMethodCalc=Count;
682 break;
683 case 5:
684 tmpMethodCalc=CountA;
685 break;
686 case 6:
687 tmpMethodCalc=NoneCalc;
688 break;
689
690 }
691 if(tmpMethodCalc!=m_pView->doc()->getTypeOfCalc())
692 {
693 m_pView->doc()->setTypeOfCalc(tmpMethodCalc);
694 config->writeEntry( "Method of Calc", (int)tmpMethodCalc);
695 m_pView->calcStatusBarOp();
696 m_pView->initCalcMenu();
697 }
698
699 double val = valIndent->value();
700 if( val != m_pView->doc()->getIndentValue() )
701 {
702 KoUnit::Unit oldUnit = m_pView->doc()->unit();
703 m_pView->doc()->setUnit(indentUnit);
704 m_pView->doc()->setIndentValue( val );
705 m_pView->doc()->setUnit(oldUnit);
706 config->writeEntry( "Indent", KoUnit::fromUserValue( val, indentUnit ) );
707 }
708
709 bool active=msgError->isChecked();
710 if(active!=m_pView->doc()->getShowMessageError())
711 {
712 m_pView->doc()->setShowMessageError( active);
713 config->writeEntry( "Msg error" ,(int)active);
714 }
715}
716
717
718
719colorParameters::colorParameters( View* _view,TQVBox *box , char *name )
720 :TQObject ( box->parent(),name)
721{
722 m_pView = _view;
723 config = Factory::global()->config();
724
725 TQColor _gridColor(TQt::lightGray);
726
727 if ( config->hasGroup("KSpread Color" ) )
728 {
729 config->setGroup( "KSpread Color" );
730 _gridColor = config->readColorEntry("GridColor",&_gridColor);
731 }
732
733 TQGroupBox* tmpTQGroupBox = new TQVGroupBox( i18n("Color"), box, "GroupBox" );
734
735 TQLabel *label = new TQLabel(i18n("&Grid color:"), tmpTQGroupBox,"label20" );
736
737 gridColor = new KColorButton( _gridColor,
738 TQt::lightGray,
739 tmpTQGroupBox );
740 TQWhatsThis::add(gridColor, i18n( "Click here to change the grid color ie the color of the borders of each cell." ) );
741 label->setBuddy(gridColor);
742
743 TQColor _pbColor(TQt::red);
744 if ( config->hasGroup("KSpread Color" ) )
745 {
746 config->setGroup( "KSpread Color" );
747 _pbColor = config->readColorEntry("PageBorderColor", &_pbColor);
748 }
749
750 TQLabel * label2 = new TQLabel( i18n("&Page borders:"), tmpTQGroupBox, "label21" );
751
752 pageBorderColor = new KColorButton( _pbColor,
753 TQt::red,
754 tmpTQGroupBox );
755 TQWhatsThis::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." ) );
756
757 label2->setBuddy(pageBorderColor);
758}
759
760void colorParameters::apply()
761{
762 TQColor _col = gridColor->color();
763 if ( m_pView->doc()->gridColor() != _col )
764 {
765 m_pView->doc()->setGridColor( _col );
766 config->setGroup( "KSpread Color" );
767 config->writeEntry( "GridColor", _col );
768 }
769
770 TQColor _pbColor = pageBorderColor->color();
771 if ( m_pView->doc()->pageBorderColor() != _pbColor )
772 {
773 m_pView->doc()->changePageBorderColor( _pbColor );
774 config->setGroup( "KSpread Color" );
775 config->writeEntry( "PageBorderColor", _pbColor );
776 }
777}
778
779void colorParameters::slotDefault()
780{
781 gridColor->setColor( lightGray );
782 pageBorderColor->setColor( red );
783}
784
785
786
787configureLayoutPage::configureLayoutPage( View* _view,TQVBox *box , char *name )
788 :TQObject ( box->parent(),name)
789{
790 m_pView = _view;
791
792 TQGroupBox* tmpTQGroupBox = new TQGroupBox( 0, TQt::Vertical, i18n("Default Parameters"), box, "GroupBox" );
793 tmpTQGroupBox->layout()->setSpacing(KDialog::spacingHint());
794 tmpTQGroupBox->layout()->setMargin(KDialog::marginHint());
795
796 TQGridLayout *grid1 = new TQGridLayout(tmpTQGroupBox->layout(),8,1);
797 grid1->addRowSpacing( 0, KDialog::marginHint() );
798 grid1->setRowStretch( 7, 10 );
799
800 config = Factory::global()->config();
801
802 TQLabel *label=new TQLabel(i18n("Default page &size:"), tmpTQGroupBox);
803
804 grid1->addWidget(label,0,0);
805
806 defaultSizePage=new TQComboBox( tmpTQGroupBox);
807 label->setBuddy(defaultSizePage);
808 defaultSizePage->insertStringList( KoPageFormat::allFormats() );
809 defaultSizePage->setCurrentItem(1);
810 TQWhatsThis::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." ) );
811 grid1->addWidget(defaultSizePage,1,0);
812
813 label=new TQLabel(i18n("Default page &orientation:"), tmpTQGroupBox);
814 grid1->addWidget(label,2,0);
815
816 defaultOrientationPage=new TQComboBox( tmpTQGroupBox);
817 label->setBuddy(defaultOrientationPage);
818
819 TQStringList listType;
820 listType+=i18n( "Portrait" );
821 listType+=i18n( "Landscape" );
822 defaultOrientationPage->insertStringList(listType);
823 defaultOrientationPage->setCurrentItem(0);
824 TQWhatsThis::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." ) );
825 grid1->addWidget(defaultOrientationPage,3,0);
826
827 label=new TQLabel(tmpTQGroupBox);
828 label->setText(i18n("Default page &unit:"));
829 grid1->addWidget(label,4,0);
830 defaultUnit=new TQComboBox( tmpTQGroupBox);
831 label->setBuddy(defaultUnit);
832
833 defaultUnit->insertStringList(KoUnit::listOfUnitName());
834 defaultUnit->setCurrentItem(0);
835 TQWhatsThis::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." ) );
836 grid1->addWidget(defaultUnit,5,0);
837 initCombo();
838
839}
840
841void configureLayoutPage::slotDefault()
842{
843 defaultSizePage->setCurrentItem(1);
844 defaultOrientationPage->setCurrentItem(0);
845 defaultUnit->setCurrentItem(0);
846}
847
848void configureLayoutPage::initCombo()
849{
850 paper=1;
851 orientation=0;
852 unit=0;
853 if( config->hasGroup("KSpread Page Layout" ))
854 {
855 config->setGroup( "KSpread Page Layout" );
856 paper=config->readNumEntry( "Default size page" ,1);
857 orientation=config->readNumEntry( "Default orientation page" ,0);
858 unit=config->readNumEntry( "Default unit page" ,0);
859 }
860
861 defaultUnit->setCurrentItem(m_pView->doc()->unit());
862 defaultSizePage->setCurrentItem(paper);
863 defaultOrientationPage->setCurrentItem(orientation);
864}
865
866
867void configureLayoutPage::apply()
868{
869 m_pView->doc()->emitBeginOperation( false );
870 config->setGroup( "KSpread Page Layout" );
871
872 if( paper != defaultSizePage->currentItem() )
873 {
874 unsigned int sizePage = defaultSizePage->currentItem();
875 config->writeEntry( "Default size page", sizePage );
876 m_pView->activeSheet()->print()->setPaperFormat( (KoFormat)sizePage );
877 }
878 if( orientation != defaultOrientationPage->currentItem() )
879 {
880 unsigned int orientationPage = defaultOrientationPage->currentItem();
881 config->writeEntry( "Default orientation page", orientationPage );
882 m_pView->activeSheet()->print()->setPaperOrientation( (KoOrientation)orientationPage );
883 }
884 if( unit != defaultUnit->currentItem() )
885 {
886 unsigned int unitPage = defaultUnit->currentItem();
887 config->writeEntry( "Default unit page", unitPage );
888 m_pView->doc()->setUnit( (KoUnit::Unit)unitPage );
889 }
890 m_pView->slotUpdateView( m_pView->activeSheet() );
891}
892
893configureSpellPage::configureSpellPage( View* _view,TQVBox *box , char *name )
894 :TQObject ( box->parent(),name)
895{
896 m_pView = _view;
897
898 config = Factory::global()->config();
899
900
901 m_spellConfigWidget = new KSpellConfig( box, "spell_check",m_pView->doc()->getKSpellConfig()/*, false*/);
902 dontCheckUpperWord = new TQCheckBox( i18n("Skip all uppercase words"),box);
903 TQWhatsThis::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 TDE for example." ) );
904 dontCheckTitleCase = new TQCheckBox( i18n("Do not check title case"),box);
905 TQWhatsThis::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." ) );
906
907 TQWidget* spacer = new TQWidget( box );
908 spacer->setSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Expanding ) );
909
910 if( config->hasGroup("KSpell kspread") )
911 {
912 config->setGroup( "KSpell kspread" );
913
914 dontCheckUpperWord->setChecked(config->readBoolEntry("KSpell_dont_check_upper_word",false));
915 dontCheckTitleCase->setChecked(config->readBoolEntry("KSpell_dont_check_title_case",false));
916 }
917 //m_spellConfigWidget->addIgnoreList( m_pView->doc()->spellListIgnoreAll() );
918}
919
920
921void configureSpellPage::apply()
922{
923 m_pView->doc()->emitBeginOperation( false );
924
925 KSpellConfig *_spellConfig = m_spellConfigWidget;
926 config->setGroup( "KSpell kspread" );
927 config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
928 config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
929 config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
930 config->writeEntry ("KSpell_DictFromList",(int) _spellConfig->dictFromList());
931 config->writeEntry ("KSpell_Encoding", (int) _spellConfig->encoding());
932 config->writeEntry ("KSpell_Client", _spellConfig->client());
933// m_spellConfigWidget->saveDictionary();
934 Doc* doc = m_pView->doc();
935 doc->setKSpellConfig(*_spellConfig);
936
937 bool state=dontCheckUpperWord->isChecked();
938 config->writeEntry ("KSpell_dont_check_upper_word",(int)state);
939 doc->setDontCheckUpperWord(state);
940
941 state=dontCheckTitleCase->isChecked();
942 config->writeEntry("KSpell_dont_check_title_case",(int)state);
943 doc->setDontCheckTitleCase(state);
944
945 //m_pView->doc()->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
946
947 m_pView->slotUpdateView( m_pView->activeSheet() );
948}
949
950void configureSpellPage::slotDefault()
951{
952 //FIXME
953 //m_spellConfigWidget->setDefault();
954}
955
957
958configureTTSPage::configureTTSPage( View *_view, TQVBox *box, char *name )
959 : TQObject( box->parent(), name )
960{
961 Q_UNUSED(_view);
962
963 m_cbSpeakPointerWidget = new TQCheckBox(i18n("Speak widget under &mouse pointer"), box);
964 m_cbSpeakFocusWidget = new TQCheckBox(i18n("Speak widget with &focus"), box);
965 m_gbScreenReaderOptions = new TQVGroupBox("", box);
966 m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
967 m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
968 m_cbSpeakTooltips = new TQCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
969 m_cbSpeakWhatsThis = new TQCheckBox(i18n("Speak &What's This"), m_gbScreenReaderOptions);
970 m_cbSpeakDisabled = new TQCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
971 "&Say whether disabled"), m_gbScreenReaderOptions);
972 m_cbSpeakAccelerators = new TQCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
973 TQHBox* hbAcceleratorPrefix = new TQHBox(m_gbScreenReaderOptions);
974 TQWidget* spacer = new TQWidget(hbAcceleratorPrefix);
975 spacer->setMinimumWidth(2 * KDialog::marginHint());
976 m_lblAcceleratorPrefix =
977 new TQLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
978 hbAcceleratorPrefix);
979 m_leAcceleratorPrefixWord = new TQLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
980 hbAcceleratorPrefix);
981 m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
982 TQHBox* hbPollingInterval = new TQHBox(m_gbScreenReaderOptions);
983 hbPollingInterval->setMargin( 0 );
984 TQLabel* lblPollingInterval = new TQLabel(i18n("&Polling interval:"), hbPollingInterval);
985 m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
986 m_iniPollingInterval->setSuffix(" ms");
987 m_iniPollingInterval->setRange(100, 5000, 100, true);
988 lblPollingInterval->setBuddy(m_iniPollingInterval);
989
990 config = Factory::global()->config();
991 config->setGroup("TTS");
992 m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
993 m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
994 m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
995 m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
996 m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
997 m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
998 m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
999 i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
1000 m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
1001
1002 screenReaderOptionChanged();
1003 connect(m_cbSpeakPointerWidget, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1004 connect(m_cbSpeakFocusWidget, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1005 connect(m_cbSpeakAccelerators, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1006}
1007
1008void configureTTSPage::slotDefault()
1009{
1010 m_cbSpeakPointerWidget->setChecked(false);
1011 m_cbSpeakFocusWidget->setChecked(false);
1012 m_cbSpeakTooltips->setChecked(true);
1013 m_cbSpeakWhatsThis->setChecked(false);
1014 m_cbSpeakDisabled->setChecked(true);
1015 m_cbSpeakAccelerators->setChecked(true);
1016 m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
1017 m_iniPollingInterval->setValue(600);
1018}
1019
1020void configureTTSPage::apply()
1021{
1022 config->setGroup("TTS");
1023 config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
1024 config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
1025 config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
1026 config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
1027 config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
1028 config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
1029 config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
1030 config->writeEntry("PollingInterval", m_iniPollingInterval->value());
1031 if (kospeaker) kospeaker->readConfig(config);
1032}
1033
1034void configureTTSPage::screenReaderOptionChanged()
1035{
1036 m_gbScreenReaderOptions->setEnabled(
1037 m_cbSpeakPointerWidget->isChecked() || m_cbSpeakFocusWidget->isChecked());
1038 m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
1039 m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
1040}
1041
1042#include "kspread_dlg_preference.moc"
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
void setShowTabBar(bool b)
If b is true, tab bar is visible, otherwise it will be hidden.
void setShowVerticalScrollBar(bool b)
If b is true, vertical scrollbar is visible, otherwise it will be hidden.
void setShowColHeader(bool b)
void setShowHorizontalScrollBar(bool b)
If b is true, horizontal scrollbar is visible, otherwise it will be hidden.
void setShowFormulaBar(bool b)
If b is true, formula bar is visible, otherwise it will be hidden.
void setKSpellConfig(KSpellConfig _tdespell)
get custom tdespell config
void setShowRowHeader(bool b)
If b is true, row header is visible, otherwise it will be hidden.
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39