KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KWConfig.cpp 44KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. /* This file is part of the KDE project
  2. Copyright (C) 2001 Montel Laurent <lmontel@mandrakesoft.com>
  3. Copyright (C) 2005 Thomas Zander <zander@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public License
  13. along with this library; see the file COPYING.LIB. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. * Boston, MA 02110-1301, USA.
  16. */
  17. #include <tdeconfig.h>
  18. #include <kiconloader.h>
  19. #include <tdelocale.h>
  20. #include <KoUnitWidgets.h>
  21. #include <knuminput.h>
  22. #include <knumvalidator.h>
  23. #include <tdefontdialog.h>
  24. #include <kdebug.h>
  25. #include <tqcheckbox.h>
  26. #include <tqlabel.h>
  27. #include <tqvbox.h>
  28. #include <tqcombobox.h>
  29. #include <tqwhatsthis.h>
  30. #include <tqvgroupbox.h>
  31. #include <tqpushbutton.h>
  32. #include <tqlistbox.h>
  33. #include <tqlineedit.h>
  34. #include <tqlayout.h>
  35. #include "KWConfig.h"
  36. #include "KWView.h"
  37. #include "KWFrameSet.h"
  38. #include "KWDocument.h"
  39. #include "KWCanvas.h"
  40. #include "KWViewMode.h"
  41. #include "KWCommand.h"
  42. #include "KWVariable.h"
  43. #include "KoEditPath.h"
  44. #include "KWPageManager.h"
  45. #include "KWPage.h"
  46. #include "KoSpeaker.h"
  47. #include <KoVariable.h>
  48. #include <kformulaconfigpage.h>
  49. #include <tdespell2/configwidget.h>
  50. #include <tdespell2/settings.h>
  51. #include <tdespell2/broker.h>
  52. using namespace KSpell2;
  53. #include <float.h>
  54. #include <tdemessagebox.h>
  55. #include <tdelistview.h>
  56. #include <kstandarddirs.h>
  57. #include <tdeglobalsettings.h>
  58. #include <tdeglobal.h>
  59. #include <kurlrequesterdlg.h>
  60. #include <tdefiledialog.h>
  61. #include <tqtabwidget.h>
  62. #include <keditlistbox.h>
  63. #include <KoGlobal.h>
  64. // little helper stolen from kmail
  65. // (Note: KDialogBase should have version of the methods that take a TQString for the icon name)
  66. static inline TQPixmap loadIcon( const char * name ) {
  67. return TDEGlobal::instance()->iconLoader()
  68. ->loadIcon( TQString::fromLatin1(name), TDEIcon::NoGroup, TDEIcon::SizeMedium );
  69. }
  70. KWConfig::KWConfig( KWView* parent )
  71. : KDialogBase(KDialogBase::IconList,i18n("Configure KWord") ,
  72. KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
  73. KDialogBase::Ok, parent)
  74. {
  75. TQVBox *page2 = addVBoxPage( i18n("Interface"), i18n("Interface Settings"),
  76. loadIcon("configure") );
  77. m_interfacePage=new ConfigureInterfacePage(parent, page2);
  78. TQVBox *page4 = addVBoxPage( i18n("Document"), i18n("Document Settings"),
  79. loadIcon(""x-office-document") );
  80. m_defaultDocPage=new ConfigureDefaultDocPage(parent, page4);
  81. TQVBox *page = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
  82. loadIcon("tools-check-spelling") );
  83. m_spellPage = new ConfigureSpellPage(parent, page);
  84. TQVBox *page5 = addVBoxPage( i18n("Formula"), i18n("Formula Defaults"),
  85. loadIcon("kformula") );
  86. m_formulaPage=new KFormula::ConfigurePage( parent->kWordDocument()->formulaDocument( false ),
  87. this, KWFactory::instance()->config(), page5 );
  88. TQVBox *page3 = addVBoxPage( i18n("Misc"), i18n("Misc Settings"),
  89. loadIcon(""application-vnd.tde.misc") );
  90. m_miscPage=new ConfigureMiscPage(parent, page3);
  91. TQVBox *page6 = addVBoxPage( i18n("Path"), i18n("Path Settings"),
  92. loadIcon("path") );
  93. m_pathPage=new ConfigurePathPage(parent, page6);
  94. if (KoSpeaker::isKttsdInstalled()) {
  95. TQVBox *page7 = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"),
  96. i18n("Text-to-Speech Settings"), loadIcon("access") );
  97. m_ttsPage=new ConfigureTTSPage(parent, page7);
  98. } else m_ttsPage = 0;
  99. m_doc = parent->kWordDocument();
  100. connect(this, TQT_SIGNAL(okClicked()),this,TQT_SLOT(slotApply()));
  101. connect( m_interfacePage, TQT_SIGNAL( unitChanged( int ) ), TQT_SLOT( unitChanged( int ) ) );
  102. unitChanged( parent->kWordDocument()->unit() );
  103. }
  104. void KWConfig::unitChanged( int u )
  105. {
  106. KoUnit::Unit unit = static_cast<KoUnit::Unit>(u);
  107. //m_spellPage->setUnit( unit );
  108. m_interfacePage->setUnit( unit );
  109. m_miscPage->setUnit( unit );
  110. m_defaultDocPage->setUnit( unit );
  111. //m_formulaPage->setUnit( unit );
  112. //m_pathPage->setUnit( unit );
  113. }
  114. void KWConfig::openPage(int flags)
  115. {
  116. if(flags & KW_TDESPELL)
  117. showPage( 2 );
  118. else if(flags & KP_INTERFACE)
  119. showPage(0 );
  120. else if(flags & KP_MISC)
  121. showPage(4);
  122. else if(flags & KP_DOCUMENT)
  123. showPage(2 );
  124. else if(flags & KP_FORMULA)
  125. showPage(3);
  126. else if ( flags & KP_PATH )
  127. showPage(4);
  128. }
  129. void KWConfig::slotApply()
  130. {
  131. KMacroCommand *macro = 0L;
  132. if (m_spellPage) m_spellPage->apply();
  133. m_interfacePage->apply();
  134. m_pathPage->apply();
  135. KCommand * cmd = m_miscPage->apply();
  136. if ( cmd )
  137. {
  138. if ( !macro )
  139. macro = new KMacroCommand( i18n("Change Config"));
  140. macro->addCommand(cmd);
  141. }
  142. cmd=m_defaultDocPage->apply();
  143. if ( cmd )
  144. {
  145. if ( !macro )
  146. macro = new KMacroCommand( i18n("Change Config"));
  147. macro->addCommand( cmd );
  148. }
  149. m_formulaPage->apply();
  150. if (m_ttsPage) m_ttsPage->apply();
  151. if (macro)
  152. m_doc->addCommand( macro );
  153. KWFactory::instance()->config()->sync();
  154. }
  155. void KWConfig::slotDefault()
  156. {
  157. switch(activePageIndex())
  158. {
  159. case 0:
  160. m_interfacePage->slotDefault();
  161. break;
  162. case 1:
  163. m_defaultDocPage->slotDefault();
  164. break;
  165. case 2:
  166. if (m_spellPage) m_spellPage->slotDefault();
  167. break;
  168. case 3:
  169. m_formulaPage->slotDefault();
  170. break;
  171. case 4:
  172. m_miscPage->slotDefault();
  173. break;
  174. case 5:
  175. m_pathPage->slotDefault();
  176. break;
  177. case 6:
  178. m_ttsPage->slotDefault();
  179. default:
  180. break;
  181. }
  182. }
  183. ////
  184. ConfigureSpellPage::ConfigureSpellPage( KWView *view, TQVBox *box, char *name )
  185. : TQObject( box->parent(), name )
  186. {
  187. m_pView=view;
  188. config = KWFactory::instance()->config();
  189. m_spellConfigWidget = new ConfigWidget( view->broker(), box );
  190. m_spellConfigWidget->setBackgroundCheckingButtonShown( true );
  191. m_spellConfigWidget->layout()->setMargin( 0 );
  192. }
  193. void ConfigureSpellPage::apply()
  194. {
  195. KWDocument* doc = m_pView->kWordDocument();
  196. m_spellConfigWidget->save();
  197. m_pView->kWordDocument()->setSpellCheckIgnoreList(
  198. m_pView->broker()->settings()->currentIgnoreList() );
  199. //FIXME reactivate just if there are changes.
  200. doc->enableBackgroundSpellCheck( m_pView->broker()->settings()->backgroundCheckerEnabled() );
  201. doc->reactivateBgSpellChecking();
  202. }
  203. void ConfigureSpellPage::slotDefault()
  204. {
  205. m_spellConfigWidget->slotDefault();
  206. }
  207. ConfigureInterfacePage::ConfigureInterfacePage( KWView *view, TQVBox *box, char *name )
  208. : TQObject( box->parent(), name )
  209. {
  210. m_pView=view;
  211. config = KWFactory::instance()->config();
  212. TQVGroupBox* gbInterfaceGroup = new TQVGroupBox( i18n("Interface"), box, "GroupBox" );
  213. gbInterfaceGroup->setMargin( KDialog::marginHint() );
  214. gbInterfaceGroup->setInsideSpacing( KDialog::spacingHint() );
  215. double ptGridX=MM_TO_POINT(5.0 );
  216. double ptGridY=MM_TO_POINT(5.0 );
  217. double ptIndent = MM_TO_POINT(10.0);
  218. bool oldShowStatusBar = true;
  219. bool oldPgUpDownMovesCaret = false;
  220. bool oldShowScrollBar = true;
  221. oldNbRecentFiles=10;
  222. int nbPagePerRow=4;
  223. KoUnit::Unit unit = m_pView->kWordDocument()->unit();
  224. if( config->hasGroup("Interface") )
  225. {
  226. config->setGroup( "Interface" );
  227. ptGridX=config->readDoubleNumEntry("GridX", ptGridX);
  228. ptGridY=config->readDoubleNumEntry("GridY", ptGridY);
  229. ptIndent = config->readDoubleNumEntry("Indent", ptIndent);
  230. oldNbRecentFiles=config->readNumEntry("NbRecentFile", oldNbRecentFiles);
  231. nbPagePerRow=config->readNumEntry("nbPagePerRow", nbPagePerRow);
  232. oldShowStatusBar = config->readBoolEntry( "ShowStatusBar", true );
  233. oldPgUpDownMovesCaret = config->readBoolEntry( "PgUpDownMovesCaret", false );
  234. oldShowScrollBar = config->readBoolEntry("ShowScrollBar", true);
  235. }
  236. TQHBox *hbUnit = new TQHBox(gbInterfaceGroup);
  237. hbUnit->setSpacing(KDialog::spacingHint());
  238. TQLabel *unitLabel= new TQLabel(i18n("&Units:"),hbUnit);
  239. m_unitCombo = new TQComboBox( hbUnit );
  240. m_unitCombo->insertStringList( KoUnit::listOfUnitName() );
  241. connect(m_unitCombo, TQT_SIGNAL(activated(int)), this, TQT_SIGNAL(unitChanged(int)));
  242. unitLabel->setBuddy( m_unitCombo );
  243. TQString unitHelp = i18n("Select the unit type used every time a distance or width/height "
  244. "is displayed or entered. This one setting is for the whole of KWord: all dialogs, the rulers etc. "
  245. "Note that KWord documents specify the unit which was used to create them, so this setting "
  246. "only affects this document and all documents that will be created later.");
  247. TQWhatsThis::add( unitLabel, unitHelp );
  248. TQWhatsThis::add( m_unitCombo, unitHelp );
  249. showStatusBar = new TQCheckBox(i18n("Show &status bar"),gbInterfaceGroup);
  250. showStatusBar->setChecked(oldShowStatusBar);
  251. TQWhatsThis::add( showStatusBar, i18n("Show or hide the status bar. If enabled, the status bar is shown at the bottom, which displays various information."));
  252. showScrollBar = new TQCheckBox( i18n("Show s&crollbar"), gbInterfaceGroup);
  253. showScrollBar->setChecked(oldShowScrollBar);
  254. 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."));
  255. pgUpDownMovesCaret = new TQCheckBox(i18n("PageUp/PageDown &moves the caret"),gbInterfaceGroup);
  256. pgUpDownMovesCaret->setChecked(oldPgUpDownMovesCaret);
  257. TQWhatsThis::add( pgUpDownMovesCaret, i18n(
  258. "If this option is enabled, the PageUp and PageDown keys "
  259. "move the text caret, as in other TDE applications. "
  260. "If it is disabled, they move the scrollbars, as in most other word processors." ) );
  261. TQHBox* hbRecent = new TQHBox( gbInterfaceGroup );
  262. TQString recentHelp = i18n("The number of files remembered in the file open dialog and in the "
  263. "recent files menu item.");
  264. TQLabel* labelRecent = new TQLabel( i18n("Number of recent &files:"), hbRecent );
  265. TQWhatsThis::add( labelRecent, recentHelp );
  266. recentFiles=new KIntNumInput( oldNbRecentFiles, hbRecent );
  267. recentFiles->setRange(1, 20, 1);
  268. labelRecent->setBuddy( recentFiles );
  269. TQWhatsThis::add( recentFiles, recentHelp );
  270. TQHBox* hbGridX = new TQHBox( gbInterfaceGroup );
  271. TQString gridxHelp = i18n("The grid size on which frames, tabs and other content snaps while "
  272. "moving and scaling.");
  273. TQLabel* labelGridX = new TQLabel( i18n("&Horizontal grid size:"), hbGridX );
  274. TQWhatsThis::add( labelGridX, gridxHelp );
  275. gridX=new KoUnitDoubleSpinBox( hbGridX,
  276. 0.1,
  277. 50,
  278. 0.1,
  279. ptGridX,
  280. unit );
  281. labelGridX->setBuddy( gridX );
  282. TQWhatsThis::add( gridX, gridxHelp );
  283. TQHBox* hbGridY = new TQHBox( gbInterfaceGroup );
  284. TQString gridyHelp = i18n("The grid size on which frames and other content snaps while "
  285. "moving and scaling.");
  286. TQLabel* labelGridY = new TQLabel( i18n("&Vertical grid size:"), hbGridY );
  287. TQWhatsThis::add( labelGridY, gridyHelp );
  288. gridY=new KoUnitDoubleSpinBox( hbGridY,
  289. 0.1,
  290. 50,
  291. 0.1,
  292. ptGridY,
  293. unit );
  294. labelGridY->setBuddy( gridY );
  295. TQWhatsThis::add( gridY, gridyHelp );
  296. TQHBox* hbIndent = new TQHBox( gbInterfaceGroup );
  297. TQString indentHelp = i18n("Configure the indent width used when using the 'Increase' "
  298. "or 'Decrease' indentation buttons on a paragraph.<p>The lower the value, "
  299. "the more often the buttons will have to be pressed to gain the same "
  300. "indentation.");
  301. TQLabel* labelIndent = new TQLabel( i18n("&Paragraph indent by toolbar buttons:"), hbIndent );
  302. TQWhatsThis::add( labelIndent, indentHelp );
  303. indent = new KoUnitDoubleSpinBox( hbIndent,
  304. 0.1,
  305. 5000,
  306. 0.1,
  307. ptIndent,
  308. unit );
  309. labelIndent->setBuddy( indent );
  310. TQWhatsThis::add( indent, indentHelp );
  311. TQHBox* hbPagePerRow = new TQHBox( gbInterfaceGroup );
  312. TQString pagePerRowHelp = i18n("After selecting Preview Mode (from the \"View\" menu,) "
  313. "this is the number of pages KWord will "
  314. "position on one horizontal row.");
  315. TQLabel* labelPagePerRow = new TQLabel( i18n("Number of pa&ges per row in preview mode:" ), hbPagePerRow );
  316. TQWhatsThis::add( labelPagePerRow, pagePerRowHelp );
  317. m_nbPagePerRow=new KIntNumInput( 0, nbPagePerRow, hbPagePerRow );
  318. m_nbPagePerRow->setRange(1, 10, 1);
  319. labelPagePerRow->setBuddy( m_nbPagePerRow );
  320. hbPagePerRow->setStretchFactor( m_nbPagePerRow, 1 );
  321. TQWhatsThis::add(m_nbPagePerRow , pagePerRowHelp );
  322. }
  323. void ConfigureInterfacePage::apply()
  324. {
  325. KWDocument * doc = m_pView->kWordDocument();
  326. double valX = TQMAX( 0.1, gridX->value() );
  327. double valY = TQMAX( 0.1, gridY->value() );
  328. int nbRecent=recentFiles->value();
  329. bool statusBar=showStatusBar->isChecked();
  330. bool scrollBar = showScrollBar->isChecked();
  331. config->setGroup( "Interface" );
  332. bool updateView = false;
  333. if(valX!=doc->gridX())
  334. {
  335. config->writeEntry( "GridX", valX, true, false, 'g', DBL_DIG /* 6 is not enough */ );
  336. doc->setGridX(valX);
  337. updateView= true;
  338. }
  339. if(valY!=doc->gridY())
  340. {
  341. config->writeEntry( "GridY", valY, true, false, 'g', DBL_DIG /* 6 is not enough */ );
  342. doc->setGridY(valY);
  343. updateView= true;
  344. }
  345. double newIndent = indent->value();
  346. if( newIndent != doc->indentValue() )
  347. {
  348. config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ );
  349. doc->setIndentValue( newIndent );
  350. }
  351. if(nbRecent!=oldNbRecentFiles)
  352. {
  353. config->writeEntry( "NbRecentFile", nbRecent);
  354. m_pView->changeNbOfRecentFiles(nbRecent);
  355. }
  356. bool refreshGUI= false;
  357. if( statusBar != doc->showStatusBar() )
  358. {
  359. config->writeEntry( "ShowStatusBar", statusBar );
  360. doc->setShowStatusBar( statusBar );
  361. refreshGUI=true;
  362. }
  363. if( scrollBar != doc->showScrollBar() )
  364. {
  365. config->writeEntry( "ShowScrollBar", scrollBar );
  366. doc->setShowScrollBar( scrollBar );
  367. refreshGUI=true;
  368. }
  369. bool b = pgUpDownMovesCaret->isChecked();
  370. if ( b != doc->pgUpDownMovesCaret() )
  371. {
  372. config->writeEntry( "PgUpDownMovesCaret", b );
  373. doc->setPgUpDownMovesCaret( b );
  374. }
  375. if( refreshGUI )
  376. doc->reorganizeGUI();
  377. int nbPageByRow=m_nbPagePerRow->value();
  378. if(nbPageByRow!=doc->nbPagePerRow())
  379. {
  380. config->writeEntry("nbPagePerRow",nbPageByRow);
  381. m_pView->getGUI()->canvasWidget()->viewMode()->setPagesPerRow(nbPageByRow);
  382. doc->setNbPagePerRow(nbPageByRow);
  383. //m_pView->getGUI()->canvasWidget()->refreshViewMode();
  384. //necessary to recreate new view because in switchViewMode
  385. //we delete viewmode that we want to apply (LM)
  386. // This needs to be cleaned up .... (DF)
  387. doc->switchViewMode( doc->viewModeType() ); // force a refresh
  388. }
  389. config->setGroup( "Misc" );
  390. KoUnit::Unit unit = static_cast<KoUnit::Unit>( m_unitCombo->currentItem() );
  391. // It's already been set in the document, see unitChanged
  392. config->writeEntry( "Units", KoUnit::unitName( unit ) );
  393. if ( updateView )
  394. doc->repaintAllViews(false);
  395. }
  396. void ConfigureInterfacePage::setUnit( KoUnit::Unit unit )
  397. {
  398. m_unitCombo->blockSignals( true );
  399. m_unitCombo->setCurrentItem( unit );
  400. m_unitCombo->blockSignals( false );
  401. // We need to set it in the doc immediately, because much code here uses doc->unit()
  402. m_pView->kWordDocument()->setUnit( unit );
  403. gridX->setUnit( unit );
  404. gridY->setUnit( unit );
  405. indent->setUnit( unit );
  406. }
  407. void ConfigureInterfacePage::slotDefault()
  408. {
  409. KWDocument * doc = m_pView->kWordDocument();
  410. m_unitCombo->setCurrentItem( KoUnit::U_CM );
  411. emit unitChanged( m_unitCombo->currentItem() );
  412. gridX->setValue( KoUnit::toUserValue( MM_TO_POINT( 5.0 ),doc->unit() ) );
  413. gridY->setValue( KoUnit::toUserValue( MM_TO_POINT( 5.0 ),doc->unit() ) );
  414. m_nbPagePerRow->setValue(4);
  415. double newIndent = KoUnit::toUserValue( MM_TO_POINT( 10 ), doc->unit() );
  416. indent->setValue( newIndent );
  417. recentFiles->setValue(10);
  418. showStatusBar->setChecked(true);
  419. pgUpDownMovesCaret->setChecked(false);
  420. showScrollBar->setChecked( true);
  421. }
  422. ////
  423. ConfigureMiscPage::ConfigureMiscPage( KWView *view, TQVBox *box, char *name )
  424. : TQObject( box->parent(), name )
  425. {
  426. m_pView=view;
  427. config = KWFactory::instance()->config();
  428. TQVGroupBox* gbMiscGroup = new TQVGroupBox( i18n("Misc"), box, "GroupBox" );
  429. gbMiscGroup->setMargin( KDialog::marginHint() );
  430. gbMiscGroup->setInsideSpacing( KDialog::spacingHint() );
  431. m_oldNbRedo=30;
  432. // Don't load the unit from config file because the unit can come from the kword file
  433. // => unit can be different from config file
  434. if( config->hasGroup("Misc") )
  435. {
  436. config->setGroup( "Misc" );
  437. m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
  438. }
  439. TQHBox* hbUndoRedo = new TQHBox( gbMiscGroup );
  440. TQLabel* labelUndoRedo = new TQLabel( i18n("Undo/&redo limit:"), hbUndoRedo );
  441. TQString undoHelp = i18n("Limit the number of undo/redo actions remembered. "
  442. "A lower value helps to save memory, a higher value allows "
  443. "you to undo and redo more editing steps.");
  444. m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, hbUndoRedo );
  445. m_undoRedoLimit->setRange(1, 100, 1);
  446. labelUndoRedo->setBuddy( m_undoRedoLimit );
  447. TQWhatsThis::add( m_undoRedoLimit, undoHelp );
  448. TQWhatsThis::add( labelUndoRedo, undoHelp );
  449. KWDocument* doc = m_pView->kWordDocument();
  450. m_displayLink=new TQCheckBox(i18n("Display &links"),gbMiscGroup);
  451. m_displayLink->setChecked(doc->variableCollection()->variableSetting()->displayLink());
  452. TQWhatsThis::add( m_displayLink, i18n("If enabled, a link is highlighted as such and is clickable.\n\n"
  453. "You can insert a link from the Insert menu."));
  454. m_underlineLink=new TQCheckBox(i18n("&Underline all links"),gbMiscGroup);
  455. m_underlineLink->setChecked(doc->variableCollection()->variableSetting()->underlineLink());
  456. TQWhatsThis::add( m_underlineLink, i18n("If enabled, a link is underlined."));
  457. m_displayComment=new TQCheckBox(i18n("Display c&omments"),gbMiscGroup);
  458. m_displayComment->setChecked(doc->variableCollection()->variableSetting()->displayComment());
  459. TQWhatsThis::add( m_displayComment, i18n("If enabled, comments are indicated by a small yellow box.\n\n"
  460. "You can show and edit a comment from the context menu."));
  461. m_displayFieldCode=new TQCheckBox(i18n("Display field code"),gbMiscGroup);
  462. m_displayFieldCode->setChecked(doc->variableCollection()->variableSetting()->displayFieldCode());
  463. TQWhatsThis::add( m_displayFieldCode, i18n("If enabled, the type of link is displayed instead "
  464. "of displaying the link text.\n\n"
  465. "There are various types of link that can be inserted, "
  466. "such as hyperlinks, files, mail, news and bookmarks."));
  467. TQVGroupBox* gbViewFormatting = new TQVGroupBox( i18n("View Formatting"), box, "view_formatting" );
  468. TQWhatsThis::add( gbViewFormatting, i18n("These settings can be used to select the formatting "
  469. "characters that should be shown.\n\n"
  470. "Note that the selected formatting characters are only "
  471. "shown if formatting characters are enabled in general, "
  472. "which can be done from the View menu."));
  473. gbViewFormatting->setMargin( KDialog::marginHint() );
  474. gbViewFormatting->setInsideSpacing( KDialog::spacingHint() );
  475. m_oldFormattingEndParag = doc->viewFormattingEndParag();
  476. m_oldFormattingSpace = doc->viewFormattingSpace();
  477. m_oldFormattingTabs = doc->viewFormattingTabs();
  478. m_oldFormattingBreak = doc->viewFormattingBreak();
  479. m_cbViewFormattingEndParag = new TQCheckBox( i18n("View formatting end paragraph"), gbViewFormatting);
  480. m_cbViewFormattingEndParag->setChecked(m_oldFormattingEndParag);
  481. m_cbViewFormattingSpace = new TQCheckBox( i18n("View formatting space"), gbViewFormatting);
  482. m_cbViewFormattingSpace->setChecked(m_oldFormattingSpace);
  483. m_cbViewFormattingTabs = new TQCheckBox( i18n("View formatting tabs"), gbViewFormatting);
  484. m_cbViewFormattingTabs->setChecked(m_oldFormattingTabs);
  485. m_cbViewFormattingBreak = new TQCheckBox( i18n("View formatting break"), gbViewFormatting);
  486. m_cbViewFormattingBreak->setChecked(m_oldFormattingBreak);
  487. }
  488. ConfigureDefaultDocPage::~ConfigureDefaultDocPage()
  489. {
  490. delete font;
  491. }
  492. KCommand *ConfigureMiscPage::apply()
  493. {
  494. KWDocument * doc = m_pView->kWordDocument();
  495. config->setGroup( "Misc" );
  496. int newUndo=m_undoRedoLimit->value();
  497. if(newUndo!=m_oldNbRedo)
  498. {
  499. config->writeEntry("UndoRedo",newUndo);
  500. doc->setUndoRedoLimit(newUndo);
  501. m_oldNbRedo=newUndo;
  502. }
  503. KMacroCommand * macroCmd=0L;
  504. bool b=m_displayLink->isChecked();
  505. if(doc->variableCollection()->variableSetting()->displayLink()!=b)
  506. {
  507. if(!macroCmd)
  508. {
  509. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  510. }
  511. KWChangeVariableSettingsCommand *cmd=new KWChangeVariableSettingsCommand( i18n("Change Display Link Command"), doc, doc->variableCollection()->variableSetting()->displayLink() ,b, KWChangeVariableSettingsCommand::VS_DISPLAYLINK);
  512. cmd->execute();
  513. macroCmd->addCommand(cmd);
  514. }
  515. b=m_underlineLink->isChecked();
  516. if(doc->variableCollection()->variableSetting()->underlineLink()!=b)
  517. {
  518. if(!macroCmd)
  519. {
  520. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  521. }
  522. KWChangeVariableSettingsCommand *cmd=new KWChangeVariableSettingsCommand( i18n("Change Display Link Command"), doc, doc->variableCollection()->variableSetting()->underlineLink() ,b, KWChangeVariableSettingsCommand::VS_UNDERLINELINK);
  523. cmd->execute();
  524. macroCmd->addCommand(cmd);
  525. }
  526. b=m_displayComment->isChecked();
  527. if(doc->variableCollection()->variableSetting()->displayComment()!=b)
  528. {
  529. if(!macroCmd)
  530. {
  531. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  532. }
  533. KWChangeVariableSettingsCommand *cmd=new KWChangeVariableSettingsCommand( i18n("Change Display Link Command"), doc, doc->variableCollection()->variableSetting()->displayComment() ,b, KWChangeVariableSettingsCommand::VS_DISPLAYCOMMENT);
  534. cmd->execute();
  535. macroCmd->addCommand(cmd);
  536. }
  537. b=m_displayFieldCode->isChecked();
  538. if(doc->variableCollection()->variableSetting()->displayFieldCode()!=b)
  539. {
  540. if(!macroCmd)
  541. {
  542. macroCmd=new KMacroCommand(i18n("Change Display Field Code Command"));
  543. }
  544. KWChangeVariableSettingsCommand *cmd=new KWChangeVariableSettingsCommand( i18n("Change Display Field Code Command"), doc, doc->variableCollection()->variableSetting()->displayFieldCode() ,b, KWChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE);
  545. cmd->execute();
  546. macroCmd->addCommand(cmd);
  547. }
  548. bool state =m_cbViewFormattingEndParag->isChecked();
  549. bool needRepaint = false;
  550. if ( state != m_oldFormattingEndParag )
  551. {
  552. doc->setViewFormattingEndParag(state);
  553. needRepaint = true;
  554. m_oldFormattingEndParag = state;
  555. }
  556. state = m_cbViewFormattingSpace->isChecked();
  557. if ( state != m_oldFormattingSpace)
  558. {
  559. doc->setViewFormattingSpace(state);
  560. needRepaint = true;
  561. m_oldFormattingSpace = state;
  562. }
  563. state = m_cbViewFormattingBreak->isChecked();
  564. if ( state != m_oldFormattingBreak)
  565. {
  566. doc->setViewFormattingBreak(state);
  567. needRepaint = true;
  568. m_oldFormattingBreak = state;
  569. }
  570. state = m_cbViewFormattingTabs->isChecked();
  571. if ( state != m_oldFormattingTabs )
  572. {
  573. doc->setViewFormattingTabs(state);
  574. needRepaint = true;
  575. m_oldFormattingTabs= state;
  576. }
  577. if ( needRepaint )
  578. {
  579. doc->layout();
  580. doc->repaintAllViews();
  581. }
  582. return macroCmd;
  583. }
  584. void ConfigureMiscPage::slotDefault()
  585. {
  586. m_undoRedoLimit->setValue(30);
  587. m_displayLink->setChecked(true);
  588. m_displayComment->setChecked(true);
  589. m_underlineLink->setChecked(true);
  590. m_cbViewFormattingEndParag->setChecked(true);
  591. m_cbViewFormattingSpace->setChecked(true);
  592. m_cbViewFormattingTabs->setChecked(true);
  593. m_cbViewFormattingBreak->setChecked(true);
  594. m_displayFieldCode->setChecked( false );
  595. }
  596. void ConfigureMiscPage::setUnit( KoUnit::Unit )
  597. {
  598. }
  599. ////
  600. ConfigureDefaultDocPage::ConfigureDefaultDocPage( KWView *view, TQVBox *box, char *name )
  601. : TQObject( box->parent(), name )
  602. {
  603. m_pView=view;
  604. KWDocument * doc = m_pView->kWordDocument();
  605. config = KWFactory::instance()->config();
  606. TQVGroupBox* gbDocumentDefaults = new TQVGroupBox( i18n("Document Defaults"), box, "GroupBox" );
  607. gbDocumentDefaults->setMargin( KDialog::marginHint() );
  608. gbDocumentDefaults->setInsideSpacing( KDialog::spacingHint() );
  609. double ptColumnSpacing=3;
  610. KoUnit::Unit unit = doc->unit();
  611. if( config->hasGroup("Document defaults") )
  612. {
  613. config->setGroup( "Document defaults" );
  614. ptColumnSpacing=config->readDoubleNumEntry("ColumnSpacing",ptColumnSpacing);
  615. // loaded by kwdoc already defaultFont=config->readEntry("DefaultFont",defaultFont);
  616. }
  617. TQHBox* hbColumnSpacing = new TQHBox( gbDocumentDefaults );
  618. TQLabel* columnSpacingLabel = new TQLabel( i18n("Default column spacing:"), hbColumnSpacing );
  619. m_columnSpacing = new KoUnitDoubleSpinBox( hbColumnSpacing,
  620. 0.1,
  621. 50,
  622. 0.1,
  623. ptColumnSpacing,
  624. unit );
  625. columnSpacingLabel->setBuddy( m_columnSpacing );
  626. TQWhatsThis::add( m_columnSpacing, i18n("When setting a document to use more than one column "
  627. "this distance will be used to separate the columns. This value is merely a default "
  628. "setting as the column spacing can be changed per document") );
  629. TQWidget *fontContainer = new TQWidget(gbDocumentDefaults);
  630. TQGridLayout * fontLayout = new TQGridLayout(fontContainer, 1, 3);
  631. fontLayout->setSpacing(KDialog::spacingHint());
  632. fontLayout->setColStretch(0, 0);
  633. fontLayout->setColStretch(1, 1);
  634. fontLayout->setColStretch(2, 0);
  635. TQLabel *fontTitle = new TQLabel(i18n("Default font:"), fontContainer);
  636. font= new TQFont( doc->defaultFont() );
  637. TQString labelName = font->family() + ' ' + TQString::number(font->pointSize());
  638. fontName = new TQLabel(labelName, fontContainer);
  639. fontName->setFont(*font);
  640. fontName->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
  641. TQPushButton *chooseButton = new TQPushButton(i18n("Choose..."), fontContainer);
  642. connect(chooseButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectNewDefaultFont()));
  643. fontLayout->addWidget(fontTitle, 0, 0);
  644. fontLayout->addWidget(fontName, 0, 1);
  645. fontLayout->addWidget(chooseButton, 0, 2);
  646. oldAutoSaveValue=KoDocument::defaultAutoSave() / 60;
  647. m_oldLanguage = doc->globalLanguage();
  648. m_oldHyphenation = doc->globalHyphenation();
  649. if( config->hasGroup("Interface") )
  650. {
  651. config->setGroup( "Interface" );
  652. oldAutoSaveValue=config->readNumEntry("AutoSave",oldAutoSaveValue);
  653. m_oldLanguage = config->readEntry( "language", m_oldLanguage);
  654. m_oldHyphenation = config->readBoolEntry( "hyphenation", m_oldHyphenation);
  655. }
  656. TQWidget *languageContainer = new TQWidget(gbDocumentDefaults);
  657. TQGridLayout * languageLayout = new TQGridLayout(languageContainer, 1, 3);
  658. languageLayout->setSpacing(KDialog::spacingHint());
  659. languageLayout->setColStretch(0, 0);
  660. languageLayout->setColStretch(1, 1);
  661. TQLabel *languageTitle = new TQLabel(i18n("Global language:"), languageContainer);
  662. m_globalLanguage = new TQComboBox( languageContainer );
  663. m_globalLanguage->insertStringList( KoGlobal::listOfLanguages() );
  664. m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( m_oldLanguage ) );
  665. languageLayout->addWidget(languageTitle, 0, 0);
  666. languageLayout->addWidget(m_globalLanguage, 0, 1);
  667. m_autoHyphenation = new TQCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults);
  668. m_autoHyphenation->setChecked( m_oldHyphenation );
  669. TQVGroupBox* gbDocumentSettings = new TQVGroupBox( i18n("Document Settings"), box );
  670. gbDocumentSettings->setMargin( KDialog::marginHint() );
  671. gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
  672. TQHBox* hbAutoSave = new TQHBox( gbDocumentSettings );
  673. TQLabel* labelAutoSave = new TQLabel( i18n("Autosave every (min):"), hbAutoSave );
  674. autoSave = new KIntNumInput( oldAutoSaveValue, hbAutoSave );
  675. autoSave->setRange(0, 60, 1);
  676. labelAutoSave->setBuddy(autoSave);
  677. TQWhatsThis::add( autoSave, i18n("A backup copy of the current document is created when a change "
  678. "has been made. The interval used to create backup documents is set here.") );
  679. autoSave->setSpecialValueText(i18n("No autosave"));
  680. autoSave->setSuffix(i18n(" min"));
  681. m_oldBackupFile = true;
  682. if( config->hasGroup("Interface") )
  683. {
  684. config->setGroup( "Interface" );
  685. m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
  686. }
  687. m_createBackupFile = new TQCheckBox( i18n("Create backup file"), gbDocumentSettings);
  688. m_createBackupFile->setChecked( m_oldBackupFile );
  689. TQHBox* hbStartingPage = new TQHBox( gbDocumentSettings );
  690. TQLabel* labelStartingPage = new TQLabel(i18n("Starting page number:"), hbStartingPage);
  691. m_oldStartingPage=doc->variableCollection()->variableSetting()->startingPageNumber();
  692. m_variableNumberOffset=new KIntNumInput(hbStartingPage);
  693. m_variableNumberOffset->setRange(-1000, 9999, 1, false);
  694. m_variableNumberOffset->setValue(m_oldStartingPage);
  695. labelStartingPage->setBuddy( m_variableNumberOffset );
  696. TQHBox* hbTabStop = new TQHBox( gbDocumentSettings );
  697. tabStop = new TQLabel(i18n("Tab stop (%1):").arg(doc->unitName()), hbTabStop);
  698. m_tabStopWidth = new KoUnitDoubleSpinBox( hbTabStop,
  699. MM_TO_POINT(2),
  700. doc->pageManager()->page(doc->startPage())->width(),
  701. 0.1,
  702. doc->tabStopValue(),
  703. unit );
  704. m_oldTabStopWidth = doc->tabStopValue();
  705. TQVGroupBox* gbDocumentCursor = new TQVGroupBox( i18n("Cursor"), box );
  706. gbDocumentCursor->setMargin( KDialog::marginHint() );
  707. gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() );
  708. m_cursorInProtectedArea= new TQCheckBox(i18n("Cursor in protected area"),gbDocumentCursor);
  709. m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
  710. // m_directInsertCursor= new TQCheckBox(i18n("Direct insert cursor"),gbDocumentCursor);
  711. // m_directInsertCursor->setChecked(doc->insertDirectCursor());
  712. }
  713. KCommand *ConfigureDefaultDocPage::apply()
  714. {
  715. config->setGroup( "Document defaults" );
  716. KWDocument * doc = m_pView->kWordDocument();
  717. double colSpacing = m_columnSpacing->value();
  718. if ( colSpacing != doc->defaultColumnSpacing() )
  719. {
  720. config->writeEntry( "ColumnSpacing", colSpacing , true, false, 'g', DBL_DIG );
  721. doc->setDefaultColumnSpacing(colSpacing);
  722. }
  723. config->writeEntry("DefaultFont",TQString(font->toString()));
  724. config->setGroup( "Interface" );
  725. int autoSaveVal=autoSave->value();
  726. if(autoSaveVal!=oldAutoSaveValue)
  727. {
  728. config->writeEntry( "AutoSave", autoSaveVal );
  729. doc->setAutoSave(autoSaveVal*60);
  730. oldAutoSaveValue=autoSaveVal;
  731. }
  732. bool state =m_createBackupFile->isChecked();
  733. if(state!=m_oldBackupFile)
  734. {
  735. config->writeEntry( "BackupFile", state );
  736. doc->setBackupFile( state);
  737. m_oldBackupFile=state;
  738. }
  739. state = m_cursorInProtectedArea->isChecked();
  740. if ( state != doc->cursorInProtectedArea() )
  741. {
  742. config->writeEntry( "cursorInProtectArea", state );
  743. doc->setCursorInProtectedArea( state );
  744. }
  745. // state = m_directInsertCursor->isChecked();
  746. // if ( state != doc->insertDirectCursor() )
  747. // doc->setInsertDirectCursor( state );
  748. //Laurent Todo add a message box to inform user that
  749. //global language will change after re-launch kword
  750. TQString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() );
  751. config->writeEntry( "language" , lang);
  752. m_oldLanguage = lang;
  753. //don't call this fiunction otherwise we can have a textobject with
  754. // a default language and other textobject with other default language.
  755. //doc->setGlobalLanguage( lang );
  756. state = m_autoHyphenation->isChecked();
  757. config->writeEntry( "hyphenation", state );
  758. m_oldHyphenation = state;
  759. KMacroCommand * macroCmd=0L;
  760. int newStartingPage=m_variableNumberOffset->value();
  761. if(newStartingPage!=m_oldStartingPage)
  762. {
  763. macroCmd=new KMacroCommand(i18n("Change Starting Page Number"));
  764. KWChangeStartingPageCommand *cmd = new KWChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage );
  765. cmd->execute();
  766. macroCmd->addCommand(cmd);
  767. m_oldStartingPage=newStartingPage;
  768. }
  769. double newTabStop = m_tabStopWidth->value();
  770. if ( newTabStop != m_oldTabStopWidth)
  771. {
  772. if ( !macroCmd )
  773. macroCmd=new KMacroCommand(i18n("Change Tab Stop Value"));
  774. KWChangeTabStopValueCommand *cmd = new KWChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
  775. cmd->execute();
  776. macroCmd->addCommand(cmd);
  777. m_oldTabStopWidth = newTabStop;
  778. }
  779. return macroCmd;
  780. }
  781. void ConfigureDefaultDocPage::slotDefault()
  782. {
  783. m_columnSpacing->setValue( 3 );
  784. autoSave->setValue( KoDocument::defaultAutoSave() / 60 );
  785. m_variableNumberOffset->setValue(1);
  786. m_cursorInProtectedArea->setChecked(true);
  787. m_tabStopWidth->setValue( MM_TO_POINT(15) );
  788. m_createBackupFile->setChecked( true );
  789. // m_directInsertCursor->setChecked( false );
  790. m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( TDEGlobal::locale()->language() ) );
  791. m_autoHyphenation->setChecked( false );
  792. }
  793. void ConfigureDefaultDocPage::selectNewDefaultFont() {
  794. TQStringList list;
  795. TDEFontChooser::getFontList(list, TDEFontChooser::SmoothScalableFonts);
  796. TDEFontDialog dlg( (TQWidget *)this->parent(), "Font Selector", false, true, list, true );
  797. dlg.setFont(*font);
  798. int result = dlg.exec();
  799. if (KDialog::Accepted == result) {
  800. delete font;
  801. font = new TQFont(dlg.font());
  802. fontName->setText(font->family() + ' ' + TQString::number(font->pointSize()));
  803. fontName->setFont(*font);
  804. m_pView->kWordDocument()->setDefaultFont( *font );
  805. }
  806. }
  807. void ConfigureDefaultDocPage::setUnit( KoUnit::Unit unit )
  808. {
  809. m_columnSpacing->setUnit( unit );
  810. m_tabStopWidth->setUnit( unit );
  811. tabStop->setText( i18n( "Tab stop:" ) );
  812. }
  813. ////
  814. ConfigurePathPage::ConfigurePathPage( KWView *view, TQVBox *box, char *name )
  815. : TQObject( box->parent(), name )
  816. {
  817. m_pView=view;
  818. KWDocument * doc = m_pView->kWordDocument();
  819. config = KWFactory::instance()->config();
  820. TQVGroupBox* gbPathGroup = new TQVGroupBox( i18n("Path"), box, "GroupBox" );
  821. gbPathGroup->setMargin( KDialog::marginHint() );
  822. gbPathGroup->setInsideSpacing( KDialog::spacingHint() );
  823. m_pPathView = new TDEListView( gbPathGroup );
  824. m_pPathView->setResizeMode(TQListView::NoColumn);
  825. m_pPathView->addColumn( i18n( "Type" ) );
  826. m_pPathView->addColumn( i18n( "Path" ), 400 ); // not too big by default
  827. (void) new TQListViewItem( m_pPathView, i18n("Personal Expression"), doc->personalExpressionPath().join(";") );
  828. (void) new TQListViewItem( m_pPathView, i18n("Backup Path"),doc->backupPath() );
  829. m_modifyPath = new TQPushButton( i18n("Modify Path..."), gbPathGroup);
  830. connect( m_modifyPath, TQT_SIGNAL( clicked ()), this, TQT_SLOT( slotModifyPath()));
  831. connect( m_pPathView, TQT_SIGNAL( doubleClicked (TQListViewItem *, const TQPoint &, int )), this, TQT_SLOT( slotModifyPath()));
  832. connect( m_pPathView, TQT_SIGNAL( selectionChanged ( TQListViewItem * )), this, TQT_SLOT( slotSelectionChanged(TQListViewItem * )));
  833. slotSelectionChanged(m_pPathView->currentItem());
  834. }
  835. void ConfigurePathPage::slotSelectionChanged(TQListViewItem * item)
  836. {
  837. m_modifyPath->setEnabled( item );
  838. }
  839. void ConfigurePathPage::slotModifyPath()
  840. {
  841. TQListViewItem *item = m_pPathView->currentItem ();
  842. if ( item )
  843. {
  844. if ( item->text(0)==i18n("Personal Expression"))
  845. {
  846. KoEditPathDia * dlg = new KoEditPathDia( item->text( 1), 0L, "editpath");
  847. if (dlg->exec() )
  848. item->setText(1, dlg->newPath());
  849. delete dlg;
  850. }
  851. if ( item->text(0)==i18n("Backup Path"))
  852. {
  853. KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L, "backup path" );
  854. if (dlg->exec() )
  855. item->setText(1, dlg->newPath());
  856. delete dlg;
  857. }
  858. }
  859. }
  860. void ConfigurePathPage::slotDefault()
  861. {
  862. TQListViewItem * item = m_pPathView->findItem(i18n("Personal Expression"), 0);
  863. if ( item )
  864. item->setText(1, KWFactory::instance()->dirs()->resourceDirs("expression").join(";"));
  865. item = m_pPathView->findItem(i18n("Backup Path"), 0);
  866. if ( item )
  867. item->setText(1, TQString() );
  868. }
  869. void ConfigurePathPage::apply()
  870. {
  871. TQListViewItem * item = m_pPathView->findItem(i18n("Personal Expression"), 0);
  872. if ( item )
  873. {
  874. TQStringList lst = TQStringList::split(TQString(";"), item->text(1));
  875. if ( lst != m_pView->kWordDocument()->personalExpressionPath())
  876. {
  877. m_pView->kWordDocument()->setPersonalExpressionPath(lst);
  878. config->setGroup( "Kword Path" );
  879. config->writePathEntry( "expression path", lst);
  880. }
  881. }
  882. item = m_pPathView->findItem(i18n("Backup Path"), 0);
  883. if ( item )
  884. {
  885. TQString res = item->text(1 );
  886. if ( res != m_pView->kWordDocument()->backupPath())
  887. {
  888. config->setGroup( "Kword Path" );
  889. m_pView->kWordDocument()->setBackupPath( res );
  890. config->writePathEntry( "backup path",res );
  891. }
  892. }
  893. }
  894. ////
  895. ConfigureTTSPage::ConfigureTTSPage( KWView *view, TQVBox *box, char *name )
  896. : TQObject( box->parent(), name )
  897. {
  898. Q_UNUSED(view);
  899. // m_pView=_view;
  900. // KWDocument * doc = m_pView->kWordDocument();
  901. m_cbSpeakPointerWidget = new TQCheckBox(i18n("Speak widget under &mouse pointer"), box);
  902. m_cbSpeakFocusWidget = new TQCheckBox(i18n("Speak widget with &focus"), box);
  903. m_gbScreenReaderOptions = new TQVGroupBox("", box);
  904. m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
  905. m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
  906. m_cbSpeakTooltips = new TQCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
  907. m_cbSpeakWhatsThis = new TQCheckBox(i18n("Speak &What's This"), m_gbScreenReaderOptions);
  908. m_cbSpeakDisabled = new TQCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
  909. "&Say whether disabled"), m_gbScreenReaderOptions);
  910. m_cbSpeakAccelerators = new TQCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
  911. TQHBox* hbAcceleratorPrefix = new TQHBox(m_gbScreenReaderOptions);
  912. TQWidget* spacer = new TQWidget(hbAcceleratorPrefix);
  913. spacer->setMinimumWidth(2 * KDialog::marginHint());
  914. m_lblAcceleratorPrefix =
  915. new TQLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
  916. hbAcceleratorPrefix);
  917. m_leAcceleratorPrefixWord = new TQLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
  918. hbAcceleratorPrefix);
  919. m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
  920. TQHBox* hbPollingInterval = new TQHBox(m_gbScreenReaderOptions);
  921. hbPollingInterval->setMargin( 0 );
  922. TQLabel* lblPollingInterval = new TQLabel(i18n("&Polling interval:"), hbPollingInterval);
  923. m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
  924. m_iniPollingInterval->setSuffix(" ms");
  925. m_iniPollingInterval->setRange(100, 5000, 100, true);
  926. lblPollingInterval->setBuddy(m_iniPollingInterval);
  927. config = KWFactory::instance()->config();
  928. config->setGroup("TTS");
  929. m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
  930. m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
  931. m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
  932. m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
  933. m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
  934. m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
  935. m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
  936. i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
  937. m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
  938. screenReaderOptionChanged();
  939. connect(m_cbSpeakPointerWidget, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  940. connect(m_cbSpeakFocusWidget, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  941. connect(m_cbSpeakAccelerators, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  942. }
  943. void ConfigureTTSPage::slotDefault()
  944. {
  945. m_cbSpeakPointerWidget->setChecked(false);
  946. m_cbSpeakFocusWidget->setChecked(false);
  947. m_cbSpeakTooltips->setChecked(true);
  948. m_cbSpeakWhatsThis->setChecked(false);
  949. m_cbSpeakDisabled->setChecked(true);
  950. m_cbSpeakAccelerators->setChecked(true);
  951. m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
  952. m_iniPollingInterval->setValue(600);
  953. }
  954. void ConfigureTTSPage::apply()
  955. {
  956. config->setGroup("TTS");
  957. config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
  958. config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
  959. config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
  960. config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
  961. config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
  962. config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
  963. config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
  964. config->writeEntry("PollingInterval", m_iniPollingInterval->value());
  965. if (kospeaker) kospeaker->readConfig(config);
  966. }
  967. void ConfigureTTSPage::screenReaderOptionChanged()
  968. {
  969. m_gbScreenReaderOptions->setEnabled(
  970. m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked());
  971. m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
  972. m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
  973. }
  974. #include "KWConfig.moc"