22#include <kiconloader.h>
24#include <KoUnitWidgets.h>
26#include <knumvalidator.h>
27#include <tdefontdialog.h>
30#include <tqcheckbox.h>
33#include <tqcombobox.h>
34#include <tqwhatsthis.h>
35#include <tqvgroupbox.h>
36#include <tqpushbutton.h>
38#include <tqlineedit.h>
43#include "KWFrameSet.h"
44#include "KWDocument.h"
46#include "KWViewMode.h"
48#include "KWVariable.h"
49#include "KoEditPath.h"
50#include "KWPageManager.h"
54#include <KoVariable.h>
55#include <kformulaconfigpage.h>
57#include <tdespell2/configwidget.h>
58#include <tdespell2/settings.h>
59#include <tdespell2/broker.h>
60using namespace KSpell2;
63#include <tdemessagebox.h>
64#include <tdelistview.h>
65#include <kstandarddirs.h>
66#include <tdeglobalsettings.h>
68#include <kurlrequesterdlg.h>
69#include <tdefiledialog.h>
70#include <tqtabwidget.h>
71#include <keditlistbox.h>
76static inline TQPixmap loadIcon(
const char * name ) {
77 return TDEGlobal::instance()->iconLoader()
78 ->loadIcon( TQString::fromLatin1(name), TDEIcon::NoGroup, TDEIcon::SizeMedium );
81KWConfig::KWConfig( KWView* parent )
82 : KDialogBase(KDialogBase::IconList,i18n(
"Configure KWord") ,
83 KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
84 KDialogBase::Ok, parent)
87 TQVBox *page2 = addVBoxPage( i18n(
"Interface"), i18n(
"Interface Settings"),
88 loadIcon(
"configure") );
89 m_interfacePage=
new ConfigureInterfacePage(parent, page2);
91 TQVBox *page4 = addVBoxPage( i18n(
"Document"), i18n(
"Document Settings"),
92 loadIcon(
"x-office-document") );
94 m_defaultDocPage=
new ConfigureDefaultDocPage(parent, page4);
96 TQVBox *page = addVBoxPage( i18n(
"Spelling"), i18n(
"Spell Checker Behavior"),
97 loadIcon(
"tools-check-spelling") );
98 m_spellPage =
new ConfigureSpellPage(parent, page);
100 TQVBox *page5 = addVBoxPage( i18n(
"Formula"), i18n(
"Formula Defaults"),
101 loadIcon(
"kformula") );
102 m_formulaPage=
new KFormula::ConfigurePage( parent->kWordDocument()->formulaDocument(
false ),
103 this, KWFactory::instance()->config(), page5 );
105 TQVBox *page3 = addVBoxPage( i18n(
"Misc"), i18n(
"Misc Settings"),
107 m_miscPage=
new ConfigureMiscPage(parent, page3);
109 TQVBox *page6 = addVBoxPage( i18n(
"Path"), i18n(
"Path Settings"),
111 m_pathPage=
new ConfigurePathPage(parent, page6);
113 if (KoSpeaker::isKttsdInstalled()) {
114 TQVBox *page7 = addVBoxPage( i18n(
"Abbreviation for Text-to-Speech",
"TTS"),
115 i18n(
"Text-to-Speech Settings"), loadIcon(
"access") );
116 m_ttsPage=
new ConfigureTTSPage(parent, page7);
117 }
else m_ttsPage = 0;
119 m_doc = parent->kWordDocument();
120 connect(
this, TQ_SIGNAL(okClicked()),
this,TQ_SLOT(slotApply()));
122 connect( m_interfacePage, TQ_SIGNAL( unitChanged(
int ) ), TQ_SLOT( unitChanged(
int ) ) );
123 unitChanged( parent->kWordDocument()->unit() );
126void KWConfig::unitChanged(
int u )
128 KoUnit::Unit unit =
static_cast<KoUnit::Unit
>(u);
130 m_interfacePage->setUnit( unit );
131 m_miscPage->setUnit( unit );
132 m_defaultDocPage->setUnit( unit );
137void KWConfig::openPage(
int flags)
139 if(flags & KW_TDESPELL)
141 else if(flags & KP_INTERFACE)
143 else if(flags & KP_MISC)
145 else if(flags & KP_DOCUMENT)
147 else if(flags & KP_FORMULA)
149 else if ( flags & KP_PATH )
153void KWConfig::slotApply()
155 KMacroCommand *macro = 0L;
156 if (m_spellPage) m_spellPage->apply();
157 m_interfacePage->apply();
159 KCommand * cmd = m_miscPage->apply();
163 macro =
new KMacroCommand( i18n(
"Change Config"));
164 macro->addCommand(cmd);
167 cmd=m_defaultDocPage->apply();
171 macro =
new KMacroCommand( i18n(
"Change Config"));
173 macro->addCommand( cmd );
175 m_formulaPage->apply();
176 if (m_ttsPage) m_ttsPage->apply();
178 m_doc->addCommand( macro );
179 KWFactory::instance()->config()->sync();
182void KWConfig::slotDefault()
184 switch(activePageIndex())
187 m_interfacePage->slotDefault();
190 m_defaultDocPage->slotDefault();
193 if (m_spellPage) m_spellPage->slotDefault();
196 m_formulaPage->slotDefault();
199 m_miscPage->slotDefault();
202 m_pathPage->slotDefault();
205 m_ttsPage->slotDefault();
213ConfigureSpellPage::ConfigureSpellPage( KWView *view, TQVBox *box,
char *name )
214 : TQObject( box->parent(), name )
217 config = KWFactory::instance()->config();
218 m_spellConfigWidget =
new ConfigWidget( view->broker(), box );
219 m_spellConfigWidget->setBackgroundCheckingButtonShown(
true );
220 m_spellConfigWidget->layout()->setMargin( 0 );
223void ConfigureSpellPage::apply()
225 KWDocument* doc = m_pView->kWordDocument();
227 m_spellConfigWidget->save();
229 m_pView->kWordDocument()->setSpellCheckIgnoreList(
230 m_pView->broker()->settings()->currentIgnoreList() );
232 doc->enableBackgroundSpellCheck( m_pView->broker()->settings()->backgroundCheckerEnabled() );
233 doc->reactivateBgSpellChecking();
236void ConfigureSpellPage::slotDefault()
238 m_spellConfigWidget->slotDefault();
241ConfigureInterfacePage::ConfigureInterfacePage( KWView *view, TQVBox *box,
char *name )
242 : TQObject( box->parent(), name )
245 config = KWFactory::instance()->config();
246 TQVGroupBox* gbInterfaceGroup =
new TQVGroupBox( i18n(
"Interface"), box,
"GroupBox" );
247 gbInterfaceGroup->setMargin( KDialog::marginHint() );
248 gbInterfaceGroup->setInsideSpacing( KDialog::spacingHint() );
250 double ptGridX=MM_TO_POINT(5.0 );
251 double ptGridY=MM_TO_POINT(5.0 );
252 double ptIndent = MM_TO_POINT(10.0);
253 bool oldShowStatusBar =
true;
254 bool oldPgUpDownMovesCaret =
false;
255 bool oldShowScrollBar =
true;
258 KoUnit::Unit unit = m_pView->kWordDocument()->unit();
259 if( config->hasGroup(
"Interface") )
261 config->setGroup(
"Interface" );
262 ptGridX=config->readDoubleNumEntry(
"GridX", ptGridX);
263 ptGridY=config->readDoubleNumEntry(
"GridY", ptGridY);
264 ptIndent = config->readDoubleNumEntry(
"Indent", ptIndent);
265 oldNbRecentFiles=config->readNumEntry(
"NbRecentFile", oldNbRecentFiles);
266 nbPagePerRow=config->readNumEntry(
"nbPagePerRow", nbPagePerRow);
267 oldShowStatusBar = config->readBoolEntry(
"ShowStatusBar",
true );
268 oldPgUpDownMovesCaret = config->readBoolEntry(
"PgUpDownMovesCaret",
false );
269 oldShowScrollBar = config->readBoolEntry(
"ShowScrollBar",
true);
272 TQHBox *hbUnit =
new TQHBox(gbInterfaceGroup);
273 hbUnit->setSpacing(KDialog::spacingHint());
274 TQLabel *unitLabel=
new TQLabel(i18n(
"&Units:"),hbUnit);
276 m_unitCombo =
new TQComboBox( hbUnit );
277 m_unitCombo->insertStringList( KoUnit::listOfUnitName() );
278 connect(m_unitCombo, TQ_SIGNAL(activated(
int)),
this, TQ_SIGNAL(unitChanged(
int)));
279 unitLabel->setBuddy( m_unitCombo );
280 TQString unitHelp = i18n(
"Select the unit type used every time a distance or width/height "
281 "is displayed or entered. This one setting is for the whole of KWord: all dialogs, the rulers etc. "
282 "Note that KWord documents specify the unit which was used to create them, so this setting "
283 "only affects this document and all documents that will be created later.");
284 TQWhatsThis::add( unitLabel, unitHelp );
285 TQWhatsThis::add( m_unitCombo, unitHelp );
287 showStatusBar =
new TQCheckBox(i18n(
"Show &status bar"),gbInterfaceGroup);
288 showStatusBar->setChecked(oldShowStatusBar);
289 TQWhatsThis::add( showStatusBar, i18n(
"Show or hide the status bar. If enabled, the status bar is shown at the bottom, which displays various information."));
291 showScrollBar =
new TQCheckBox( i18n(
"Show s&crollbar"), gbInterfaceGroup);
292 showScrollBar->setChecked(oldShowScrollBar);
293 TQWhatsThis::add( showScrollBar, i18n(
"Show or hide the scroll bar. If enabled, the scroll bar is shown on the right and lets you scroll up and down, which is useful for navigating through the document."));
295 pgUpDownMovesCaret =
new TQCheckBox(i18n(
"PageUp/PageDown &moves the caret"),gbInterfaceGroup);
296 pgUpDownMovesCaret->setChecked(oldPgUpDownMovesCaret);
297 TQWhatsThis::add( pgUpDownMovesCaret, i18n(
298 "If this option is enabled, the PageUp and PageDown keys "
299 "move the text caret, as in other TDE applications. "
300 "If it is disabled, they move the scrollbars, as in most other word processors." ) );
302 TQHBox* hbRecent =
new TQHBox( gbInterfaceGroup );
303 TQString recentHelp = i18n(
"The number of files remembered in the file open dialog and in the "
304 "recent files menu item.");
305 TQLabel* labelRecent =
new TQLabel( i18n(
"Number of recent &files:"), hbRecent );
306 TQWhatsThis::add( labelRecent, recentHelp );
307 recentFiles=
new KIntNumInput( oldNbRecentFiles, hbRecent );
308 recentFiles->setRange(1, 20, 1);
309 labelRecent->setBuddy( recentFiles );
310 TQWhatsThis::add( recentFiles, recentHelp );
312 TQHBox* hbGridX =
new TQHBox( gbInterfaceGroup );
313 TQString gridxHelp = i18n(
"The grid size on which frames, tabs and other content snaps while "
314 "moving and scaling.");
315 TQLabel* labelGridX =
new TQLabel( i18n(
"&Horizontal grid size:"), hbGridX );
316 TQWhatsThis::add( labelGridX, gridxHelp );
317 gridX=
new KoUnitDoubleSpinBox( hbGridX,
323 labelGridX->setBuddy( gridX );
324 TQWhatsThis::add( gridX, gridxHelp );
326 TQHBox* hbGridY =
new TQHBox( gbInterfaceGroup );
327 TQString gridyHelp = i18n(
"The grid size on which frames and other content snaps while "
328 "moving and scaling.");
329 TQLabel* labelGridY =
new TQLabel( i18n(
"&Vertical grid size:"), hbGridY );
330 TQWhatsThis::add( labelGridY, gridyHelp );
331 gridY=
new KoUnitDoubleSpinBox( hbGridY,
337 labelGridY->setBuddy( gridY );
339 TQWhatsThis::add( gridY, gridyHelp );
341 TQHBox* hbIndent =
new TQHBox( gbInterfaceGroup );
342 TQString indentHelp = i18n(
"Configure the indent width used when using the 'Increase' "
343 "or 'Decrease' indentation buttons on a paragraph.<p>The lower the value, "
344 "the more often the buttons will have to be pressed to gain the same "
346 TQLabel* labelIndent =
new TQLabel( i18n(
"&Paragraph indent by toolbar buttons:"), hbIndent );
347 TQWhatsThis::add( labelIndent, indentHelp );
348 indent =
new KoUnitDoubleSpinBox( hbIndent,
354 labelIndent->setBuddy( indent );
355 TQWhatsThis::add( indent, indentHelp );
357 TQHBox* hbPagePerRow =
new TQHBox( gbInterfaceGroup );
358 TQString pagePerRowHelp = i18n(
"After selecting Preview Mode (from the \"View\" menu,) "
359 "this is the number of pages KWord will "
360 "position on one horizontal row.");
361 TQLabel* labelPagePerRow =
new TQLabel( i18n(
"Number of pa&ges per row in preview mode:" ), hbPagePerRow );
362 TQWhatsThis::add( labelPagePerRow, pagePerRowHelp );
363 m_nbPagePerRow=
new KIntNumInput( 0, nbPagePerRow, hbPagePerRow );
364 m_nbPagePerRow->setRange(1, 10, 1);
365 labelPagePerRow->setBuddy( m_nbPagePerRow );
366 hbPagePerRow->setStretchFactor( m_nbPagePerRow, 1 );
367 TQWhatsThis::add(m_nbPagePerRow , pagePerRowHelp );
370void ConfigureInterfacePage::apply()
372 KWDocument * doc = m_pView->kWordDocument();
373 double valX = TQMAX( 0.1, gridX->value() );
374 double valY = TQMAX( 0.1, gridY->value() );
375 int nbRecent=recentFiles->value();
377 bool statusBar=showStatusBar->isChecked();
378 bool scrollBar = showScrollBar->isChecked();
379 config->setGroup(
"Interface" );
380 bool updateView =
false;
381 if(valX!=doc->gridX())
383 config->writeEntry(
"GridX", valX,
true,
false,
'g', DBL_DIG );
387 if(valY!=doc->gridY())
389 config->writeEntry(
"GridY", valY,
true,
false,
'g', DBL_DIG );
393 double newIndent = indent->value();
394 if( newIndent != doc->indentValue() )
396 config->writeEntry(
"Indent", newIndent,
true,
false,
'g', DBL_DIG );
397 doc->setIndentValue( newIndent );
399 if(nbRecent!=oldNbRecentFiles)
401 config->writeEntry(
"NbRecentFile", nbRecent);
402 m_pView->changeNbOfRecentFiles(nbRecent);
404 bool refreshGUI=
false;
406 if( statusBar != doc->showStatusBar() )
408 config->writeEntry(
"ShowStatusBar", statusBar );
409 doc->setShowStatusBar( statusBar );
413 if( scrollBar != doc->showScrollBar() )
415 config->writeEntry(
"ShowScrollBar", scrollBar );
416 doc->setShowScrollBar( scrollBar );
420 bool b = pgUpDownMovesCaret->isChecked();
421 if ( b != doc->pgUpDownMovesCaret() )
423 config->writeEntry(
"PgUpDownMovesCaret", b );
424 doc->setPgUpDownMovesCaret( b );
428 doc->reorganizeGUI();
431 int nbPageByRow=m_nbPagePerRow->value();
432 if(nbPageByRow!=doc->nbPagePerRow())
434 config->writeEntry(
"nbPagePerRow",nbPageByRow);
435 m_pView->getGUI()->canvasWidget()->viewMode()->setPagesPerRow(nbPageByRow);
436 doc->setNbPagePerRow(nbPageByRow);
441 doc->switchViewMode( doc->viewModeType() );
444 config->setGroup(
"Misc" );
445 KoUnit::Unit unit =
static_cast<KoUnit::Unit
>( m_unitCombo->currentItem() );
447 config->writeEntry(
"Units", KoUnit::unitName( unit ) );
449 doc->repaintAllViews(
false);
452void ConfigureInterfacePage::setUnit( KoUnit::Unit unit )
454 m_unitCombo->blockSignals(
true );
455 m_unitCombo->setCurrentItem( unit );
456 m_unitCombo->blockSignals(
false );
458 m_pView->kWordDocument()->setUnit( unit );
460 gridX->setUnit( unit );
461 gridY->setUnit( unit );
462 indent->setUnit( unit );
465void ConfigureInterfacePage::slotDefault()
467 KWDocument * doc = m_pView->kWordDocument();
468 m_unitCombo->setCurrentItem( KoUnit::U_CM );
469 emit unitChanged( m_unitCombo->currentItem() );
470 gridX->setValue( KoUnit::toUserValue( MM_TO_POINT( 5.0 ),doc->unit() ) );
471 gridY->setValue( KoUnit::toUserValue( MM_TO_POINT( 5.0 ),doc->unit() ) );
472 m_nbPagePerRow->setValue(4);
473 double newIndent = KoUnit::toUserValue( MM_TO_POINT( 10 ), doc->unit() );
474 indent->setValue( newIndent );
475 recentFiles->setValue(10);
476 showStatusBar->setChecked(
true);
477 pgUpDownMovesCaret->setChecked(
false);
478 showScrollBar->setChecked(
true);
483ConfigureMiscPage::ConfigureMiscPage( KWView *view, TQVBox *box,
char *name )
484 : TQObject( box->parent(), name )
487 config = KWFactory::instance()->config();
488 TQVGroupBox* gbMiscGroup =
new TQVGroupBox( i18n(
"Misc"), box,
"GroupBox" );
489 gbMiscGroup->setMargin( KDialog::marginHint() );
490 gbMiscGroup->setInsideSpacing( KDialog::spacingHint() );
497 if( config->hasGroup(
"Misc") )
499 config->setGroup(
"Misc" );
500 m_oldNbRedo=config->readNumEntry(
"UndoRedo",m_oldNbRedo);
503 TQHBox* hbUndoRedo =
new TQHBox( gbMiscGroup );
504 TQLabel* labelUndoRedo =
new TQLabel( i18n(
"Undo/&redo limit:"), hbUndoRedo );
505 TQString undoHelp = i18n(
"Limit the number of undo/redo actions remembered. "
506 "A lower value helps to save memory, a higher value allows "
507 "you to undo and redo more editing steps.");
508 m_undoRedoLimit=
new KIntNumInput( m_oldNbRedo, hbUndoRedo );
509 m_undoRedoLimit->setRange(1, 100, 1);
510 labelUndoRedo->setBuddy( m_undoRedoLimit );
511 TQWhatsThis::add( m_undoRedoLimit, undoHelp );
512 TQWhatsThis::add( labelUndoRedo, undoHelp );
514 KWDocument* doc = m_pView->kWordDocument();
515 m_displayLink=
new TQCheckBox(i18n(
"Display &links"),gbMiscGroup);
516 m_displayLink->setChecked(doc->variableCollection()->variableSetting()->displayLink());
517 TQWhatsThis::add( m_displayLink, i18n(
"If enabled, a link is highlighted as such and is clickable.\n\n"
518 "You can insert a link from the Insert menu."));
519 m_underlineLink=
new TQCheckBox(i18n(
"&Underline all links"),gbMiscGroup);
520 m_underlineLink->setChecked(doc->variableCollection()->variableSetting()->underlineLink());
521 TQWhatsThis::add( m_underlineLink, i18n(
"If enabled, a link is underlined."));
523 m_displayComment=
new TQCheckBox(i18n(
"Display c&omments"),gbMiscGroup);
524 m_displayComment->setChecked(doc->variableCollection()->variableSetting()->displayComment());
525 TQWhatsThis::add( m_displayComment, i18n(
"If enabled, comments are indicated by a small yellow box.\n\n"
526 "You can show and edit a comment from the context menu."));
528 m_displayFieldCode=
new TQCheckBox(i18n(
"Display field code"),gbMiscGroup);
529 m_displayFieldCode->setChecked(doc->variableCollection()->variableSetting()->displayFieldCode());
530 TQWhatsThis::add( m_displayFieldCode, i18n(
"If enabled, the type of link is displayed instead "
531 "of displaying the link text.\n\n"
532 "There are various types of link that can be inserted, "
533 "such as hyperlinks, files, mail, news and bookmarks."));
536 TQVGroupBox* gbViewFormatting =
new TQVGroupBox( i18n(
"View Formatting"), box,
"view_formatting" );
537 TQWhatsThis::add( gbViewFormatting, i18n(
"These settings can be used to select the formatting "
538 "characters that should be shown.\n\n"
539 "Note that the selected formatting characters are only "
540 "shown if formatting characters are enabled in general, "
541 "which can be done from the View menu."));
542 gbViewFormatting->setMargin( KDialog::marginHint() );
543 gbViewFormatting->setInsideSpacing( KDialog::spacingHint() );
545 m_oldFormattingEndParag = doc->viewFormattingEndParag();
546 m_oldFormattingSpace = doc->viewFormattingSpace();
547 m_oldFormattingTabs = doc->viewFormattingTabs();
548 m_oldFormattingBreak = doc->viewFormattingBreak();
550 m_cbViewFormattingEndParag =
new TQCheckBox( i18n(
"View formatting end paragraph"), gbViewFormatting);
551 m_cbViewFormattingEndParag->setChecked(m_oldFormattingEndParag);
553 m_cbViewFormattingSpace =
new TQCheckBox( i18n(
"View formatting space"), gbViewFormatting);
554 m_cbViewFormattingSpace->setChecked(m_oldFormattingSpace);
556 m_cbViewFormattingTabs =
new TQCheckBox( i18n(
"View formatting tabs"), gbViewFormatting);
557 m_cbViewFormattingTabs->setChecked(m_oldFormattingTabs);
559 m_cbViewFormattingBreak =
new TQCheckBox( i18n(
"View formatting break"), gbViewFormatting);
560 m_cbViewFormattingBreak->setChecked(m_oldFormattingBreak);
563ConfigureDefaultDocPage::~ConfigureDefaultDocPage()
568KCommand *ConfigureMiscPage::apply()
570 KWDocument * doc = m_pView->kWordDocument();
571 config->setGroup(
"Misc" );
572 int newUndo=m_undoRedoLimit->value();
573 if(newUndo!=m_oldNbRedo)
575 config->writeEntry(
"UndoRedo",newUndo);
576 doc->setUndoRedoLimit(newUndo);
579 KMacroCommand * macroCmd=0L;
580 bool b=m_displayLink->isChecked();
581 if(doc->variableCollection()->variableSetting()->displayLink()!=b)
585 macroCmd=
new KMacroCommand(i18n(
"Change Display Link Command"));
590 macroCmd->addCommand(cmd);
592 b=m_underlineLink->isChecked();
593 if(doc->variableCollection()->variableSetting()->underlineLink()!=b)
597 macroCmd=
new KMacroCommand(i18n(
"Change Display Link Command"));
601 macroCmd->addCommand(cmd);
604 b=m_displayComment->isChecked();
605 if(doc->variableCollection()->variableSetting()->displayComment()!=b)
609 macroCmd=
new KMacroCommand(i18n(
"Change Display Link Command"));
613 macroCmd->addCommand(cmd);
615 b=m_displayFieldCode->isChecked();
616 if(doc->variableCollection()->variableSetting()->displayFieldCode()!=b)
620 macroCmd=
new KMacroCommand(i18n(
"Change Display Field Code Command"));
624 macroCmd->addCommand(cmd);
627 bool state =m_cbViewFormattingEndParag->isChecked();
628 bool needRepaint =
false;
629 if ( state != m_oldFormattingEndParag )
631 doc->setViewFormattingEndParag(state);
633 m_oldFormattingEndParag = state;
635 state = m_cbViewFormattingSpace->isChecked();
636 if ( state != m_oldFormattingSpace)
638 doc->setViewFormattingSpace(state);
640 m_oldFormattingSpace = state;
642 state = m_cbViewFormattingBreak->isChecked();
643 if ( state != m_oldFormattingBreak)
645 doc->setViewFormattingBreak(state);
647 m_oldFormattingBreak = state;
649 state = m_cbViewFormattingTabs->isChecked();
650 if ( state != m_oldFormattingTabs )
652 doc->setViewFormattingTabs(state);
654 m_oldFormattingTabs= state;
659 doc->repaintAllViews();
664void ConfigureMiscPage::slotDefault()
666 m_undoRedoLimit->setValue(30);
667 m_displayLink->setChecked(
true);
668 m_displayComment->setChecked(
true);
669 m_underlineLink->setChecked(
true);
670 m_cbViewFormattingEndParag->setChecked(
true);
671 m_cbViewFormattingSpace->setChecked(
true);
672 m_cbViewFormattingTabs->setChecked(
true);
673 m_cbViewFormattingBreak->setChecked(
true);
674 m_displayFieldCode->setChecked(
false );
677void ConfigureMiscPage::setUnit( KoUnit::Unit )
683ConfigureDefaultDocPage::ConfigureDefaultDocPage( KWView *view, TQVBox *box,
char *name )
684 : TQObject( box->parent(), name )
687 KWDocument * doc = m_pView->kWordDocument();
688 config = KWFactory::instance()->config();
689 TQVGroupBox* gbDocumentDefaults =
new TQVGroupBox( i18n(
"Document Defaults"), box,
"GroupBox" );
690 gbDocumentDefaults->setMargin( KDialog::marginHint() );
691 gbDocumentDefaults->setInsideSpacing( KDialog::spacingHint() );
693 double ptColumnSpacing=3;
694 KoUnit::Unit unit = doc->unit();
695 if( config->hasGroup(
"Document defaults") )
697 config->setGroup(
"Document defaults" );
698 ptColumnSpacing=config->readDoubleNumEntry(
"ColumnSpacing",ptColumnSpacing);
703 TQHBox* hbColumnSpacing =
new TQHBox( gbDocumentDefaults );
704 TQLabel* columnSpacingLabel =
new TQLabel( i18n(
"Default column spacing:"), hbColumnSpacing );
705 m_columnSpacing =
new KoUnitDoubleSpinBox( hbColumnSpacing,
711 columnSpacingLabel->setBuddy( m_columnSpacing );
712 TQWhatsThis::add( m_columnSpacing, i18n(
"When setting a document to use more than one column "
713 "this distance will be used to separate the columns. This value is merely a default "
714 "setting as the column spacing can be changed per document") );
716 TQWidget *fontContainer =
new TQWidget(gbDocumentDefaults);
717 TQGridLayout * fontLayout =
new TQGridLayout(fontContainer, 1, 3);
719 fontLayout->setSpacing(KDialog::spacingHint());
720 fontLayout->setColStretch(0, 0);
721 fontLayout->setColStretch(1, 1);
722 fontLayout->setColStretch(2, 0);
724 TQLabel *fontTitle =
new TQLabel(i18n(
"Default font:"), fontContainer);
726 font=
new TQFont( doc->defaultFont() );
728 TQString labelName = font->family() +
' ' + TQString::number(font->pointSize());
729 fontName =
new TQLabel(labelName, fontContainer);
730 fontName->setFont(*font);
731 fontName->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
733 TQPushButton *chooseButton =
new TQPushButton(i18n(
"Choose..."), fontContainer);
734 connect(chooseButton, TQ_SIGNAL(clicked()),
this, TQ_SLOT(selectNewDefaultFont()));
736 fontLayout->addWidget(fontTitle, 0, 0);
737 fontLayout->addWidget(fontName, 0, 1);
738 fontLayout->addWidget(chooseButton, 0, 2);
741 oldAutoSaveValue=KoDocument::defaultAutoSave() / 60;
742 m_oldLanguage = doc->globalLanguage();
743 m_oldHyphenation = doc->globalHyphenation();
744 if( config->hasGroup(
"Interface") )
746 config->setGroup(
"Interface" );
747 oldAutoSaveValue=config->readNumEntry(
"AutoSave",oldAutoSaveValue);
748 m_oldLanguage = config->readEntry(
"language", m_oldLanguage);
749 m_oldHyphenation = config->readBoolEntry(
"hyphenation", m_oldHyphenation);
753 TQWidget *languageContainer =
new TQWidget(gbDocumentDefaults);
754 TQGridLayout * languageLayout =
new TQGridLayout(languageContainer, 1, 3);
756 languageLayout->setSpacing(KDialog::spacingHint());
757 languageLayout->setColStretch(0, 0);
758 languageLayout->setColStretch(1, 1);
760 TQLabel *languageTitle =
new TQLabel(i18n(
"Global language:"), languageContainer);
762 m_globalLanguage =
new TQComboBox( languageContainer );
763 m_globalLanguage->insertStringList( KoGlobal::listOfLanguages() );
764 m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( m_oldLanguage ) );
766 languageLayout->addWidget(languageTitle, 0, 0);
767 languageLayout->addWidget(m_globalLanguage, 0, 1);
769 m_autoHyphenation =
new TQCheckBox( i18n(
"Automatic hyphenation"), gbDocumentDefaults);
770 m_autoHyphenation->setChecked( m_oldHyphenation );
772 TQVGroupBox* gbDocumentSettings =
new TQVGroupBox( i18n(
"Document Settings"), box );
773 gbDocumentSettings->setMargin( KDialog::marginHint() );
774 gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
776 TQHBox* hbAutoSave =
new TQHBox( gbDocumentSettings );
777 TQLabel* labelAutoSave =
new TQLabel( i18n(
"Autosave every (min):"), hbAutoSave );
778 autoSave =
new KIntNumInput( oldAutoSaveValue, hbAutoSave );
779 autoSave->setRange(0, 60, 1);
780 labelAutoSave->setBuddy(autoSave);
781 TQWhatsThis::add( autoSave, i18n(
"A backup copy of the current document is created when a change "
782 "has been made. The interval used to create backup documents is set here.") );
783 autoSave->setSpecialValueText(i18n(
"No autosave"));
784 autoSave->setSuffix(i18n(
" min"));
786 m_oldBackupFile =
true;
787 if( config->hasGroup(
"Interface") )
789 config->setGroup(
"Interface" );
790 m_oldBackupFile=config->readBoolEntry(
"BackupFile",m_oldBackupFile);
793 m_createBackupFile =
new TQCheckBox( i18n(
"Create backup file"), gbDocumentSettings);
794 m_createBackupFile->setChecked( m_oldBackupFile );
796 TQHBox* hbStartingPage =
new TQHBox( gbDocumentSettings );
797 TQLabel* labelStartingPage =
new TQLabel(i18n(
"Starting page number:"), hbStartingPage);
799 m_oldStartingPage=doc->variableCollection()->variableSetting()->startingPageNumber();
800 m_variableNumberOffset=
new KIntNumInput(hbStartingPage);
801 m_variableNumberOffset->setRange(-1000, 9999, 1,
false);
802 m_variableNumberOffset->setValue(m_oldStartingPage);
803 labelStartingPage->setBuddy( m_variableNumberOffset );
805 TQHBox* hbTabStop =
new TQHBox( gbDocumentSettings );
806 tabStop =
new TQLabel(i18n(
"Tab stop (%1):").arg(doc->unitName()), hbTabStop);
807 m_tabStopWidth =
new KoUnitDoubleSpinBox( hbTabStop,
809 doc->pageManager()->page(doc->startPage())->width(),
813 m_oldTabStopWidth = doc->tabStopValue();
815 TQVGroupBox* gbDocumentCursor =
new TQVGroupBox( i18n(
"Cursor"), box );
816 gbDocumentCursor->setMargin( KDialog::marginHint() );
817 gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() );
819 m_cursorInProtectedArea=
new TQCheckBox(i18n(
"Cursor in protected area"),gbDocumentCursor);
820 m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
826KCommand *ConfigureDefaultDocPage::apply()
828 config->setGroup(
"Document defaults" );
829 KWDocument * doc = m_pView->kWordDocument();
830 double colSpacing = m_columnSpacing->value();
831 if ( colSpacing != doc->defaultColumnSpacing() )
833 config->writeEntry(
"ColumnSpacing", colSpacing ,
true,
false,
'g', DBL_DIG );
834 doc->setDefaultColumnSpacing(colSpacing);
836 config->writeEntry(
"DefaultFont",TQString(font->toString()));
838 config->setGroup(
"Interface" );
839 int autoSaveVal=autoSave->value();
840 if(autoSaveVal!=oldAutoSaveValue)
842 config->writeEntry(
"AutoSave", autoSaveVal );
843 doc->setAutoSave(autoSaveVal*60);
844 oldAutoSaveValue=autoSaveVal;
847 bool state =m_createBackupFile->isChecked();
848 if(state!=m_oldBackupFile)
850 config->writeEntry(
"BackupFile", state );
851 doc->setBackupFile( state);
852 m_oldBackupFile=state;
855 state = m_cursorInProtectedArea->isChecked();
856 if ( state != doc->cursorInProtectedArea() )
858 config->writeEntry(
"cursorInProtectArea", state );
859 doc->setCursorInProtectedArea( state );
868 TQString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() );
869 config->writeEntry(
"language" , lang);
870 m_oldLanguage = lang;
875 state = m_autoHyphenation->isChecked();
876 config->writeEntry(
"hyphenation", state );
877 m_oldHyphenation = state;
879 KMacroCommand * macroCmd=0L;
880 int newStartingPage=m_variableNumberOffset->value();
881 if(newStartingPage!=m_oldStartingPage)
883 macroCmd=
new KMacroCommand(i18n(
"Change Starting Page Number"));
886 macroCmd->addCommand(cmd);
887 m_oldStartingPage=newStartingPage;
889 double newTabStop = m_tabStopWidth->value();
890 if ( newTabStop != m_oldTabStopWidth)
893 macroCmd=
new KMacroCommand(i18n(
"Change Tab Stop Value"));
896 KWChangeTabStopValueCommand *cmd =
new KWChangeTabStopValueCommand( i18n(
"Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
898 macroCmd->addCommand(cmd);
899 m_oldTabStopWidth = newTabStop;
905void ConfigureDefaultDocPage::slotDefault()
907 m_columnSpacing->setValue( 3 );
908 autoSave->setValue( KoDocument::defaultAutoSave() / 60 );
909 m_variableNumberOffset->setValue(1);
910 m_cursorInProtectedArea->setChecked(
true);
911 m_tabStopWidth->setValue( MM_TO_POINT(15) );
912 m_createBackupFile->setChecked(
true );
914 m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( TDEGlobal::locale()->language() ) );
915 m_autoHyphenation->setChecked(
false );
918void ConfigureDefaultDocPage::selectNewDefaultFont() {
920 TDEFontChooser::getFontList(list, TDEFontChooser::SmoothScalableFonts);
921 TDEFontDialog dlg( (TQWidget *)this->parent(),
"Font Selector",
false,
true, list,
true );
923 int result = dlg.exec();
924 if (KDialog::Accepted == result) {
926 font =
new TQFont(dlg.font());
927 fontName->setText(font->family() +
' ' + TQString::number(font->pointSize()));
928 fontName->setFont(*font);
929 m_pView->kWordDocument()->setDefaultFont( *font );
933void ConfigureDefaultDocPage::setUnit( KoUnit::Unit unit )
935 m_columnSpacing->setUnit( unit );
936 m_tabStopWidth->setUnit( unit );
937 tabStop->setText( i18n(
"Tab stop:" ) );
942ConfigurePathPage::ConfigurePathPage( KWView *view, TQVBox *box,
char *name )
943 : TQObject( box->parent(), name )
946 KWDocument * doc = m_pView->kWordDocument();
947 config = KWFactory::instance()->config();
948 TQVGroupBox* gbPathGroup =
new TQVGroupBox( i18n(
"Path"), box,
"GroupBox" );
949 gbPathGroup->setMargin( KDialog::marginHint() );
950 gbPathGroup->setInsideSpacing( KDialog::spacingHint() );
952 m_pPathView =
new TDEListView( gbPathGroup );
953 m_pPathView->setResizeMode(TQListView::NoColumn);
954 m_pPathView->addColumn( i18n(
"Type" ) );
955 m_pPathView->addColumn( i18n(
"Path" ), 400 );
956 (void)
new TQListViewItem( m_pPathView, i18n(
"Personal Expression"), doc->personalExpressionPath().join(
";") );
957 (void)
new TQListViewItem( m_pPathView, i18n(
"Backup Path"),doc->backupPath() );
959 m_modifyPath =
new TQPushButton( i18n(
"Modify Path..."), gbPathGroup);
960 connect( m_modifyPath, TQ_SIGNAL( clicked ()),
this, TQ_SLOT( slotModifyPath()));
961 connect( m_pPathView, TQ_SIGNAL( doubleClicked (TQListViewItem *,
const TQPoint &,
int )),
this, TQ_SLOT( slotModifyPath()));
962 connect( m_pPathView, TQ_SIGNAL( selectionChanged ( TQListViewItem * )),
this, TQ_SLOT( slotSelectionChanged(TQListViewItem * )));
963 slotSelectionChanged(m_pPathView->currentItem());
966void ConfigurePathPage::slotSelectionChanged(TQListViewItem * item)
968 m_modifyPath->setEnabled( item );
971void ConfigurePathPage::slotModifyPath()
973 TQListViewItem *item = m_pPathView->currentItem ();
976 if ( item->text(0)==i18n(
"Personal Expression"))
978 KoEditPathDia * dlg =
new KoEditPathDia( item->text( 1), 0L,
"editpath");
980 item->setText(1, dlg->newPath());
983 if ( item->text(0)==i18n(
"Backup Path"))
985 KoChangePathDia *dlg =
new KoChangePathDia( item->text(1), 0L,
"backup path" );
987 item->setText(1, dlg->newPath());
993void ConfigurePathPage::slotDefault()
995 TQListViewItem * item = m_pPathView->findItem(i18n(
"Personal Expression"), 0);
997 item->setText(1, KWFactory::instance()->dirs()->resourceDirs(
"expression").join(
";"));
998 item = m_pPathView->findItem(i18n(
"Backup Path"), 0);
1000 item->setText(1, TQString() );
1003void ConfigurePathPage::apply()
1005 TQListViewItem * item = m_pPathView->findItem(i18n(
"Personal Expression"), 0);
1008 TQStringList lst = TQStringList::split(TQString(
";"), item->text(1));
1009 if ( lst != m_pView->kWordDocument()->personalExpressionPath())
1011 m_pView->kWordDocument()->setPersonalExpressionPath(lst);
1012 config->setGroup(
"Kword Path" );
1013 config->writePathEntry(
"expression path", lst);
1016 item = m_pPathView->findItem(i18n(
"Backup Path"), 0);
1019 TQString res = item->text(1 );
1020 if ( res != m_pView->kWordDocument()->backupPath())
1022 config->setGroup(
"Kword Path" );
1023 m_pView->kWordDocument()->setBackupPath( res );
1024 config->writePathEntry(
"backup path",res );
1032ConfigureTTSPage::ConfigureTTSPage( KWView *view, TQVBox *box,
char *name )
1033 : TQObject( box->parent(), name )
1039 m_cbSpeakPointerWidget =
new TQCheckBox(i18n(
"Speak widget under &mouse pointer"), box);
1040 m_cbSpeakFocusWidget =
new TQCheckBox(i18n(
"Speak widget with &focus"), box);
1041 m_gbScreenReaderOptions =
new TQVGroupBox(
"", box);
1042 m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
1043 m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
1044 m_cbSpeakTooltips =
new TQCheckBox(i18n(
"Speak &tool tips"), m_gbScreenReaderOptions);
1045 m_cbSpeakWhatsThis =
new TQCheckBox(i18n(
"Speak &What's This"), m_gbScreenReaderOptions);
1046 m_cbSpeakDisabled =
new TQCheckBox(i18n(
"Verbal indication if widget is disabled (grayed)",
1047 "&Say whether disabled"), m_gbScreenReaderOptions);
1048 m_cbSpeakAccelerators =
new TQCheckBox(i18n(
"Spea&k accelerators"), m_gbScreenReaderOptions);
1049 TQHBox* hbAcceleratorPrefix =
new TQHBox(m_gbScreenReaderOptions);
1050 TQWidget* spacer =
new TQWidget(hbAcceleratorPrefix);
1051 spacer->setMinimumWidth(2 * KDialog::marginHint());
1052 m_lblAcceleratorPrefix =
1053 new TQLabel(i18n(
"A word spoken before another word",
"Pr&efaced by the word:"),
1054 hbAcceleratorPrefix);
1055 m_leAcceleratorPrefixWord =
new TQLineEdit(i18n(
"Keyboard accelerator, such as Alt+F",
"Accelerator"),
1056 hbAcceleratorPrefix);
1057 m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
1058 TQHBox* hbPollingInterval =
new TQHBox(m_gbScreenReaderOptions);
1059 hbPollingInterval->setMargin( 0 );
1060 TQLabel* lblPollingInterval =
new TQLabel(i18n(
"&Polling interval:"), hbPollingInterval);
1061 m_iniPollingInterval =
new KIntNumInput(hbPollingInterval);
1062 m_iniPollingInterval->setSuffix(
" ms");
1063 m_iniPollingInterval->setRange(100, 5000, 100,
true);
1064 lblPollingInterval->setBuddy(m_iniPollingInterval);
1066 config = KWFactory::instance()->config();
1067 config->setGroup(
"TTS");
1068 m_cbSpeakPointerWidget->setChecked(config->readBoolEntry(
"SpeakPointerWidget",
false));
1069 m_cbSpeakFocusWidget->setChecked(config->readBoolEntry(
"SpeakFocusWidget",
false));
1070 m_cbSpeakTooltips->setChecked(config->readBoolEntry(
"SpeakTooltips",
true));
1071 m_cbSpeakWhatsThis->setChecked(config->readBoolEntry(
"SpeakWhatsThis",
false));
1072 m_cbSpeakDisabled->setChecked(config->readBoolEntry(
"SpeakDisabled",
true));
1073 m_cbSpeakAccelerators->setChecked(config->readBoolEntry(
"SpeakAccelerators",
true));
1074 m_leAcceleratorPrefixWord->setText(config->readEntry(
"AcceleratorPrefixWord",
1075 i18n(
"Keyboard accelerator, such as Alt+F",
"Accelerator")));
1076 m_iniPollingInterval->setValue(config->readNumEntry(
"PollingInterval", 600));
1078 screenReaderOptionChanged();
1079 connect(m_cbSpeakPointerWidget, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(screenReaderOptionChanged()));
1080 connect(m_cbSpeakFocusWidget, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(screenReaderOptionChanged()));
1081 connect(m_cbSpeakAccelerators, TQ_SIGNAL(toggled(
bool)),
this, TQ_SLOT(screenReaderOptionChanged()));
1084void ConfigureTTSPage::slotDefault()
1086 m_cbSpeakPointerWidget->setChecked(
false);
1087 m_cbSpeakFocusWidget->setChecked(
false);
1088 m_cbSpeakTooltips->setChecked(
true);
1089 m_cbSpeakWhatsThis->setChecked(
false);
1090 m_cbSpeakDisabled->setChecked(
true);
1091 m_cbSpeakAccelerators->setChecked(
true);
1092 m_leAcceleratorPrefixWord->setText(i18n(
"Keyboard accelerator, such as Alt+F",
"Accelerator"));
1093 m_iniPollingInterval->setValue(600);
1096void ConfigureTTSPage::apply()
1098 config->setGroup(
"TTS");
1099 config->writeEntry(
"SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
1100 config->writeEntry(
"SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
1101 config->writeEntry(
"SpeakTooltips", m_cbSpeakTooltips->isChecked());
1102 config->writeEntry(
"SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
1103 config->writeEntry(
"SpeakDisabled", m_cbSpeakDisabled->isChecked());
1104 config->writeEntry(
"SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
1105 config->writeEntry(
"AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
1106 config->writeEntry(
"PollingInterval", m_iniPollingInterval->value());
1107 if (kospeaker) kospeaker->readConfig(config);
1110void ConfigureTTSPage::screenReaderOptionChanged()
1112 m_gbScreenReaderOptions->setEnabled(
1113 m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked());
1114 m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
1115 m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
1118#include "KWConfig.moc"
Command to starting page setting.
Command to display link setting.