1
/* This file is part of the KDE project
2
Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@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.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
21
#include "KoStyleCollection.h"
22
#include "KoStyleManager.h"
23
#include "KoStyleManager.moc"
24
#include <KoFontDia.h>
28
#include <kiconloader.h>
31
#include <qtabwidget.h>
32
#include <qpushbutton.h>
34
#include <qcombobox.h>
35
#include <qcheckbox.h>
38
/******************************************************************/
39
/* Class: KoStyleManager */
40
/******************************************************************/
42
/* keep 2 qlists with the styles.
43
1 of the origs, another with the changed ones (in order of the stylesList)
44
When an orig entry is empty and the other is not, a new one has to be made,
45
when the orig is present and the other is not, the orig has to be deleted.
46
Otherwise all changes are copied from the changed ones to the origs on OK.
47
OK updates the doc if styles are deleted.
48
The dtor frees all the changed ones.
50
/* Months later the above seems SOO stupid.. Just should have created a small class
51
containing the orig and the copy and an enum plus some simple methods..
52
Well; just keep that for those loonly uninspiring days :) (Thomas Z)
54
class KoStyleManagerPrivate
57
KoStylePreview* preview;
58
QCheckBox* cbIncludeInTOC;
61
KoStyleManager::KoStyleManager( QWidget *_parent, KoUnit::Unit unit,
62
const KoStyleCollection& styles, const QString & activeStyleName,
64
: KDialogBase( _parent, "Stylist", true,
65
i18n("Style Manager"),
66
KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Apply )
68
d = new KoStyleManagerPrivate;
69
//setWFlags(getWFlags() || WDestructiveClose);
72
m_origStyles.setAutoDelete(false);
73
m_changedStyles.setAutoDelete(false);
74
setupWidget(styles); // build the widget with the buttons and the list selector.
75
addGeneralTab( flags );
76
KoStyleFontTab * fontTab = new KoStyleFontTab( m_tabs );
79
KoStyleParagTab *newTab = new KoStyleParagTab( m_tabs );
80
newTab->setWidget( new KoIndentSpacingWidget( unit, -1/*no limit*/,newTab ) );
83
newTab = new KoStyleParagTab( m_tabs );
84
newTab->setWidget( new KoParagAlignWidget( true, newTab ) );
87
newTab = new KoStyleParagTab( m_tabs );
88
KoParagLayoutWidget *decorations = new KoParagDecorationWidget( newTab );
89
decorations->layout()->setMargin(KDialog::marginHint());
90
newTab->setWidget( decorations );
93
newTab = new KoStyleParagTab( m_tabs );
94
newTab->setWidget( new KoParagCounterWidget( false , newTab ) );
97
newTab = new KoStyleParagTab( m_tabs );
98
newTab->setWidget( new KoParagTabulatorsWidget( unit, -1, newTab ) );
101
QListBoxItem * item = m_stylesList->findItem( activeStyleName );
102
m_stylesList->setCurrentItem( item ? m_stylesList->index(item) : 0 );
106
setInitialSize( QSize( 600, 570 ) );
109
KoStyleManager::~KoStyleManager()
111
for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
112
KoParagStyle *orig = m_origStyles.at(i);
113
KoParagStyle *changed = m_changedStyles.at(i);
114
if( orig && changed && orig != changed ) // modified style, we can delete the changed one now that changes have been applied
121
void KoStyleManager::addTab( KoStyleManagerTab * tab )
123
m_tabsList.append( tab );
124
m_tabs->insertTab( tab, tab->tabName() );
125
tab->layout()->activate();
128
void KoStyleManager::setupWidget(const KoStyleCollection& styleCollection)
130
QFrame * frame1 = makeMainWidget();
131
QGridLayout *frame1Layout = new QGridLayout( frame1, 0, 0, // auto
132
0, KDialog::spacingHint() );
133
numStyles = styleCollection.count();
134
m_stylesList = new QListBox( frame1, "stylesList" );
135
m_stylesList->insertStringList( styleCollection.displayNameList() );
137
const QValueList<KoUserStyle*> styleList = styleCollection.styleList();
138
for ( QValueList<KoUserStyle *>::const_iterator it = styleList.begin(), end = styleList.end();
141
KoParagStyle* style = static_cast<KoParagStyle *>( *it );
142
m_origStyles.append( style );
143
m_changedStyles.append( style );
144
m_styleOrder<< style->name();
147
frame1Layout->addMultiCellWidget( m_stylesList, 0, 0, 0, 1 );
150
m_moveUpButton = new QPushButton( frame1, "moveUpButton" );
151
m_moveUpButton->setIconSet( SmallIconSet( "up" ) );
152
connect( m_moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUpStyle() ) );
153
frame1Layout->addWidget( m_moveUpButton, 1, 1 );
155
m_moveDownButton = new QPushButton( frame1, "moveDownButton" );
156
m_moveDownButton->setIconSet( SmallIconSet( "down" ) );
157
connect( m_moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDownStyle() ) );
158
frame1Layout->addWidget( m_moveDownButton, 1, 0 );
161
m_deleteButton = new QPushButton( frame1, "deleteButton" );
162
m_deleteButton->setText( i18n( "&Delete" ) );
163
connect( m_deleteButton, SIGNAL( clicked() ), this, SLOT( deleteStyle() ) );
165
frame1Layout->addWidget( m_deleteButton, 2, 1 );
167
m_newButton = new QPushButton( frame1, "newButton" );
168
m_newButton->setText( i18n( "New" ) );
169
connect( m_newButton, SIGNAL( clicked() ), this, SLOT( addStyle() ) );
171
frame1Layout->addWidget( m_newButton, 2, 0 );
173
m_tabs = new QTabWidget( frame1 );
174
frame1Layout->addMultiCellWidget( m_tabs, 0, 2, 2, 2 );
176
connect( m_stylesList, SIGNAL( selectionChanged() ), this, SLOT( switchStyle() ) );
177
connect( m_tabs, SIGNAL( currentChanged ( QWidget * ) ), this, SLOT( switchTabs() ) );
180
void KoStyleManager::addGeneralTab( int flags ) {
181
QWidget *tab = new QWidget( m_tabs );
183
QGridLayout *tabLayout = new QGridLayout( tab );
184
tabLayout->setSpacing( KDialog::spacingHint() );
185
tabLayout->setMargin( KDialog::marginHint() );
187
m_nameString = new QLineEdit( tab );
188
m_nameString->resize(m_nameString->sizeHint() );
189
connect( m_nameString, SIGNAL( textChanged( const QString &) ), this, SLOT( renameStyle(const QString &) ) );
191
tabLayout->addWidget( m_nameString, 0, 1 );
193
QLabel *nameLabel = new QLabel( tab );
194
nameLabel->setText( i18n( "Name:" ) );
195
nameLabel->resize(nameLabel->sizeHint());
196
nameLabel->setAlignment( AlignRight | AlignVCenter );
198
tabLayout->addWidget( nameLabel, 0, 0 );
200
m_styleCombo = new QComboBox( FALSE, tab, "styleCombo" );
202
tabLayout->addWidget( m_styleCombo, 1, 1 );
204
QLabel *nextStyleLabel = new QLabel( tab );
205
nextStyleLabel->setText( i18n( "Next style:" ) );
206
nextStyleLabel->setAlignment( AlignRight | AlignVCenter );
208
tabLayout->addWidget( nextStyleLabel, 1, 0 );
210
m_inheritCombo = new QComboBox( FALSE, tab, "inheritCombo" );
211
tabLayout->addWidget( m_inheritCombo, 2, 1 );
213
QLabel *inheritStyleLabel = new QLabel( tab );
214
inheritStyleLabel->setText( i18n( "Inherit style:" ) );
215
inheritStyleLabel->setAlignment( AlignRight | AlignVCenter );
217
tabLayout->addWidget( inheritStyleLabel, 2, 0 );
221
if ( flags & ShowIncludeInToc ) {
222
d->cbIncludeInTOC = new QCheckBox( i18n("Include in table of contents"), tab );
223
tabLayout->addMultiCellWidget( d->cbIncludeInTOC, row, row, 0, 1 );
226
d->cbIncludeInTOC = 0;
229
d->preview = new KoStylePreview( i18n( "Preview" ), i18n( "The quick brown fox jumps over the lazy dog. And, what about the cat, one may ask? Well, the cat is playing cards with the mouse, the bird and the fish. It is, to say the least a hell of a party!" ), tab, "stylepreview" );
231
tabLayout->addMultiCellWidget( d->preview, row, row, 0, 1 );
233
m_tabs->insertTab( tab, i18n( "General" ) );
235
m_inheritCombo->insertItem( i18n("<None>"));
237
for ( unsigned int i = 0; i < m_stylesList->count(); i++ ) {
238
m_styleCombo->insertItem( m_stylesList->text(i));
239
m_inheritCombo->insertItem( m_stylesList->text(i));
244
void KoStyleManager::switchStyle() {
245
kdDebug(32500) << "KoStyleManager::switchStyle noSignals=" << noSignals << endl;
246
if(noSignals) return;
249
if(m_currentStyle !=0L)
253
int num = styleIndex( m_stylesList->currentItem() );
254
kdDebug(32500) << "KoStyleManager::switchStyle switching to " << num << endl;
255
if(m_origStyles.at(num) == m_changedStyles.at(num)) {
256
m_currentStyle = new KoParagStyle( *m_origStyles.at(num) );
257
m_changedStyles.take(num);
258
m_changedStyles.insert(num, m_currentStyle);
260
m_currentStyle = m_changedStyles.at(num);
267
void KoStyleManager::switchTabs()
269
// Called when the user switches tabs
270
// We call save() to update our style, for the preview on the 1st tab
275
// Return the index of the a style from its position in the GUI
276
// (e.g. in m_stylesList or m_styleCombo). This index is used in
277
// the m_origStyles and m_changedStyles lists.
278
// The reason for the difference is that a deleted style is removed
279
// from the GUI but not from the internal lists.
280
int KoStyleManager::styleIndex( int pos ) {
282
for(unsigned int i=0; i < m_changedStyles.count(); i++) {
283
// Skip deleted styles, they're no in m_stylesList anymore
284
KoParagStyle * style = m_changedStyles.at(i);
285
if ( !style ) continue;
290
kdWarning() << "KoStyleManager::styleIndex no style found at pos " << pos << endl;
293
#warning implement undo/redo
299
// Update the GUI so that it shows m_currentStyle
300
void KoStyleManager::updateGUI() {
301
kdDebug(32500) << "KoStyleManager::updateGUI m_currentStyle=" << m_currentStyle << " " << m_currentStyle->name() << endl;
302
QPtrListIterator<KoStyleManagerTab> it( m_tabsList );
303
for ( ; it.current() ; ++it )
305
it.current()->setStyle( m_currentStyle );
306
it.current()->update();
309
m_nameString->setText(m_currentStyle->displayName());
311
QString followingName = m_currentStyle->followingStyle() ? m_currentStyle->followingStyle()->displayName() : QString::null;
312
kdDebug(32500) << "KoStyleManager::updateGUI updating combo to " << followingName << endl;
313
for ( int i = 0; i < m_styleCombo->count(); i++ ) {
314
if ( m_styleCombo->text( i ) == followingName ) {
315
m_styleCombo->setCurrentItem( i );
316
kdDebug(32500) << "found at " << i << endl;
321
QString inheritName = m_currentStyle->parentStyle() ? m_currentStyle->parentStyle()->displayName() : QString::null;
322
kdDebug(32500) << "KoStyleManager::updateGUI updating combo to " << inheritName << endl;
323
for ( int i = 0; i < m_inheritCombo->count(); i++ ) {
324
if ( m_inheritCombo->text( i ) == inheritName ) {
325
m_inheritCombo->setCurrentItem( i );
326
kdDebug(32500) << "found at " << i << endl;
330
m_inheritCombo->setCurrentItem( 0 );//none !!!
333
if ( d->cbIncludeInTOC )
334
d->cbIncludeInTOC->setChecked( m_currentStyle->isOutline() );
336
// update delete button (can't delete first style);
337
m_deleteButton->setEnabled(m_stylesList->currentItem() != 0);
339
m_moveUpButton->setEnabled(m_stylesList->currentItem() != 0);
340
m_moveDownButton->setEnabled(m_stylesList->currentItem()!=(int)m_stylesList->count()-1);
345
void KoStyleManager::updatePreview()
347
d->preview->setStyle(m_currentStyle);
348
d->preview->repaint(true);
351
void KoStyleManager::save() {
353
// save changes from UI to object.
354
QPtrListIterator<KoStyleManagerTab> it( m_tabsList );
355
for ( ; it.current() ; ++it )
356
it.current()->save();
358
// Rename the style - only if it's actually been renamed.
359
if ( m_currentStyle->name() != m_nameString->text() &&
360
m_currentStyle->displayName() != m_nameString->text() )
362
m_currentStyle->setDisplayName( m_nameString->text() );
365
int indexNextStyle = styleIndex( m_styleCombo->currentItem() );
366
m_currentStyle->setFollowingStyle( m_origStyles.at( indexNextStyle ) ); // point to orig, not changed! (#47377)
367
m_currentStyle->setParentStyle( style( m_inheritCombo->currentText() ) );
368
if ( d->cbIncludeInTOC )
369
m_currentStyle->setOutline( d->cbIncludeInTOC->isChecked() );
373
KoParagStyle * KoStyleManager::style( const QString & _name )
375
for(unsigned int i=0; i < m_changedStyles.count(); i++) {
376
// Skip deleted styles, they're no in m_stylesList anymore
377
KoParagStyle * style = m_changedStyles.at(i);
378
if ( !style ) continue;
379
if ( style->name() == _name)
385
QString KoStyleManager::generateUniqueName()
390
name = "new" + QString::number( count++ );
391
} while ( style( name ) );
396
void KoStyleManager::addStyle() {
399
QString str = i18n( "New Style Template (%1)" ).arg(numStyles++);
400
if ( m_currentStyle )
402
m_currentStyle = new KoParagStyle( *m_currentStyle ); // Create a new style, initializing from the current one
403
m_currentStyle->setDisplayName( str );
404
m_currentStyle->setName( generateUniqueName() );
407
m_currentStyle = new KoParagStyle( str );
408
m_currentStyle->setFollowingStyle( m_currentStyle ); // #45868
411
m_origStyles.append(0L);
412
m_changedStyles.append(m_currentStyle);
413
m_stylesList->insertItem( str );
414
m_styleCombo->insertItem( str );
415
m_inheritCombo->insertItem( str );
416
m_stylesList->setCurrentItem( m_stylesList->count() - 1 );
418
m_styleOrder << m_currentStyle->name();
423
void KoStyleManager::updateFollowingStyle( KoParagStyle *s )
425
for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
427
if ( p->followingStyle() == s)
428
p->setFollowingStyle(p);
433
void KoStyleManager::updateInheritStyle( KoParagStyle *s )
435
for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
437
//when we remove style, we must replace inherite style to 0L
438
//when parent style was removed.
439
//##########Laurent change inherited style attribute
440
if ( p->parentStyle() == s)
441
p->setParentStyle(0L);
446
void KoStyleManager::deleteStyle() {
448
unsigned int cur = styleIndex( m_stylesList->currentItem() );
449
unsigned int curItem = m_stylesList->currentItem();
450
QString name = m_stylesList->currentText();
451
KoParagStyle *s = m_changedStyles.at(cur);
452
m_styleOrder.remove( s->name());
453
updateFollowingStyle( s );
454
updateInheritStyle( s );
455
Q_ASSERT( s == m_currentStyle );
458
m_changedStyles.remove(cur);
459
m_changedStyles.insert(cur,0L);
461
// Done with noSignals still false, so that when m_stylesList changes the current item
462
// we display it automatically
463
m_stylesList->removeItem(curItem);
464
m_styleCombo->removeItem(curItem);
466
m_inheritCombo->listBox()->removeItem( m_inheritCombo->listBox()->index(m_inheritCombo->listBox()->findItem(name )));
469
m_stylesList->setSelected( m_stylesList->currentItem(), true );
472
void KoStyleManager::moveUpStyle()
474
Q_ASSERT( m_currentStyle );
475
if ( m_currentStyle )
477
const QString currentStyleName = m_currentStyle->name();
478
const QString currentStyleDisplayName = m_stylesList->currentText();
479
int pos2 = m_styleOrder.findIndex( currentStyleName );
482
m_styleOrder.remove( m_styleOrder.at(pos2));
483
m_styleOrder.insert( m_styleOrder.at(pos2-1), currentStyleName);
486
int pos = m_stylesList->currentItem();
488
m_stylesList->changeItem( m_stylesList->text( pos-1 ), pos );
489
m_styleCombo->changeItem( m_stylesList->text( pos-1 ), pos );
491
m_stylesList->changeItem( currentStyleDisplayName, pos-1 );
492
m_styleCombo->changeItem( currentStyleDisplayName, pos-1 );
494
m_stylesList->setCurrentItem( m_stylesList->currentItem() );
500
void KoStyleManager::moveDownStyle()
502
Q_ASSERT( m_currentStyle );
503
if ( m_currentStyle )
505
const QString currentStyleName = m_currentStyle->name();
506
const QString currentStyleDisplayName = m_stylesList->currentText();
507
int pos2 = m_styleOrder.findIndex( currentStyleName );
510
m_styleOrder.remove( m_styleOrder.at(pos2));
511
m_styleOrder.insert( m_styleOrder.at(pos2+1), currentStyleName);
514
int pos = m_stylesList->currentItem();
516
m_stylesList->changeItem( m_stylesList->text( pos+1 ), pos );
517
m_styleCombo->changeItem( m_stylesList->text( pos+1 ), pos );
518
m_stylesList->changeItem( currentStyleDisplayName, pos+1 );
519
m_styleCombo->changeItem( currentStyleDisplayName, pos+1 );
520
m_stylesList->setCurrentItem( m_stylesList->currentItem() );
526
void KoStyleManager::slotOk() {
529
KDialogBase::slotOk();
532
void KoStyleManager::slotApply() {
535
KDialogBase::slotApply();
538
void KoStyleManager::apply() {
540
KoStyleChangeDefMap styleChanged;
541
QPtrList<KoParagStyle> removeStyle;
542
for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
543
if(m_origStyles.at(i) == 0L && m_changedStyles.at(i)!=0L) { // newly added style
544
kdDebug(32500) << "adding new " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
545
KoParagStyle *tmp = addStyleTemplate(m_changedStyles.take(i));
546
m_changedStyles.insert(i, tmp);
547
} else if(m_changedStyles.at(i) == 0L && m_origStyles.at(i) != 0L) { // deleted style
548
kdDebug(32500) << "deleting orig " << m_origStyles.at(i)->name() << " (" << i << ")" << endl;
550
KoParagStyle *orig = m_origStyles.at(i);
551
//applyStyleChange( orig, -1, -1 );
552
KoStyleChangeDef tmp( -1,-1);
553
styleChanged.insert( orig, tmp);
555
removeStyle.append( orig );
556
// Note that the style is never deleted (we'll need it for undo/redo purposes)
558
} else if(m_changedStyles.at(i) != 0L && m_origStyles.at(i)!=0L) { // simply updated style
559
kdDebug(32500) << "update style " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
560
KoParagStyle *orig = m_origStyles.at(i);
561
KoParagStyle *changed = m_changedStyles.at(i);
562
if ( orig != changed )
564
int paragLayoutChanged = orig->paragLayout().compare( changed->paragLayout() );
565
int formatChanged = orig->format().compare( changed->format() );
566
//kdDebug(32500) << "old format " << orig->format().key() << " pointsize " << orig->format().pointSizeFloat() << endl;
567
//kdDebug(32500) << "new format " << changed->format().key() << " pointsize " << changed->format().pointSizeFloat() << endl;
569
// Copy everything from changed to orig
572
// Apply the change selectively - i.e. only what changed
573
//applyStyleChange( orig, paragLayoutChanged, formatChanged );
574
if ( formatChanged != 0 || paragLayoutChanged != 0 ) {
575
KoStyleChangeDef tmp(paragLayoutChanged, formatChanged);
576
styleChanged.insert( orig, tmp );
582
// kdDebug(32500) << "has not changed " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
585
applyStyleChange( styleChanged );
587
KoParagStyle *tmp = 0L;
588
for ( tmp = removeStyle.first(); tmp ;tmp = removeStyle.next() )
589
removeStyleTemplate( tmp );
591
updateStyleListOrder( m_styleOrder );
592
updateAllStyleLists();
596
void KoStyleManager::renameStyle(const QString &theText) {
597
if(noSignals) return;
600
int index = m_stylesList->currentItem();
601
kdDebug(32500) << "KoStyleManager::renameStyle " << index << " to " << theText << endl;
603
// rename only in the GUI, not even in the underlying objects (save() does it).
604
kdDebug(32500) << "KoStyleManager::renameStyle before " << m_styleCombo->currentText() << endl;
605
m_styleCombo->changeItem( theText, index );
606
m_inheritCombo->changeItem( theText, index+1 );
607
//m_styleOrder[index]=theText; // not needed anymore, we use internal names
608
kdDebug(32500) << "KoStyleManager::renameStyle after " << m_styleCombo->currentText() << endl;
609
m_stylesList->changeItem( theText, index );
611
// Check how many styles with that name we have now
613
for ( int i = 0; i < m_styleCombo->count(); i++ ) {
614
if ( m_styleCombo->text( i ) == m_stylesList->currentText() )
617
Q_ASSERT( synonyms > 0 ); // should have found 'index' at least !
619
// Can't close the dialog if two styles have the same name
620
bool state=!theText.isEmpty() && (synonyms == 1);
621
enableButtonOK(state );
622
enableButtonApply(state);
623
m_deleteButton->setEnabled(state&&(m_stylesList->currentItem() != 0));
624
m_newButton->setEnabled(state);
625
m_stylesList->setEnabled( state );
628
m_moveUpButton->setEnabled(m_stylesList->currentItem() != 0);
629
m_moveDownButton->setEnabled(m_stylesList->currentItem()!=(int)m_stylesList->count()-1);
633
m_moveUpButton->setEnabled(false);
634
m_moveDownButton->setEnabled(false);
640
KoStyleParagTab::KoStyleParagTab( QWidget * parent )
641
: KoStyleManagerTab( parent )
643
( new QVBoxLayout( this ) )->setAutoAdd( true );
647
void KoStyleParagTab::update()
649
m_widget->display( m_style->paragLayout() );
652
void KoStyleParagTab::save()
654
m_widget->save( m_style->paragLayout() );
657
void KoStyleParagTab::setWidget( KoParagLayoutWidget * widget )
662
void KoStyleParagTab::resizeEvent( QResizeEvent *e )
664
QWidget::resizeEvent( e );
665
if ( m_widget ) m_widget->resize( size() );
668
KoStyleFontTab::KoStyleFontTab( QWidget * parent )
669
: KoStyleManagerTab( parent )
671
( new QVBoxLayout( this ) )->setAutoAdd( true );
672
QTabWidget *fontTabContainer = new QTabWidget( this );
674
m_fontTab = new KoFontTab( KFontChooser::SmoothScalableFonts, this );
675
m_decorationTab = new KoDecorationTab( this );
676
m_highlightingTab = new KoHighlightingTab( this );
677
m_layoutTab = new KoLayoutTab( true, this );
678
m_languageTab = new KoLanguageTab( 0, this );
680
fontTabContainer->addTab( m_fontTab, i18n( "Font" ) );
681
fontTabContainer->addTab( m_decorationTab, i18n( "Decoration" ) );
682
fontTabContainer->addTab( m_highlightingTab, i18n( "Highlighting" ) );
683
fontTabContainer->addTab( m_layoutTab, i18n( "Layout" ) );
684
fontTabContainer->addTab( m_languageTab, i18n( "Language" ) );
687
KoStyleFontTab::~KoStyleFontTab()
691
void KoStyleFontTab::update()
693
m_fontTab->setSelection( m_style->format().font() );
694
m_highlightingTab->setUnderline( m_style->format().underlineType() );
695
m_highlightingTab->setUnderlineStyle( m_style->format().underlineStyle() );
696
m_highlightingTab->setUnderlineColor( m_style->format().textUnderlineColor() );
697
m_highlightingTab->setStrikethrough( m_style->format().strikeOutType() );
698
m_highlightingTab->setStrikethroughStyle( m_style->format().strikeOutStyle() );
699
m_highlightingTab->setWordByWord( m_style->format().wordByWord() );
700
m_highlightingTab->setCapitalisation( m_style->format().attributeFont() );
701
m_decorationTab->setTextColor( m_style->format().color() );
702
m_decorationTab->setBackgroundColor( m_style->format().textBackgroundColor() );
703
m_decorationTab->setShadow( m_style->format().shadowDistanceX(), m_style->format().shadowDistanceY(), m_style->format().shadowColor() );
704
m_layoutTab->setSubSuperScript( m_style->format().vAlign(), m_style->format().offsetFromBaseLine(), m_style->format().relativeTextSize() );
705
m_layoutTab->setAutoHyphenation( m_style->format().hyphenation() );
706
m_languageTab->setLanguage( m_style->format().language() );
709
bool subScript = m_style->format().vAlign() == KoTextFormat::AlignSubScript;
710
bool superScript = m_style->format().vAlign() == KoTextFormat::AlignSuperScript;
711
QFont fn = m_style->format().font();
712
kdDebug()<<" fn.bold() :"<<fn.bold()<<" fn.italic():"<<fn.italic()<<endl;
713
kdDebug()<<" fn.family() :"<<fn.family()<<endl;
714
m_chooser->setFont( fn, subScript, superScript );
715
m_chooser->setColor( m_style->format().color() );
716
QColor col=m_style->format().textBackgroundColor();
717
col=col.isValid() ? col : QApplication::palette().color( QPalette::Active, QColorGroup::Base );
718
m_chooser->setBackGroundColor(col);
720
m_chooser->setUnderlineColor( m_style->format().textUnderlineColor());
722
m_chooser->setUnderlineType(m_style->format().underlineType());
723
m_chooser->setUnderlineStyle(m_style->format().underlineStyle());
724
m_chooser->setStrikeOutStyle(m_style->format().strikeOutStyle());
725
m_chooser->setStrikeOutlineType(m_style->format().strikeOutType());
726
m_chooser->setShadowText( m_style->format().shadowText());
727
m_chooser->setFontAttribute( m_style->format().attributeFont());
728
m_chooser->setWordByWord( m_style->format().wordByWord());
729
m_chooser->setRelativeTextSize( m_style->format().relativeTextSize());
730
m_chooser->setOffsetFromBaseLine( m_style->format().offsetFromBaseLine());
731
m_chooser->setLanguage( m_style->format().language());
732
m_chooser->setHyphenation( m_style->format().hyphenation());
736
void KoStyleFontTab::save()
738
m_style->format() = KoTextFormat( m_fontTab->getSelection(),
739
m_layoutTab->getSubSuperScript(),
740
m_decorationTab->getTextColor(),
741
m_decorationTab->getBackgroundColor(),
742
m_highlightingTab->getUnderlineColor(),
743
m_highlightingTab->getUnderline(),
744
m_highlightingTab->getUnderlineStyle(),
745
m_highlightingTab->getStrikethrough(),
746
m_highlightingTab->getStrikethroughStyle(),
747
m_highlightingTab->getCapitalisation(),
748
m_languageTab->getLanguage(),
749
m_layoutTab->getRelativeTextSize(),
750
m_layoutTab->getOffsetFromBaseline(),
751
m_highlightingTab->getWordByWord(),
752
m_layoutTab->getAutoHyphenation(),
753
m_decorationTab->getShadowDistanceX(),
754
m_decorationTab->getShadowDistanceY(),
755
m_decorationTab->getShadowColor()
758
m_style->format().setFont( m_fontTab->getSelection() );
759
m_style->format().setColor( m_decorationTab->getTextColor() );
760
if( m_decorationTab->getBackGroundColor()!=QApplication::palette().color( QPalette::Active, QColorGroup::Base ))
761
m_style->format().setTextBackgroundColor( m_decorationTab->getBackGroundColor() );
763
m_style->format().setTextUnderlineColor(m_chooser->underlineColor());
764
m_style->format().setUnderlineType (m_chooser->getUnderlineType());
765
m_style->format().setUnderlineStyle (m_chooser->getUnderlineStyle());
766
m_style->format().setStrikeOutStyle( m_chooser->getStrikeOutStyle() );
767
m_style->format().setStrikeOutType (m_chooser->getStrikeOutType());
768
m_style->format().setShadowText(m_chooser->getShadowText());
769
m_style->format().setWordByWord( m_chooser->getWordByWord());
770
m_style->format().setRelativeTextSize( m_chooser->getRelativeTextSize());
771
m_style->format().setAttributeFont( m_chooser->getFontAttribute());
772
m_style->format().setOffsetFromBaseLine( m_chooser->getOffsetFromBaseLine());
773
m_style->format().setVAlign( m_layoutTab->getSubSuperScript() );
775
m_style->format().setLanguage( m_chooser->getLanguage());
776
m_style->format().setHyphenation( m_chooser->getHyphenation());
779
QString KoStyleFontTab::tabName()