17
17
Boston, MA 02111-1307, USA.
20
#include <kapplication.h>
21
22
#include <kconfig.h>
22
23
#include <kdialogbase.h>
23
24
#include <kiconloader.h>
24
25
#include <knuminput.h>
25
26
#include <kcolorbutton.h>
27
#include "kprvariable.h"
28
#include "kprcanvas.h"
29
#include <tkcoloractions.h>
27
31
#include <qgroupbox.h>
28
32
#include <qlabel.h>
29
33
#include <qlayout.h>
32
#include <kpresenter_dlg_config.h>
33
#include <kpresenter_view.h>
34
#include <kpresenter_doc.h>
35
#include <qcheckbox.h>
36
#include <qtabwidget.h>
39
#include "confpiedia.h"
40
#include "confrectdia.h"
41
#include "confpolygondia.h"
42
#include "confpicturedia.h"
44
#include "kpresenter_dlg_config.h"
45
#include "kpresenter_view.h"
46
#include "kpresenter_doc.h"
51
#include <knumvalidator.h>
52
#include <qlineedit.h>
53
#include "kprcommand.h"
54
#include <qvgroupbox.h>
55
#include <kfontdialog.h>
56
#include <klineedit.h>
58
#include <kmessagebox.h>
59
#include <kdeversion.h>
60
#include <kurlrequesterdlg.h>
61
#include <klistview.h>
62
#include <kfiledialog.h>
63
#include <koSpellConfig.h>
64
#include <koeditpath.h>
65
#include <koSconfig.h>
36
67
KPConfig::KPConfig( KPresenterView* parent )
37
: KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
38
KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
68
: KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
69
KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
73
m_doc = parent->kPresenterDoc();
42
74
QVBox *page = addVBoxPage( i18n("Interface"), i18n("Interface"),
43
BarIcon("misc", KIcon::SizeMedium) );
75
BarIcon("misc", KIcon::SizeMedium) );
44
76
_interfacePage=new configureInterfacePage( parent, page );
45
77
page = addVBoxPage( i18n("Color"), i18n("Color"),
46
78
BarIcon("colorize", KIcon::SizeMedium) );
47
79
_colorBackground = new configureColorBackground( parent, page );
81
page = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
82
BarIcon("spellcheck", KIcon::SizeMedium) );
83
_spellPage=new configureSpellPage(parent, page);
85
page = addVBoxPage( i18n("Misc"), i18n("Misc"),
86
BarIcon("misc", KIcon::SizeMedium) );
87
_miscPage=new configureMiscPage(parent, page);
89
page = addVBoxPage( i18n("Document"), i18n("Document Settings"),
90
BarIcon("document", KIcon::SizeMedium) );
92
_defaultDocPage=new configureDefaultDocPage(parent, page);
94
page = addVBoxPage( i18n("Tools"), i18n("Default Tools Settings"),
95
BarIcon("configure", KIcon::SizeMedium) );
97
_toolsPage=new configureToolsPage(parent, page);
99
page = addVBoxPage( i18n("Paths"), i18n("Path Settings"),
102
m_pathPage=new configurePathPage(parent, page);
48
104
connect( this, SIGNAL( okClicked() ),this, SLOT( slotApply() ) );
107
void KPConfig::openPage(int flags)
109
if(flags & KP_INTERFACE)
111
else if(flags & KP_COLOR)
113
else if(flags & KP_KSPELL)
115
else if(flags & KP_MISC)
117
else if(flags & KP_DOC)
119
else if(flags & KP_TOOLS)
121
else if(flags & KP_PATH)
51
125
void KPConfig::slotApply()
127
KMacroCommand *macro = 0L;
53
128
_interfacePage->apply();
54
129
_colorBackground->apply();
132
KCommand *cmd = _miscPage->apply();
136
macro = new KMacroCommand(i18n("Change Config") );
137
macro->addCommand( cmd );
139
cmd = _defaultDocPage->apply();
143
macro = new KMacroCommand(i18n("Change Config") );
145
macro->addCommand( cmd );
150
m_doc->addCommand( macro);
57
153
void KPConfig::slotDefault()
59
155
switch( activePageIndex() ) {
61
_interfacePage->slotDefault();
64
_colorBackground->slotDefault();
157
_interfacePage->slotDefault();
160
_colorBackground->slotDefault();
163
_spellPage->slotDefault();
166
_miscPage->slotDefault();
169
_defaultDocPage->slotDefault();
172
_toolsPage->slotDefault();
175
m_pathPage->slotDefault();
70
182
configureInterfacePage::configureInterfacePage( KPresenterView *_view, QWidget *parent , char *name )
71
:QWidget ( parent,name )
183
:QWidget ( parent,name )
185
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
74
188
config = KPresenterFactory::global()->config();
75
QVBoxLayout *box = new QVBoxLayout( this );
77
box->setSpacing( 10 );
78
QGroupBox* tmpQGroupBox = new QGroupBox( this, "GroupBox" );
79
tmpQGroupBox->setTitle( i18n("Interface") );
81
QVBoxLayout *lay1 = new QVBoxLayout( tmpQGroupBox );
82
lay1->setMargin( 20 );
83
lay1->setSpacing( 10 );
85
int oldRastX = m_pView->kPresenterDoc()->rastX();
86
int oldRastY = m_pView->kPresenterDoc()->rastY();
87
oldAutoSaveValue = m_pView->kPresenterDoc()->defaultAutoSave()/60;
190
KoUnit::Unit unit = m_pView->kPresenterDoc()->getUnit();
193
double ptIndent = MM_TO_POINT(10.0);
194
bool bShowRuler=true;
195
bool oldShowStatusBar = true;
89
197
if( config->hasGroup("Interface") ) {
90
198
config->setGroup( "Interface" );
91
oldAutoSaveValue = config->readNumEntry( "AutoSave", oldAutoSaveValue );
199
oldNbRecentFiles=config->readNumEntry("NbRecentFile",oldNbRecentFiles);
200
ptIndent = config->readDoubleNumEntry("Indent", ptIndent);
201
bShowRuler=config->readBoolEntry("Rulers",true);
202
oldShowStatusBar = config->readBoolEntry( "ShowStatusBar" , true );
94
autoSave = new KIntNumInput( oldAutoSaveValue, tmpQGroupBox );
95
autoSave->setRange( 0, 60, 1 );
96
autoSave->setLabel( i18n("Auto save (min):") );
97
autoSave->setSpecialValueText( i18n("No auto save") );
98
autoSave->setSuffix( i18n("min") );
99
lay1->addWidget( autoSave );
101
eRastX = new KIntNumInput( oldRastX, tmpQGroupBox );
102
eRastX->setRange( 1, 400, 1 );
103
eRastX->setLabel( i18n("Horizontal Raster: ") );
104
lay1->addWidget( eRastX );
106
eRastY = new KIntNumInput( oldRastY, tmpQGroupBox );
107
eRastY->setRange( 1, 400, 1 );
108
eRastY->setLabel( i18n("Vertical Raster: ") );
109
lay1->addWidget( eRastY );
111
box->addWidget( tmpQGroupBox );
206
showRuler= new QCheckBox(i18n("Show rulers"),this);
207
showRuler->setChecked(bShowRuler);
208
box->addWidget(showRuler);
210
showStatusBar = new QCheckBox(i18n("Show status bar"),this);
211
showStatusBar->setChecked(oldShowStatusBar);
212
box->addWidget(showStatusBar);
215
recentFiles=new KIntNumInput( oldNbRecentFiles, this);
216
recentFiles->setRange(1, 20, 1);
217
recentFiles->setLabel(i18n("Number of recent files:"));
219
box->addWidget(recentFiles);
221
QString suffix = KoUnit::unitName( unit ).prepend(' ');
222
double val = KoUnit::ptToUnit( ptIndent, unit );
223
indent = new KDoubleNumInput( val, this);
224
indent->setRange(KoUnit::ptToUnit( 0.1, unit ), KoUnit::ptToUnit( 50, unit ), KoUnit::ptToUnit( 0.1, unit ));
227
indent->setSuffix( suffix );
228
indent->setLabel(i18n("Paragraph indent by toolbar buttons:"));
230
box->addWidget(indent);
232
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
233
box->addItem( spacer);
114
236
void configureInterfacePage::apply()
116
unsigned int rastX = eRastX->value();
117
unsigned int rastY = eRastY->value();
238
bool ruler=showRuler->isChecked();
239
bool statusBar=showStatusBar->isChecked();
119
241
KPresenterDoc * doc = m_pView->kPresenterDoc();
121
243
config->setGroup( "Interface" );
122
if( rastX != oldRastX || rastY != oldRastX ) {
123
config->writeEntry( "RastX", rastX );
124
config->writeEntry( "RastY", rastY );
125
doc->setRasters( rastX, rastY, true );
126
doc->repaint( false );
129
int autoSaveVal = autoSave->value();
130
if( autoSaveVal != oldAutoSaveValue ) {
131
config->writeEntry( "AutoSave", autoSaveVal );
132
m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 );
245
double newIndent = KoUnit::ptFromUnit( indent->value(), doc->getUnit() );
246
if( newIndent != doc->getIndentValue() )
248
config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ );
249
doc->setIndentValue( newIndent );
251
int nbRecent=recentFiles->value();
252
if(nbRecent!=oldNbRecentFiles)
254
config->writeEntry( "NbRecentFile", nbRecent);
255
m_pView->changeNbOfRecentFiles(nbRecent);
256
oldNbRecentFiles=nbRecent;
258
bool refreshGUI=false;
259
if(ruler != doc->showRuler())
261
config->writeEntry( "Rulers", ruler );
262
doc->setShowRuler( ruler );
266
if( statusBar != doc->showStatusBar() )
268
config->writeEntry( "ShowStatusBar", statusBar );
269
doc->setShowStatusBar( statusBar );
274
doc->reorganizeGUI();
136
278
void configureInterfacePage::slotDefault()
138
eRastX->setValue( 10 );
139
eRastY->setValue( 10 );
140
autoSave->setValue( m_pView->kPresenterDoc()->defaultAutoSave()/60 );
280
double newIndent = KoUnit::ptToUnit( MM_TO_POINT( 10 ), m_pView->kPresenterDoc()->getUnit() );
281
indent->setValue( newIndent );
282
recentFiles->setValue(10);
283
showRuler->setChecked(true);
284
showStatusBar->setChecked(true);
143
287
configureColorBackground::configureColorBackground( KPresenterView* _view, QWidget *parent , char *name )
144
:QWidget ( parent,name )
288
:QWidget ( parent,name )
147
291
config = KPresenterFactory::global()->config();
149
293
oldBgColor = m_pView->kPresenterDoc()->txtBackCol();
151
QVBoxLayout *box = new QVBoxLayout( this );
153
box->setSpacing( 10 );
155
QGroupBox* tmpQGroupBox = new QGroupBox( this, "GroupBox" );
156
tmpQGroupBox->setTitle( i18n("Objects in editing mode") );
157
QGridLayout *grid1 = new QGridLayout( tmpQGroupBox, 5, 1, 15, 7);
158
QLabel *lab = new QLabel( tmpQGroupBox, "label20" );
159
lab->setText( i18n( "Background color:" ) );
160
grid1->addWidget( lab, 0, 0 );
162
bgColor = new KColorButton( tmpQGroupBox );
294
oldGridColor = m_pView->kPresenterDoc()->gridColor();
295
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
297
QLabel *lab = new QLabel( this, "label20" );
298
lab->setText( i18n( "Background object color:" ) );
301
bgColor = new KColorButton( oldBgColor,
163
304
bgColor->setColor( oldBgColor );
164
grid1->addWidget( bgColor, 1, 0 );
166
box->addWidget( tmpQGroupBox );
305
box->addWidget(bgColor);
308
lab = new QLabel( this, "label20" );
309
lab->setText( i18n( "Grid color:" ) );
312
gridColor = new KColorButton( oldGridColor,
315
box->addWidget(gridColor);
316
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
317
box->addItem( spacer);
169
321
void configureColorBackground::apply()
323
KPresenterDoc * doc = m_pView->kPresenterDoc();
324
bool repaintNeeded = false;
171
325
QColor _col = bgColor->color();
172
KPresenterDoc * doc = m_pView->kPresenterDoc();
173
326
if( oldBgColor != _col ) {
174
327
config->setGroup( "KPresenter Color" );
175
328
config->writeEntry( "BackgroundColor", _col );
176
329
doc->setTxtBackCol( _col );
177
330
doc->replaceObjs();
178
doc->repaint( false );
332
repaintNeeded = true;
334
_col = gridColor->color();
335
if( oldGridColor != _col ) {
336
config->setGroup( "KPresenter Color" );
337
config->writeEntry( "GridColor", _col );
338
doc->repaint( false );
339
doc->setGridColor( _col );
341
repaintNeeded = true;
344
doc->repaint( false );
182
347
void configureColorBackground::slotDefault()
184
349
bgColor->setColor( Qt::white );
187
#include <kpresenter_dlg_config.moc>
350
gridColor->setColor( Qt::black );
355
configureSpellPage::configureSpellPage( KPresenterView *_view, QWidget *parent, char *name )
356
: QWidget( parent, name )
359
config = KPresenterFactory::global()->config();
360
m_spellConfigWidget = new KoSpellConfigWidget( parent, m_pView->kPresenterDoc()->getKOSpellConfig(), true);
362
if( config->hasGroup("KSpell kpresenter") )
364
config->setGroup( "KSpell kpresenter" );
365
m_spellConfigWidget->setDontCheckUpperWord(config->readBoolEntry("KSpell_dont_check_upper_word",false));
366
m_spellConfigWidget->setDontCheckTitleCase(config->readBoolEntry("KSpell_dont_check_title_case",false));
369
m_spellConfigWidget->setBackgroundSpellCheck( m_pView->kPresenterDoc()->backgroundSpellCheckEnabled() );
370
m_spellConfigWidget->addIgnoreList( m_pView->kPresenterDoc()->spellListIgnoreAll() );
373
void configureSpellPage::apply()
376
KOSpellConfig *_spellConfig = m_spellConfigWidget->spellConfig();
377
config->setGroup( "KSpell kpresenter" );
378
config->writeEntry ("KSpell_NoRootAffix",(int) _spellConfig->noRootAffix ());
379
config->writeEntry ("KSpell_RunTogether", (int) _spellConfig->runTogether ());
380
config->writeEntry ("KSpell_Dictionary", _spellConfig->dictionary ());
381
config->writeEntry ("KSpell_DictFromList",(int) _spellConfig->dictFromList());
382
config->writeEntry ("KSpell_Encoding", (int) _spellConfig->encoding());
383
config->writeEntry ("KSpell_Client", _spellConfig->client());
384
config->writeEntry( "KSpell_dont_check_title_case", (int)_spellConfig->dontCheckTitleCase());
385
config->writeEntry( "KSpell_dont_check_upper_word", (int)_spellConfig->dontCheckUpperWord());
386
config->writeEntry ("KSpell_IgnoreCase",(int) _spellConfig->ignoreCase());
387
config->writeEntry( "KSpell_IgnoreAccent", (int) _spellConfig->ignoreAccent());
388
config->writeEntry( "KSpell_SpellWordWithNumber", (int)_spellConfig->spellWordWithNumber());
389
m_spellConfigWidget->saveDictionary();
390
KPresenterDoc* doc = m_pView->kPresenterDoc();
391
doc->setKOSpellConfig(*_spellConfig);
393
bool state = m_spellConfigWidget->backgroundSpellCheck();
394
config->writeEntry( "SpellCheck", (int)state );
396
doc->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
398
doc->reactivateBgSpellChecking(state);
399
//FIXME reactivate just if there is a changes.
400
doc->enableBackgroundSpellCheck( state );
403
void configureSpellPage::slotDefault()
405
m_spellConfigWidget->setDefault();
408
configureMiscPage::configureMiscPage( KPresenterView *_view, QWidget *parent, char *name )
409
: QWidget( parent, name )
411
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
414
config = KPresenterFactory::global()->config();
416
QGroupBox* tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Misc"), this, "GroupBox" );
417
tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint());
418
tmpQGroupBox->layout()->setMargin(KDialog::marginHint());
419
QGridLayout *grid = new QGridLayout( tmpQGroupBox->layout(), 8, 1 );
423
if( config->hasGroup("Misc") )
425
config->setGroup( "Misc" );
426
m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
427
m_printNotes = config->readBoolEntry("PrintNotes", true);
430
m_undoRedoLimit=new KIntNumInput( m_oldNbRedo, tmpQGroupBox );
431
m_undoRedoLimit->setLabel(i18n("Undo/redo limit:"));
432
m_undoRedoLimit->setRange(10, 60, 1);
433
grid->addWidget(m_undoRedoLimit,0,0);
435
KPresenterDoc* doc = m_pView->kPresenterDoc();
437
m_displayLink=new QCheckBox(i18n("Display links"),tmpQGroupBox);
438
grid->addWidget(m_displayLink,3,0);
439
m_displayLink->setChecked(doc->getVariableCollection()->variableSetting()->displayLink());
441
m_underlineLink=new QCheckBox(i18n("&Underline all links"),tmpQGroupBox);
442
m_underlineLink->setChecked(doc->getVariableCollection()->variableSetting()->underlineLink());
443
grid->addWidget(m_underlineLink,4,0);
446
m_displayComment=new QCheckBox(i18n("Display comments"),tmpQGroupBox);
447
m_displayComment->setChecked(doc->getVariableCollection()->variableSetting()->displayComment());
448
grid->addWidget(m_displayComment,5,0);
450
m_displayFieldCode=new QCheckBox(i18n("Display field code"),tmpQGroupBox);
451
m_displayFieldCode->setChecked(doc->getVariableCollection()->variableSetting()->displayFieldCode());
452
grid->addWidget(m_displayFieldCode,6,0);
454
m_cbPrintNotes=new QCheckBox(i18n("Print slide notes"),tmpQGroupBox);
455
m_cbPrintNotes->setChecked(m_printNotes);
456
grid->addWidget(m_cbPrintNotes,7,0);
458
box->addWidget(tmpQGroupBox);
460
tmpQGroupBox = new QGroupBox( 0, Qt::Vertical, i18n("Grid"), this, "GroupBox" );
461
tmpQGroupBox->layout()->setSpacing(KDialog::spacingHint());
462
tmpQGroupBox->layout()->setMargin(KDialog::marginHint());
463
grid = new QGridLayout( tmpQGroupBox->layout(), 8, 1 );
465
KoRect rect = doc->stickyPage()->getPageRect();
466
QLabel *lab=new QLabel(i18n("Resolution X (%1):").arg(doc->getUnitName()), tmpQGroupBox);
467
grid->addWidget(lab,0,0);
468
KoUnit::Unit unit = doc->getUnit();
469
resolutionX = new KDoubleNumInput(tmpQGroupBox);
470
resolutionX->setValue( KoUnit::ptToUnit( doc->getGridX(), unit ) );
471
resolutionX->setRange( KoUnit::ptToUnit(10.0 , unit), KoUnit::ptToUnit(rect.width(), unit), KoUnit::ptToUnit(1, unit ), false);
473
grid->addWidget(resolutionX,1,0);
475
lab=new QLabel(i18n("Resolution Y (%1):").arg(doc->getUnitName()), tmpQGroupBox);
476
grid->addWidget(lab,2,0);
478
resolutionY = new KDoubleNumInput(tmpQGroupBox);
479
resolutionY->setValue( KoUnit::ptToUnit( doc->getGridY(), unit ) );
480
resolutionY->setRange( KoUnit::ptToUnit(10.0,unit), KoUnit::ptToUnit(rect.width(), unit), KoUnit::ptToUnit( 1,unit ), false);
482
grid->addWidget(resolutionY, 3, 0);
483
box->addWidget(tmpQGroupBox);
485
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
486
box->addItem( spacer);
491
KCommand * configureMiscPage::apply()
493
config->setGroup( "Misc" );
494
int newUndo=m_undoRedoLimit->value();
495
KPresenterDoc* doc = m_pView->kPresenterDoc();
496
if(newUndo!=m_oldNbRedo)
498
config->writeEntry("UndoRedo",newUndo);
499
doc->setUndoRedoLimit(newUndo);
502
config->writeEntry("PrintNotes", m_cbPrintNotes->isChecked());
504
KMacroCommand * macroCmd=0L;
505
bool b=m_displayLink->isChecked();
506
bool b_new=doc->getVariableCollection()->variableSetting()->displayLink();
510
macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
512
KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
513
i18n("Change Display Link Command"), doc, b_new, b, KPrChangeVariableSettingsCommand::VS_DISPLAYLINK);
515
macroCmd->addCommand(cmd);
518
b=m_underlineLink->isChecked();
519
if(doc->getVariableCollection()->variableSetting()->underlineLink()!=b)
522
macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
524
KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
525
i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->underlineLink(),
526
b, KPrChangeVariableSettingsCommand::VS_UNDERLINELINK);
528
macroCmd->addCommand(cmd);
531
b=m_displayComment->isChecked();
532
if(doc->getVariableCollection()->variableSetting()->displayComment()!=b)
535
macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
537
KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
538
i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
539
b, KPrChangeVariableSettingsCommand::VS_DISPLAYCOMMENT);
541
macroCmd->addCommand(cmd);
544
b=m_displayFieldCode->isChecked();
545
if(doc->getVariableCollection()->variableSetting()->displayFieldCode()!=b)
548
macroCmd=new KMacroCommand(i18n("Change Display Field Code Command"));
550
KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
551
i18n("Change Display Field Code Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
552
b, KPrChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE);
554
macroCmd->addCommand(cmd);
557
doc->setGridValue( KoUnit::ptFromUnit( resolutionX->value(), doc->getUnit() ),
558
KoUnit::ptFromUnit( resolutionY->value(), doc->getUnit() ), true);
559
doc->repaint( false );
566
void configureMiscPage::slotDefault()
568
m_undoRedoLimit->setValue(30);
569
m_displayLink->setChecked(true);
570
m_displayComment->setChecked(true);
571
m_underlineLink->setChecked(true);
572
m_displayFieldCode->setChecked( false );
573
m_cbPrintNotes->setChecked(true);
574
KPresenterDoc* doc = m_pView->kPresenterDoc();
576
resolutionY->setValue( KoUnit::ptToUnit( MM_TO_POINT( 10.0 ), doc->getUnit() ) );
577
resolutionX->setValue( KoUnit::ptToUnit( MM_TO_POINT( 10.0 ), doc->getUnit() ) );
580
configureDefaultDocPage::configureDefaultDocPage(KPresenterView *_view, QWidget *parent, char *name )
581
: QWidget( parent, name )
583
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
586
config = KPresenterFactory::global()->config();
587
KPresenterDoc *doc = m_pView->kPresenterDoc();
588
oldAutoSaveValue = doc->defaultAutoSave()/60;
589
m_oldBackupFile = true;
590
m_oldLanguage = doc->globalLanguage();
591
m_oldHyphenation = doc->globalHyphenation();
592
if( config->hasGroup("Interface") ) {
593
config->setGroup( "Interface" );
594
oldAutoSaveValue = config->readNumEntry( "AutoSave", oldAutoSaveValue );
595
m_oldBackupFile=config->readBoolEntry("BackupFile",m_oldBackupFile);
596
m_oldLanguage = config->readEntry( "language", m_oldLanguage );
597
m_oldHyphenation = config->readBoolEntry( "hyphenation", m_oldHyphenation);
600
QVGroupBox* gbDocumentDefaults = new QVGroupBox( i18n("Document Defaults"), this, "GroupBox" );
601
gbDocumentDefaults->setMargin( KDialog::marginHint() );
602
gbDocumentDefaults->setInsideSpacing( 5 );
604
QWidget *fontContainer = new QWidget(gbDocumentDefaults);
605
QGridLayout * fontLayout = new QGridLayout(fontContainer, 1, 3);
607
fontLayout->setColStretch(0, 0);
608
fontLayout->setColStretch(1, 1);
609
fontLayout->setColStretch(2, 0);
611
QLabel *fontTitle = new QLabel(i18n("Default font:"), fontContainer);
613
font= new QFont( doc->defaultFont() );
615
QString labelName = font->family() + ' ' + QString::number(font->pointSize());
616
fontName = new QLabel(labelName, fontContainer);
617
fontName->setFont(*font);
618
fontName->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
620
QPushButton *chooseButton = new QPushButton(i18n("Choose..."), fontContainer);
621
connect(chooseButton, SIGNAL(clicked()), this, SLOT(selectNewDefaultFont()));
623
fontLayout->addWidget(fontTitle, 0, 0);
624
fontLayout->addWidget(fontName, 0, 1);
625
fontLayout->addWidget(chooseButton, 0, 2);
627
QWidget *languageContainer = new QWidget(gbDocumentDefaults);
628
QGridLayout * languageLayout = new QGridLayout(languageContainer, 1, 3);
630
languageLayout->setColStretch(0, 0);
631
languageLayout->setColStretch(1, 1);
633
QLabel *languageTitle = new QLabel(i18n("Global language:"), languageContainer);
635
m_globalLanguage = new QComboBox( languageContainer );
636
m_globalLanguage->insertStringList( KoGlobal::listOfLanguages());
639
m_globalLanguage->setCurrentItem(KoGlobal::languageIndexFromTag(doc->globalLanguage()));
641
languageLayout->addWidget(languageTitle, 0, 0);
642
languageLayout->addWidget(m_globalLanguage, 0, 1);
644
m_autoHyphenation = new QCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults);
645
m_autoHyphenation->setChecked( m_oldHyphenation );
647
box->addWidget(gbDocumentDefaults);
649
QVGroupBox* gbDocumentSettings = new QVGroupBox( i18n("Document Settings"), this );
650
gbDocumentSettings->setMargin( KDialog::marginHint() );
651
gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
653
m_createBackupFile = new QCheckBox( i18n("Create backup file"), gbDocumentSettings);
654
m_createBackupFile->setChecked( m_oldBackupFile );
657
autoSave = new KIntNumInput( oldAutoSaveValue, gbDocumentSettings );
658
autoSave->setRange( 0, 60, 1 );
659
autoSave->setLabel( i18n("Autosave (min):") );
660
autoSave->setSpecialValueText( i18n("No autosave") );
661
autoSave->setSuffix( i18n("min") );
663
new QLabel(i18n("Starting page number:"), gbDocumentSettings);
664
m_oldStartingPage=doc->getVariableCollection()->variableSetting()->startingPage();
665
m_variableNumberOffset=new KIntNumInput(gbDocumentSettings);
666
m_variableNumberOffset->setRange(1, 9999, 1, false);
667
m_variableNumberOffset->setValue(m_oldStartingPage);
669
new QLabel(i18n("Tab stop (%1):").arg(doc->getUnitName()), gbDocumentSettings);
670
m_tabStopWidth = new KDoubleNumInput( gbDocumentSettings );
671
m_oldTabStopWidth = doc->tabStopValue();
672
KoRect rect = doc->stickyPage()->getPageRect();
674
m_tabStopWidth->setRange( KoUnit::ptToUnit( MM_TO_POINT(2),doc->getUnit() ) , KoUnit::ptToUnit( rect.width(), doc->getUnit() ) , 0.1, false);
675
m_tabStopWidth->setValue( KoUnit::ptToUnit( m_oldTabStopWidth, doc->getUnit() ));
676
box->addWidget(gbDocumentSettings);
677
QVGroupBox* gbDocumentCursor = new QVGroupBox( i18n("Cursor"), this );
678
gbDocumentCursor->setMargin( KDialog::marginHint() );
679
gbDocumentCursor->setInsideSpacing( KDialog::spacingHint() );
681
m_cursorInProtectedArea= new QCheckBox(i18n("Cursor in protected area"),gbDocumentCursor);
682
m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
684
m_directInsertCursor= new QCheckBox(i18n("Direct insert cursor"),gbDocumentCursor);
685
m_directInsertCursor->setChecked(doc->insertDirectCursor());
686
box->addWidget(gbDocumentCursor);
688
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
689
box->addItem(spacer);
693
configureDefaultDocPage::~configureDefaultDocPage()
698
KCommand *configureDefaultDocPage::apply()
700
config->setGroup( "Document defaults" );
701
KPresenterDoc* doc = m_pView->kPresenterDoc();
702
config->writeEntry("DefaultFont",font->toString());
704
config->setGroup( "Interface" );
705
int autoSaveVal = autoSave->value();
706
if( autoSaveVal != oldAutoSaveValue ) {
707
config->writeEntry( "AutoSave", autoSaveVal );
708
m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 );
709
oldAutoSaveValue=autoSaveVal;
711
bool state =m_createBackupFile->isChecked();
713
if(state!=m_oldBackupFile)
715
config->writeEntry( "BackupFile", state );
716
doc->setBackupFile( state);
717
m_oldBackupFile=state;
720
state = m_cursorInProtectedArea->isChecked();
721
if ( state != doc->cursorInProtectedArea() )
723
config->writeEntry( "cursorInProtectArea", state );
724
m_pView->kPresenterDoc()->setCursorInProtectedArea( state );
727
state = m_directInsertCursor->isChecked();
728
if ( state != doc->insertDirectCursor() )
729
doc->setInsertDirectCursor( state );
731
//Laurent Todo add a message box to inform user that
732
//global language will change after re-launch kword
733
QString lang = KoGlobal::tagOfLanguage( m_globalLanguage->currentText() );
734
config->writeEntry( "language" , lang);
735
m_oldLanguage = lang;
736
//don't call this fiunction otherwise we can have a textobject with
737
// a default language and other textobject with other default language.
738
//doc->setGlobalLanguage( lang );
741
state = m_autoHyphenation->isChecked();
742
config->writeEntry( "hyphenation", state );
743
m_oldHyphenation = state;
745
KMacroCommand *macro = 0L;
746
int newStartingPage=m_variableNumberOffset->value();
747
if(newStartingPage!=m_oldStartingPage)
749
macro = new KMacroCommand( i18n("Change Starting Page Number") );
750
KPrChangeStartingPageCommand *cmd = new KPrChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage );
752
macro->addCommand( cmd);
753
m_oldStartingPage=newStartingPage;
755
double newTabStop = KoUnit::ptFromUnit( m_tabStopWidth->value(), doc->getUnit() );
756
if ( newTabStop != m_oldTabStopWidth)
759
macro = new KMacroCommand( i18n("Change Tab Stop Value") );
760
KPrChangeTabStopValueCommand *cmd = new KPrChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
762
macro->addCommand( cmd );
763
m_oldTabStopWidth = newTabStop;
768
void configureDefaultDocPage::slotDefault()
770
autoSave->setValue( m_pView->kPresenterDoc()->defaultAutoSave()/60 );
771
m_variableNumberOffset->setValue(1);
772
m_cursorInProtectedArea->setChecked(true);
773
m_tabStopWidth->setValue(KoUnit::ptToUnit( MM_TO_POINT(15), m_pView->kPresenterDoc()->getUnit()));
774
m_createBackupFile->setChecked( true );
775
m_directInsertCursor->setChecked( false );
776
m_globalLanguage->setCurrentItem(KoGlobal::languageIndexFromTag(KGlobal::locale()->language()));
777
m_autoHyphenation->setChecked( false );
780
void configureDefaultDocPage::selectNewDefaultFont() {
782
KFontChooser::getFontList(list, KFontChooser::SmoothScalableFonts);
783
KFontDialog dlg( this, "Font Selector", false, true, list, true );
785
int result = dlg.exec();
786
if (KDialog::Accepted == result) {
788
font = new QFont(dlg.font());
789
fontName->setText(font->family() + ' ' + QString::number(font->pointSize()));
790
fontName->setFont(*font);
791
m_pView->kPresenterDoc()->setDefaultFont( *font );
795
configureToolsPage::configureToolsPage( KPresenterView *_view, QWidget *parent, char *name )
796
: QWidget( parent, name )
798
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
801
config = KPresenterFactory::global()->config();
802
m_pView->getCanvas()->deSelectAllObj();
804
QTabWidget *tab = new QTabWidget(this);
806
m_confPenDia = new ConfPenDia(tab, 0, StyleDia::SdAll);
807
m_confPenDia->setPen(m_pView->getPen());
808
m_confPenDia->setLineBegin(m_pView->getLineBegin());
809
m_confPenDia->setLineEnd(m_pView->getLineEnd());
810
tab->addTab(m_confPenDia, i18n("&Pen"));
812
m_confBrushDia = new ConfBrushDia(tab, 0, StyleDia::SdAll);
813
m_confBrushDia->setBrush(m_pView->getBrush());
814
m_confBrushDia->setFillType(m_pView->getFillType());
815
m_confBrushDia->setGradient(m_pView->getGColor1(), m_pView->getGColor2(), m_pView->getGType(),
816
m_pView->getGUnbalanced(), m_pView->getGXFactor(), m_pView->getGYFactor());
817
tab->addTab(m_confBrushDia, i18n("&Brush"));
819
m_confPieDia = new ConfPieDia(tab, "ConfPieDia");
820
m_confPieDia->setType(m_pView->getPieType());
821
m_confPieDia->setAngle(m_pView->getPieAngle());
822
m_confPieDia->setLength(m_pView->getPieLength());
823
m_confPieDia->setPenBrush(m_pView->getPen(), m_pView->getBrush());
824
tab->addTab(m_confPieDia, i18n("P&ie"));
826
m_confPolygonDia = new ConfPolygonDia(tab, "ConfPolygonDia");
827
m_confPolygonDia->setCheckConcavePolygon(m_pView->getCheckConcavePolygon());
828
m_confPolygonDia->setCornersValue(m_pView->getCornersValue());
829
m_confPolygonDia->setSharpnessValue(m_pView->getSharpnessValue());
830
m_confPolygonDia->setPenBrush(m_pView->getPen(), m_pView->getBrush());
831
tab->addTab(m_confPolygonDia, i18n("P&olygon"));
833
m_confRectDia = new ConfRectDia(tab, "ConfRectDia" );
834
m_confRectDia->setRnds(m_pView->getRndX(), m_pView->getRndY());
835
m_confRectDia->setPenBrush(m_pView->getPen(), m_pView->getBrush());
836
tab->addTab(m_confRectDia, i18n("&Rectangle"));
840
configureToolsPage::~configureToolsPage()
844
void configureToolsPage::apply()
846
m_pView->setPieType(m_confPieDia->getType());
847
m_pView->setPieAngle(m_confPieDia->getAngle());
848
m_pView->setPieLength(m_confPieDia->getLength());
849
m_pView->setCheckConcavePolygon(m_confPolygonDia->getCheckConcavePolygon());
850
m_pView->setCornersValue(m_confPolygonDia->getCornersValue());
851
m_pView->setSharpnessValue(m_confPolygonDia->getSharpnessValue());
852
m_pView->setRndX(m_confRectDia->getRndX());
853
m_pView->setRndY(m_confRectDia->getRndY());
854
m_pView->setPen(m_confPenDia->getPen());
855
m_pView->setBrush(m_confBrushDia->getBrush());
856
m_pView->setLineBegin(m_confPenDia->getLineBegin());
857
m_pView->setLineEnd(m_confPenDia->getLineEnd());
858
m_pView->setFillType(m_confBrushDia->getFillType());
859
m_pView->setGColor1(m_confBrushDia->getGColor1());
860
m_pView->setGColor2(m_confBrushDia->getGColor2());
861
m_pView->setGType(m_confBrushDia->getGType());
862
m_pView->setGUnbalanced(m_confBrushDia->getGUnbalanced());
863
m_pView->setGXFactor(m_confBrushDia->getGXFactor());
864
m_pView->setGYFactor(m_confBrushDia->getGYFactor());
865
m_pView->getActionBrushColor()->setCurrentColor((m_confBrushDia->getBrush()).color());
866
m_pView->getActionPenColor()->setCurrentColor((m_confPenDia->getPen()).color());
867
m_confRectDia->setPenBrush(m_confPenDia->getPen(),
868
m_confBrushDia->getBrush());
869
m_confPolygonDia->setPenBrush(m_confPenDia->getPen(),
870
m_confBrushDia->getBrush());
871
m_confPieDia->setPenBrush(m_confPenDia->getPen(),
872
m_confBrushDia->getBrush());
875
void configureToolsPage::slotDefault()
877
m_confPieDia->setType(PT_PIE);
878
m_confPieDia->setLength(90 * 16);
879
m_confPieDia->setAngle(45 * 16);
880
m_confPolygonDia->setCheckConcavePolygon(false);
881
m_confPolygonDia->setCornersValue(3);
882
m_confPolygonDia->setSharpnessValue(0);
883
m_confRectDia->setRnds(0, 0);
884
m_confPenDia->setPen(QPen(black, 1, SolidLine));
885
m_confBrushDia->setBrush(QBrush(white, SolidPattern));
886
m_confPenDia->setLineBegin(L_NORMAL);
887
m_confPenDia->setLineEnd(L_NORMAL);
888
m_confBrushDia->setGradient(red, green, BCT_GHORZ, false, 100, 100);
889
m_confBrushDia->setFillType(FT_BRUSH);
890
m_pView->getActionBrushColor()->setCurrentColor((m_confBrushDia->getBrush()).color());
891
m_pView->getActionPenColor()->setCurrentColor((m_confPenDia->getPen()).color());
894
configurePathPage::configurePathPage( KPresenterView *_view, QWidget *parent, char *name )
895
: QWidget( parent, name )
897
QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
900
KPresenterDoc* doc = m_pView->kPresenterDoc();
901
config = KPresenterFactory::global()->config();
903
m_pPathView = new KListView( this );
904
m_pPathView->setResizeMode(QListView::NoColumn);
905
m_pPathView->addColumn( i18n( "Type" ) );
906
m_pPathView->addColumn( i18n( "Path" ) );
907
(void) new QListViewItem( m_pPathView, i18n("Picture Path"),doc->picturePath() );
908
(void) new QListViewItem( m_pPathView, i18n("Backup Path"),doc->backupPath() );
910
box->addWidget(m_pPathView);
912
m_modifyPath = new QPushButton( i18n("Modify Path..."), this);
913
connect( m_modifyPath, SIGNAL( clicked ()), this, SLOT( slotModifyPath()));
914
connect( m_pPathView, SIGNAL( doubleClicked (QListViewItem *, const QPoint &, int )),
915
this, SLOT( slotModifyPath()));
916
connect( m_pPathView, SIGNAL( selectionChanged ( QListViewItem * )),
917
this, SLOT( slotSelectionChanged(QListViewItem * )));
918
slotSelectionChanged(m_pPathView->currentItem());
919
box->addWidget(m_modifyPath);
923
void configurePathPage::slotSelectionChanged(QListViewItem * item)
925
m_modifyPath->setEnabled( item );
928
void configurePathPage::slotModifyPath()
930
QListViewItem *item = m_pPathView->currentItem ();
933
if ( item->text(0)==i18n("Picture Path"))
935
KURLRequesterDlg * dlg = new KURLRequesterDlg( item->text(1), 0L,
937
dlg->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
939
item->setText( 1, dlg->selectedURL().path());
942
else if ( item->text(0)==i18n("Backup Path"))
944
KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L,
947
item->setText(1, dlg->newPath());
953
void configurePathPage::slotDefault()
955
QListViewItem * item = m_pPathView->findItem(i18n("Picture Path"), 0);
957
item->setText(1, KGlobalSettings::documentPath());
958
item = m_pPathView->findItem(i18n("Backup Path"), 0);
960
item->setText(1, QString::null );
963
void configurePathPage::apply()
965
QListViewItem *item = m_pPathView->findItem(i18n("Backup Path"), 0);
968
QString res = item->text(1 );
969
if ( res != m_pView->kPresenterDoc()->backupPath())
971
config->setGroup( "Kpresenter Path" );
972
m_pView->kPresenterDoc()->setBackupPath( res );
973
#if KDE_IS_VERSION(3,1,3)
974
config->writePathEntry( "backup path",res );
976
config->writeEntry( "backup path",res );
980
item = m_pPathView->findItem(i18n("Picture Path"), 0);
983
QString res = item->text(1 );
984
if ( res != m_pView->kPresenterDoc()->picturePath())
986
config->setGroup( "Kpresenter Path" );
987
m_pView->kPresenterDoc()->setPicturePath( res );
988
#if KDE_IS_VERSION(3,1,3)
989
config->writePathEntry( "picture path",res );
991
config->writeEntry( "picture path",res );
997
#include "kpresenter_dlg_config.moc"