~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to kpresenter/kpresenter_dlg_config.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
   Boston, MA 02111-1307, USA.
18
18
*/
19
19
 
20
 
#include <kapp.h>
 
20
#include <kapplication.h>
 
21
#include <klocale.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>
26
30
 
27
31
#include <qgroupbox.h>
28
32
#include <qlabel.h>
29
33
#include <qlayout.h>
30
34
#include <qvbox.h>
31
 
 
32
 
#include <kpresenter_dlg_config.h>
33
 
#include <kpresenter_view.h>
34
 
#include <kpresenter_doc.h>
 
35
#include <qcheckbox.h>
 
36
#include <qtabwidget.h>
 
37
 
 
38
#include "styledia.h"
 
39
#include "confpiedia.h"
 
40
#include "confrectdia.h"
 
41
#include "confpolygondia.h"
 
42
#include "confpicturedia.h"
 
43
 
 
44
#include "kpresenter_dlg_config.h"
 
45
#include "kpresenter_view.h"
 
46
#include "kpresenter_doc.h"
 
47
#include <koUnit.h>
 
48
 
 
49
#include <float.h>
 
50
#include <kspell.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>
 
57
#include <koRect.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>
35
66
 
36
67
KPConfig::KPConfig( KPresenterView* parent )
37
 
  : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
38
 
                KDialogBase::Ok | KDialogBase::Cancel| KDialogBase::Default,
39
 
                KDialogBase::Ok)
 
68
    : KDialogBase(KDialogBase::IconList,i18n("Configure KPresenter") ,
 
69
                  KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel| KDialogBase::Default,
 
70
                  KDialogBase::Ok)
40
71
 
41
72
{
 
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 );
 
80
 
 
81
    page = addVBoxPage( i18n("Spelling"), i18n("Spell Checker Behavior"),
 
82
                        BarIcon("spellcheck", KIcon::SizeMedium) );
 
83
    _spellPage=new configureSpellPage(parent, page);
 
84
 
 
85
    page = addVBoxPage( i18n("Misc"), i18n("Misc"),
 
86
                        BarIcon("misc", KIcon::SizeMedium) );
 
87
    _miscPage=new configureMiscPage(parent, page);
 
88
 
 
89
    page = addVBoxPage( i18n("Document"), i18n("Document Settings"),
 
90
                        BarIcon("document", KIcon::SizeMedium) );
 
91
 
 
92
    _defaultDocPage=new configureDefaultDocPage(parent, page);
 
93
 
 
94
    page = addVBoxPage( i18n("Tools"), i18n("Default Tools Settings"),
 
95
                        BarIcon("configure", KIcon::SizeMedium) );
 
96
 
 
97
    _toolsPage=new configureToolsPage(parent, page);
 
98
 
 
99
    page = addVBoxPage( i18n("Paths"), i18n("Path Settings"),
 
100
                        BarIcon("path") );
 
101
 
 
102
    m_pathPage=new configurePathPage(parent, page);
 
103
 
48
104
    connect( this, SIGNAL( okClicked() ),this, SLOT( slotApply() ) );
49
105
}
50
106
 
 
107
void KPConfig::openPage(int flags)
 
108
{
 
109
    if(flags & KP_INTERFACE)
 
110
        showPage( 0 );
 
111
    else if(flags & KP_COLOR)
 
112
        showPage(1 );
 
113
    else if(flags & KP_KSPELL)
 
114
        showPage(2);
 
115
    else if(flags & KP_MISC)
 
116
        showPage(3 );
 
117
    else if(flags & KP_DOC)
 
118
        showPage(4 );
 
119
    else if(flags & KP_TOOLS)
 
120
        showPage(5);
 
121
    else if(flags & KP_PATH)
 
122
        showPage(6);
 
123
}
 
124
 
