kpresenter

KPrConfig.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25
26#include <tdeapplication.h>
27#include <KoUnitWidgets.h>
28#include <tdelocale.h>
29#include <tdeconfig.h>
30#include <kdialogbase.h>
31#include <kiconloader.h>
32#include <knuminput.h>
33#include <kcolorbutton.h>
34#include "KPrVariableCollection.h"
35#include "KPrCanvas.h"
36#include <tkcoloractions.h>
37
38#include <KoSpeaker.h>
39
40#include <tqgroupbox.h>
41#include <tqvgroupbox.h>
42#include <tqlabel.h>
43#include <tqlayout.h>
44#include <tqvbox.h>
45#include <tqcheckbox.h>
46#include <tqcombobox.h>
47#include <tqtabwidget.h>
48#include <tqwhatsthis.h>
49
50#include "KPrPenStyleWidget.h"
51#include "KPrBrushProperty.h"
52#include "KPrPieProperty.h"
53#include "KPrRectProperty.h"
54#include "KPrPolygonProperty.h"
55
56#include "KPrConfig.h"
57#include "KPrView.h"
58#include "KPrDocument.h"
59#include "KPrPage.h"
60#include <KoUnit.h>
61
62#include <float.h>
63#include <knumvalidator.h>
64#include <tqlineedit.h>
65#include "KPrCommand.h"
66#include <tqvgroupbox.h>
67#include <tdefontdialog.h>
68#include <klineedit.h>
69#include <KoRect.h>
70#include <tdemessagebox.h>
71#include <kurlrequesterdlg.h>
72#include <tdelistview.h>
73#include <tdefiledialog.h>
74#include <KoEditPath.h>
75
76#include <tdespell2/configwidget.h>
77#include <tdespell2/settings.h>
78#include <tdespell2/broker.h>
79using namespace KSpell2;
80
81KPrConfig::KPrConfig( KPrView* parent )
82 : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
83 KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
84 KDialogBase::Ok, parent)
85
86{
87 m_doc = parent->kPresenterDoc();
88 TQVBox *page = addVBoxPage( i18n("Interface"), i18n("Interface"),
89 BarIcon("misc", TDEIcon::SizeMedium) );
90 _interfacePage=new KPrConfigureInterfacePage( parent, page );
91 page = addVBoxPage( i18n("Color"), i18n("Color"),
92 BarIcon("colorize", TDEIcon::SizeMedium) );
93 _colorBackground = new KPrConfigureColorBackground( parent, page );
94
95 page = addVBoxPage( i18n("Spelling"), i18n("Spellchecker Behavior"),
96 BarIcon("tools-check-spelling", TDEIcon::SizeMedium) );
97 _spellPage=new KPrConfigureSpellPage(parent, page);
98
99 page = addVBoxPage( i18n("Misc"), i18n("Misc"),
100 BarIcon("misc", TDEIcon::SizeMedium) );
101 _miscPage=new KPrConfigureMiscPage(parent, page);
102
103 page = addVBoxPage( i18n("Document"), i18n("Document Settings"),
104 BarIcon("application-x-kpresenter", TDEIcon::SizeMedium) );
105
106 _defaultDocPage=new KPrConfigureDefaultDocPage(parent, page);
107
108 page = addVBoxPage( i18n("Tools"), i18n("Default Tools Settings"),
109 BarIcon("configure", TDEIcon::SizeMedium) );
110
111 _toolsPage=new KPrConfigureToolsPage(parent, page);
112
113 page = addVBoxPage( i18n("Paths"), i18n("Path Settings"),
114 BarIcon("path") );
115
116 m_pathPage=new KPrConfigurePathPage(parent, page);
117
118 if (KoSpeaker::isKttsdInstalled()) {
119 page = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"), i18n("Text-to-Speech Settings"),
120 BarIcon("access", TDEIcon::SizeMedium) );
121 m_ttsPage=new KPrConfigureTTSPage(parent, page);
122 } else m_ttsPage = 0;
123
124 connect( this, TQ_SIGNAL( okClicked() ),this, TQ_SLOT( slotApply() ) );
125}
126
127void KPrConfig::openPage(int flags)
128{
129 if(flags & KP_INTERFACE)
130 showPage( 0 );
131 else if(flags & KP_COLOR)
132 showPage(1 );
133 else if(flags & KP_TDESPELL)
134 showPage(2);
135 else if(flags & KP_MISC)
136 showPage(3 );
137 else if(flags & KP_DOC)
138 showPage(4 );
139 else if(flags & KP_TOOLS)
140 showPage(5);
141 else if(flags & KP_PATH)
142 showPage(6);
143}
144
145void KPrConfig::slotApply()
146{
147 KMacroCommand *macro = 0L;
148 _interfacePage->apply();
149 _colorBackground->apply();
150 if (_spellPage) _spellPage->apply();
151 m_pathPage->apply();
152 KCommand *cmd = _miscPage->apply();
153 if ( cmd )
154 {
155 if ( !macro )
156 macro = new KMacroCommand(i18n("Change Config") );
157 macro->addCommand( cmd );
158 }
159 cmd = _defaultDocPage->apply();
160 if ( cmd )
161 {
162 if ( !macro )
163 macro = new KMacroCommand(i18n("Change Config") );
164
165 macro->addCommand( cmd );
166 }
167
168 _toolsPage->apply();
169 if (m_ttsPage) m_ttsPage->apply();
170 if ( macro )
171 m_doc->addCommand( macro);
172}
173
174void KPrConfig::slotDefault()
175{
176 switch( activePageIndex() ) {
177 case 0:
178 _interfacePage->slotDefault();
179 break;
180 case 1:
181 _colorBackground->slotDefault();
182 break;
183 case 2:
184 if (_spellPage) _spellPage->slotDefault();
185 break;
186 case 3:
187 _miscPage->slotDefault();
188 break;
189 case 4:
190 _defaultDocPage->slotDefault();
191 break;
192 case 5:
193 _toolsPage->slotDefault();
194 break;
195 case 6:
196 m_pathPage->slotDefault();
197 break;
198 case 7:
199 m_ttsPage->slotDefault();
200 default:
201 break;
202 }
203}
204
205KPrConfigureInterfacePage::KPrConfigureInterfacePage( KPrView *_view, TQWidget *parent , char *name )
206 :TQWidget ( parent,name )
207{
208 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
209
210 m_pView=_view;
211 config = KPrFactory::global()->config();
212
213 KoUnit::Unit unit = m_pView->kPresenterDoc()->unit();
214
215 oldNbRecentFiles=10;
216 double ptIndent = MM_TO_POINT(10.0);
217 bool bShowRuler=true;
218 bool oldShowStatusBar = true;
219
220 if( config->hasGroup("Interface") ) {
221 config->setGroup( "Interface" );
222 oldNbRecentFiles=config->readNumEntry("NbRecentFile",oldNbRecentFiles);
223 ptIndent = config->readDoubleNumEntry("Indent", ptIndent);
224 bShowRuler=config->readBoolEntry("Rulers",true);
225 oldShowStatusBar = config->readBoolEntry( "ShowStatusBar" , true );
226
227 }
228
229 showRuler= new TQCheckBox(i18n("Show rulers"),this);
230 TQWhatsThis::add(showRuler, i18n( "When checked, both vertical and horizontal rulers are shown on the KPresenter slide (this is the default). When unchecked, the rulers are not shown on any slide." ) );
231 showRuler->setChecked(bShowRuler);
232 box->addWidget(showRuler);
233
234 showStatusBar = new TQCheckBox(i18n("Show status bar"),this);
235 TQWhatsThis::add(showStatusBar, i18n( "Toggle the statusbar, which is shown by default." ) );
236 showStatusBar->setChecked(oldShowStatusBar);
237 box->addWidget(showStatusBar);
238
239
240 recentFiles=new KIntNumInput( oldNbRecentFiles, this);
241 recentFiles->setRange(1, 20, 1);
242 recentFiles->setLabel(i18n("Number of recent files:"));
243 TQWhatsThis::add(recentFiles, i18n( "Set the number of recent files which will be opened using the File->Open Recent menu. Default is to remember 10 filenames. The maximum you can set is 20 and the minimum is 1." ) );
244
245 box->addWidget(recentFiles);
246
247 TQString suffix = KoUnit::unitName( unit ).prepend(' ');
248 indent = new KDoubleNumInput( this );
249 indent->setValue( KoUnit::toUserValue( ptIndent, unit ) );
250 indent->setRange(KoUnit::toUserValue( 0.1, unit ), KoUnit::toUserValue( 50, unit ), KoUnit::toUserValue( 0.1, unit ));
251
252
253 indent->setSuffix( suffix );
254 indent->setLabel(i18n("Text indentation depth:"));
255 TQWhatsThis::add(indent, i18n( "This setting is used by Increase Depth and Decrease Depth menu items (in the Text menu) to change the indentation depth. The Default is 1 centimeter." ) );
256
257 box->addWidget(indent);
258
259 TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
260 box->addItem( spacer);
261}
262
263void KPrConfigureInterfacePage::apply()
264{
265 bool ruler=showRuler->isChecked();
266 bool statusBar=showStatusBar->isChecked();
267
268 KPrDocument * doc = m_pView->kPresenterDoc();
269
270 config->setGroup( "Interface" );
271
272 double newIndent = KoUnit::fromUserValue( indent->value(), doc->unit() );
273 if( newIndent != doc->getIndentValue() )
274 {
275 config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ );
276 doc->setIndentValue( newIndent );
277 }
278 int nbRecent=recentFiles->value();
279 if(nbRecent!=oldNbRecentFiles)
280 {
281 config->writeEntry( "NbRecentFile", nbRecent);
282 m_pView->changeNbOfRecentFiles(nbRecent);
283 oldNbRecentFiles=nbRecent;
284 }
285 bool refreshGUI=false;
286 if(ruler != doc->showRuler())
287 {
288 config->writeEntry( "Rulers", ruler );
289 doc->setShowRuler( ruler );
290 refreshGUI=true;
291
292 }
293 if( statusBar != doc->showStatusBar() )
294 {
295 config->writeEntry( "ShowStatusBar", statusBar );
296 doc->setShowStatusBar( statusBar );
297 refreshGUI=true;
298 }
299
300 if( refreshGUI )
301 doc->reorganizeGUI();
302
303}
304
305void KPrConfigureInterfacePage::slotDefault()
306{
307 double newIndent = KoUnit::toUserValue( MM_TO_POINT( 10 ), m_pView->kPresenterDoc()->unit() );
308 indent->setValue( newIndent );
309 recentFiles->setValue(10);
310 showRuler->setChecked(true);
311 showStatusBar->setChecked(true);
312}
313
314KPrConfigureColorBackground::KPrConfigureColorBackground( KPrView* _view, TQWidget *parent , char *name )
315 :TQWidget ( parent,name )
316{
317 m_pView = _view;
318 config = KPrFactory::global()->config();
319
320 oldBgColor = m_pView->kPresenterDoc()->txtBackCol();
321 oldGridColor = m_pView->kPresenterDoc()->gridColor();
322 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
323
324 TQLabel *lab = new TQLabel( this, "label20" );
325 lab->setText( i18n( "Background object color:" ) );
326 TQWhatsThis::add(lab, i18n( "Change the background color of the text box. The background is white by default. If you have a dark background color and you want to put some white text on it, you can change the color of the text box so that you can see what you are typing. When you have finished, the area around the text will revert to the background color. The Defaults button restores the original settings." ) );
327 box->addWidget(lab);
328
329 bgColor = new KColorButton( oldBgColor,
330 oldBgColor,
331 this );
332 bgColor->setColor( oldBgColor );
333 box->addWidget(bgColor);
334
335
336 lab = new TQLabel( this, "label20" );
337 lab->setText( i18n( "Grid color:" ) );
338 TQWhatsThis::add(lab, i18n( "Here you can change the grid color, which is black by default." ) );
339 box->addWidget(lab);
340
341 gridColor = new KColorButton( oldGridColor,
342 oldGridColor,
343 this );
344 box->addWidget(gridColor);
345 TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
346 box->addItem( spacer);
347
348}
349
350void KPrConfigureColorBackground::apply()
351{
352 KPrDocument * doc = m_pView->kPresenterDoc();
353 bool repaintNeeded = false;
354 TQColor _col = bgColor->color();
355 if( oldBgColor != _col ) {
356 config->setGroup( "KPresenter Color" );
357 config->writeEntry( "BackgroundColor", _col );
358 doc->setTxtBackCol( _col );
359 doc->replaceObjs();
360 oldBgColor=_col;
361 repaintNeeded = true;
362 }
363 _col = gridColor->color();
364 if( oldGridColor != _col ) {
365 config->setGroup( "KPresenter Color" );
366 config->writeEntry( "GridColor", _col );
367 doc->repaint( false );
368 doc->setGridColor( _col );
369 oldGridColor=_col;
370 repaintNeeded = true;
371 }
372 if (repaintNeeded)
373 doc->repaint( false );
374}
375
376void KPrConfigureColorBackground::slotDefault()
377{
378 bgColor->setColor( TQt::white );
379 gridColor->setColor( TQt::black );
380}
381
382
383
384KPrConfigureSpellPage::KPrConfigureSpellPage( KPrView *_view, TQWidget *parent, char *name )
385 : TQWidget( parent, name )
386{
387 m_pView=_view;
388 config = KPrFactory::global()->config();
389 m_spellConfigWidget = new ConfigWidget( _view->broker(), parent );
390 m_spellConfigWidget->setBackgroundCheckingButtonShown( true );
391}
392
393void KPrConfigureSpellPage::apply()
394{
395
396 KPrDocument* doc = m_pView->kPresenterDoc();
397 m_spellConfigWidget->save();
398
399
400 m_pView->kPresenterDoc()->setSpellCheckIgnoreList(
401 m_pView->broker()->settings()->currentIgnoreList() );
402 //FIXME reactivate just if there are changes.
403 doc->enableBackgroundSpellCheck( m_pView->broker()->settings()->backgroundCheckerEnabled() );
404 doc->reactivateBgSpellChecking();
405}
406
407void KPrConfigureSpellPage::slotDefault()
408{
409 m_spellConfigWidget->slotDefault();
410}
411
412KPrConfigureMiscPage::KPrConfigureMiscPage( KPrView *_view, TQWidget *parent, char *name )
413 : TQWidget( parent, name )
414{
415 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
416
417 m_pView=_view;
418 config = KPrFactory::global()->config();
419
420 TQGroupBox* tmpTQGroupBox = new TQGroupBox( 0, TQt::Vertical, i18n("Misc"), this, "GroupBox" );
421 tmpTQGroupBox->layout()->setSpacing(KDialog::spacingHint());
422 tmpTQGroupBox->layout()->setMargin(KDialog::marginHint());
423 TQGridLayout *grid = new TQGridLayout( tmpTQGroupBox->layout(), 8, 1 );
424
425 m_oldNbRedo=30;
426 m_printNotes=true;
427 if( config->hasGroup("Misc") )
428 {
429 config->setGroup( "Misc" );
430 m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
431 m_printNotes = config->readBoolEntry("PrintNotes", true);
432 }
433
434 m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpTQGroupBox );
435 m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
436 m_undoRedoLimit->setRange(10, 60, 1);
437 TQWhatsThis::add(m_undoRedoLimit, i18n( "Set the number of actions you can undo and redo (how many actions KPresenter keeps in its Undo buffer). This ranges from a minimum of 10 to a maximum of 60 (the default is 30). Once the number of actions reaches the number set here, earlier actions will be forgotten." ) );
438 grid->addWidget(m_undoRedoLimit,0,0);
439
440 KPrDocument* doc = m_pView->kPresenterDoc();
441
442 m_displayLink=new TQCheckBox(i18n("Display links"),tmpTQGroupBox);
443 TQWhatsThis::add(m_displayLink, i18n( "When you want to include a link in your slide, you can use the Insert->Link... menu, which allows you to insert URL, mail or file links. If the option Display links is checked, all links will be active and displayed in a different color (this is the default behavior). If the option is unchecked, the links will be inactive and the same color as the text. This affects both the edited slides and the slide show." ) );
444 grid->addWidget(m_displayLink,3,0);
445 m_displayLink->setChecked(doc->getVariableCollection()->variableSetting()->displayLink());
446
447 m_underlineLink=new TQCheckBox(i18n("&Underline all links"),tmpTQGroupBox);
448 m_underlineLink->setChecked(doc->getVariableCollection()->variableSetting()->underlineLink());
449 TQWhatsThis::add(m_underlineLink, i18n( "If this is checked, all links will be underlined (this is the default). If it is not checked, the links will not be underlined." ) );
450 grid->addWidget(m_underlineLink,4,0);
451
452
453 m_displayComment=new TQCheckBox(i18n("Display comments"),tmpTQGroupBox);
454 m_displayComment->setChecked(doc->getVariableCollection()->variableSetting()->displayComment());
455 TQWhatsThis::add(m_displayComment, i18n( "Comments are inserted in the text at the cursor using the Insert->Comment... menu. Comments can only be viewed in edit mode and not in the slide show. If this option is checked (default) then each comment will be shown as a small yellow rectangle. You can then right-click on them to edit them, remove them or copy the text." ) );
456 grid->addWidget(m_displayComment,5,0);
457
458 m_displayFieldCode=new TQCheckBox(i18n("Display field code"),tmpTQGroupBox);
459 m_displayFieldCode->setChecked(doc->getVariableCollection()->variableSetting()->displayFieldCode());
460 TQWhatsThis::add(m_displayFieldCode, i18n( "In editor mode (not in slide show) this option will display all the variable codes as well as Link at links location. This is very useful to see what variable is displayed. Variables are inserted using the Insert -> Variable menu." ) );
461 grid->addWidget(m_displayFieldCode,6,0);
462
463 m_cbPrintNotes=new TQCheckBox(i18n("Print slide notes"),tmpTQGroupBox);
464 m_cbPrintNotes->setChecked(m_printNotes);
465 TQWhatsThis::add(m_cbPrintNotes, i18n( "If checked, all notes will be printed on paper. The notes will all be printed separately on the last page, from the first slide to the last and finally the Master Page Note. You can see the notes for each slide using the View->Show notebar menu." ) );
466 grid->addWidget(m_cbPrintNotes,7,0);
467
468 box->addWidget(tmpTQGroupBox);
469
470 tmpTQGroupBox = new TQGroupBox( 0, TQt::Vertical, i18n("Grid"), this, "GroupBox" );
471 tmpTQGroupBox->layout()->setSpacing(KDialog::spacingHint());
472 tmpTQGroupBox->layout()->setMargin(KDialog::marginHint());
473 grid = new TQGridLayout( tmpTQGroupBox->layout(), 8, 1 );
474
475 KoRect rect = doc->masterPage()->getPageRect();
476 TQLabel *lab=new TQLabel(i18n("Horizontal grid size:"), tmpTQGroupBox);
477 TQWhatsThis::add(lab, i18n( "Set the space in millimeters between two horizontal points on the grid. Default is 5 millimeters." ) );
478 grid->addWidget(lab,0,0);
479 KoUnit::Unit unit = doc->unit();
480 resolutionX = new KoUnitDoubleSpinBox(tmpTQGroupBox, 5.0,rect.width(),1,doc->getGridX() );
481 resolutionX->setUnit( unit );
482
483 grid->addWidget(resolutionX,1,0);
484
485 lab=new TQLabel(i18n("Vertical grid size:"), tmpTQGroupBox);
486 TQWhatsThis::add(lab, i18n( "Set the space in millimeters between two vertical points on the grid. Default is 5 millimeters." ) );
487 grid->addWidget(lab,2,0);
488
489 resolutionY = new KoUnitDoubleSpinBox(tmpTQGroupBox, 5.0,rect.height(),1,doc->getGridY() );
490 resolutionY->setUnit( unit );
491
492 grid->addWidget(resolutionY, 3, 0);
493 box->addWidget(tmpTQGroupBox);
494
495 TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
496 box->addItem( spacer);
497
498
499}
500
501KCommand * KPrConfigureMiscPage::apply()
502{
503 config->setGroup( "Misc" );
504 int newUndo=m_undoRedoLimit->value();
505 KPrDocument* doc = m_pView->kPresenterDoc();
506 if(newUndo!=m_oldNbRedo)
507 {
508 config->writeEntry("UndoRedo",newUndo);
509 doc->setUndoRedoLimit(newUndo);
510 m_oldNbRedo=newUndo;
511 }
512 config->writeEntry("PrintNotes", m_cbPrintNotes->isChecked());
513
514 KMacroCommand * macroCmd=0L;
515 bool b=m_displayLink->isChecked();
516 bool b_new=doc->getVariableCollection()->variableSetting()->displayLink();
517 if(b_new!=b)
518 {
519 if(!macroCmd)
520 macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
521
522 KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
523 i18n("Change Display Link Command"), doc, b_new, b, KPrChangeVariableSettingsCommand::VS_DISPLAYLINK);
524 cmd->execute();
525 macroCmd->addCommand(cmd);
526 }
527
528 b=m_underlineLink->isChecked();
529 if(doc->getVariableCollection()->variableSetting()->underlineLink()!=b)
530 {
531 if(!macroCmd)
532 macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
533
534 KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
535 i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->underlineLink(),
536 b, KPrChangeVariableSettingsCommand::VS_UNDERLINELINK);
537 cmd->execute();
538 macroCmd->addCommand(cmd);
539 }
540
541 b=m_displayComment->isChecked();
542 if(doc->getVariableCollection()->variableSetting()->displayComment()!=b)
543 {
544 if(!macroCmd)
545 macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
546
547 KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
548 i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
549 b, KPrChangeVariableSettingsCommand::VS_DISPLAYCOMMENT);
550 cmd->execute();
551 macroCmd->addCommand(cmd);
552 }
553
554 b=m_displayFieldCode->isChecked();
555 if(doc->getVariableCollection()->variableSetting()->displayFieldCode()!=b)
556 {
557 if(!macroCmd)
558 macroCmd=new KMacroCommand(i18n("Change Display Field Code Command"));
559
560 KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
561 i18n("Change Display Field Code Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
562 b, KPrChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE);
563 cmd->execute();
564 macroCmd->addCommand(cmd);
565 }
566
567 doc->setGridValue( resolutionX->value(),
568 resolutionY->value(), true);
569 doc->repaint( false );
570
571 config->sync();
572
573 return macroCmd;
574}
575
576void KPrConfigureMiscPage::slotDefault()
577{
578 m_undoRedoLimit->setValue(30);
579 m_displayLink->setChecked(true);
580 m_displayComment->setChecked(true);
581 m_underlineLink->setChecked(true);
582 m_displayFieldCode->setChecked( false );
583 m_cbPrintNotes->setChecked(true);
584 //KPrDocument* doc = m_pView->kPresenterDoc();
585
586 resolutionY->setValue( MM_TO_POINT( 5.0 ));
587 resolutionX->setValue( MM_TO_POINT( 5.0 ));
588}
589
590KPrConfigureDefaultDocPage::KPrConfigureDefaultDocPage(KPrView *_view, TQWidget *parent, char *name )
591 : TQWidget( parent, name )
592{
593 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
594
595 m_pView=_view;
596 config = KPrFactory::global()->config();
597 KPrDocument *doc = m_pView->kPresenterDoc();
598 oldAutoSaveValue = doc->defaultAutoSave()/60;
599 m_oldBackupFile = true;
600 m_oldLanguage = doc->globalLanguage();
601 m_oldHyphenation = doc->globalHyphenation();
602 if( config->hasGroup("Interface") ) {
603 config->setGroup( "Interface" );
604 oldAutoSaveValue = config->readNumEntry( "AutoSave", oldAutoSaveValue );
605 m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
606 m_oldLanguage = config->readEntry( "language", m_oldLanguage );
607 m_oldHyphenation = config->readBoolEntry( "hyphenation", m_oldHyphenation);
608 }
609
610 TQVGroupBox* gbDocumentDefaults = new TQVGroupBox( i18n("Document Defaults"), this, "GroupBox" );
611 gbDocumentDefaults->setMargin( KDialog::marginHint() );
612 gbDocumentDefaults->setInsideSpacing( 5 );
613
614 TQWidget *fontContainer = new TQWidget(gbDocumentDefaults);
615 TQGridLayout * fontLayout = new TQGridLayout(fontContainer, 1, 3);
616
617 fontLayout->setColStretch(0, 0);
618 fontLayout->setColStretch(1, 1);
619 fontLayout->setColStretch(2, 0);
620
621 TQLabel *fontTitle = new TQLabel(i18n("Default font:"), fontContainer);
622
623 font= new TQFont( doc->defaultFont() );
624
625 TQString labelName = font->family() + ' ' + TQString::number(font->pointSize());
626 fontName = new TQLabel(labelName, fontContainer);
627 fontName->setFont(*font);
628 fontName->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
629
630 TQPushButton *chooseButton = new TQPushButton(i18n("Choose..."), fontContainer);
631 TQWhatsThis::add(chooseButton, i18n( "Click here if you want to set a new font. The TDE default Select Font dialog will then be displayed." ) );
632 connect(chooseButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(selectNewDefaultFont()));
633
634 fontLayout->addWidget(fontTitle, 0, 0);
635 fontLayout->addWidget(fontName, 0, 1);
636 fontLayout->addWidget(chooseButton, 0, 2);
637
638 TQWidget *languageContainer = new TQWidget(gbDocumentDefaults);
639 TQGridLayout * languageLayout = new TQGridLayout(languageContainer, 1, 3);
640
641 languageLayout->setColStretch(0, 0);
642 languageLayout->setColStretch(1, 1);
643
644 TQLabel *languageTitle = new TQLabel(i18n("Global language:"), languageContainer);
645 TQWhatsThis::add(languageTitle, i18n( "Use this drop down box to determine the default language for the document. This setting is used by the hyphenation and spelling tools." ) );
646
647 m_globalLanguage = new TQComboBox( languageContainer );
648 m_globalLanguage->insertStringList( KoGlobal::listOfLanguages() );
649 m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( doc->globalLanguage() ) );
650
651 languageLayout->addWidget(languageTitle, 0, 0);
652 languageLayout->addWidget(m_globalLanguage, 0, 1);
653
654 m_autoHyphenation = new TQCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults);
655 TQWhatsThis::add(m_autoHyphenation, i18n( "Check this box if you want KPresenter to automatically hyphenate long words when it determines the word wrap in text frames. This is not set by default." ) );
656 m_autoHyphenation->setChecked( m_oldHyphenation );
657
658 box->addWidget(gbDocumentDefaults);
659
660 TQVGroupBox* gbDocumentSettings = new TQVGroupBox( i18n("Document Settings"), this );
661 gbDocumentSettings->setMargin( KDialog::marginHint() );
662 gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
663
664 m_createBackupFile = new TQCheckBox( i18n("Create backup file"), gbDocumentSettings);
665 TQWhatsThis::add(m_createBackupFile, i18n( "If checked, this will create a .<name>.kpr.autosave.kpr in the folder where your file is. This backup file can then be used in case of a problem.\nThe backup file is updated every time you save your document or every time there is an autosave." ) );
666 m_createBackupFile->setChecked( m_oldBackupFile );
667
668
669 autoSave = new KIntNumInput( oldAutoSaveValue, gbDocumentSettings );
670 autoSave->setRange( 0, 60, 1 );
671 autoSave->setLabel( i18n("Autosave (min):") );
672 autoSave->setSpecialValueText( i18n("No autosave") );
673 autoSave->setSuffix( i18n("min") );
674 TQWhatsThis::add(autoSave, i18n( "You can use this to adjust how often KPresenter saves a temporary file. If you set this value to No autosave, KPresenter will not autosave. You can adjust the autosave from 1 to 60 minutes." ) );
675
676 new TQLabel(i18n("Starting page number:"), gbDocumentSettings);
677 m_oldStartingPage=doc->getVariableCollection()->variableSetting()->startingPageNumber();
678 m_variableNumberOffset=new KIntNumInput(gbDocumentSettings);
679 m_variableNumberOffset->setRange(1, 9999, 1, false);
680 m_variableNumberOffset->setValue(m_oldStartingPage);
681 TQWhatsThis::add(m_variableNumberOffset, i18n( "Here you can change the number for the first page. It is set to 1 by default.\nTip: this is helpful if you have split a single document into multiple files." ) );
682
683 new TQLabel(i18n("Tab stop:"), gbDocumentSettings);
684 m_oldTabStopWidth = doc->tabStopValue();
685 KoRect rect = doc->masterPage()->getPageRect();
686 m_tabStopWidth = new KoUnitDoubleSpinBox( gbDocumentSettings , MM_TO_POINT(2), rect.width() ,0.1, m_oldTabStopWidth );
687
688 m_tabStopWidth->setUnit( doc->unit() );
689
690 TQWhatsThis::add(m_tabStopWidth, i18n( "Each KPresenter document has a default set of tab stops. If you add tab stops to your document, the newly added tab stops override the default ones. You can use this text box to define the spacing between default tab stops. As an example, if you enter 1.5 in this text box, and the unit of measurement is in centimeters, the first default tab stop will be located 1.5 cm to the right of the frame's left-hand margin. The second default tab stop will be located at 3 cm from the left-hand margin, and so on." ) );
691
692 box->addWidget(gbDocumentSettings);
693 TQVGroupBox* gbDocumentCursor = new TQVGroupBox( i18n("Cursor"), this );
694 gbDocumentCursor->setMargin( KDialog::marginHint() );
695 gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() );
696
697 m_cursorInProtectedArea= new TQCheckBox(i18n("Cursor in protected area"),gbDocumentCursor);
698 m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
699 TQWhatsThis::add(m_cursorInProtectedArea, i18n( "When this box is checked and you click in a protected frame within your document, a cursor will appear. When this box is unchecked, and you click in a protected frame, no cursor will be visible." ) );
700
701 m_directInsertCursor= new TQCheckBox(i18n("Direct insert cursor"),gbDocumentCursor);
702 m_directInsertCursor->setChecked(doc->insertDirectCursor());
703 TQWhatsThis::add(m_directInsertCursor, i18n( "When this box is checked, you can select a section of text using your mouse. Move the mouse to a new area in your document and click once with the middle mouse button and a copy of the selected text will be copied and pasted to the new location in the document.\nWhen this box is unchecked, in order to copy text from one section to another, you must select the text, manually copy the text to the clipboard, then manually paste the text in the new location." ) );
704 box->addWidget(gbDocumentCursor);
705
706 TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
707 box->addItem(spacer);
708
709}
710
711KPrConfigureDefaultDocPage::~KPrConfigureDefaultDocPage()
712{
713 delete font;
714}
715
716KCommand *KPrConfigureDefaultDocPage::apply()
717{
718 config->setGroup( "Document defaults" );
719 KPrDocument* doc = m_pView->kPresenterDoc();
720 config->writeEntry("DefaultFont",TQString(font->toString()));
721
722 config->setGroup( "Interface" );
723 int autoSaveVal = autoSave->value();
724 if( autoSaveVal != oldAutoSaveValue ) {
725 config->writeEntry( "AutoSave", autoSaveVal );
726 m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 );
727 oldAutoSaveValue=autoSaveVal;
728 }
729 bool state =m_createBackupFile->isChecked();
730
731 if(state!=m_oldBackupFile)
732 {
733 config->writeEntry( "BackupFile", state );
734 doc->setBackupFile( state);
735 m_oldBackupFile=state;
736 }
737
738 state = m_cursorInProtectedArea->isChecked();
739 if ( state != doc->cursorInProtectedArea() )
740 {
741 config->writeEntry( "cursorInProtectArea", state );
742 m_pView->kPresenterDoc()->setCursorInProtectedArea( state );
743 }
744
745 state = m_directInsertCursor->isChecked();
746 if ( state != doc->insertDirectCursor() )
747 doc->setInsertDirectCursor( state );
748
749 //Laurent Todo add a message box to inform user that
750 //global language will change after re-launch kword
751 const TQString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() );
752 config->writeEntry( "language" , lang);
753 m_oldLanguage = lang;
754 //don't call this function otherwise we can have a textobject with
755 // a default language and other textobject with other default language.
756 //doc->setGlobalLanguage( lang );
757
758
759 state = m_autoHyphenation->isChecked();
760 config->writeEntry( "hyphenation", state );
761 m_oldHyphenation = state;
762
763 KMacroCommand *macro = 0L;
764 int newStartingPage=m_variableNumberOffset->value();
765 if(newStartingPage!=m_oldStartingPage)
766 {
767 macro = new KMacroCommand( i18n("Change Starting Page Number") );
768 KPrChangeStartingPageCommand *cmd = new KPrChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage );
769 cmd->execute();
770 macro->addCommand( cmd);
771 m_oldStartingPage=newStartingPage;
772 }
773 double newTabStop = m_tabStopWidth->value();
774 if ( newTabStop != m_oldTabStopWidth)
775 {
776 if ( !macro )
777 macro = new KMacroCommand( i18n("Change Tab Stop Value") );
778 KPrChangeTabStopValueCommand *cmd = new KPrChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
779 cmd->execute();
780 macro->addCommand( cmd );
781 m_oldTabStopWidth = newTabStop;
782 }
783 return macro;
784}
785
786void KPrConfigureDefaultDocPage::slotDefault()
787{
788 autoSave->setValue( m_pView->kPresenterDoc()->defaultAutoSave()/60 );
789 m_variableNumberOffset->setValue(1);
790 m_cursorInProtectedArea->setChecked(true);
791 m_tabStopWidth->setValue( MM_TO_POINT(15));
792 m_createBackupFile->setChecked( true );
793 m_directInsertCursor->setChecked( false );
794 m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( TDEGlobal::locale()->language() ) );
795 m_autoHyphenation->setChecked( false );
796}
797
798void KPrConfigureDefaultDocPage::selectNewDefaultFont() {
799 TQStringList list;
800 TDEFontChooser::getFontList(list, TDEFontChooser::SmoothScalableFonts);
801 TDEFontDialog dlg( this, "Font Selector", false, true, list, true );
802 dlg.setFont(*font);
803 int result = dlg.exec();
804 if (KDialog::Accepted == result) {
805 delete font;
806 font = new TQFont(dlg.font());
807 fontName->setText(font->family() + ' ' + TQString::number(font->pointSize()));
808 fontName->setFont(*font);
809 m_pView->kPresenterDoc()->setDefaultFont( *font );
810 }
811}
812
813KPrConfigureToolsPage::KPrConfigureToolsPage( KPrView *_view, TQWidget *parent, char *name )
814 : TQWidget( parent, name )
815{
816 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
817
818 m_pView = _view;
819 config = KPrFactory::global()->config();
820 m_pView->getCanvas()->deSelectAllObj();
821
822 TQTabWidget *tab = new TQTabWidget(this);
823
824 KoPenCmd::Pen pen( m_pView->getPen(), m_pView->getLineBegin(), m_pView->getLineEnd() );
825 m_confPenDia = new KPrPenStyleWidget(tab, 0, pen, true );
826 tab->addTab( m_confPenDia, i18n( "Outl&ine" ) );
827
828 KPrBrushCmd::Brush brush( m_pView->getBrush(),
829 m_pView->getGColor1(),
830 m_pView->getGColor2(),
831 m_pView->getGType(),
832 m_pView->getFillType(),
833 m_pView->getGUnbalanced(),
834 m_pView->getGXFactor(),
835 m_pView->getGYFactor() );
836 m_brushProperty = new KPrBrushProperty( this, 0, brush );
837 tab->addTab( m_brushProperty, i18n( "&Fill" ) );
838
839 KPrRectValueCmd::RectValues rectValues;
840 rectValues.xRnd = m_pView->getRndX();
841 rectValues.yRnd = m_pView->getRndY();
842 m_rectProperty = new KPrRectProperty( this, 0, rectValues );
843 tab->addTab( m_rectProperty, i18n( "&Rectangle" ) );
844
845 KPrPolygonSettingCmd::PolygonSettings polygonSettings;
846 polygonSettings.checkConcavePolygon = m_pView->getCheckConcavePolygon();
847 polygonSettings.cornersValue = m_pView->getCornersValue();
848 polygonSettings.sharpnessValue = m_pView->getSharpnessValue();
849 m_polygonProperty = new KPrPolygonProperty( this, 0, polygonSettings );
850 tab->addTab( m_polygonProperty, i18n( "Polygo&n" ) );
851
852 KPrPieValueCmd::PieValues pieValues;
853 pieValues.pieType = m_pView->getPieType();
854 pieValues.pieAngle = m_pView->getPieAngle();
855 pieValues.pieLength = m_pView->getPieLength();
856 m_pieProperty = new KPrPieProperty( this, 0, pieValues );
857 tab->addTab( m_pieProperty, i18n( "&Pie" ) );
858
859 box->addWidget(tab);
860}
861
862KPrConfigureToolsPage::~KPrConfigureToolsPage()
863{
864}
865
866void KPrConfigureToolsPage::apply()
867{
868 KoPenCmd::Pen pen = m_confPenDia->getPen();
869 m_pView->setPen( pen.pen );
870 m_pView->setLineBegin( pen.lineBegin );
871 m_pView->setLineEnd( pen.lineEnd );
872 m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() );
873
874 KPrBrushCmd::Brush brush = m_brushProperty->getBrush();
875 m_pView->setBrush( brush.brush );
876 m_pView->setFillType( brush.fillType );
877 m_pView->setGColor1( brush.gColor1 );
878 m_pView->setGColor2( brush.gColor2 );
879 m_pView->setGType( brush.gType );
880 m_pView->setGUnbalanced( brush.unbalanced );
881 m_pView->setGXFactor( brush.xfactor );
882 m_pView->setGYFactor( brush.yfactor );
883 m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() );
884
885 KPrRectValueCmd::RectValues rectValues = m_rectProperty->getRectValues();
886 m_pView->setRndX( rectValues.xRnd );
887 m_pView->setRndY( rectValues.yRnd );
888
889 KPrPolygonSettingCmd::PolygonSettings polygonSettings = m_polygonProperty->getPolygonSettings();
890 m_pView->setCheckConcavePolygon( polygonSettings.checkConcavePolygon );
891 m_pView->setCornersValue( polygonSettings.cornersValue );
892 m_pView->setSharpnessValue( polygonSettings.sharpnessValue );
893
894 KPrPieValueCmd::PieValues pieValues = m_pieProperty->getPieValues();
895 m_pView->setPieType( pieValues.pieType );
896 m_pView->setPieAngle( pieValues.pieAngle );
897 m_pView->setPieLength( pieValues.pieLength );
898
899 //TODO set pen brush in m_rectProperty
900 //TODO set pen brush in m_polygonProperty
901 //TODO set pen brush in m_pieProperty
902}
903
904void KPrConfigureToolsPage::slotDefault()
905{
906 KoPenCmd::Pen pen( KoPen(black, 1.0, TQt::SolidLine), L_NORMAL, L_NORMAL );
907 m_confPenDia->setPen( pen );
908 m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() );
909
910 KPrBrushCmd::Brush brush( TQBrush( white, SolidPattern ), red, green,
911 BCT_GHORZ, FT_BRUSH, false, 100, 100 );
912 m_brushProperty->setBrush( brush );
913 m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() );
914
915 KPrRectValueCmd::RectValues rectValues;
916 rectValues.xRnd = 0;
917 rectValues.yRnd = 0;
918 m_rectProperty->setRectValues( rectValues );
919
920 KPrPolygonSettingCmd::PolygonSettings polygonSettings;
921 polygonSettings.checkConcavePolygon = false;
922 polygonSettings.cornersValue = 3;
923 polygonSettings.sharpnessValue = 0;
924 m_polygonProperty->setPolygonSettings( polygonSettings );
925
926 KPrPieValueCmd::PieValues pieValues;
927 pieValues.pieType = PT_PIE;
928 pieValues.pieAngle = 45 * 16;
929 pieValues.pieLength = 270 * 16;
930}
931
932KPrConfigurePathPage::KPrConfigurePathPage( KPrView *_view, TQWidget *parent, char *name )
933 : TQWidget( parent, name )
934{
935 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
936
937 m_pView=_view;
938 KPrDocument* doc = m_pView->kPresenterDoc();
939 config = KPrFactory::global()->config();
940
941 m_pPathView = new TDEListView( this );
942 m_pPathView->setResizeMode(TQListView::NoColumn);
943 m_pPathView->addColumn( i18n( "Type" ) );
944 m_pPathView->addColumn( i18n( "Path" ) );
945 (void) new TQListViewItem( m_pPathView, i18n("Picture Path"),doc->picturePath() );
946 (void) new TQListViewItem( m_pPathView, i18n("Backup Path"),doc->backupPath() );
947 TQWhatsThis::add(m_pPathView, i18n( "There are two paths that are set here: the Backup Path and the Picture Path. The Backup path is the folder where your backup files are saved and the Picture Path is the folder where your pictures are saved." ) );
948 box->addWidget(m_pPathView);
949
950 m_modifyPath = new TQPushButton( i18n("Modify Path..."), this);
951 connect( m_modifyPath, TQ_SIGNAL( clicked ()), this, TQ_SLOT( slotModifyPath()));
952 connect( m_pPathView, TQ_SIGNAL( doubleClicked (TQListViewItem *, const TQPoint &, int )),
953 this, TQ_SLOT( slotModifyPath()));
954 connect( m_pPathView, TQ_SIGNAL( selectionChanged ( TQListViewItem * )),
955 this, TQ_SLOT( slotSelectionChanged(TQListViewItem * )));
956 slotSelectionChanged(m_pPathView->currentItem());
957 TQWhatsThis::add(m_modifyPath, i18n( "When you click this button, a small dialog will appear and, if Default path is unchecked, you can either enter a path yourself or choose one using the standard TDE file dialog." ) );
958 box->addWidget(m_modifyPath);
959
960}
961
962void KPrConfigurePathPage::slotSelectionChanged(TQListViewItem * item)
963{
964 m_modifyPath->setEnabled( item );
965}
966
967void KPrConfigurePathPage::slotModifyPath()
968{
969 TQListViewItem *item = m_pPathView->currentItem ();
970 if ( item )
971 {
972 if ( item->text(0)==i18n("Picture Path"))
973 {
974 KURLRequesterDlg * dlg = new KURLRequesterDlg( item->text(1), 0L,
975 "picture path dlg");
976 dlg->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
977 if ( dlg->exec() )
978 item->setText( 1, dlg->selectedURL().path());
979 delete dlg;
980 }
981 else if ( item->text(0)==i18n("Backup Path"))
982 {
983 KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L,
984 "backup path" );
985 if (dlg->exec() )
986 item->setText(1, dlg->newPath());
987 delete dlg;
988 }
989 }
990}
991
992void KPrConfigurePathPage::slotDefault()
993{
994 TQListViewItem * item = m_pPathView->findItem(i18n("Picture Path"), 0);
995 if ( item )
996 item->setText(1, TDEGlobalSettings::documentPath());
997 item = m_pPathView->findItem(i18n("Backup Path"), 0);
998 if ( item )
999 item->setText(1, TQString() );
1000}
1001
1002void KPrConfigurePathPage::apply()
1003{
1004 TQListViewItem *item = m_pPathView->findItem(i18n("Backup Path"), 0);
1005 if ( item )
1006 {
1007 TQString res = item->text(1 );
1008 if ( res != m_pView->kPresenterDoc()->backupPath())
1009 {
1010 config->setGroup( "Kpresenter Path" );
1011 m_pView->kPresenterDoc()->setBackupPath( res );
1012 config->writePathEntry( "backup path",res );
1013 }
1014 }
1015 item = m_pPathView->findItem(i18n("Picture Path"), 0);
1016 if ( item )
1017 {
1018 TQString res = item->text(1 );
1019 if ( res != m_pView->kPresenterDoc()->picturePath())
1020 {
1021 config->setGroup( "Kpresenter Path" );
1022 m_pView->kPresenterDoc()->setPicturePath( res );
1023 config->writePathEntry( "picture path",res );
1024 }
1025 }
1026}
1027
1029
1030KPrConfigureTTSPage::KPrConfigureTTSPage( KPrView *_view, TQWidget *parent, char *name )
1031 : TQWidget( parent, name )
1032{
1033 Q_UNUSED(_view);
1034
1035 TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
1036
1037 m_cbSpeakPointerWidget = new TQCheckBox(i18n("Speak widget under &mouse pointer"), this);
1038 m_cbSpeakFocusWidget = new TQCheckBox(i18n("Speak widget with &focus"), this);
1039 m_gbScreenReaderOptions = new TQVGroupBox("", this);
1040 box->add(m_cbSpeakPointerWidget);
1041 box->add(m_cbSpeakFocusWidget);
1042 box->add(m_gbScreenReaderOptions);
1043 m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
1044 m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
1045 m_cbSpeakTooltips = new TQCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
1046 m_cbSpeakWhatsThis = new TQCheckBox(i18n("Speak &What's This?"), m_gbScreenReaderOptions);
1047 m_cbSpeakDisabled = new TQCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
1048 "&Say whether disabled"), m_gbScreenReaderOptions);
1049 m_cbSpeakAccelerators = new TQCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
1050 TQHBox* hbAcceleratorPrefix = new TQHBox(m_gbScreenReaderOptions);
1051 TQWidget* spacer = new TQWidget(hbAcceleratorPrefix);
1052 spacer->setMinimumWidth(2 * KDialog::marginHint());
1053 m_lblAcceleratorPrefix =
1054 new TQLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
1055 hbAcceleratorPrefix);
1056 m_leAcceleratorPrefixWord = new TQLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
1057 hbAcceleratorPrefix);
1058 m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
1059 TQHBox* hbPollingInterval = new TQHBox(m_gbScreenReaderOptions);
1060 hbPollingInterval->setMargin( 0 );
1061 TQLabel* lblPollingInterval = new TQLabel(i18n("&Polling interval:"), hbPollingInterval);
1062 m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
1063 m_iniPollingInterval->setSuffix(" ms");
1064 m_iniPollingInterval->setRange(100, 5000, 100, true);
1065 lblPollingInterval->setBuddy(m_iniPollingInterval);
1066
1067 config = KPrFactory::global()->config();
1068 config->setGroup("TTS");
1069 m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
1070 m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
1071 m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
1072 m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
1073 m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
1074 m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
1075 m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
1076 i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
1077 m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
1078
1079 screenReaderOptionChanged();
1080 connect(m_cbSpeakPointerWidget, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1081 connect(m_cbSpeakFocusWidget, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1082 connect(m_cbSpeakAccelerators, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(screenReaderOptionChanged()));
1083}
1084
1085void KPrConfigureTTSPage::slotDefault()
1086{
1087 m_cbSpeakPointerWidget->setChecked(false);
1088 m_cbSpeakFocusWidget->setChecked(false);
1089 m_cbSpeakTooltips->setChecked(true);
1090 m_cbSpeakWhatsThis->setChecked(false);
1091 m_cbSpeakDisabled->setChecked(true);
1092 m_cbSpeakAccelerators->setChecked(true);
1093 m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
1094 m_iniPollingInterval->setValue(600);
1095}
1096
1097void KPrConfigureTTSPage::apply()
1098{
1099 config->setGroup("TTS");
1100 config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
1101 config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
1102 config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
1103 config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
1104 config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
1105 config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
1106 config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
1107 config->writeEntry("PollingInterval", m_iniPollingInterval->value());
1108 if (kospeaker) kospeaker->readConfig(config);
1109}
1110
1111void KPrConfigureTTSPage::screenReaderOptionChanged()
1112{
1113 m_gbScreenReaderOptions->setEnabled(
1114 m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked());
1115 m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
1116 m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
1117}
1118
1119#include "KPrConfig.moc"