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.

KPrConfig.cpp 46KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. 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. #ifdef HAVE_CONFIG_H
  18. #include <config.h>
  19. #endif
  20. #include <tdeapplication.h>
  21. #include <KoUnitWidgets.h>
  22. #include <tdelocale.h>
  23. #include <tdeconfig.h>
  24. #include <kdialogbase.h>
  25. #include <kiconloader.h>
  26. #include <knuminput.h>
  27. #include <kcolorbutton.h>
  28. #include "KPrVariableCollection.h"
  29. #include "KPrCanvas.h"
  30. #include <tkcoloractions.h>
  31. #include <KoSpeaker.h>
  32. #include <tqgroupbox.h>
  33. #include <tqvgroupbox.h>
  34. #include <tqlabel.h>
  35. #include <tqlayout.h>
  36. #include <tqvbox.h>
  37. #include <tqcheckbox.h>
  38. #include <tqcombobox.h>
  39. #include <tqtabwidget.h>
  40. #include <tqwhatsthis.h>
  41. #include "KPrPenStyleWidget.h"
  42. #include "KPrBrushProperty.h"
  43. #include "KPrPieProperty.h"
  44. #include "KPrRectProperty.h"
  45. #include "KPrPolygonProperty.h"
  46. #include "KPrConfig.h"
  47. #include "KPrView.h"
  48. #include "KPrDocument.h"
  49. #include "KPrPage.h"
  50. #include <KoUnit.h>
  51. #include <float.h>
  52. #include <knumvalidator.h>
  53. #include <tqlineedit.h>
  54. #include "KPrCommand.h"
  55. #include <tqvgroupbox.h>
  56. #include <tdefontdialog.h>
  57. #include <klineedit.h>
  58. #include <KoRect.h>
  59. #include <tdemessagebox.h>
  60. #include <tdeversion.h>
  61. #include <kurlrequesterdlg.h>
  62. #include <tdelistview.h>
  63. #include <tdefiledialog.h>
  64. #include <KoEditPath.h>
  65. #include <tdespell2/configwidget.h>
  66. #include <tdespell2/settings.h>
  67. #include <tdespell2/broker.h>
  68. using namespace KSpell2;
  69. KPrConfig::KPrConfig( KPrView* parent )
  70. : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
  71. KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
  72. KDialogBase::Ok, parent)
  73. {
  74. m_doc = parent->kPresenterDoc();
  75. TQVBox *page = addVBoxPage( i18n("Interface"), i18n("Interface"),
  76. BarIcon("misc", TDEIcon::SizeMedium) );
  77. _interfacePage=new KPrConfigureInterfacePage( parent, page );
  78. page = addVBoxPage( i18n("Color"), i18n("Color"),
  79. BarIcon("colorize", TDEIcon::SizeMedium) );
  80. _colorBackground = new KPrConfigureColorBackground( parent, page );
  81. page = addVBoxPage( i18n("Spelling"), i18n("Spellchecker Behavior"),
  82. BarIcon("tools-check-spelling", TDEIcon::SizeMedium) );
  83. _spellPage=new KPrConfigureSpellPage(parent, page);
  84. page = addVBoxPage( i18n("Misc"), i18n("Misc"),
  85. BarIcon("misc", TDEIcon::SizeMedium) );
  86. _miscPage=new KPrConfigureMiscPage(parent, page);
  87. page = addVBoxPage( i18n("Document"), i18n("Document Settings"),
  88. BarIcon("application-x-kpresenter", TDEIcon::SizeMedium) );
  89. _defaultDocPage=new KPrConfigureDefaultDocPage(parent, page);
  90. page = addVBoxPage( i18n("Tools"), i18n("Default Tools Settings"),
  91. BarIcon("configure", TDEIcon::SizeMedium) );
  92. _toolsPage=new KPrConfigureToolsPage(parent, page);
  93. page = addVBoxPage( i18n("Paths"), i18n("Path Settings"),
  94. BarIcon("path") );
  95. m_pathPage=new KPrConfigurePathPage(parent, page);
  96. if (KoSpeaker::isKttsdInstalled()) {
  97. page = addVBoxPage( i18n("Abbreviation for Text-to-Speech", "TTS"), i18n("Text-to-Speech Settings"),
  98. BarIcon("access", TDEIcon::SizeMedium) );
  99. m_ttsPage=new KPrConfigureTTSPage(parent, page);
  100. } else m_ttsPage = 0;
  101. connect( this, TQT_SIGNAL( okClicked() ),this, TQT_SLOT( slotApply() ) );
  102. }
  103. void KPrConfig::openPage(int flags)
  104. {
  105. if(flags & KP_INTERFACE)
  106. showPage( 0 );
  107. else if(flags & KP_COLOR)
  108. showPage(1 );
  109. else if(flags & KP_TDESPELL)
  110. showPage(2);
  111. else if(flags & KP_MISC)
  112. showPage(3 );
  113. else if(flags & KP_DOC)
  114. showPage(4 );
  115. else if(flags & KP_TOOLS)
  116. showPage(5);
  117. else if(flags & KP_PATH)
  118. showPage(6);
  119. }
  120. void KPrConfig::slotApply()
  121. {
  122. KMacroCommand *macro = 0L;
  123. _interfacePage->apply();
  124. _colorBackground->apply();
  125. if (_spellPage) _spellPage->apply();
  126. m_pathPage->apply();
  127. KCommand *cmd = _miscPage->apply();
  128. if ( cmd )
  129. {
  130. if ( !macro )
  131. macro = new KMacroCommand(i18n("Change Config") );
  132. macro->addCommand( cmd );
  133. }
  134. cmd = _defaultDocPage->apply();
  135. if ( cmd )
  136. {
  137. if ( !macro )
  138. macro = new KMacroCommand(i18n("Change Config") );
  139. macro->addCommand( cmd );
  140. }
  141. _toolsPage->apply();
  142. if (m_ttsPage) m_ttsPage->apply();
  143. if ( macro )
  144. m_doc->addCommand( macro);
  145. }
  146. void KPrConfig::slotDefault()
  147. {
  148. switch( activePageIndex() ) {
  149. case 0:
  150. _interfacePage->slotDefault();
  151. break;
  152. case 1:
  153. _colorBackground->slotDefault();
  154. break;
  155. case 2:
  156. if (_spellPage) _spellPage->slotDefault();
  157. break;
  158. case 3:
  159. _miscPage->slotDefault();
  160. break;
  161. case 4:
  162. _defaultDocPage->slotDefault();
  163. break;
  164. case 5:
  165. _toolsPage->slotDefault();
  166. break;
  167. case 6:
  168. m_pathPage->slotDefault();
  169. break;
  170. case 7:
  171. m_ttsPage->slotDefault();
  172. default:
  173. break;
  174. }
  175. }
  176. KPrConfigureInterfacePage::KPrConfigureInterfacePage( KPrView *_view, TQWidget *parent , char *name )
  177. :TQWidget ( parent,name )
  178. {
  179. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  180. m_pView=_view;
  181. config = KPrFactory::global()->config();
  182. KoUnit::Unit unit = m_pView->kPresenterDoc()->unit();
  183. oldNbRecentFiles=10;
  184. double ptIndent = MM_TO_POINT(10.0);
  185. bool bShowRuler=true;
  186. bool oldShowStatusBar = true;
  187. if( config->hasGroup("Interface") ) {
  188. config->setGroup( "Interface" );
  189. oldNbRecentFiles=config->readNumEntry("NbRecentFile",oldNbRecentFiles);
  190. ptIndent = config->readDoubleNumEntry("Indent", ptIndent);
  191. bShowRuler=config->readBoolEntry("Rulers",true);
  192. oldShowStatusBar = config->readBoolEntry( "ShowStatusBar" , true );
  193. }
  194. showRuler= new TQCheckBox(i18n("Show rulers"),this);
  195. 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." ) );
  196. showRuler->setChecked(bShowRuler);
  197. box->addWidget(showRuler);
  198. showStatusBar = new TQCheckBox(i18n("Show status bar"),this);
  199. TQWhatsThis::add(showStatusBar, i18n( "Toggle the statusbar, which is shown by default." ) );
  200. showStatusBar->setChecked(oldShowStatusBar);
  201. box->addWidget(showStatusBar);
  202. recentFiles=new KIntNumInput( oldNbRecentFiles, this);
  203. recentFiles->setRange(1, 20, 1);
  204. recentFiles->setLabel(i18n("Number of recent files:"));
  205. 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." ) );
  206. box->addWidget(recentFiles);
  207. TQString suffix = KoUnit::unitName( unit ).prepend(' ');
  208. indent = new KDoubleNumInput( this );
  209. indent->setValue( KoUnit::toUserValue( ptIndent, unit ) );
  210. indent->setRange(KoUnit::toUserValue( 0.1, unit ), KoUnit::toUserValue( 50, unit ), KoUnit::toUserValue( 0.1, unit ));
  211. indent->setSuffix( suffix );
  212. indent->setLabel(i18n("Text indentation depth:"));
  213. 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." ) );
  214. box->addWidget(indent);
  215. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
  216. box->addItem( spacer);
  217. }
  218. void KPrConfigureInterfacePage::apply()
  219. {
  220. bool ruler=showRuler->isChecked();
  221. bool statusBar=showStatusBar->isChecked();
  222. KPrDocument * doc = m_pView->kPresenterDoc();
  223. config->setGroup( "Interface" );
  224. double newIndent = KoUnit::fromUserValue( indent->value(), doc->unit() );
  225. if( newIndent != doc->getIndentValue() )
  226. {
  227. config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ );
  228. doc->setIndentValue( newIndent );
  229. }
  230. int nbRecent=recentFiles->value();
  231. if(nbRecent!=oldNbRecentFiles)
  232. {
  233. config->writeEntry( "NbRecentFile", nbRecent);
  234. m_pView->changeNbOfRecentFiles(nbRecent);
  235. oldNbRecentFiles=nbRecent;
  236. }
  237. bool refreshGUI=false;
  238. if(ruler != doc->showRuler())
  239. {
  240. config->writeEntry( "Rulers", ruler );
  241. doc->setShowRuler( ruler );
  242. refreshGUI=true;
  243. }
  244. if( statusBar != doc->showStatusBar() )
  245. {
  246. config->writeEntry( "ShowStatusBar", statusBar );
  247. doc->setShowStatusBar( statusBar );
  248. refreshGUI=true;
  249. }
  250. if( refreshGUI )
  251. doc->reorganizeGUI();
  252. }
  253. void KPrConfigureInterfacePage::slotDefault()
  254. {
  255. double newIndent = KoUnit::toUserValue( MM_TO_POINT( 10 ), m_pView->kPresenterDoc()->unit() );
  256. indent->setValue( newIndent );
  257. recentFiles->setValue(10);
  258. showRuler->setChecked(true);
  259. showStatusBar->setChecked(true);
  260. }
  261. KPrConfigureColorBackground::KPrConfigureColorBackground( KPrView* _view, TQWidget *parent , char *name )
  262. :TQWidget ( parent,name )
  263. {
  264. m_pView = _view;
  265. config = KPrFactory::global()->config();
  266. oldBgColor = m_pView->kPresenterDoc()->txtBackCol();
  267. oldGridColor = m_pView->kPresenterDoc()->gridColor();
  268. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  269. TQLabel *lab = new TQLabel( this, "label20" );
  270. lab->setText( i18n( "Background object color:" ) );
  271. 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." ) );
  272. box->addWidget(lab);
  273. bgColor = new KColorButton( oldBgColor,
  274. oldBgColor,
  275. this );
  276. bgColor->setColor( oldBgColor );
  277. box->addWidget(bgColor);
  278. lab = new TQLabel( this, "label20" );
  279. lab->setText( i18n( "Grid color:" ) );
  280. TQWhatsThis::add(lab, i18n( "Here you can change the grid color, which is black by default." ) );
  281. box->addWidget(lab);
  282. gridColor = new KColorButton( oldGridColor,
  283. oldGridColor,
  284. this );
  285. box->addWidget(gridColor);
  286. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
  287. box->addItem( spacer);
  288. }
  289. void KPrConfigureColorBackground::apply()
  290. {
  291. KPrDocument * doc = m_pView->kPresenterDoc();
  292. bool repaintNeeded = false;
  293. TQColor _col = bgColor->color();
  294. if( oldBgColor != _col ) {
  295. config->setGroup( "KPresenter Color" );
  296. config->writeEntry( "BackgroundColor", _col );
  297. doc->setTxtBackCol( _col );
  298. doc->replaceObjs();
  299. oldBgColor=_col;
  300. repaintNeeded = true;
  301. }
  302. _col = gridColor->color();
  303. if( oldGridColor != _col ) {
  304. config->setGroup( "KPresenter Color" );
  305. config->writeEntry( "GridColor", _col );
  306. doc->repaint( false );
  307. doc->setGridColor( _col );
  308. oldGridColor=_col;
  309. repaintNeeded = true;
  310. }
  311. if (repaintNeeded)
  312. doc->repaint( false );
  313. }
  314. void KPrConfigureColorBackground::slotDefault()
  315. {
  316. bgColor->setColor( TQt::white );
  317. gridColor->setColor( TQt::black );
  318. }
  319. KPrConfigureSpellPage::KPrConfigureSpellPage( KPrView *_view, TQWidget *parent, char *name )
  320. : TQWidget( parent, name )
  321. {
  322. m_pView=_view;
  323. config = KPrFactory::global()->config();
  324. m_spellConfigWidget = new ConfigWidget( _view->broker(), parent );
  325. m_spellConfigWidget->setBackgroundCheckingButtonShown( true );
  326. }
  327. void KPrConfigureSpellPage::apply()
  328. {
  329. KPrDocument* doc = m_pView->kPresenterDoc();
  330. m_spellConfigWidget->save();
  331. m_pView->kPresenterDoc()->setSpellCheckIgnoreList(
  332. m_pView->broker()->settings()->currentIgnoreList() );
  333. //FIXME reactivate just if there are changes.
  334. doc->enableBackgroundSpellCheck( m_pView->broker()->settings()->backgroundCheckerEnabled() );
  335. doc->reactivateBgSpellChecking();
  336. }
  337. void KPrConfigureSpellPage::slotDefault()
  338. {
  339. m_spellConfigWidget->slotDefault();
  340. }
  341. KPrConfigureMiscPage::KPrConfigureMiscPage( KPrView *_view, TQWidget *parent, char *name )
  342. : TQWidget( parent, name )
  343. {
  344. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  345. m_pView=_view;
  346. config = KPrFactory::global()->config();
  347. TQGroupBox* tmpTQGroupBox = new TQGroupBox( 0, Qt::Vertical, i18n("Misc"), this, "GroupBox" );
  348. tmpTQGroupBox->layout()->setSpacing(KDialog::spacingHint());
  349. tmpTQGroupBox->layout()->setMargin(KDialog::marginHint());
  350. TQGridLayout *grid = new TQGridLayout( tmpTQGroupBox->layout(), 8, 1 );
  351. m_oldNbRedo=30;
  352. m_printNotes=true;
  353. if( config->hasGroup("Misc") )
  354. {
  355. config->setGroup( "Misc" );
  356. m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
  357. m_printNotes = config->readBoolEntry("PrintNotes", true);
  358. }
  359. m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpTQGroupBox );
  360. m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
  361. m_undoRedoLimit->setRange(10, 60, 1);
  362. 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." ) );
  363. grid->addWidget(m_undoRedoLimit,0,0);
  364. KPrDocument* doc = m_pView->kPresenterDoc();
  365. m_displayLink=new TQCheckBox(i18n("Display links"),tmpTQGroupBox);
  366. 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." ) );
  367. grid->addWidget(m_displayLink,3,0);
  368. m_displayLink->setChecked(doc->getVariableCollection()->variableSetting()->displayLink());
  369. m_underlineLink=new TQCheckBox(i18n("&Underline all links"),tmpTQGroupBox);
  370. m_underlineLink->setChecked(doc->getVariableCollection()->variableSetting()->underlineLink());
  371. 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." ) );
  372. grid->addWidget(m_underlineLink,4,0);
  373. m_displayComment=new TQCheckBox(i18n("Display comments"),tmpTQGroupBox);
  374. m_displayComment->setChecked(doc->getVariableCollection()->variableSetting()->displayComment());
  375. 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." ) );
  376. grid->addWidget(m_displayComment,5,0);
  377. m_displayFieldCode=new TQCheckBox(i18n("Display field code"),tmpTQGroupBox);
  378. m_displayFieldCode->setChecked(doc->getVariableCollection()->variableSetting()->displayFieldCode());
  379. 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." ) );
  380. grid->addWidget(m_displayFieldCode,6,0);
  381. m_cbPrintNotes=new TQCheckBox(i18n("Print slide notes"),tmpTQGroupBox);
  382. m_cbPrintNotes->setChecked(m_printNotes);
  383. 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." ) );
  384. grid->addWidget(m_cbPrintNotes,7,0);
  385. box->addWidget(tmpTQGroupBox);
  386. tmpTQGroupBox = new TQGroupBox( 0, Qt::Vertical, i18n("Grid"), this, "GroupBox" );
  387. tmpTQGroupBox->layout()->setSpacing(KDialog::spacingHint());
  388. tmpTQGroupBox->layout()->setMargin(KDialog::marginHint());
  389. grid = new TQGridLayout( tmpTQGroupBox->layout(), 8, 1 );
  390. KoRect rect = doc->masterPage()->getPageRect();
  391. TQLabel *lab=new TQLabel(i18n("Horizontal grid size:"), tmpTQGroupBox);
  392. TQWhatsThis::add(lab, i18n( "Set the space in millimeters between two horizontal points on the grid. Default is 5 millimeters." ) );
  393. grid->addWidget(lab,0,0);
  394. KoUnit::Unit unit = doc->unit();
  395. resolutionX = new KoUnitDoubleSpinBox(tmpTQGroupBox, 5.0,rect.width(),1,doc->getGridX() );
  396. resolutionX->setUnit( unit );
  397. grid->addWidget(resolutionX,1,0);
  398. lab=new TQLabel(i18n("Vertical grid size:"), tmpTQGroupBox);
  399. TQWhatsThis::add(lab, i18n( "Set the space in millimeters between two vertical points on the grid. Default is 5 millimeters." ) );
  400. grid->addWidget(lab,2,0);
  401. resolutionY = new KoUnitDoubleSpinBox(tmpTQGroupBox, 5.0,rect.height(),1,doc->getGridY() );
  402. resolutionY->setUnit( unit );
  403. grid->addWidget(resolutionY, 3, 0);
  404. box->addWidget(tmpTQGroupBox);
  405. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
  406. box->addItem( spacer);
  407. }
  408. KCommand * KPrConfigureMiscPage::apply()
  409. {
  410. config->setGroup( "Misc" );
  411. int newUndo=m_undoRedoLimit->value();
  412. KPrDocument* doc = m_pView->kPresenterDoc();
  413. if(newUndo!=m_oldNbRedo)
  414. {
  415. config->writeEntry("UndoRedo",newUndo);
  416. doc->setUndoRedoLimit(newUndo);
  417. m_oldNbRedo=newUndo;
  418. }
  419. config->writeEntry("PrintNotes", m_cbPrintNotes->isChecked());
  420. KMacroCommand * macroCmd=0L;
  421. bool b=m_displayLink->isChecked();
  422. bool b_new=doc->getVariableCollection()->variableSetting()->displayLink();
  423. if(b_new!=b)
  424. {
  425. if(!macroCmd)
  426. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  427. KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
  428. i18n("Change Display Link Command"), doc, b_new, b, KPrChangeVariableSettingsCommand::VS_DISPLAYLINK);
  429. cmd->execute();
  430. macroCmd->addCommand(cmd);
  431. }
  432. b=m_underlineLink->isChecked();
  433. if(doc->getVariableCollection()->variableSetting()->underlineLink()!=b)
  434. {
  435. if(!macroCmd)
  436. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  437. KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
  438. i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->underlineLink(),
  439. b, KPrChangeVariableSettingsCommand::VS_UNDERLINELINK);
  440. cmd->execute();
  441. macroCmd->addCommand(cmd);
  442. }
  443. b=m_displayComment->isChecked();
  444. if(doc->getVariableCollection()->variableSetting()->displayComment()!=b)
  445. {
  446. if(!macroCmd)
  447. macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
  448. KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
  449. i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
  450. b, KPrChangeVariableSettingsCommand::VS_DISPLAYCOMMENT);
  451. cmd->execute();
  452. macroCmd->addCommand(cmd);
  453. }
  454. b=m_displayFieldCode->isChecked();
  455. if(doc->getVariableCollection()->variableSetting()->displayFieldCode()!=b)
  456. {
  457. if(!macroCmd)
  458. macroCmd=new KMacroCommand(i18n("Change Display Field Code Command"));
  459. KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
  460. i18n("Change Display Field Code Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
  461. b, KPrChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE);
  462. cmd->execute();
  463. macroCmd->addCommand(cmd);
  464. }
  465. doc->setGridValue( resolutionX->value(),
  466. resolutionY->value(), true);
  467. doc->repaint( false );
  468. config->sync();
  469. return macroCmd;
  470. }
  471. void KPrConfigureMiscPage::slotDefault()
  472. {
  473. m_undoRedoLimit->setValue(30);
  474. m_displayLink->setChecked(true);
  475. m_displayComment->setChecked(true);
  476. m_underlineLink->setChecked(true);
  477. m_displayFieldCode->setChecked( false );
  478. m_cbPrintNotes->setChecked(true);
  479. //KPrDocument* doc = m_pView->kPresenterDoc();
  480. resolutionY->setValue( MM_TO_POINT( 5.0 ));
  481. resolutionX->setValue( MM_TO_POINT( 5.0 ));
  482. }
  483. KPrConfigureDefaultDocPage::KPrConfigureDefaultDocPage(KPrView *_view, TQWidget *parent, char *name )
  484. : TQWidget( parent, name )
  485. {
  486. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  487. m_pView=_view;
  488. config = KPrFactory::global()->config();
  489. KPrDocument *doc = m_pView->kPresenterDoc();
  490. oldAutoSaveValue = doc->defaultAutoSave()/60;
  491. m_oldBackupFile = true;
  492. m_oldLanguage = doc->globalLanguage();
  493. m_oldHyphenation = doc->globalHyphenation();
  494. if( config->hasGroup("Interface") ) {
  495. config->setGroup( "Interface" );
  496. oldAutoSaveValue = config->readNumEntry( "AutoSave", oldAutoSaveValue );
  497. m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
  498. m_oldLanguage = config->readEntry( "language", m_oldLanguage );
  499. m_oldHyphenation = config->readBoolEntry( "hyphenation", m_oldHyphenation);
  500. }
  501. TQVGroupBox* gbDocumentDefaults = new TQVGroupBox( i18n("Document Defaults"), this, "GroupBox" );
  502. gbDocumentDefaults->setMargin( KDialog::marginHint() );
  503. gbDocumentDefaults->setInsideSpacing( 5 );
  504. TQWidget *fontContainer = new TQWidget(gbDocumentDefaults);
  505. TQGridLayout * fontLayout = new TQGridLayout(fontContainer, 1, 3);
  506. fontLayout->setColStretch(0, 0);
  507. fontLayout->setColStretch(1, 1);
  508. fontLayout->setColStretch(2, 0);
  509. TQLabel *fontTitle = new TQLabel(i18n("Default font:"), fontContainer);
  510. font= new TQFont( doc->defaultFont() );
  511. TQString labelName = font->family() + ' ' + TQString::number(font->pointSize());
  512. fontName = new TQLabel(labelName, fontContainer);
  513. fontName->setFont(*font);
  514. fontName->setFrameStyle(TQFrame::StyledPanel | TQFrame::Sunken);
  515. TQPushButton *chooseButton = new TQPushButton(i18n("Choose..."), fontContainer);
  516. TQWhatsThis::add(chooseButton, i18n( "Click here if you want to set a new font. The TDE default Select Font dialog will then be displayed." ) );
  517. connect(chooseButton, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectNewDefaultFont()));
  518. fontLayout->addWidget(fontTitle, 0, 0);
  519. fontLayout->addWidget(fontName, 0, 1);
  520. fontLayout->addWidget(chooseButton, 0, 2);
  521. TQWidget *languageContainer = new TQWidget(gbDocumentDefaults);
  522. TQGridLayout * languageLayout = new TQGridLayout(languageContainer, 1, 3);
  523. languageLayout->setColStretch(0, 0);
  524. languageLayout->setColStretch(1, 1);
  525. TQLabel *languageTitle = new TQLabel(i18n("Global language:"), languageContainer);
  526. 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." ) );
  527. m_globalLanguage = new TQComboBox( languageContainer );
  528. m_globalLanguage->insertStringList( KoGlobal::listOfLanguages() );
  529. m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( doc->globalLanguage() ) );
  530. languageLayout->addWidget(languageTitle, 0, 0);
  531. languageLayout->addWidget(m_globalLanguage, 0, 1);
  532. m_autoHyphenation = new TQCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults);
  533. 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." ) );
  534. m_autoHyphenation->setChecked( m_oldHyphenation );
  535. box->addWidget(gbDocumentDefaults);
  536. TQVGroupBox* gbDocumentSettings = new TQVGroupBox( i18n("Document Settings"), this );
  537. gbDocumentSettings->setMargin( KDialog::marginHint() );
  538. gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
  539. m_createBackupFile = new TQCheckBox( i18n("Create backup file"), gbDocumentSettings);
  540. 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." ) );
  541. m_createBackupFile->setChecked( m_oldBackupFile );
  542. autoSave = new KIntNumInput( oldAutoSaveValue, gbDocumentSettings );
  543. autoSave->setRange( 0, 60, 1 );
  544. autoSave->setLabel( i18n("Autosave (min):") );
  545. autoSave->setSpecialValueText( i18n("No autosave") );
  546. autoSave->setSuffix( i18n("min") );
  547. 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." ) );
  548. new TQLabel(i18n("Starting page number:"), gbDocumentSettings);
  549. m_oldStartingPage=doc->getVariableCollection()->variableSetting()->startingPageNumber();
  550. m_variableNumberOffset=new KIntNumInput(gbDocumentSettings);
  551. m_variableNumberOffset->setRange(1, 9999, 1, false);
  552. m_variableNumberOffset->setValue(m_oldStartingPage);
  553. 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." ) );
  554. new TQLabel(i18n("Tab stop:"), gbDocumentSettings);
  555. m_oldTabStopWidth = doc->tabStopValue();
  556. KoRect rect = doc->masterPage()->getPageRect();
  557. m_tabStopWidth = new KoUnitDoubleSpinBox( gbDocumentSettings , MM_TO_POINT(2), rect.width() ,0.1, m_oldTabStopWidth );
  558. m_tabStopWidth->setUnit( doc->unit() );
  559. 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." ) );
  560. box->addWidget(gbDocumentSettings);
  561. TQVGroupBox* gbDocumentCursor = new TQVGroupBox( i18n("Cursor"), this );
  562. gbDocumentCursor->setMargin( KDialog::marginHint() );
  563. gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() );
  564. m_cursorInProtectedArea= new TQCheckBox(i18n("Cursor in protected area"),gbDocumentCursor);
  565. m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
  566. 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." ) );
  567. m_directInsertCursor= new TQCheckBox(i18n("Direct insert cursor"),gbDocumentCursor);
  568. m_directInsertCursor->setChecked(doc->insertDirectCursor());
  569. 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." ) );
  570. box->addWidget(gbDocumentCursor);
  571. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding );
  572. box->addItem(spacer);
  573. }
  574. KPrConfigureDefaultDocPage::~KPrConfigureDefaultDocPage()
  575. {
  576. delete font;
  577. }
  578. KCommand *KPrConfigureDefaultDocPage::apply()
  579. {
  580. config->setGroup( "Document defaults" );
  581. KPrDocument* doc = m_pView->kPresenterDoc();
  582. config->writeEntry("DefaultFont",TQString(font->toString()));
  583. config->setGroup( "Interface" );
  584. int autoSaveVal = autoSave->value();
  585. if( autoSaveVal != oldAutoSaveValue ) {
  586. config->writeEntry( "AutoSave", autoSaveVal );
  587. m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 );
  588. oldAutoSaveValue=autoSaveVal;
  589. }
  590. bool state =m_createBackupFile->isChecked();
  591. if(state!=m_oldBackupFile)
  592. {
  593. config->writeEntry( "BackupFile", state );
  594. doc->setBackupFile( state);
  595. m_oldBackupFile=state;
  596. }
  597. state = m_cursorInProtectedArea->isChecked();
  598. if ( state != doc->cursorInProtectedArea() )
  599. {
  600. config->writeEntry( "cursorInProtectArea", state );
  601. m_pView->kPresenterDoc()->setCursorInProtectedArea( state );
  602. }
  603. state = m_directInsertCursor->isChecked();
  604. if ( state != doc->insertDirectCursor() )
  605. doc->setInsertDirectCursor( state );
  606. //Laurent Todo add a message box to inform user that
  607. //global language will change after re-launch kword
  608. const TQString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() );
  609. config->writeEntry( "language" , lang);
  610. m_oldLanguage = lang;
  611. //don't call this function otherwise we can have a textobject with
  612. // a default language and other textobject with other default language.
  613. //doc->setGlobalLanguage( lang );
  614. state = m_autoHyphenation->isChecked();
  615. config->writeEntry( "hyphenation", state );
  616. m_oldHyphenation = state;
  617. KMacroCommand *macro = 0L;
  618. int newStartingPage=m_variableNumberOffset->value();
  619. if(newStartingPage!=m_oldStartingPage)
  620. {
  621. macro = new KMacroCommand( i18n("Change Starting Page Number") );
  622. KPrChangeStartingPageCommand *cmd = new KPrChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage );
  623. cmd->execute();
  624. macro->addCommand( cmd);
  625. m_oldStartingPage=newStartingPage;
  626. }
  627. double newTabStop = m_tabStopWidth->value();
  628. if ( newTabStop != m_oldTabStopWidth)
  629. {
  630. if ( !macro )
  631. macro = new KMacroCommand( i18n("Change Tab Stop Value") );
  632. KPrChangeTabStopValueCommand *cmd = new KPrChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
  633. cmd->execute();
  634. macro->addCommand( cmd );
  635. m_oldTabStopWidth = newTabStop;
  636. }
  637. return macro;
  638. }
  639. void KPrConfigureDefaultDocPage::slotDefault()
  640. {
  641. autoSave->setValue( m_pView->kPresenterDoc()->defaultAutoSave()/60 );
  642. m_variableNumberOffset->setValue(1);
  643. m_cursorInProtectedArea->setChecked(true);
  644. m_tabStopWidth->setValue( MM_TO_POINT(15));
  645. m_createBackupFile->setChecked( true );
  646. m_directInsertCursor->setChecked( false );
  647. m_globalLanguage->setCurrentText( KoGlobal::languageFromTag( TDEGlobal::locale()->language() ) );
  648. m_autoHyphenation->setChecked( false );
  649. }
  650. void KPrConfigureDefaultDocPage::selectNewDefaultFont() {
  651. TQStringList list;
  652. TDEFontChooser::getFontList(list, TDEFontChooser::SmoothScalableFonts);
  653. TDEFontDialog dlg( this, "Font Selector", false, true, list, true );
  654. dlg.setFont(*font);
  655. int result = dlg.exec();
  656. if (KDialog::Accepted == result) {
  657. delete font;
  658. font = new TQFont(dlg.font());
  659. fontName->setText(font->family() + ' ' + TQString::number(font->pointSize()));
  660. fontName->setFont(*font);
  661. m_pView->kPresenterDoc()->setDefaultFont( *font );
  662. }
  663. }
  664. KPrConfigureToolsPage::KPrConfigureToolsPage( KPrView *_view, TQWidget *parent, char *name )
  665. : TQWidget( parent, name )
  666. {
  667. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  668. m_pView = _view;
  669. config = KPrFactory::global()->config();
  670. m_pView->getCanvas()->deSelectAllObj();
  671. TQTabWidget *tab = new TQTabWidget(this);
  672. KoPenCmd::Pen pen( m_pView->getPen(), m_pView->getLineBegin(), m_pView->getLineEnd() );
  673. m_confPenDia = new KPrPenStyleWidget(tab, 0, pen, true );
  674. tab->addTab( m_confPenDia, i18n( "Outl&ine" ) );
  675. KPrBrushCmd::Brush brush( m_pView->getBrush(),
  676. m_pView->getGColor1(),
  677. m_pView->getGColor2(),
  678. m_pView->getGType(),
  679. m_pView->getFillType(),
  680. m_pView->getGUnbalanced(),
  681. m_pView->getGXFactor(),
  682. m_pView->getGYFactor() );
  683. m_brushProperty = new KPrBrushProperty( this, 0, brush );
  684. tab->addTab( m_brushProperty, i18n( "&Fill" ) );
  685. KPrRectValueCmd::RectValues rectValues;
  686. rectValues.xRnd = m_pView->getRndX();
  687. rectValues.yRnd = m_pView->getRndY();
  688. m_rectProperty = new KPrRectProperty( this, 0, rectValues );
  689. tab->addTab( m_rectProperty, i18n( "&Rectangle" ) );
  690. KPrPolygonSettingCmd::PolygonSettings polygonSettings;
  691. polygonSettings.checkConcavePolygon = m_pView->getCheckConcavePolygon();
  692. polygonSettings.cornersValue = m_pView->getCornersValue();
  693. polygonSettings.sharpnessValue = m_pView->getSharpnessValue();
  694. m_polygonProperty = new KPrPolygonProperty( this, 0, polygonSettings );
  695. tab->addTab( m_polygonProperty, i18n( "Polygo&n" ) );
  696. KPrPieValueCmd::PieValues pieValues;
  697. pieValues.pieType = m_pView->getPieType();
  698. pieValues.pieAngle = m_pView->getPieAngle();
  699. pieValues.pieLength = m_pView->getPieLength();
  700. m_pieProperty = new KPrPieProperty( this, 0, pieValues );
  701. tab->addTab( m_pieProperty, i18n( "&Pie" ) );
  702. box->addWidget(tab);
  703. }
  704. KPrConfigureToolsPage::~KPrConfigureToolsPage()
  705. {
  706. }
  707. void KPrConfigureToolsPage::apply()
  708. {
  709. KoPenCmd::Pen pen = m_confPenDia->getPen();
  710. m_pView->setPen( pen.pen );
  711. m_pView->setLineBegin( pen.lineBegin );
  712. m_pView->setLineEnd( pen.lineEnd );
  713. m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() );
  714. KPrBrushCmd::Brush brush = m_brushProperty->getBrush();
  715. m_pView->setBrush( brush.brush );
  716. m_pView->setFillType( brush.fillType );
  717. m_pView->setGColor1( brush.gColor1 );
  718. m_pView->setGColor2( brush.gColor2 );
  719. m_pView->setGType( brush.gType );
  720. m_pView->setGUnbalanced( brush.unbalanced );
  721. m_pView->setGXFactor( brush.xfactor );
  722. m_pView->setGYFactor( brush.yfactor );
  723. m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() );
  724. KPrRectValueCmd::RectValues rectValues = m_rectProperty->getRectValues();
  725. m_pView->setRndX( rectValues.xRnd );
  726. m_pView->setRndY( rectValues.yRnd );
  727. KPrPolygonSettingCmd::PolygonSettings polygonSettings = m_polygonProperty->getPolygonSettings();
  728. m_pView->setCheckConcavePolygon( polygonSettings.checkConcavePolygon );
  729. m_pView->setCornersValue( polygonSettings.cornersValue );
  730. m_pView->setSharpnessValue( polygonSettings.sharpnessValue );
  731. KPrPieValueCmd::PieValues pieValues = m_pieProperty->getPieValues();
  732. m_pView->setPieType( pieValues.pieType );
  733. m_pView->setPieAngle( pieValues.pieAngle );
  734. m_pView->setPieLength( pieValues.pieLength );
  735. //TODO set pen brush in m_rectProperty
  736. //TODO set pen brush in m_polygonProperty
  737. //TODO set pen brush in m_pieProperty
  738. }
  739. void KPrConfigureToolsPage::slotDefault()
  740. {
  741. KoPenCmd::Pen pen( KoPen(black, 1.0, Qt::SolidLine), L_NORMAL, L_NORMAL );
  742. m_confPenDia->setPen( pen );
  743. m_pView->getActionPenColor()->setCurrentColor( pen.pen.color() );
  744. KPrBrushCmd::Brush brush( TQBrush( white, SolidPattern ), red, green,
  745. BCT_GHORZ, FT_BRUSH, false, 100, 100 );
  746. m_brushProperty->setBrush( brush );
  747. m_pView->getActionBrushColor()->setCurrentColor( brush.brush.color() );
  748. KPrRectValueCmd::RectValues rectValues;
  749. rectValues.xRnd = 0;
  750. rectValues.yRnd = 0;
  751. m_rectProperty->setRectValues( rectValues );
  752. KPrPolygonSettingCmd::PolygonSettings polygonSettings;
  753. polygonSettings.checkConcavePolygon = false;
  754. polygonSettings.cornersValue = 3;
  755. polygonSettings.sharpnessValue = 0;
  756. m_polygonProperty->setPolygonSettings( polygonSettings );
  757. KPrPieValueCmd::PieValues pieValues;
  758. pieValues.pieType = PT_PIE;
  759. pieValues.pieAngle = 45 * 16;
  760. pieValues.pieLength = 270 * 16;
  761. }
  762. KPrConfigurePathPage::KPrConfigurePathPage( KPrView *_view, TQWidget *parent, char *name )
  763. : TQWidget( parent, name )
  764. {
  765. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  766. m_pView=_view;
  767. KPrDocument* doc = m_pView->kPresenterDoc();
  768. config = KPrFactory::global()->config();
  769. m_pPathView = new TDEListView( this );
  770. m_pPathView->setResizeMode(TQListView::NoColumn);
  771. m_pPathView->addColumn( i18n( "Type" ) );
  772. m_pPathView->addColumn( i18n( "Path" ) );
  773. (void) new TQListViewItem( m_pPathView, i18n("Picture Path"),doc->picturePath() );
  774. (void) new TQListViewItem( m_pPathView, i18n("Backup Path"),doc->backupPath() );
  775. 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." ) );
  776. box->addWidget(m_pPathView);
  777. m_modifyPath = new TQPushButton( i18n("Modify Path..."), this);
  778. connect( m_modifyPath, TQT_SIGNAL( clicked ()), this, TQT_SLOT( slotModifyPath()));
  779. connect( m_pPathView, TQT_SIGNAL( doubleClicked (TQListViewItem *, const TQPoint &, int )),
  780. this, TQT_SLOT( slotModifyPath()));
  781. connect( m_pPathView, TQT_SIGNAL( selectionChanged ( TQListViewItem * )),
  782. this, TQT_SLOT( slotSelectionChanged(TQListViewItem * )));
  783. slotSelectionChanged(m_pPathView->currentItem());
  784. 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." ) );
  785. box->addWidget(m_modifyPath);
  786. }
  787. void KPrConfigurePathPage::slotSelectionChanged(TQListViewItem * item)
  788. {
  789. m_modifyPath->setEnabled( item );
  790. }
  791. void KPrConfigurePathPage::slotModifyPath()
  792. {
  793. TQListViewItem *item = m_pPathView->currentItem ();
  794. if ( item )
  795. {
  796. if ( item->text(0)==i18n("Picture Path"))
  797. {
  798. KURLRequesterDlg * dlg = new KURLRequesterDlg( item->text(1), 0L,
  799. "picture path dlg");
  800. dlg->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
  801. if ( dlg->exec() )
  802. item->setText( 1, dlg->selectedURL().path());
  803. delete dlg;
  804. }
  805. else if ( item->text(0)==i18n("Backup Path"))
  806. {
  807. KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L,
  808. "backup path" );
  809. if (dlg->exec() )
  810. item->setText(1, dlg->newPath());
  811. delete dlg;
  812. }
  813. }
  814. }
  815. void KPrConfigurePathPage::slotDefault()
  816. {
  817. TQListViewItem * item = m_pPathView->findItem(i18n("Picture Path"), 0);
  818. if ( item )
  819. item->setText(1, TDEGlobalSettings::documentPath());
  820. item = m_pPathView->findItem(i18n("Backup Path"), 0);
  821. if ( item )
  822. item->setText(1, TQString() );
  823. }
  824. void KPrConfigurePathPage::apply()
  825. {
  826. TQListViewItem *item = m_pPathView->findItem(i18n("Backup Path"), 0);
  827. if ( item )
  828. {
  829. TQString res = item->text(1 );
  830. if ( res != m_pView->kPresenterDoc()->backupPath())
  831. {
  832. config->setGroup( "Kpresenter Path" );
  833. m_pView->kPresenterDoc()->setBackupPath( res );
  834. #if KDE_IS_VERSION(3,1,3)
  835. config->writePathEntry( "backup path",res );
  836. #else
  837. config->writeEntry( "backup path",res );
  838. #endif
  839. }
  840. }
  841. item = m_pPathView->findItem(i18n("Picture Path"), 0);
  842. if ( item )
  843. {
  844. TQString res = item->text(1 );
  845. if ( res != m_pView->kPresenterDoc()->picturePath())
  846. {
  847. config->setGroup( "Kpresenter Path" );
  848. m_pView->kPresenterDoc()->setPicturePath( res );
  849. #if KDE_IS_VERSION(3,1,3)
  850. config->writePathEntry( "picture path",res );
  851. #else
  852. config->writeEntry( "picture path",res );
  853. #endif
  854. }
  855. }
  856. }
  857. ////
  858. KPrConfigureTTSPage::KPrConfigureTTSPage( KPrView *_view, TQWidget *parent, char *name )
  859. : TQWidget( parent, name )
  860. {
  861. Q_UNUSED(_view);
  862. TQVBoxLayout *box = new TQVBoxLayout( this, 0, 0 );
  863. m_cbSpeakPointerWidget = new TQCheckBox(i18n("Speak widget under &mouse pointer"), this);
  864. m_cbSpeakFocusWidget = new TQCheckBox(i18n("Speak widget with &focus"), this);
  865. m_gbScreenReaderOptions = new TQVGroupBox("", this);
  866. box->add(m_cbSpeakPointerWidget);
  867. box->add(m_cbSpeakFocusWidget);
  868. box->add(m_gbScreenReaderOptions);
  869. m_gbScreenReaderOptions->setMargin( KDialog::marginHint() );
  870. m_gbScreenReaderOptions->setInsideSpacing( KDialog::spacingHint() );
  871. m_cbSpeakTooltips = new TQCheckBox(i18n("Speak &tool tips"), m_gbScreenReaderOptions);
  872. m_cbSpeakWhatsThis = new TQCheckBox(i18n("Speak &What's This?"), m_gbScreenReaderOptions);
  873. m_cbSpeakDisabled = new TQCheckBox(i18n("Verbal indication if widget is disabled (grayed)",
  874. "&Say whether disabled"), m_gbScreenReaderOptions);
  875. m_cbSpeakAccelerators = new TQCheckBox(i18n("Spea&k accelerators"), m_gbScreenReaderOptions);
  876. TQHBox* hbAcceleratorPrefix = new TQHBox(m_gbScreenReaderOptions);
  877. TQWidget* spacer = new TQWidget(hbAcceleratorPrefix);
  878. spacer->setMinimumWidth(2 * KDialog::marginHint());
  879. m_lblAcceleratorPrefix =
  880. new TQLabel(i18n("A word spoken before another word", "Pr&efaced by the word:"),
  881. hbAcceleratorPrefix);
  882. m_leAcceleratorPrefixWord = new TQLineEdit(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"),
  883. hbAcceleratorPrefix);
  884. m_lblAcceleratorPrefix->setBuddy(m_leAcceleratorPrefixWord);
  885. TQHBox* hbPollingInterval = new TQHBox(m_gbScreenReaderOptions);
  886. hbPollingInterval->setMargin( 0 );
  887. TQLabel* lblPollingInterval = new TQLabel(i18n("&Polling interval:"), hbPollingInterval);
  888. m_iniPollingInterval = new KIntNumInput(hbPollingInterval);
  889. m_iniPollingInterval->setSuffix(" ms");
  890. m_iniPollingInterval->setRange(100, 5000, 100, true);
  891. lblPollingInterval->setBuddy(m_iniPollingInterval);
  892. config = KPrFactory::global()->config();
  893. config->setGroup("TTS");
  894. m_cbSpeakPointerWidget->setChecked(config->readBoolEntry("SpeakPointerWidget", false));
  895. m_cbSpeakFocusWidget->setChecked(config->readBoolEntry("SpeakFocusWidget", false));
  896. m_cbSpeakTooltips->setChecked(config->readBoolEntry("SpeakTooltips", true));
  897. m_cbSpeakWhatsThis->setChecked(config->readBoolEntry("SpeakWhatsThis", false));
  898. m_cbSpeakDisabled->setChecked(config->readBoolEntry("SpeakDisabled", true));
  899. m_cbSpeakAccelerators->setChecked(config->readBoolEntry("SpeakAccelerators", true));
  900. m_leAcceleratorPrefixWord->setText(config->readEntry("AcceleratorPrefixWord",
  901. i18n("Keyboard accelerator, such as Alt+F", "Accelerator")));
  902. m_iniPollingInterval->setValue(config->readNumEntry("PollingInterval", 600));
  903. screenReaderOptionChanged();
  904. connect(m_cbSpeakPointerWidget, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  905. connect(m_cbSpeakFocusWidget, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  906. connect(m_cbSpeakAccelerators, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(screenReaderOptionChanged()));
  907. }
  908. void KPrConfigureTTSPage::slotDefault()
  909. {
  910. m_cbSpeakPointerWidget->setChecked(false);
  911. m_cbSpeakFocusWidget->setChecked(false);
  912. m_cbSpeakTooltips->setChecked(true);
  913. m_cbSpeakWhatsThis->setChecked(false);
  914. m_cbSpeakDisabled->setChecked(true);
  915. m_cbSpeakAccelerators->setChecked(true);
  916. m_leAcceleratorPrefixWord->setText(i18n("Keyboard accelerator, such as Alt+F", "Accelerator"));
  917. m_iniPollingInterval->setValue(600);
  918. }
  919. void KPrConfigureTTSPage::apply()
  920. {
  921. config->setGroup("TTS");
  922. config->writeEntry("SpeakPointerWidget", m_cbSpeakPointerWidget->isChecked());
  923. config->writeEntry("SpeakFocusWidget", m_cbSpeakFocusWidget->isChecked());
  924. config->writeEntry("SpeakTooltips", m_cbSpeakTooltips->isChecked());
  925. config->writeEntry("SpeakWhatsThis", m_cbSpeakWhatsThis->isChecked());
  926. config->writeEntry("SpeakDisabled", m_cbSpeakDisabled->isChecked());
  927. config->writeEntry("SpeakAccelerators", m_cbSpeakAccelerators->isChecked());
  928. config->writeEntry("AcceleratorPrefixWord", m_leAcceleratorPrefixWord->text());
  929. config->writeEntry("PollingInterval", m_iniPollingInterval->value());
  930. if (kospeaker) kospeaker->readConfig(config);
  931. }
  932. void KPrConfigureTTSPage::screenReaderOptionChanged()
  933. {
  934. m_gbScreenReaderOptions->setEnabled(
  935. m_cbSpeakPointerWidget->isChecked() | m_cbSpeakFocusWidget->isChecked());
  936. m_leAcceleratorPrefixWord->setEnabled(m_cbSpeakAccelerators->isChecked());
  937. m_lblAcceleratorPrefix->setEnabled(m_cbSpeakAccelerators->isChecked());
  938. }
  939. #include "KPrConfig.moc"