51
125
void KPConfig::slotApply()
52
126
{
 
127
    KMacroCommand *macro = 0L;
53
128
    _interfacePage->apply();
54
129
    _colorBackground->apply();
 
130
    _spellPage->apply();
 
131
    m_pathPage->apply();
 
132
    KCommand *cmd = _miscPage->apply();
 
133
    if ( cmd )
 
134
    {
 
135
        if ( !macro )
 
136
            macro = new KMacroCommand(i18n("Change Config") );
 
137
        macro->addCommand( cmd );
 
138
    }
 
139
    cmd = _defaultDocPage->apply();
 
140
    if ( cmd )
 
141
    {
 
142
        if ( !macro )
 
143
            macro = new KMacroCommand(i18n("Change Config") );
 
144
 
 
145
        macro->addCommand( cmd );
 
146
    }
 
147
 
 
148
    _toolsPage->apply();
 
149
    if ( macro )
 
150
        m_doc->addCommand( macro);
55
151
}
56
152
 
57
153
void KPConfig::slotDefault()
58
154
{
59
155
    switch( activePageIndex() ) {
60
 
        case 0:
61
 
            _interfacePage->slotDefault();
62
 
            break;
63
 
        case 1:
64
 
            _colorBackground->slotDefault();
65
 
        default:
66
 
            break;
 
156
    case 0:
 
157
        _interfacePage->slotDefault();
 
158
        break;
 
159
    case 1:
 
160
        _colorBackground->slotDefault();
 
161
        break;
 
162
    case 2:
 
163
        _spellPage->slotDefault();
 
164
        break;
 
165
    case 3:
 
166
        _miscPage->slotDefault();
 
167
        break;
 
168
    case 4:
 
169
        _defaultDocPage->slotDefault();
 
170
        break;
 
171
    case 5:
 
172
        _toolsPage->slotDefault();
 
173
        break;
 
174
    case 6:
 
175
        m_pathPage->slotDefault();
 
176
        break;
 
177
    default:
 
178
        break;
67
179
    }
68
180
}
69
181
 
70
182
configureInterfacePage::configureInterfacePage( KPresenterView *_view, QWidget *parent , char *name )
71
 
 :QWidget ( parent,name )
 
183
    :QWidget ( parent,name )
72
184
{
 
185
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
186
 
73
187
    m_pView=_view;
74
188
    config = KPresenterFactory::global()->config();
75
 
    QVBoxLayout *box = new QVBoxLayout( this );
76
 
    box->setMargin( 5 );
77
 
    box->setSpacing( 10 );
78
 
    QGroupBox* tmpQGroupBox = new QGroupBox( this, "GroupBox" );
79
 
    tmpQGroupBox->setTitle( i18n("Interface") );
80
 
 
81
 
    QVBoxLayout *lay1 = new QVBoxLayout( tmpQGroupBox );
82
 
    lay1->setMargin( 20 );
83
 
    lay1->setSpacing( 10 );
84
 
 
85
 
    int oldRastX = m_pView->kPresenterDoc()->rastX();
86
 
    int oldRastY = m_pView->kPresenterDoc()->rastY();
87
 
    oldAutoSaveValue =  m_pView->kPresenterDoc()->defaultAutoSave()/60;
 
189
 
 
190
    KoUnit::Unit unit = m_pView->kPresenterDoc()->getUnit();
 
191
 
 
192
    oldNbRecentFiles=10;
 
193
    double ptIndent = MM_TO_POINT(10.0);
 
194
    bool bShowRuler=true;
 
195
    bool oldShowStatusBar = true;
88
196
 
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 );
 
203
 
92
204
    }
93
205
 
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 );
100
 
 
101
 
    eRastX = new KIntNumInput( oldRastX, tmpQGroupBox );
102
 
    eRastX->setRange( 1, 400, 1 );
103
 
    eRastX->setLabel( i18n("Horizontal Raster: ") );
104
 
    lay1->addWidget( eRastX );
105
 
 
106
 
    eRastY = new KIntNumInput( oldRastY, tmpQGroupBox );
107
 
    eRastY->setRange( 1, 400, 1 );
108
 
    eRastY->setLabel( i18n("Vertical Raster: ") );
109
 
    lay1->addWidget( eRastY );
110
 
 
111
 
    box->addWidget( tmpQGroupBox );
 
206
    showRuler= new QCheckBox(i18n("Show rulers"),this);
 
207
    showRuler->setChecked(bShowRuler);
 
208
    box->addWidget(showRuler);
 
209
 
 
210
    showStatusBar = new QCheckBox(i18n("Show status bar"),this);
 
211
    showStatusBar->setChecked(oldShowStatusBar);
 
212
    box->addWidget(showStatusBar);
 
