2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
8
#include "smtextstyles.h"
9
#include "smtextstyles.moc"
10
#include "smtextstylewidgets.h"
13
#include "alignselect.h"
15
#include "fontcombo.h"
16
#include "styleselect.h"
17
#include "sccombobox.h"
18
#include "shadebutton.h"
19
#include "commonstrings.h"
21
#include "scribusdoc.h"
22
#include "selection.h"
24
#include "prefsmanager.h"
25
#include "colorcombo.h"
27
#include "menumanager.h"
30
#include "smwidgets.h"
32
#include <qtabwidget.h>
34
SMParagraphStyle::SMParagraphStyle(StyleSet<CharStyle> *cstyles) : StyleItem(),
35
pwidget_(0), doc_(0), selectionIsDirty_(false), unitRatio_(1.0), cstyles_(cstyles)
38
pwidget_ = new SMPStyleWidget();
39
Q_CHECK_PTR(pwidget_);
42
QTabWidget* SMParagraphStyle::widget()
44
return pwidget_->tabWidget;
47
QString SMParagraphStyle::typeNamePlural()
49
return tr("Paragraph Styles");
52
QString SMParagraphStyle::typeNameSingular()
54
return tr("Paragraph Style");
57
void SMParagraphStyle::currentDoc(ScribusDoc *doc)
64
pwidget_->cpage->fillLangCombo(doc_->scMW()->LangTransl);
65
pwidget_->cpage->fillColorCombo(doc_->PageColors);
66
pwidget_->cpage->fontFace_->RebuildList(doc_);
67
if (unitRatio_ != doc_->unitRatio())
80
StyleSet<ParagraphStyle>* SMParagraphStyle::tmpStyles()
85
QValueList<StyleName> SMParagraphStyle::styles(bool reloadFromDoc)
87
QValueList<StyleName> tmpList;
90
return tmpList; // no doc available
98
for (uint i = 0; i < tmpStyles_.count(); ++i)
100
if (tmpStyles_[i].hasName())
102
QString styleName(tmpStyles_[i].name());
103
QString parentName(QString::null);
105
if (tmpStyles_[i].hasParent() )
106
parentName = tmpStyles_[i].parent();
108
tmpList << StyleName(styleName, parentName);
115
void SMParagraphStyle::reload()
120
void SMParagraphStyle::selected(const QStringList &styleNames)
126
selectionIsDirty_ = false;
127
removeConnections(); // we don't want to record changes during style setup
129
tmpStyles_.invalidate();
131
QValueList<ParagraphStyle> pstyles; // get saved styles
132
QValueList<CharStyle> cstyles;
133
for (uint i = 0; i < tmpStyles_.count(); ++i)
134
pstyles << tmpStyles_[i];
135
for (uint i = 0; i < cstyles_->count(); ++i)
136
cstyles << (*cstyles_)[i];
139
for (uint i = 0; i < styleNames.count(); ++i)
141
index = tmpStyles_.find(styleNames[i]);
143
selection_.append(&tmpStyles_[index]);
146
pwidget_->show(selection_, pstyles, cstyles, doc_->unitIndex(), (*cstyles_)[""].language());
151
QValueList<CharStyle> SMParagraphStyle::getCharStyles()
153
QValueList<CharStyle> charStyles;
155
return charStyles; // no doc available
157
const StyleSet<CharStyle> &tmp(doc_->charStyles());
158
for (uint i = 0; i < tmp.count(); ++i)
159
charStyles.append(tmp[i]);
163
QString SMParagraphStyle::fromSelection() const
165
QString lsName(QString::null);
167
return lsName; // no doc available
169
for (uint i = 0; i < doc_->m_Selection->count(); ++i)
171
// wth is going on here
172
PageItem *item = doc_->m_Selection->itemAt(i);
174
QString tmpName = item->itemText.defaultStyle().parent();
176
if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
180
else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
182
lsName = QString::null;
189
void SMParagraphStyle::toSelection(const QString &styleName) const
192
return; // nowhere to apply or no doc
194
doc_->itemSelection_SetNamedParagraphStyle(styleName);
197
QString SMParagraphStyle::newStyle()
200
return QString::null;
202
QString s(getUniqueName( tr("New Style")));
205
tmpStyles_.create(p);
209
QString SMParagraphStyle::newStyle(const QString &fromStyle)
211
Q_ASSERT(tmpStyles_.resolve(fromStyle));
212
if (!tmpStyles_.resolve(fromStyle))
213
return QString::null;
215
QString s(getUniqueName( tr("Clone of %1").arg(fromStyle)));
216
ParagraphStyle p(tmpStyles_[fromStyle]);
218
p.setShortcut(QString::null); // do not clone the sc
219
tmpStyles_.create(p);
224
// helper function to find a unique name to a new style or a clone
225
QString SMParagraphStyle::getUniqueName(const QString &name)
235
for (uint i = 0; i < tmpStyles_.count(); ++i)
237
if (tmpStyles_[i].name() == s)
239
s = tr("%1 (%2)", "This for unique name when creating "
240
"a new character style. %1 will be the name "
241
"of the style and %2 will be a number forming "
242
"a style name like: New Style (2)").arg(name).arg(id);
252
void SMParagraphStyle::apply()
257
QMap<QString, QString> replacement;
258
for (uint i = 0; i < deleted_.count(); ++i)
259
replacement[deleted_[i].first] = deleted_[i].second;
261
doc_->redefineStyles(tmpStyles_, false);
262
doc_->replaceStyles(replacement);
264
deleted_.clear(); // deletion done at this point
266
doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
267
doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
268
doc_->scMW()->view->DrawNew();
272
void SMParagraphStyle::editMode(bool isOn)
278
QString SMParagraphStyle::shortcut(const QString &stylename) const
280
QString s(QString::null);
282
int index = tmpStyles_.find(stylename);
284
s = tmpStyles_[index].shortcut();
289
void SMParagraphStyle::setShortcut(const QString &shortcut)
291
Q_ASSERT(selection_.count() == 1);
292
if (selection_.count() != 1)
295
selection_[0]->setShortcut(shortcut);
297
if (!selectionIsDirty_)
299
selectionIsDirty_ = true;
300
emit selectionDirty();
304
void SMParagraphStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
306
for (uint i = 0; i < removeList.count(); ++i)
308
for (uint k = 0; k < selection_.count(); ++k)
310
if (selection_[k]->name() == removeList[i].first)
312
selection_.erase(selection_.at(k));
317
int index = tmpStyles_.find(removeList[i].first);
319
tmpStyles_.remove(index);
321
deleted_.append(removeList[i]);
325
void SMParagraphStyle::nameChanged(const QString &newName)
327
if (selection_.count() != 1)
330
QString oldName(selection_[0]->name());
331
ParagraphStyle p(*selection_[0]);
333
tmpStyles_.create(p);
335
selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
336
for (uint j = 0; j < tmpStyles_.count(); ++j)
338
int index = tmpStyles_.find(oldName);
341
tmpStyles_.remove(index);
346
for (uint j = 0; j < tmpStyles_.count(); ++j)
348
if (tmpStyles_[j].parent() == oldName)
349
tmpStyles_[j].setParent(newName);
352
QValueList<RemoveItem>::iterator it;
353
for (it = deleted_.begin(); it != deleted_.end(); ++it)
355
if ((*it).second == oldName)
357
oldName = (*it).first;
363
deleted_.append(RemoveItem(oldName, newName));
365
if (!selectionIsDirty_)
367
selectionIsDirty_ = true;
368
emit selectionDirty();
372
void SMParagraphStyle::languageChange()
376
pwidget_->languageChange();
377
pwidget_->cpage->languageChange();
381
void SMParagraphStyle::unitChange()
383
double oldRatio = unitRatio_;
384
unitRatio_ = doc_->unitRatio();
385
pwidget_->unitChange(oldRatio, unitRatio_, doc_->unitIndex());
388
void SMParagraphStyle::reloadTmpStyles()
396
tmpStyles_.redefine(doc_->paragraphStyles(), true);
397
Q_ASSERT(tmpStyles_.count() > 0);
398
tmpStyles_[0].charStyle().setContext(cstyles_);
401
void SMParagraphStyle::setupConnections()
406
// paragraph attributes
407
connect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
408
connect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
409
connect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
410
connect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
411
connect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
412
connect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
413
connect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
414
connect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
415
connect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
416
connect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
418
connect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
419
connect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
420
connect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
421
connect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
423
connect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
424
connect(pwidget_->tabList_, SIGNAL(mouseReleased()), this, SLOT(slotTabRuler()));
425
connect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
426
connect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
427
connect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
429
connect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
430
this, SLOT(slotParentChanged(const QString&)));
432
// character attributes
433
connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
434
connect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
435
connect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
436
this, SLOT(slotEffectProperties()));
437
connect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
438
this, SLOT(slotEffectProperties()));
439
connect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
440
this, SLOT(slotEffectProperties()));
441
connect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
442
this, SLOT(slotEffectProperties()));
443
connect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
444
this, SLOT(slotEffectProperties()));
445
connect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
446
this, SLOT(slotEffectProperties()));
447
connect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
448
this, SLOT(slotEffectProperties()));
449
connect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
450
connect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
451
connect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
452
connect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
453
connect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
454
connect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
455
connect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
456
connect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
457
connect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
458
connect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
459
connect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
460
connect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
461
this, SLOT(slotCharParentChanged(const QString&)));
464
void SMParagraphStyle::removeConnections()
469
disconnect(pwidget_->lineSpacingMode_, SIGNAL(activated(int)), this, SLOT(slotLineSpacingMode(int)));
470
disconnect(pwidget_->lineSpacing_, SIGNAL(valueChanged(int)), this, SLOT(slotLineSpacing()));
471
disconnect(pwidget_->spaceAbove_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceAbove()));
472
disconnect(pwidget_->spaceBelow_, SIGNAL(valueChanged(int)), this, SLOT(slotSpaceBelow()));
473
disconnect(pwidget_->alignement_->TextL, SIGNAL(clicked()), this, SLOT(slotAlignment()));
474
disconnect(pwidget_->alignement_->TextR, SIGNAL(clicked()), this, SLOT(slotAlignment()));
475
disconnect(pwidget_->alignement_->TextC, SIGNAL(clicked()), this, SLOT(slotAlignment()));
476
disconnect(pwidget_->alignement_->TextB, SIGNAL(clicked()), this, SLOT(slotAlignment()));
477
disconnect(pwidget_->alignement_->TextF, SIGNAL(clicked()), this, SLOT(slotAlignment()));
478
disconnect(pwidget_->alignement_->parentButton, SIGNAL(clicked()), this, SLOT(slotAlignment()));
480
disconnect(pwidget_, SIGNAL(useParentDropCap()), this, SLOT(slotParentDropCap()));
481
disconnect(pwidget_->dropCapsBox, SIGNAL(toggled(bool)), this, SLOT(slotDropCap(bool)));
482
disconnect(pwidget_->dropCapLines_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapLines(int)));
483
disconnect(pwidget_->dropCapOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotDropCapOffset()));
485
disconnect(pwidget_->parentCombo, SIGNAL(activated(const QString&)),
486
this, SLOT(slotParentChanged(const QString&)));
488
disconnect(pwidget_->tabList_, SIGNAL(tabsChanged()), this, SLOT(slotTabRuler()));
489
disconnect(pwidget_->tabList_->left_, SIGNAL(valueChanged(int)), this, SLOT(slotLeftIndent()));
490
disconnect(pwidget_->tabList_->right_, SIGNAL(valueChanged(int)), this, SLOT(slotRightIndent()));
491
disconnect(pwidget_->tabList_->first_, SIGNAL(valueChanged(int)), this, SLOT(slotFirstLine()));
493
disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
494
disconnect(pwidget_->cpage->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
495
disconnect(pwidget_->cpage->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
496
this, SLOT(slotEffectProperties()));
497
disconnect(pwidget_->cpage->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
498
this, SLOT(slotEffectProperties()));
499
disconnect(pwidget_->cpage->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
500
this, SLOT(slotEffectProperties()));
501
disconnect(pwidget_->cpage->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
502
this, SLOT(slotEffectProperties()));
503
disconnect(pwidget_->cpage->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
504
this, SLOT(slotEffectProperties()));
505
disconnect(pwidget_->cpage->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
506
this, SLOT(slotEffectProperties()));
507
disconnect(pwidget_->cpage->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
508
this, SLOT(slotEffectProperties()));
509
disconnect(pwidget_->cpage->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
510
disconnect(pwidget_->cpage->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
511
disconnect(pwidget_->cpage->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
512
disconnect(pwidget_->cpage->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
513
disconnect(pwidget_->cpage->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
514
disconnect(pwidget_->cpage->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
515
disconnect(pwidget_->cpage->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
516
disconnect(pwidget_->cpage->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
517
disconnect(pwidget_->cpage->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
518
disconnect(pwidget_->cpage->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
519
disconnect(pwidget_->cpage->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
520
disconnect(pwidget_->cpage->parentCombo, SIGNAL(activated(const QString&)),
521
this, SLOT(slotCharParentChanged(const QString&)));
524
void SMParagraphStyle::slotLineSpacingMode(int mode)
526
ParagraphStyle::LineSpacingMode lsm = static_cast<ParagraphStyle::LineSpacingMode>(mode);
528
if (pwidget_->lineSpacingMode_->useParentValue())
529
for (uint i = 0; i < selection_.count(); ++i)
530
selection_[i]->resetLineSpacingMode();
532
for (uint i = 0; i < selection_.count(); ++i)
533
selection_[i]->setLineSpacingMode(lsm);
535
if (!selectionIsDirty_)
537
selectionIsDirty_ = true;
538
emit selectionDirty();
542
void SMParagraphStyle::slotLineSpacing()
544
if (pwidget_->lineSpacing_->useParentValue())
545
for (uint i = 0; i < selection_.count(); ++i)
546
selection_[i]->resetLineSpacing();
552
pwidget_->lineSpacing_->getValues(&a, &b, &c, &value);
553
for (uint i = 0; i < selection_.count(); ++i)
554
selection_[i]->setLineSpacing(value);
557
if (!selectionIsDirty_)
559
selectionIsDirty_ = true;
560
emit selectionDirty();
564
void SMParagraphStyle::slotSpaceAbove()
566
if (pwidget_->spaceAbove_->useParentValue())
567
for (uint i = 0; i < selection_.count(); ++i)
568
selection_[i]->resetGapBefore();
574
pwidget_->spaceAbove_->getValues(&a, &b, &c, &value);
575
value = value / unitRatio_;
576
for (uint i = 0; i < selection_.count(); ++i)
577
selection_[i]->setGapBefore(value);
580
if (!selectionIsDirty_)
582
selectionIsDirty_ = true;
583
emit selectionDirty();
587
void SMParagraphStyle::slotSpaceBelow()
589
if (pwidget_->spaceBelow_->useParentValue())
590
for (uint i = 0; i < selection_.count(); ++i)
591
selection_[i]->resetGapAfter();
597
pwidget_->spaceBelow_->getValues(&a, &b, &c, &value);
598
value = value / unitRatio_;
599
for (uint i = 0; i < selection_.count(); ++i)
600
selection_[i]->setGapAfter(value);
603
if (!selectionIsDirty_)
605
selectionIsDirty_ = true;
606
emit selectionDirty();
610
void SMParagraphStyle::slotAlignment()
612
ParagraphStyle::AlignmentType style = static_cast<ParagraphStyle::AlignmentType>(pwidget_->alignement_->getStyle());
613
if (pwidget_->alignement_->useParentValue())
614
for (uint i = 0; i < selection_.count(); ++i)
615
selection_[i]->resetAlignment();
617
for (uint i = 0; i < selection_.count(); ++i)
618
selection_[i]->setAlignment(style);
620
if (!selectionIsDirty_)
622
selectionIsDirty_ = true;
623
emit selectionDirty();
627
void SMParagraphStyle::slotDropCap(bool isOn)
629
for (uint i = 0; i < selection_.count(); ++i)
630
selection_[i]->setHasDropCap(isOn);
632
if (!selectionIsDirty_)
634
selectionIsDirty_ = true;
635
emit selectionDirty();
639
void SMParagraphStyle::slotParentDropCap()
641
for (uint i = 0; i < selection_.count(); ++i)
642
selection_[i]->resetHasDropCap();
644
if (!selectionIsDirty_)
646
selectionIsDirty_ = true;
647
emit selectionDirty();
651
void SMParagraphStyle::slotDropCapLines(int lines)
653
if (pwidget_->dropCapLines_->useParentValue())
654
for (uint i = 0; i < selection_.count(); ++i)
655
selection_[i]->resetDropCapLines();
657
for (uint i = 0; i < selection_.count(); ++i)
658
selection_[i]->setDropCapLines(lines);
660
if (!selectionIsDirty_)
662
selectionIsDirty_ = true;
663
emit selectionDirty();
667
void SMParagraphStyle::slotDropCapOffset()
669
if (pwidget_->dropCapOffset_->useParentValue())
670
for (uint i = 0; i < selection_.count(); ++i)
671
selection_[i]->resetDropCapOffset();
677
pwidget_->dropCapOffset_->getValues(&a, &b, &c, &value);
678
value = value / unitRatio_;
679
for (uint i = 0; i < selection_.count(); ++i)
680
selection_[i]->setDropCapOffset(value);
683
if (!selectionIsDirty_)
685
selectionIsDirty_ = true;
686
emit selectionDirty();
690
void SMParagraphStyle::slotTabRuler()
692
if (pwidget_->tabList_->useParentTabs())
694
for (uint i = 0; i < selection_.count(); ++i)
695
selection_[i]->resetTabValues();
699
QValueList<ParagraphStyle::TabRecord> newTabs = pwidget_->tabList_->getTabVals();
700
for (uint i = 0; i < selection_.count(); ++i)
701
selection_[i]->setTabValues(newTabs);
704
if (!selectionIsDirty_)
706
selectionIsDirty_ = true;
707
emit selectionDirty();
711
void SMParagraphStyle::slotLeftIndent()
713
if (pwidget_->tabList_->useParentLeftIndent())
714
for (uint i = 0; i < selection_.count(); ++i)
715
selection_[i]->resetLeftMargin();
721
pwidget_->tabList_->left_->getValues(&a, &b, &c, &value);
722
value = value / unitRatio_;
723
for (uint i = 0; i < selection_.count(); ++i)
724
selection_[i]->setLeftMargin(value);
727
if (!selectionIsDirty_)
729
selectionIsDirty_ = true;
730
emit selectionDirty();
734
void SMParagraphStyle::slotRightIndent()
736
if (pwidget_->tabList_->useParentRightIndent())
737
for (uint i = 0; i < selection_.count(); ++i)
738
selection_[i]->resetRightMargin();
744
pwidget_->tabList_->right_->getValues(&a, &b, &c, &value);
745
value = value / unitRatio_;
746
for (uint i = 0; i < selection_.count(); ++i)
747
selection_[i]->setRightMargin(value);
750
if (!selectionIsDirty_)
752
selectionIsDirty_ = true;
753
emit selectionDirty();
757
void SMParagraphStyle::slotFirstLine()
759
if (pwidget_->tabList_->useParentFirstLine())
760
for (uint i = 0; i < selection_.count(); ++i)
761
selection_[i]->resetFirstIndent();
767
pwidget_->tabList_->first_->getValues(&a, &b, &c, &value);
768
value = value / unitRatio_;
769
for (uint i = 0; i < selection_.count(); ++i)
770
selection_[i]->setFirstIndent(value);
773
if (!selectionIsDirty_)
775
selectionIsDirty_ = true;
776
emit selectionDirty();
780
void SMParagraphStyle::slotFontSize()
782
if (pwidget_->cpage->fontSize_->useParentValue())
783
for (uint i = 0; i < selection_.count(); ++i)
784
selection_[i]->charStyle().resetFontSize();
790
pwidget_->cpage->fontSize_->getValues(&a, &b, &c, &value);
792
for (uint i = 0; i < selection_.count(); ++i)
793
selection_[i]->charStyle().setFontSize(qRound(value));
797
if (!selectionIsDirty_)
799
selectionIsDirty_ = true;
800
emit selectionDirty();
804
void SMParagraphStyle::slotEffects(int e)
806
StyleFlag s = ScStyle_None;
807
if (pwidget_->cpage->effects_->useParentValue())
809
for (uint i = 0; i < selection_.count(); ++i)
811
selection_[i]->charStyle().resetFeatures();
812
selection_[i]->charStyle().resetShadowXOffset();
813
selection_[i]->charStyle().resetShadowYOffset();
814
selection_[i]->charStyle().resetOutlineWidth();
815
selection_[i]->charStyle().resetUnderlineOffset();
816
selection_[i]->charStyle().resetUnderlineWidth();
817
selection_[i]->charStyle().resetStrikethruOffset();
818
selection_[i]->charStyle().resetStrikethruWidth();
823
double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
826
s = static_cast<StyleFlag>(e);
827
pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
829
pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
832
pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
835
pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
837
pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
840
pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
842
pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
845
for (uint i = 0; i < selection_.count(); ++i)
847
selection_[i]->charStyle().setFeatures(s.featureList());
848
selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
849
selection_[i]->charStyle().setShadowYOffset(qRound(syo));
850
selection_[i]->charStyle().setOutlineWidth(qRound(olw));
851
selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
852
selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
853
selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
854
selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
859
if (!selectionIsDirty_)
861
selectionIsDirty_ = true;
862
emit selectionDirty();
866
void SMParagraphStyle::slotEffectProperties()
868
double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
871
pwidget_->cpage->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
873
pwidget_->cpage->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
876
pwidget_->cpage->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
879
pwidget_->cpage->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
881
pwidget_->cpage->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
884
pwidget_->cpage->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
886
pwidget_->cpage->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
889
for (uint i = 0; i < selection_.count(); ++i)
891
selection_[i]->charStyle().setShadowXOffset(qRound(sxo));
892
selection_[i]->charStyle().setShadowYOffset(qRound(syo));
893
selection_[i]->charStyle().setOutlineWidth(qRound(olw));
894
selection_[i]->charStyle().setUnderlineOffset(qRound(ulp));
895
selection_[i]->charStyle().setUnderlineWidth(qRound(ulw));
896
selection_[i]->charStyle().setStrikethruOffset(qRound(slp));
897
selection_[i]->charStyle().setStrikethruWidth(qRound(slw));
900
if (!selectionIsDirty_)
902
selectionIsDirty_ = true;
903
emit selectionDirty();
907
void SMParagraphStyle::slotFillColor()
909
if (pwidget_->cpage->fillColor_->useParentValue())
910
for (uint i = 0; i < selection_.count(); ++i)
911
selection_[i]->charStyle().resetFillColor();
913
QString c( pwidget_->cpage->fillColor_->currentText());
914
for (uint i = 0; i < selection_.count(); ++i)
915
selection_[i]->charStyle().setFillColor(c);
918
if (!selectionIsDirty_)
920
selectionIsDirty_ = true;
921
emit selectionDirty();
925
void SMParagraphStyle::slotFillShade()
927
if (pwidget_->cpage->fillShade_->useParentValue())
928
for (uint i = 0; i < selection_.count(); ++i)
929
selection_[i]->charStyle().resetFillShade();
931
int fs = pwidget_->cpage->fillShade_->getValue();
933
for (uint i = 0; i < selection_.count(); ++i)
934
selection_[i]->charStyle().setFillShade(fs);
937
if (!selectionIsDirty_)
939
selectionIsDirty_ = true;
940
emit selectionDirty();
944
void SMParagraphStyle::slotStrokeColor()
946
if (pwidget_->cpage->strokeColor_->useParentValue())
947
for (uint i = 0; i < selection_.count(); ++i)
948
selection_[i]->charStyle().resetStrokeColor();
950
QString c(pwidget_->cpage->strokeColor_->currentText());
952
for (uint i = 0; i < selection_.count(); ++i)
953
selection_[i]->charStyle().setStrokeColor(c);
956
if (!selectionIsDirty_)
958
selectionIsDirty_ = true;
959
emit selectionDirty();
963
void SMParagraphStyle::slotStrokeShade()
965
if (pwidget_->cpage->strokeShade_->useParentValue())
966
for (uint i = 0; i < selection_.count(); ++i)
967
selection_[i]->charStyle().resetStrokeShade();
970
int ss = pwidget_->cpage->strokeShade_->getValue();
972
for (uint i = 0; i < selection_.count(); ++i)
973
selection_[i]->charStyle().setStrokeShade(ss);
976
if (!selectionIsDirty_)
978
selectionIsDirty_ = true;
979
emit selectionDirty();
983
void SMParagraphStyle::slotLanguage()
985
QMap<QString,QString>::Iterator it;
986
QString language = doc_->paragraphStyle("").charStyle().language();
988
if (pwidget_->cpage->language_->useParentValue())
989
for (uint i = 0; i < selection_.count(); ++i)
990
selection_[i]->charStyle().resetLanguage();
993
for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
995
if (it.data() == pwidget_->cpage->language_->currentText())
1001
for (uint i = 0; i < selection_.count(); ++i)
1002
selection_[i]->charStyle().setLanguage(language);
1005
if (!selectionIsDirty_)
1007
selectionIsDirty_ = true;
1008
emit selectionDirty();
1012
void SMParagraphStyle::slotScaleH()
1014
if (pwidget_->cpage->fontHScale_->useParentValue())
1015
for (uint i = 0; i < selection_.count(); ++i)
1016
selection_[i]->charStyle().resetScaleH();
1021
pwidget_->cpage->fontHScale_->getValues(&a, &b, &c, &value);
1023
for (uint i = 0; i < selection_.count(); ++i)
1024
selection_[i]->charStyle().setScaleH(qRound(value));
1027
if (!selectionIsDirty_)
1029
selectionIsDirty_ = true;
1030
emit selectionDirty();
1034
void SMParagraphStyle::slotScaleV()
1036
if (pwidget_->cpage->fontVScale_->useParentValue())
1037
for (uint i = 0; i < selection_.count(); ++i)
1038
selection_[i]->charStyle().resetScaleV();
1043
pwidget_->cpage->fontVScale_->getValues(&a, &b, &c, &value);
1045
for (uint i = 0; i < selection_.count(); ++i)
1046
selection_[i]->charStyle().setScaleV(qRound(value));
1049
if (!selectionIsDirty_)
1051
selectionIsDirty_ = true;
1052
emit selectionDirty();
1056
void SMParagraphStyle::slotTracking()
1058
if (pwidget_->cpage->tracking_->useParentValue())
1059
for (uint i = 0; i < selection_.count(); ++i)
1060
selection_[i]->charStyle().resetTracking();
1065
pwidget_->cpage->tracking_->getValues(&a, &b, &c, &value);
1067
for (uint i = 0; i < selection_.count(); ++i)
1068
selection_[i]->charStyle().setTracking(qRound(value));
1071
if (!selectionIsDirty_)
1073
selectionIsDirty_ = true;
1074
emit selectionDirty();
1078
void SMParagraphStyle::slotBaselineOffset()
1080
if (pwidget_->cpage->baselineOffset_->useParentValue())
1081
for (uint i = 0; i < selection_.count(); ++i)
1082
selection_[i]->charStyle().resetBaselineOffset();
1087
pwidget_->cpage->baselineOffset_->getValues(&a, &b, &c, &value);
1089
for (uint i = 0; i < selection_.count(); ++i)
1090
selection_[i]->charStyle().setBaselineOffset(qRound(value));
1093
if (!selectionIsDirty_)
1095
selectionIsDirty_ = true;
1096
emit selectionDirty();
1100
void SMParagraphStyle::slotFont(QString s)
1102
if (pwidget_->cpage->fontFace_->useParentFont())
1103
for (uint i = 0; i < selection_.count(); ++i)
1104
selection_[i]->charStyle().resetFont();
1106
ScFace sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
1108
for (uint i = 0; i < selection_.count(); ++i)
1109
selection_[i]->charStyle().setFont(sf);
1112
if (!selectionIsDirty_)
1114
selectionIsDirty_ = true;
1115
emit selectionDirty();
1119
void SMParagraphStyle::slotParentChanged(const QString &parent)
1121
Q_ASSERT(!parent.isNull());
1125
for (uint i = 0; i < selection_.count(); ++i)
1127
// const ParagraphStyle *style = & (doc_->paragraphStyle(parent));
1130
selection_[i]->erase(); // reset everything to NOVALUE
1131
selection_[i]->setParent(parent);
1132
selection_[i]->charStyle().setParent("");
1133
sel << selection_[i]->name();
1139
if (!selectionIsDirty_)
1141
selectionIsDirty_ = true;
1142
emit selectionDirty();
1146
void SMParagraphStyle::slotCharParentChanged(const QString &parent)
1148
Q_ASSERT(parent != QString::null);
1152
for (uint i = 0; i < selection_.count(); ++i)
1154
selection_[i]->charStyle().erase();
1155
if (parent != QString::null)
1156
selection_[i]->charStyle().setParent(parent);
1158
sel << selection_[i]->name();
1163
if (!selectionIsDirty_)
1165
selectionIsDirty_ = true;
1166
emit selectionDirty();
1170
SMParagraphStyle::~SMParagraphStyle()
1175
/******************************************************************************/
1176
/******************************************************************************/
1178
SMCharacterStyle::SMCharacterStyle() : StyleItem(), widget_(0), page_(0), doc_(0), selectionIsDirty_(false)
1180
widget_ = new QTabWidget();
1181
Q_CHECK_PTR(widget_);
1182
widget_->setMargin(5);//CB the SMCStylePage parent has a 0 value to fit properly onto the pstyle page, so add it here
1183
page_ = new SMCStylePage();
1185
widget_->addTab(page_, tr("Properties"));
1188
QTabWidget* SMCharacterStyle::widget()
1193
QString SMCharacterStyle::typeNamePlural()
1195
return tr("Character Styles");
1198
QString SMCharacterStyle::typeNameSingular()
1200
return tr("Character Style");
1203
void SMCharacterStyle::currentDoc(ScribusDoc *doc)
1210
page_->fillLangCombo(doc_->scMW()->LangTransl);
1211
page_->fillColorCombo(doc_->PageColors);
1212
page_->fontFace_->RebuildList(doc_);
1217
removeConnections();
1224
StyleSet<CharStyle>* SMCharacterStyle::tmpStyles()
1229
QValueList<StyleName> SMCharacterStyle::styles(bool reloadFromDoc)
1231
QValueList<StyleName> tmpList;
1234
return tmpList; // no doc available
1239
for (uint i = 0; i < tmpStyles_.count(); ++i)
1241
if (tmpStyles_[i].hasName())
1243
QString styleName(tmpStyles_[i].name());
1244
QString parentName(QString::null);
1246
if (tmpStyles_[i].hasParent())
1247
parentName = tmpStyles_[i].parent();
1249
tmpList << StyleName(styleName, parentName);
1256
void SMCharacterStyle::reload()
1261
void SMCharacterStyle::selected(const QStringList &styleNames)
1264
selectionIsDirty_ = false;
1265
removeConnections();
1266
QValueList<CharStyle> cstyles;
1268
tmpStyles_.invalidate();
1270
for (uint i = 0; i < tmpStyles_.count(); ++i)
1271
cstyles << tmpStyles_[i];
1273
for (uint i = 0; i < styleNames.count(); ++i)
1275
int index = tmpStyles_.find(styleNames[i]);
1277
selection_.append(&tmpStyles_[index]);
1281
page_->show(selection_, cstyles, doc_->paragraphStyle("").charStyle().language(), doc_->unitIndex());
1285
QString SMCharacterStyle::fromSelection() const
1287
QString lsName(QString::null);
1289
return lsName; // no doc available
1291
for (uint i = 0; i < doc_->m_Selection->count(); ++i)
1293
// wth is going on here
1294
PageItem *item = doc_->m_Selection->itemAt(i);
1296
QString tmpName = item->itemText.defaultStyle().charStyle().parent();
1298
if (lsName.isNull() && !tmpName.isEmpty() && tmpName != "")
1302
else if (!lsName.isNull() && !tmpName.isEmpty() && tmpName != "" && lsName != tmpName)
1304
lsName = QString::null;
1311
void SMCharacterStyle::toSelection(const QString &styleName) const
1314
return; // nowhere to apply or no doc
1316
doc_->itemSelection_SetNamedCharStyle(styleName);
1319
QString SMCharacterStyle::newStyle()
1321
Q_ASSERT(doc_ && doc_->paragraphStyles().count() > 0);
1323
QString s = getUniqueName( tr("New Style"));
1326
tmpStyles_.create(c);
1330
QString SMCharacterStyle::newStyle(const QString &fromStyle)
1332
Q_ASSERT(tmpStyles_.resolve(fromStyle));
1333
if (!tmpStyles_.resolve(fromStyle))
1334
return QString::null;
1336
QString s = getUniqueName( tr("Clone of %1").arg(fromStyle));
1337
CharStyle c(tmpStyles_[fromStyle]);
1339
c.setShortcut(QString::null);
1340
tmpStyles_.create(c);
1345
QString SMCharacterStyle::getUniqueName(const QString &name)
1355
for (uint i = 0; i < tmpStyles_.count(); ++i)
1357
if (tmpStyles_[i].name() == s)
1359
s = tr("%1 (%2)", "This for unique name when creating "
1360
"a new character style. %1 will be the name "
1361
"of the style and %2 will be a number forming "
1362
"a style name like: New Style (2)").arg(name).arg(id);
1372
void SMCharacterStyle::apply()
1377
QMap<QString, QString> replacement;
1378
for (uint i = 0; i < deleted_.count(); ++i)
1379
replacement[deleted_[i].first] = deleted_[i].second;
1381
doc_->redefineCharStyles(tmpStyles_, false);
1382
doc_->replaceCharStyles(replacement);
1384
deleted_.clear(); // deletion done at this point
1386
doc_->scMW()->propertiesPalette->paraStyleCombo->updateFormatList();
1387
doc_->scMW()->propertiesPalette->charStyleCombo->updateFormatList();
1388
doc_->scMW()->view->DrawNew();
1392
void SMCharacterStyle::editMode(bool isOn)
1398
QString SMCharacterStyle::shortcut(const QString &stylename) const
1400
QString s = QString::null;
1401
int index = tmpStyles_.find(stylename);
1403
s = tmpStyles_[index].shortcut();
1408
void SMCharacterStyle::setShortcut(const QString &shortcut)
1410
Q_ASSERT(selection_.count() == 1);
1411
if (selection_.count() != 1)
1414
selection_[0]->setShortcut(shortcut);
1416
if (!selectionIsDirty_)
1418
selectionIsDirty_ = true;
1419
emit selectionDirty();
1423
void SMCharacterStyle::deleteStyles(const QValueList<RemoveItem> &removeList)
1425
for (uint i = 0; i < removeList.count(); ++i)
1427
for (uint k = 0; k < selection_.count(); ++k)
1429
if (selection_[k]->name() == removeList[i].first)
1431
selection_.erase(selection_.at(k));
1436
int index = tmpStyles_.find(removeList[i].first);
1438
tmpStyles_.remove(index);
1439
deleted_ << removeList[i];
1443
void SMCharacterStyle::nameChanged(const QString &newName)
1445
// for (uint i = 0; i < selection_.count(); ++i)
1446
// selection_[i]->setName(newName);
1448
QString oldName(selection_[0]->name());
1449
CharStyle c(*selection_[0]);
1451
tmpStyles_.create(c);
1453
selection_.append(&tmpStyles_[tmpStyles_.find(newName)]);
1454
for (uint j = 0; j < tmpStyles_.count(); ++j)
1456
int index = tmpStyles_.find(oldName);
1459
tmpStyles_.remove(index);
1464
for (uint j = 0; j < tmpStyles_.count(); ++j)
1466
if (tmpStyles_[j].parent() == oldName)
1467
tmpStyles_[j].setParent(newName);
1470
QValueList<RemoveItem>::iterator it;
1471
for (it = deleted_.begin(); it != deleted_.end(); ++it)
1473
if ((*it).second == oldName)
1475
oldName = (*it).first;
1476
deleted_.remove(it);
1481
deleted_.append(RemoveItem(oldName, newName));
1483
if (!selectionIsDirty_)
1485
selectionIsDirty_ = true;
1486
emit selectionDirty();
1490
void SMCharacterStyle::languageChange()
1492
if (widget_ && page_)
1494
widget_->setTabLabel(page_, tr("Properties"));
1495
page_->languageChange();
1499
void SMCharacterStyle::unitChange()
1504
void SMCharacterStyle::reloadTmpStyles()
1511
tmpStyles_.redefine(doc_->charStyles(), true);
1514
void SMCharacterStyle::setupConnections()
1519
connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
1520
connect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
1521
connect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
1522
this, SLOT(slotEffectProperties()));
1523
connect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
1524
this, SLOT(slotEffectProperties()));
1525
connect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
1526
this, SLOT(slotEffectProperties()));
1527
connect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
1528
this, SLOT(slotEffectProperties()));
1529
connect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
1530
this, SLOT(slotEffectProperties()));
1531
connect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
1532
this, SLOT(slotEffectProperties()));
1533
connect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
1534
this, SLOT(slotEffectProperties()));
1535
connect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
1536
connect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
1537
connect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
1538
connect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
1539
connect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
1540
connect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
1541
connect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
1542
connect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
1543
connect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
1544
connect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
1545
connect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
1546
connect(page_->parentCombo, SIGNAL(activated(const QString&)),
1547
this, SLOT(slotParentChanged(const QString&)));
1550
void SMCharacterStyle::removeConnections()
1555
disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
1556
disconnect(page_->effects_, SIGNAL(State(int)), this, SLOT(slotEffects(int)));
1557
disconnect(page_->effects_->ShadowVal->Xoffset, SIGNAL(valueChanged(int)),
1558
this, SLOT(slotEffectProperties()));
1559
disconnect(page_->effects_->ShadowVal->Yoffset, SIGNAL(valueChanged(int)),
1560
this, SLOT(slotEffectProperties()));
1561
disconnect(page_->effects_->OutlineVal->LWidth, SIGNAL(valueChanged(int)),
1562
this, SLOT(slotEffectProperties()));
1563
disconnect(page_->effects_->UnderlineVal->LPos, SIGNAL(valueChanged(int)),
1564
this, SLOT(slotEffectProperties()));
1565
disconnect(page_->effects_->UnderlineVal->LWidth, SIGNAL(valueChanged(int)),
1566
this, SLOT(slotEffectProperties()));
1567
disconnect(page_->effects_->StrikeVal->LPos, SIGNAL(valueChanged(int)),
1568
this, SLOT(slotEffectProperties()));
1569
disconnect(page_->effects_->StrikeVal->LWidth, SIGNAL(valueChanged(int)),
1570
this, SLOT(slotEffectProperties()));
1571
disconnect(page_->fillColor_, SIGNAL(activated(const QString&)), this, SLOT(slotFillColor()));
1572
disconnect(page_->fillShade_, SIGNAL(clicked()), this, SLOT(slotFillShade()));
1573
disconnect(page_->strokeColor_, SIGNAL(activated(const QString&)), this, SLOT(slotStrokeColor()));
1574
disconnect(page_->strokeShade_, SIGNAL(clicked()), this, SLOT(slotStrokeShade()));
1575
disconnect(page_->language_, SIGNAL(activated(int)), this, SLOT(slotLanguage()));
1576
disconnect(page_->fontSize_, SIGNAL(valueChanged(int)), this, SLOT(slotFontSize()));
1577
disconnect(page_->fontHScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleH()));
1578
disconnect(page_->fontVScale_, SIGNAL(valueChanged(int)), this, SLOT(slotScaleV()));
1579
disconnect(page_->tracking_, SIGNAL(valueChanged(int)), this, SLOT(slotTracking()));
1580
disconnect(page_->baselineOffset_, SIGNAL(valueChanged(int)), this, SLOT(slotBaselineOffset()));
1581
disconnect(page_->fontFace_, SIGNAL(fontSelected(QString)), this, SLOT(slotFont(QString)));
1582
disconnect(page_->parentCombo, SIGNAL(activated(const QString&)),
1583
this, SLOT(slotParentChanged(const QString&)));
1586
void SMCharacterStyle::slotFontSize()
1588
if (page_->fontSize_->useParentValue())
1589
for (uint i = 0; i < selection_.count(); ++i)
1590
selection_[i]->resetFontSize();
1596
page_->fontSize_->getValues(&a, &b, &c, &value);
1598
for (uint i = 0; i < selection_.count(); ++i)
1599
selection_[i]->setFontSize(qRound(value));
1602
if (!selectionIsDirty_)
1604
selectionIsDirty_ = true;
1605
emit selectionDirty();
1609
void SMCharacterStyle::slotEffects(int e)
1611
StyleFlag s = ScStyle_None;
1612
if (page_->effects_->useParentValue())
1614
for (uint i = 0; i < selection_.count(); ++i)
1616
selection_[i]->resetFeatures();
1617
selection_[i]->resetShadowXOffset();
1618
selection_[i]->resetShadowYOffset();
1619
selection_[i]->resetOutlineWidth();
1620
selection_[i]->resetUnderlineOffset();
1621
selection_[i]->resetUnderlineWidth();
1622
selection_[i]->resetStrikethruOffset();
1623
selection_[i]->resetStrikethruWidth();
1628
s = static_cast<StyleFlag>(e);
1629
double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
1632
page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
1634
page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
1637
page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
1640
page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
1642
page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
1645
page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
1647
page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
1650
for (uint i = 0; i < selection_.count(); ++i)
1652
selection_[i]->setFeatures(s.featureList());
1653
selection_[i]->setShadowXOffset(qRound(sxo));
1654
selection_[i]->setShadowYOffset(qRound(syo));
1655
selection_[i]->setOutlineWidth(qRound(olw));
1656
selection_[i]->setUnderlineOffset(qRound(ulp));
1657
selection_[i]->setUnderlineWidth(qRound(ulw));
1658
selection_[i]->setStrikethruOffset(qRound(slp));
1659
selection_[i]->setStrikethruWidth(qRound(slw));
1664
if (!selectionIsDirty_)
1666
selectionIsDirty_ = true;
1667
emit selectionDirty();
1671
void SMCharacterStyle::slotEffectProperties()
1673
double a, b, sxo, syo, olw, ulp, ulw, slp, slw;
1676
page_->effects_->ShadowVal->Xoffset->getValues(&a, &b, &c, &sxo);
1678
page_->effects_->ShadowVal->Yoffset->getValues(&a, &b, &c, &syo);
1681
page_->effects_->OutlineVal->LWidth->getValues(&a, &b, &c, &olw);
1684
page_->effects_->UnderlineVal->LPos->getValues(&a, &b, &c, &ulp);
1686
page_->effects_->UnderlineVal->LWidth->getValues(&a, &b, &c, &ulw);
1689
page_->effects_->StrikeVal->LPos->getValues(&a, &b, &c, &slp);
1691
page_->effects_->StrikeVal->LWidth->getValues(&a, &b, &c, &slw);
1694
for (uint i = 0; i < selection_.count(); ++i)
1696
selection_[i]->setShadowXOffset(qRound(sxo));
1697
selection_[i]->setShadowYOffset(qRound(syo));
1698
selection_[i]->setOutlineWidth(qRound(olw));
1699
selection_[i]->setUnderlineOffset(qRound(ulp));
1700
selection_[i]->setUnderlineWidth(qRound(ulw));
1701
selection_[i]->setStrikethruOffset(qRound(slp));
1702
selection_[i]->setStrikethruWidth(qRound(slw));
1705
if (!selectionIsDirty_)
1707
selectionIsDirty_ = true;
1708
emit selectionDirty();
1712
void SMCharacterStyle::slotFillColor()
1714
if (page_->fillColor_->useParentValue())
1715
for (uint i = 0; i < selection_.count(); ++i)
1716
selection_[i]->resetFillColor();
1718
QString col(page_->fillColor_->currentText());
1720
for (uint i = 0; i < selection_.count(); ++i)
1721
selection_[i]->setFillColor(col);
1724
if (!selectionIsDirty_)
1726
selectionIsDirty_ = true;
1727
emit selectionDirty();
1731
void SMCharacterStyle::slotFillShade()
1733
if (page_->fillShade_->useParentValue())
1734
for (uint i = 0; i < selection_.count(); ++i)
1735
selection_[i]->resetFillShade();
1737
int fs = page_->fillShade_->getValue();
1739
for (uint i = 0; i < selection_.count(); ++i)
1740
selection_[i]->setFillShade(fs);
1743
if (!selectionIsDirty_)
1745
selectionIsDirty_ = true;
1746
emit selectionDirty();
1750
void SMCharacterStyle::slotStrokeColor()
1752
if (page_->strokeColor_->useParentValue())
1753
for (uint i = 0; i < selection_.count(); ++i)
1754
selection_[i]->resetStrokeColor();
1756
QString c(page_->strokeColor_->currentText());
1758
for (uint i = 0; i < selection_.count(); ++i)
1759
selection_[i]->setStrokeColor(c);
1762
if (!selectionIsDirty_)
1764
selectionIsDirty_ = true;
1765
emit selectionDirty();
1769
void SMCharacterStyle::slotStrokeShade()
1771
if (page_->strokeShade_->useParentValue())
1772
for (uint i = 0; i < selection_.count(); ++i)
1773
selection_[i]->resetStrokeShade();
1775
int ss = page_->strokeShade_->getValue();
1777
for (uint i = 0; i < selection_.count(); ++i)
1778
selection_[i]->setStrokeShade(ss);
1781
if (!selectionIsDirty_)
1783
selectionIsDirty_ = true;
1784
emit selectionDirty();
1788
void SMCharacterStyle::slotLanguage()
1790
QMap<QString,QString>::Iterator it;
1791
QString language = doc_->paragraphStyle("").charStyle().language();
1793
if (page_->language_->useParentValue())
1794
for (uint i = 0; i < selection_.count(); ++i)
1795
selection_[i]->resetLanguage();
1798
for (it = doc_->scMW()->LangTransl.begin(); it != doc_->scMW()->LangTransl.end(); ++it)
1800
if (it.data() == page_->language_->currentText())
1802
language = it.key();
1806
for (uint i = 0; i < selection_.count(); ++i)
1807
selection_[i]->setLanguage(language);
1811
if (!selectionIsDirty_)
1813
selectionIsDirty_ = true;
1814
emit selectionDirty();
1818
void SMCharacterStyle::slotScaleH()
1820
if (page_->fontHScale_->useParentValue())
1821
for (uint i = 0; i < selection_.count(); ++i)
1822
selection_[i]->resetScaleH();
1828
page_->fontHScale_->getValues(&a, &b, &c, &value);
1830
for (uint i = 0; i < selection_.count(); ++i)
1831
selection_[i]->setScaleH(qRound(value));
1835
if (!selectionIsDirty_)
1837
selectionIsDirty_ = true;
1838
emit selectionDirty();
1842
void SMCharacterStyle::slotScaleV()
1844
if (page_->fontVScale_->useParentValue())
1845
for (uint i = 0; i < selection_.count(); ++i)
1846
selection_[i]->resetScaleV();
1852
page_->fontVScale_->getValues(&a, &b, &c, &value);
1854
for (uint i = 0; i < selection_.count(); ++i)
1855
selection_[i]->setScaleV(qRound(value));
1859
if (!selectionIsDirty_)
1861
selectionIsDirty_ = true;
1862
emit selectionDirty();
1866
void SMCharacterStyle::slotTracking()
1868
if (page_->tracking_->useParentValue())
1869
for (uint i = 0; i < selection_.count(); ++i)
1870
selection_[i]->resetTracking();
1876
page_->tracking_->getValues(&a, &b, &c, &value);
1878
for (uint i = 0; i < selection_.count(); ++i)
1879
selection_[i]->setTracking(qRound(value));
1882
if (!selectionIsDirty_)
1884
selectionIsDirty_ = true;
1885
emit selectionDirty();
1889
void SMCharacterStyle::slotBaselineOffset()
1891
if (page_->baselineOffset_->useParentValue())
1892
for (uint i = 0; i < selection_.count(); ++i)
1893
selection_[i]->resetBaselineOffset();
1899
page_->baselineOffset_->getValues(&a, &b, &c, &value);
1901
for (uint i = 0; i < selection_.count(); ++i)
1902
selection_[i]->setBaselineOffset(qRound(value));
1905
if (!selectionIsDirty_)
1907
selectionIsDirty_ = true;
1908
emit selectionDirty();
1912
void SMCharacterStyle::slotFont(QString s)
1915
if (page_->fontFace_->useParentFont())
1916
for (uint i = 0; i < selection_.count(); ++i)
1917
selection_[i]->resetFont();
1919
sf = PrefsManager::instance()->appPrefs.AvailFonts[s];
1921
for (uint i = 0; i < selection_.count(); ++i)
1922
selection_[i]->setFont(sf);
1925
if (!selectionIsDirty_)
1927
selectionIsDirty_ = true;
1928
emit selectionDirty();
1932
void SMCharacterStyle::slotParentChanged(const QString &parent)
1934
Q_ASSERT(!parent.isNull());
1938
for (uint i = 0; i < selection_.count(); ++i)
1940
selection_[i]->erase();
1941
selection_[i]->setParent(parent);
1942
sel << selection_[i]->name();
1947
if (!selectionIsDirty_)
1949
selectionIsDirty_ = true;
1950
emit selectionDirty();
1954
SMCharacterStyle::~SMCharacterStyle()