213
 
 
214
 
 
215
    recentFiles=new KIntNumInput( oldNbRecentFiles, this);
 
216
    recentFiles->setRange(1, 20, 1);
 
217
    recentFiles->setLabel(i18n("Number of recent files:"));
 
218
 
 
219
    box->addWidget(recentFiles);
 
220
 
 
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 ));
 
225
 
 
226
 
 
227
    indent->setSuffix( suffix );
 
228
    indent->setLabel(i18n("Paragraph indent by toolbar buttons:"));
 
229
 
 
230
    box->addWidget(indent);
 
231
 
 
232
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
233
    box->addItem( spacer);
112
234
}
113
235
 
114
236
void configureInterfacePage::apply()
115
237
{
116
 
    unsigned int rastX = eRastX->value();
117
 
    unsigned int rastY = eRastY->value();
 
238
    bool ruler=showRuler->isChecked();
 
239
    bool statusBar=showStatusBar->isChecked();
118
240
 
119
241
    KPresenterDoc * doc = m_pView->kPresenterDoc();
120
242
 
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 );
127
 
    }
128
 
 
129
 
    int autoSaveVal = autoSave->value();
130
 
    if( autoSaveVal != oldAutoSaveValue ) {
131
 
        config->writeEntry( "AutoSave", autoSaveVal );
132
 
        m_pView->kPresenterDoc()->setAutoSave( autoSaveVal*60 );
133
 
    }
 
244
 
 
245
    double newIndent = KoUnit::ptFromUnit( indent->value(), doc->getUnit() );
 
246
    if( newIndent != doc->getIndentValue() )
 
247
    {
 
248
        config->writeEntry( "Indent", newIndent, true, false, 'g', DBL_DIG /* 6 is not enough */ );
 
249
        doc->setIndentValue( newIndent );
 
250
    }
 
251
    int nbRecent=recentFiles->value();
 
252
    if(nbRecent!=oldNbRecentFiles)
 
253
    {
 
254
        config->writeEntry( "NbRecentFile", nbRecent);
 
255
        m_pView->changeNbOfRecentFiles(nbRecent);
 
256
        oldNbRecentFiles=nbRecent;
 
257
    }
 
258
    bool refreshGUI=false;
 
259
    if(ruler != doc->showRuler())
 
260
    {
 
261
        config->writeEntry( "Rulers", ruler );
 
262
        doc->setShowRuler( ruler );
 
263
        refreshGUI=true;
 
264
 
 
265
    }
 
266
    if( statusBar != doc->showStatusBar() )
 
267
    {
 
268
        config->writeEntry( "ShowStatusBar", statusBar );
 
269
        doc->setShowStatusBar( statusBar );
 
270
        refreshGUI=true;
 
271
    }
 
272
 
 
273
    if( refreshGUI )
 
274
        doc->reorganizeGUI();
 
275
 
134
276
}
135
277
 
136
278
void configureInterfacePage::slotDefault()
137
279
{
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);
141
285
}
142
286
 
143
287
configureColorBackground::configureColorBackground( KPresenterView* _view, QWidget *parent , char *name )
144
 
 :QWidget ( parent,name )
 
288
    :QWidget ( parent,name )
145
289
{
146
290
    m_pView = _view;
147
291
    config = KPresenterFactory::global()->config();
148
292
 
149
293
    oldBgColor = m_pView->kPresenterDoc()->txtBackCol();
150
 
 
151
 
    QVBoxLayout *box = new QVBoxLayout( this );
152
 
    box->setMargin( 5 );
153
 
    box->setSpacing( 10 );
154
 
 
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 );
161
 
 
162
 
    bgColor = new KColorButton( tmpQGroupBox );
 
294
    oldGridColor = m_pView->kPresenterDoc()->gridColor();
 
295
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
296
 
 
297
    QLabel *lab = new QLabel( this, "label20" );
 
298
    lab->setText( i18n( "Background object color:" ) );
 
299
    box->addWidget(lab);
 
300
 
 
301
    bgColor = new KColorButton( oldBgColor,
 
302
                                oldBgColor,
 
303
                                this );
163
304
    bgColor->setColor( oldBgColor );
164
 
    grid1->addWidget( bgColor, 1, 0 );
165
 
 
166
 
    box->addWidget( tmpQGroupBox );
 
305
    box->addWidget(bgColor);
 
306
 
 
307
 
 
308
    lab = new QLabel( this, "label20" );
 
309
    lab->setText( i18n( "Grid color:" ) );
 
310
    box->addWidget(lab);
 
311
 
 
312
    gridColor = new KColorButton( oldGridColor,
 
313
                                  oldGridColor,
 
314
                                  this );
 
315
    box->addWidget(gridColor);
 
316
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
317
    box->addItem( spacer);
 
318
 
167
319
}
168
320
 
169
321
void configureColorBackground::apply()
170
322
{
 
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 );
179
 
    }
 
331
        oldBgColor=_col;
 
332
        repaintNeeded = true;
 
333
    }
 
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 );
 
340
        oldGridColor=_col;
 
341
        repaintNeeded = true;
 
342
    }
 
343
    if (repaintNeeded)
 
344
        doc->repaint( false );
180
345
}
181
346
 
182
347
void configureColorBackground::slotDefault()
183
348
{
184
349
    bgColor->setColor( Qt::white );
185
 
}
186
 
 
187
 
#include <kpresenter_dlg_config.moc>
 
350
    gridColor->setColor( Qt::black );
 
351
}
 
352
 
 
353
 
 
354
 
 
355
configureSpellPage::configureSpellPage( KPresenterView *_view, QWidget *parent, char *name )
 
356
    : QWidget( parent, name )
 
357
{
 
358
    m_pView=_view;
 
359
    config = KPresenterFactory::global()->config();
 
360
    m_spellConfigWidget = new KoSpellConfigWidget( parent, m_pView->kPresenterDoc()->getKOSpellConfig(), true);
 
361
#if 0
 
362
    if( config->hasGroup("KSpell kpresenter") )
 
363
    {
 
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));
 
367
    }
 
368
#endif
 
369
    m_spellConfigWidget->setBackgroundSpellCheck( m_pView->kPresenterDoc()->backgroundSpellCheckEnabled() );
 
370
    m_spellConfigWidget->addIgnoreList( m_pView->kPresenterDoc()->spellListIgnoreAll() );
 
371
}
 
372
 
 
373
void configureSpellPage::apply()
 
374
{
 
375
 
 
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);
 
392
 
 
393
    bool state = m_spellConfigWidget->backgroundSpellCheck();
 
394
    config->writeEntry( "SpellCheck", (int)state );
 
395
 
 
396
    doc->addIgnoreWordAllList( m_spellConfigWidget->ignoreList() );
 
397
 
 
398
    doc->reactivateBgSpellChecking(state);
 
399
    //FIXME reactivate just if there is a changes.
 
400
    doc->enableBackgroundSpellCheck( state );
 
401
}
 
402
 
 
403
void configureSpellPage::slotDefault()
 
404
{
 
405
    m_spellConfigWidget->setDefault();
 
406
}
 
407
 
 
408
configureMiscPage::configureMiscPage( KPresenterView *_view, QWidget *parent, char *name )
 
409
    : QWidget( parent, name )
 
410
{
 
411
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
412
 
 
413
    m_pView=_view;
 
414
    config = KPresenterFactory::global()->config();
 
415
 
 
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 );
 
420
 
 
421
    m_oldNbRedo=30;
 
422
    m_printNotes=true;
 
423
    if( config->hasGroup("Misc") )
 
424
    {
 
425
        config->setGroup( "Misc" );
 
426
        m_oldNbRedo=config->readNumEntry("UndoRedo",m_oldNbRedo);
 
427
        m_printNotes = config->readBoolEntry("PrintNotes", true);
 
428
    }
 
429
 
 
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);
 
434
 
 
435
    KPresenterDoc* doc = m_pView->kPresenterDoc();
 
436
 
 
437
    m_displayLink=new QCheckBox(i18n("Display links"),tmpQGroupBox);
 
438
    grid->addWidget(m_displayLink,3,0);
 
439
    m_displayLink->setChecked(doc->getVariableCollection()->variableSetting()->displayLink());
 
440
 
 
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);
 
444
 
 
445
 
 
446
    m_displayComment=new QCheckBox(i18n("Display comments"),tmpQGroupBox);
 
447
    m_displayComment->setChecked(doc->getVariableCollection()->variableSetting()->displayComment());
 
448
    grid->addWidget(m_displayComment,5,0);
 
449
 
 
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);
 
453
 
 
454
    m_cbPrintNotes=new QCheckBox(i18n("Print slide notes"),tmpQGroupBox);
 
455
    m_cbPrintNotes->setChecked(m_printNotes);
 
456
    grid->addWidget(m_cbPrintNotes,7,0);
 
457
 
 
458
    box->addWidget(tmpQGroupBox);
 
459
 
 
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 );
 
464
 
 
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);
 
472
 
 
473
    grid->addWidget(resolutionX,1,0);
 
474
 
 
475
    lab=new QLabel(i18n("Resolution Y (%1):").arg(doc->getUnitName()), tmpQGroupBox);
 
476
    grid->addWidget(lab,2,0);
 
477
 
 
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);
 
481
 
 
482
    grid->addWidget(resolutionY, 3, 0);
 
483
    box->addWidget(tmpQGroupBox);
 
484
 
 
485
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
486
    box->addItem( spacer);
 
487
 
 
488
 
 
489
}
 
490
 
 
491
KCommand * configureMiscPage::apply()
 
492
{
 
493
    config->setGroup( "Misc" );
 
494
    int newUndo=m_undoRedoLimit->value();
 
495
    KPresenterDoc* doc = m_pView->kPresenterDoc();
 
496
    if(newUndo!=m_oldNbRedo)
 
497
    {
 
498
        config->writeEntry("UndoRedo",newUndo);
 
499
        doc->setUndoRedoLimit(newUndo);
 
500
        m_oldNbRedo=newUndo;
 
501
    }
 
502
    config->writeEntry("PrintNotes", m_cbPrintNotes->isChecked());
 
503
 
 
504
    KMacroCommand * macroCmd=0L;
 
505
    bool b=m_displayLink->isChecked();
 
506
    bool b_new=doc->getVariableCollection()->variableSetting()->displayLink();
 
507
    if(b_new!=b)
 
508
    {
 
509
        if(!macroCmd)
 
510
            macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
 
511
 
 
512
        KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
 
513
            i18n("Change Display Link Command"), doc, b_new, b, KPrChangeVariableSettingsCommand::VS_DISPLAYLINK);
 
514
        cmd->execute();
 
515
        macroCmd->addCommand(cmd);
 
516
    }
 
517
 
 
518
    b=m_underlineLink->isChecked();
 
519
    if(doc->getVariableCollection()->variableSetting()->underlineLink()!=b)
 
520
    {
 
521
        if(!macroCmd)
 
522
            macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
 
523
 
 
524
        KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
 
525
            i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->underlineLink(),
 
526
            b, KPrChangeVariableSettingsCommand::VS_UNDERLINELINK);
 
527
        cmd->execute();
 
528
        macroCmd->addCommand(cmd);
 
529
    }
 
530
 
 
531
    b=m_displayComment->isChecked();
 
532
    if(doc->getVariableCollection()->variableSetting()->displayComment()!=b)
 
533
    {
 
534
        if(!macroCmd)
 
535
            macroCmd=new KMacroCommand(i18n("Change Display Link Command"));
 
536
 
 
537
        KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
 
538
            i18n("Change Display Link Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
 
539
            b, KPrChangeVariableSettingsCommand::VS_DISPLAYCOMMENT);
 
540
        cmd->execute();
 
541
        macroCmd->addCommand(cmd);
 
542
    }
 
543
 
 
544
    b=m_displayFieldCode->isChecked();
 
545
    if(doc->getVariableCollection()->variableSetting()->displayFieldCode()!=b)
 
546
    {
 
547
        if(!macroCmd)
 
548
            macroCmd=new KMacroCommand(i18n("Change Display Field Code Command"));
 
549
 
 
550
        KPrChangeVariableSettingsCommand *cmd=new KPrChangeVariableSettingsCommand(
 
551
            i18n("Change Display Field Code Command"), doc, doc->getVariableCollection()->variableSetting()->displayComment(),
 
552
            b, KPrChangeVariableSettingsCommand::VS_DISPLAYFIELDCODE);
 
553
        cmd->execute();
 
554
        macroCmd->addCommand(cmd);
 
555
    }
 
556
 
 
557
    doc->setGridValue( KoUnit::ptFromUnit( resolutionX->value(), doc->getUnit() ),
 
558
                       KoUnit::ptFromUnit( resolutionY->value(), doc->getUnit() ), true);
 
559
    doc->repaint( false );
 
560
 
 
561
    config->sync();
 
562
 
 
563
    return macroCmd;
 
564
}
 
565
 
 
566
void configureMiscPage::slotDefault()
 
567
{
 
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();
 
575
 
 
576
    resolutionY->setValue( KoUnit::ptToUnit( MM_TO_POINT( 10.0 ), doc->getUnit() ) );
 
577
    resolutionX->setValue( KoUnit::ptToUnit( MM_TO_POINT( 10.0 ), doc->getUnit() ) );
 
578
}
 
579
 
 
580
configureDefaultDocPage::configureDefaultDocPage(KPresenterView *_view, QWidget *parent, char *name )
 
581
    : QWidget( parent, name )
 
582
{
 
583
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
584
 
 
585
    m_pView=_view;
 
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);
 
598
    }
 
599
 
 
600
    QVGroupBox* gbDocumentDefaults = new QVGroupBox( i18n("Document Defaults"), this, "GroupBox" );
 
601
    gbDocumentDefaults->setMargin( KDialog::marginHint() );
 
602
    gbDocumentDefaults->setInsideSpacing( 5 );
 
603
 
 
604
    QWidget *fontContainer = new QWidget(gbDocumentDefaults);
 
605
    QGridLayout * fontLayout = new QGridLayout(fontContainer, 1, 3);
 
606
 
 
607
    fontLayout->setColStretch(0, 0);
 
608
    fontLayout->setColStretch(1, 1);
 
609
    fontLayout->setColStretch(2, 0);
 
610
 
 
611
    QLabel *fontTitle = new QLabel(i18n("Default font:"), fontContainer);
 
612
 
 
613
    font= new QFont( doc->defaultFont() );
 
614
 
 
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);
 
619
 
 
620
    QPushButton *chooseButton = new QPushButton(i18n("Choose..."), fontContainer);
 
621
    connect(chooseButton, SIGNAL(clicked()), this, SLOT(selectNewDefaultFont()));
 
622
 
 
623
    fontLayout->addWidget(fontTitle, 0, 0);
 
624
    fontLayout->addWidget(fontName, 0, 1);
 
625
    fontLayout->addWidget(chooseButton, 0, 2);
 
626
 
 
627
    QWidget *languageContainer = new QWidget(gbDocumentDefaults);
 
628
    QGridLayout * languageLayout = new QGridLayout(languageContainer, 1, 3);
 
629
 
 
630
    languageLayout->setColStretch(0, 0);
 
631
    languageLayout->setColStretch(1, 1);
 
632
 
 
633
    QLabel *languageTitle = new QLabel(i18n("Global language:"), languageContainer);
 
634
 
 
635
    m_globalLanguage = new QComboBox( languageContainer );
 
636
    m_globalLanguage->insertStringList( KoGlobal::listOfLanguages());
 
637
 
 
638
 
 
639
    m_globalLanguage->setCurrentItem(KoGlobal::languageIndexFromTag(doc->globalLanguage()));
 
640
 
 
641
    languageLayout->addWidget(languageTitle, 0, 0);
 
642
    languageLayout->addWidget(m_globalLanguage, 0, 1);
 
643
 
 
644
    m_autoHyphenation = new QCheckBox( i18n("Automatic hyphenation"), gbDocumentDefaults);
 
645
    m_autoHyphenation->setChecked( m_oldHyphenation );
 
646
 
 
647
    box->addWidget(gbDocumentDefaults);
 
648
 
 
649
    QVGroupBox* gbDocumentSettings = new QVGroupBox( i18n("Document Settings"), this );
 
650
    gbDocumentSettings->setMargin( KDialog::marginHint() );
 
651
    gbDocumentSettings->setInsideSpacing( KDialog::spacingHint() );
 
652
 
 
653
    m_createBackupFile = new QCheckBox( i18n("Create backup file"), gbDocumentSettings);
 
654
    m_createBackupFile->setChecked( m_oldBackupFile );
 
655
 
 
656
 
 
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") );
 
662
 
 
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);
 
668
 
 
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();
 
673
 
 
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() );
 
680
 
 
681
    m_cursorInProtectedArea= new QCheckBox(i18n("Cursor in protected area"),gbDocumentCursor);
 
682
    m_cursorInProtectedArea->setChecked(doc->cursorInProtectedArea());
 
683
 
 
684
    m_directInsertCursor= new QCheckBox(i18n("Direct insert cursor"),gbDocumentCursor);
 
685
    m_directInsertCursor->setChecked(doc->insertDirectCursor());
 
686
    box->addWidget(gbDocumentCursor);
 
687
 
 
688
    QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
 
689
    box->addItem(spacer);
 
690
 
 
691
}
 
692
 
 
693
configureDefaultDocPage::~configureDefaultDocPage()
 
694
{
 
695
    delete font;
 
696
}
 
697
 
 
698
KCommand *configureDefaultDocPage::apply()
 
699
{
 
700
    config->setGroup( "Document defaults" );
 
701
    KPresenterDoc* doc = m_pView->kPresenterDoc();
 
702
    config->writeEntry("DefaultFont",font->toString());
 
703
 
 
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;
 
710
    }
 
711
    bool state =m_createBackupFile->isChecked();
 
712
 
 
713
    if(state!=m_oldBackupFile)
 
714
    {
 
715
        config->writeEntry( "BackupFile", state );
 
716
        doc->setBackupFile( state);
 
717
        m_oldBackupFile=state;
 
718
    }
 
719
 
 
720
    state = m_cursorInProtectedArea->isChecked();
 
721
    if ( state != doc->cursorInProtectedArea() )
 
722
    {
 
723
        config->writeEntry( "cursorInProtectArea", state );
 
724
        m_pView->kPresenterDoc()->setCursorInProtectedArea( state );
 
725
    }
 
726
 
 
727
    state = m_directInsertCursor->isChecked();
 
728
    if ( state != doc->insertDirectCursor() )
 
729
        doc->setInsertDirectCursor( state );
 
730
 
 
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 );
 
739
 
 
740
 
 
741
    state = m_autoHyphenation->isChecked();
 
742
    config->writeEntry( "hyphenation", state  );
 
743
    m_oldHyphenation = state;
 
744
 
 
745
    KMacroCommand *macro = 0L;
 
746
    int newStartingPage=m_variableNumberOffset->value();
 
747
    if(newStartingPage!=m_oldStartingPage)
 
748
    {
 
749
        macro = new KMacroCommand( i18n("Change Starting Page Number") );
 
750
        KPrChangeStartingPageCommand *cmd = new KPrChangeStartingPageCommand( i18n("Change Starting Page Number"), doc, m_oldStartingPage,newStartingPage );
 
751
        cmd->execute();
 
752
        macro->addCommand( cmd);
 
753
        m_oldStartingPage=newStartingPage;
 
754
    }
 
755
    double newTabStop = KoUnit::ptFromUnit( m_tabStopWidth->value(), doc->getUnit() );
 
756
    if ( newTabStop != m_oldTabStopWidth)
 
757
    {
 
758
        if ( !macro )
 
759
            macro = new KMacroCommand( i18n("Change Tab Stop Value") );
 
760
        KPrChangeTabStopValueCommand *cmd = new KPrChangeTabStopValueCommand( i18n("Change Tab Stop Value"), m_oldTabStopWidth, newTabStop, doc);
 
761
        cmd->execute();
 
762
        macro->addCommand( cmd );
 
763
        m_oldTabStopWidth = newTabStop;
 
764
    }
 
765
    return macro;
 
766
}
 
767
 
 
768
void configureDefaultDocPage::slotDefault()
 
769
{
 
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 );
 
778
}
 
779
 
 
780
void configureDefaultDocPage::selectNewDefaultFont() {
 
781
    QStringList list;
 
782
    KFontChooser::getFontList(list, KFontChooser::SmoothScalableFonts);
 
783
    KFontDialog dlg( this, "Font Selector", false, true, list, true );
 
784
    dlg.setFont(*font);
 
785
    int result = dlg.exec();
 
786
    if (KDialog::Accepted == result) {
 
787
        delete font;
 
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 );
 
792
    }
 
793
}
 
794
 
 
795
configureToolsPage::configureToolsPage( KPresenterView *_view, QWidget *parent, char *name )
 
796
    : QWidget( parent, name )
 
797
{
 
798
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
799
 
 
800
    m_pView = _view;
 
801
    config = KPresenterFactory::global()->config();
 
802
    m_pView->getCanvas()->deSelectAllObj();
 
803
 
 
804
    QTabWidget *tab = new QTabWidget(this);
 
805
 
 
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"));
 
811
 
 
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"));
 
818
 
 
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"));
 
825
 
 
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"));
 
832
 
 
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"));
 
837
    box->addWidget(tab);
 
838
}
 
839
 
 
840
configureToolsPage::~configureToolsPage()
 
841
{
 
842
}
 
843
 
 
844
void configureToolsPage::apply()
 
845
{
 
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());
 
873
}
 
874
 
 
875
void configureToolsPage::slotDefault()
 
876
{
 
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());
 
892
}
 
893
 
 
894
configurePathPage::configurePathPage( KPresenterView *_view, QWidget *parent, char *name )
 
895
    : QWidget( parent, name )
 
896
{
 
897
    QVBoxLayout *box = new QVBoxLayout( this, 0, 0 );
 
898
 
 
899
    m_pView=_view;
 
900
    KPresenterDoc* doc = m_pView->kPresenterDoc();
 
901
    config = KPresenterFactory::global()->config();
 
902
 
 
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() );
 
909
 
 
910
    box->addWidget(m_pPathView);
 
911
 
 
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);
 
920
 
 
921
}
 
922
 
 
923
void configurePathPage::slotSelectionChanged(QListViewItem * item)
 
924
{
 
925
    m_modifyPath->setEnabled( item );
 
926
}
 
927
 
 
928
void configurePathPage::slotModifyPath()
 
929
{
 
930
    QListViewItem *item = m_pPathView->currentItem ();
 
931
    if ( item )
 
932
    {
 
933
        if ( item->text(0)==i18n("Picture Path"))
 
934
        {
 
935
            KURLRequesterDlg * dlg = new KURLRequesterDlg( item->text(1), 0L,
 
936
                                                           "picture path dlg");
 
937
            dlg->fileDialog()->setMode(KFile::Directory | KFile::LocalOnly);
 
938
            if ( dlg->exec() )
 
939
                item->setText( 1, dlg->selectedURL().path());
 
940
            delete dlg;
 
941
        }
 
942
        else if ( item->text(0)==i18n("Backup Path"))
 
943
        {
 
944
            KoChangePathDia *dlg = new KoChangePathDia( item->text(1), 0L,
 
945
                                                        "backup path" );
 
946
            if (dlg->exec() )
 
947
                item->setText(1, dlg->newPath());
 
948
            delete dlg;
 
949
        }
 
950
    }
 
951
}
 
952
 
 
953
void configurePathPage::slotDefault()
 
954
{
 
955
    QListViewItem * item = m_pPathView->findItem(i18n("Picture Path"), 0);
 
956
    if ( item )
 
957
        item->setText(1, KGlobalSettings::documentPath());
 
958
    item = m_pPathView->findItem(i18n("Backup Path"), 0);
 
959
    if ( item )
 
960
        item->setText(1, QString::null );
 
961
}
 
962
 
 
963
void configurePathPage::apply()
 
964
{
 
965
    QListViewItem *item = m_pPathView->findItem(i18n("Backup Path"), 0);
 
966
    if ( item )
 
967
    {
 
968
        QString res = item->text(1 );
 
969
        if ( res != m_pView->kPresenterDoc()->backupPath())
 
970
        {
 
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 );
 
975
#else
 
976
            config->writeEntry( "backup path",res );
 
977
#endif
 
978
        }
 
979
    }
 
980
    item = m_pPathView->findItem(i18n("Picture Path"), 0);
 
981
    if ( item )
 
982
    {
 
983
        QString res = item->text(1 );
 
984
        if ( res != m_pView->kPresenterDoc()->picturePath())
 
985
        {
 
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 );
 
990
#else
 
991
            config->writeEntry( "picture path",res );
 
992
#endif
 
993
        }
 
994
    }
 
995
}
 
996
 
 
997
#include "kpresenter_dlg_config.moc"