Rev 18063 | Rev 18795 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
18051 | craig | 1 | /* |
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. |
||
6 | */ |
||
7 | |||
8 | #include "pageitem.h" |
||
9 | #include "pageitem_table.h" |
||
10 | #include "propertywidget_pareffect.h" |
||
11 | #include "scribus.h" |
||
12 | #include "scribusdoc.h" |
||
13 | #include "selection.h" |
||
14 | #include "units.h" |
||
15 | #include "util.h" |
||
16 | #include "util_icon.h" |
||
17 | #include "ui/sctreewidget.h" |
||
18 | |||
19 | PropertyWidget_ParEffect::PropertyWidget_ParEffect(QWidget *parent) : QFrame(parent), m_enhanced(NULL), m_item(NULL), m_ScMW(NULL) |
||
20 | { |
||
21 | setupUi(this); |
||
22 | setFrameStyle(QFrame::Box | QFrame::Plain); |
||
23 | setLineWidth(1); |
||
24 | layout()->setAlignment( Qt::AlignTop ); |
||
25 | |||
26 | languageChange(); |
||
27 | dropCapLines->setValue(2); |
||
28 | |||
29 | if (m_doc) |
||
30 | peCharStyleCombo->updateFormatList(); |
||
31 | fillBulletStrEditCombo(); |
||
32 | fillNumFormatCombo(); |
||
33 | enableParEffect(false); |
||
18534 | jghali | 34 | bulletCharTableButton->setIcon(loadIcon("22/insert-table.png")); |
18051 | craig | 35 | numStart->setMinimum(1); |
36 | numStart->setMaximum(9999); |
||
37 | numLevelSpin->setMinimum(1); |
||
38 | numLevelSpin->setMaximum(3); |
||
39 | dropCapLines->setMinimum(2); |
||
40 | dropCapLines->setMaximum(99); |
||
41 | } |
||
42 | |||
43 | void PropertyWidget_ParEffect::setMainWindow(ScribusMainWindow* mw) |
||
44 | { |
||
45 | m_ScMW = mw; |
||
46 | |||
47 | connect(m_ScMW, SIGNAL(AppModeChanged(int, int)), this, SLOT(handleAppModeChanged(int, int))); |
||
48 | connect(m_ScMW, SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int))); |
||
49 | } |
||
50 | |||
51 | void PropertyWidget_ParEffect::setDoc(ScribusDoc *doc) |
||
52 | { |
||
53 | if(doc == (ScribusDoc*) m_doc) |
||
54 | return; |
||
55 | |||
56 | if (m_doc) |
||
57 | { |
||
58 | disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
59 | disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
60 | } |
||
61 | |||
62 | m_doc = doc; |
||
63 | peCharStyleCombo->setDoc(doc); |
||
64 | |||
65 | if (m_doc.isNull()) |
||
66 | { |
||
67 | disconnectSignals(); |
||
68 | return; |
||
69 | } |
||
70 | |||
71 | m_unitRatio = m_doc->unitRatio(); |
||
72 | m_unitIndex = m_doc->unitIndex(); |
||
73 | |||
18534 | jghali | 74 | fillNumerationsCombo(); |
75 | |||
18051 | craig | 76 | connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
77 | connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
18534 | jghali | 78 | |
79 | // Handle properties update when switching document |
||
80 | handleSelectionChanged(); |
||
18051 | craig | 81 | } |
82 | |||
83 | void PropertyWidget_ParEffect::setCurrentItem(PageItem *item) |
||
84 | { |
||
85 | if (item && m_doc.isNull()) |
||
86 | setDoc(item->doc()); |
||
87 | |||
88 | m_item = item; |
||
18534 | jghali | 89 | disconnectSignals(); |
18051 | craig | 90 | |
91 | if (!m_item) return; |
||
92 | |||
93 | if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable()) |
||
94 | { |
||
95 | configureWidgets(); |
||
96 | ParagraphStyle parStyle = m_item->itemText.defaultStyle(); |
||
97 | if (m_doc->appMode == modeEdit) |
||
98 | m_item->currentTextProps(parStyle); |
||
99 | else if (m_doc->appMode == modeEditTable) |
||
100 | m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle); |
||
101 | updateStyle(parStyle); |
||
18534 | jghali | 102 | connectSignals(); |
18051 | craig | 103 | } |
104 | } |
||
105 | |||
106 | void PropertyWidget_ParEffect::unitChange() |
||
107 | { |
||
108 | if (!m_doc) |
||
109 | return; |
||
110 | |||
111 | m_unitRatio = m_doc->unitRatio(); |
||
112 | m_unitIndex = m_doc->unitIndex(); |
||
113 | |||
18534 | jghali | 114 | peOffset->blockSignals(true); |
115 | peOffset->setNewUnit( m_unitIndex ); |
||
116 | peOffset->blockSignals(false); |
||
18051 | craig | 117 | } |
118 | |||
119 | void PropertyWidget_ParEffect::fillNumerationsCombo() |
||
120 | { |
||
121 | QStringList numNames; |
||
122 | if (m_doc) |
||
123 | { |
||
124 | foreach (QString numName, m_doc->numerations.keys()) |
||
125 | numNames.append(numName); |
||
126 | numNames.sort(); |
||
127 | } |
||
128 | numNames.prepend("<local block>"); |
||
129 | numComboBox->clear(); |
||
130 | numComboBox->insertItems(0, numNames); |
||
131 | } |
||
132 | |||
133 | void PropertyWidget_ParEffect::updateCharStyles() |
||
134 | { |
||
135 | peCharStyleCombo->updateFormatList(); |
||
136 | } |
||
137 | |||
138 | void PropertyWidget_ParEffect::displayCharStyle(const QString& name) |
||
139 | { |
||
140 | bool blocked = peCharStyleCombo->blockSignals(true); |
||
141 | peCharStyleCombo->setFormat(name); |
||
142 | peCharStyleCombo->blockSignals(blocked); |
||
143 | } |
||
144 | |||
145 | void PropertyWidget_ParEffect::enableDropCap(bool enable) |
||
146 | { |
||
147 | // dropCapRadio_->setChecked(enable); |
||
148 | dropCapLines->setEnabled(enable); |
||
149 | if (enable) |
||
150 | { |
||
151 | dropCapsGroup->show(); |
||
152 | enableBullet(false); |
||
153 | enableNum(false); |
||
154 | } |
||
155 | else |
||
156 | dropCapsGroup->hide(); |
||
157 | } |
||
158 | void PropertyWidget_ParEffect::enableBullet(bool enable) |
||
159 | { |
||
18534 | jghali | 160 | bulletStrEdit->setVisible(enable); |
161 | bulletCharTableButton->setVisible(enable); |
||
18051 | craig | 162 | bullGroup->setVisible(enable); |
163 | if (enable) |
||
164 | { |
||
165 | enableDropCap(false); |
||
166 | enableNum(false); |
||
167 | } |
||
168 | } |
||
169 | void PropertyWidget_ParEffect::enableNum(bool enable) |
||
170 | { |
||
171 | numComboBox->setVisible(enable); |
||
172 | numLevelSpin->setVisible(enable); |
||
173 | numStart->setVisible(enable); |
||
174 | numPrefix->setVisible(enable); |
||
175 | numSuffix->setVisible(enable); |
||
176 | numFormatCombo->setVisible(enable); |
||
177 | numGroup->setVisible(enable); |
||
178 | if (enable) |
||
179 | { |
||
180 | enableBullet(false); |
||
181 | enableDropCap(false); |
||
182 | } |
||
183 | } |
||
184 | void PropertyWidget_ParEffect::enableParEffect(bool enable) |
||
185 | { |
||
18534 | jghali | 186 | peOffset->setVisible(enable); |
18051 | craig | 187 | peCharStyleCombo->setVisible(enable); |
18534 | jghali | 188 | peIndent->setVisible(enable); |
18051 | craig | 189 | peGroup->setVisible(enable); |
190 | if (!enable) |
||
191 | { |
||
192 | enableBullet(false); |
||
193 | enableDropCap(false); |
||
194 | enableNum(false); |
||
195 | peCombo->setCurrentIndex(0); |
||
196 | } |
||
197 | } |
||
198 | |||
199 | void PropertyWidget_ParEffect::updateStyle(const ParagraphStyle& newPStyle) |
||
200 | { |
||
201 | if (peCombo->currentIndex() && !newPStyle.hasBullet() && !newPStyle.hasDropCap() && !newPStyle.hasNum()) |
||
202 | { |
||
203 | enableParEffect(false); |
||
204 | return; |
||
205 | } |
||
206 | disconnectSignals (); |
||
207 | |||
208 | bool enablePE = true; |
||
209 | if (newPStyle.hasDropCap()) |
||
210 | { |
||
211 | peCombo->setCurrentIndex(1); |
||
212 | enableDropCap(true); |
||
213 | } |
||
214 | else if (newPStyle.hasBullet()) |
||
215 | { |
||
216 | peCombo->setCurrentIndex(2); |
||
217 | enableBullet(true); |
||
218 | } |
||
219 | else if (newPStyle.hasNum()) |
||
220 | { |
||
221 | peCombo->setCurrentIndex(3); |
||
222 | enableNum(true); |
||
223 | } |
||
224 | else |
||
225 | enablePE = false; |
||
226 | |||
227 | QString numName = numComboBox->currentText(); |
||
228 | int nFormat = 0; |
||
229 | dropCapLines->setValue(newPStyle.dropCapLines()); |
||
18534 | jghali | 230 | bulletStrEdit->setEditText(newPStyle.bulletStr()); |
18051 | craig | 231 | numName = newPStyle.numName(); |
232 | if (numName == "") |
||
233 | numName = "<local block>"; |
||
234 | numComboBox->setCurrentIndex(numComboBox->findText(numName)); |
||
235 | NumStruct * numS = m_doc->numerations.value(numName); |
||
236 | if (numS) |
||
237 | numLevelSpin->setMaximum(numS->m_counters.count()+1); |
||
238 | else |
||
239 | numLevelSpin->setMaximum(3); |
||
240 | numLevelSpin->setValue(newPStyle.numLevel() +1); |
||
241 | numPrefix->setText(newPStyle.numPrefix()); |
||
242 | numSuffix->setText(newPStyle.numSuffix()); |
||
243 | numStart->setValue(newPStyle.numStart()); |
||
244 | |||
245 | nFormat = newPStyle.numFormat(); |
||
246 | numFormatCombo->setCurrentIndex(nFormat); |
||
18534 | jghali | 247 | peOffset->setValue(newPStyle.parEffectOffset() * m_unitRatio); |
248 | peIndent->setChecked(newPStyle.parEffectIndent()); |
||
18051 | craig | 249 | displayCharStyle(newPStyle.peCharStyleName()); |
250 | |||
251 | enableParEffect(enablePE); |
||
252 | connectSignals (); |
||
253 | } |
||
254 | |||
255 | void PropertyWidget_ParEffect::connectSignals() |
||
256 | { |
||
257 | connect(peCombo, SIGNAL(activated(int)), this, SLOT(handleParEffectUse()), Qt::UniqueConnection); |
||
258 | connect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines(int)), Qt::UniqueConnection); |
||
18534 | jghali | 259 | connect(bulletStrEdit, SIGNAL(editTextChanged(QString)), this, SLOT(handleBulletStr(QString)), Qt::UniqueConnection); |
18051 | craig | 260 | connect(numComboBox, SIGNAL(activated(QString)), this, SLOT(handleNumName(QString)), Qt::UniqueConnection); |
261 | connect(numLevelSpin, SIGNAL(valueChanged(int)), this, SLOT(handleNumLevel(int)), Qt::UniqueConnection); |
||
262 | connect(numFormatCombo, SIGNAL(activated(int)), this, SLOT(handleNumFormat(int)), Qt::UniqueConnection); |
||
263 | connect(numPrefix, SIGNAL(textChanged(QString)), this, SLOT(handleNumPrefix(QString)), Qt::UniqueConnection); |
||
264 | connect(numSuffix, SIGNAL(textChanged(QString)), this, SLOT(handleNumSuffix(QString)), Qt::UniqueConnection); |
||
265 | connect(numStart, SIGNAL(valueChanged(int)), this, SLOT(handleNumStart(int)), Qt::UniqueConnection); |
||
18534 | jghali | 266 | connect(peOffset, SIGNAL(valueChanged(double)), this, SLOT(handlePEOffset(double)), Qt::UniqueConnection); |
267 | connect(peIndent, SIGNAL(toggled(bool)), this, SLOT(handlePEIndent(bool)), Qt::UniqueConnection); |
||
18051 | craig | 268 | connect(peCharStyleCombo, SIGNAL(activated(QString)), this, SLOT(handlePECharStyle(QString)), Qt::UniqueConnection); |
269 | } |
||
270 | |||
271 | void PropertyWidget_ParEffect::disconnectSignals() |
||
272 | { |
||
273 | disconnect(peCombo, SIGNAL(activated(int)), this, SLOT(handleParEffectUse())); |
||
274 | disconnect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines(int))); |
||
18534 | jghali | 275 | disconnect(bulletStrEdit, SIGNAL(editTextChanged(QString)), this, SLOT(handleBulletStr(QString))); |
18051 | craig | 276 | disconnect(numComboBox, SIGNAL(activated(QString)), this, SLOT(handleNumName(QString))); |
277 | disconnect(numLevelSpin, SIGNAL(valueChanged(int)), this, SLOT(handleNumLevel(int))); |
||
278 | disconnect(numFormatCombo, SIGNAL(activated(int)), this, SLOT(handleNumFormat(int))); |
||
279 | disconnect(numPrefix, SIGNAL(textChanged(QString)), this, SLOT(handleNumPrefix(QString))); |
||
280 | disconnect(numSuffix, SIGNAL(textChanged(QString)), this, SLOT(handleNumSuffix(QString))); |
||
281 | disconnect(numStart, SIGNAL(valueChanged(int)), this, SLOT(handleNumStart(int))); |
||
18534 | jghali | 282 | disconnect(peOffset, SIGNAL(valueChanged(double)), this, SLOT(handlePEOffset(double))); |
283 | disconnect(peIndent, SIGNAL(toggled(bool)), this, SLOT(handlePEIndent(bool))); |
||
18051 | craig | 284 | disconnect(peCharStyleCombo, SIGNAL(activated(QString)), this, SLOT(handlePECharStyle(QString))); |
285 | } |
||
286 | |||
287 | void PropertyWidget_ParEffect::configureWidgets(void) |
||
288 | { |
||
289 | bool enabled = false; |
||
290 | if (m_item && m_doc) |
||
291 | { |
||
292 | PageItem_TextFrame *textItem = m_item->asTextFrame(); |
||
293 | if (m_doc->appMode == modeEditTable) |
||
294 | textItem = m_item->asTable()->activeCell().textFrame(); |
||
295 | if (textItem || m_item->asPathText()) |
||
296 | enabled = true; |
||
297 | } |
||
298 | setEnabled(enabled); |
||
299 | } |
||
300 | |||
301 | void PropertyWidget_ParEffect::handleAppModeChanged(int oldMode, int mode) |
||
302 | { |
||
303 | if (oldMode == modeEditTable || mode == modeEditTable) |
||
304 | { |
||
305 | setCurrentItem(m_item); |
||
306 | } |
||
307 | } |
||
308 | |||
309 | void PropertyWidget_ParEffect::handleSelectionChanged() |
||
310 | { |
||
311 | if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning()) |
||
312 | return; |
||
313 | |||
314 | PageItem* currItem = currentItemFromSelection(); |
||
315 | setCurrentItem(currItem); |
||
316 | updateGeometry(); |
||
317 | repaint(); |
||
318 | } |
||
319 | |||
320 | void PropertyWidget_ParEffect::handleUpdateRequest(int updateFlags) |
||
321 | { |
||
322 | if (updateFlags & reqCharStylesUpdate) |
||
323 | updateCharStyles(); |
||
324 | if (updateFlags & reqStyleComboDocUpdate) |
||
325 | setDoc(m_doc ? m_doc : 0); |
||
326 | if (updateFlags & reqNumUpdate) |
||
327 | fillNumerationsCombo(); |
||
328 | } |
||
329 | |||
330 | void PropertyWidget_ParEffect::handleParEffectUse() |
||
331 | { |
||
332 | if (!m_doc || !m_item) |
||
333 | return; |
||
334 | ParagraphStyle newStyle; |
||
335 | enableParEffect(peCombo->currentIndex() != 0); |
||
336 | if (peCombo->currentIndex() == 1) |
||
337 | { |
||
338 | enableDropCap(true); |
||
339 | newStyle.setDropCapLines(dropCapLines->value()); |
||
340 | newStyle.setHasDropCap(true); |
||
341 | newStyle.setHasBullet(false); |
||
342 | newStyle.setHasNum(false); |
||
343 | } |
||
344 | else if (peCombo->currentIndex() == 2) |
||
345 | { |
||
346 | enableBullet(true); |
||
347 | newStyle.setHasBullet(true); |
||
18534 | jghali | 348 | QString bStr = bulletStrEdit->currentText(); |
18051 | craig | 349 | if (bStr.isEmpty()) |
350 | bStr = QChar(0x2022); |
||
351 | newStyle.setBulletStr(bStr); |
||
352 | newStyle.setHasNum(false); |
||
353 | newStyle.setHasDropCap(false); |
||
354 | } |
||
355 | else if (peCombo->currentIndex() == 3) |
||
356 | { |
||
357 | enableNum(true); |
||
358 | newStyle.setHasDropCap(false); |
||
359 | newStyle.setHasBullet(false); |
||
360 | newStyle.setHasNum(true); |
||
361 | newStyle.setNumName(numComboBox->currentText()); |
||
362 | newStyle.setNumFormat(numFormatCombo->currentIndex()); |
||
363 | newStyle.setNumLevel(numLevelSpin->value() -1); |
||
364 | newStyle.setNumStart(numStart->value()); |
||
365 | newStyle.setNumPrefix(numPrefix->text()); |
||
366 | newStyle.setNumSuffix(numSuffix->text()); |
||
367 | if (newStyle.numName() == "<local block>") |
||
368 | { |
||
369 | newStyle.setNumOther(true); |
||
370 | newStyle.setNumHigher(true); |
||
371 | } |
||
372 | } |
||
373 | else |
||
374 | { |
||
375 | newStyle.setHasDropCap(false); |
||
376 | newStyle.setHasBullet(false); |
||
377 | newStyle.setHasNum(false); |
||
378 | } |
||
18534 | jghali | 379 | newStyle.setParEffectOffset(peOffset->value() / m_unitRatio); |
380 | newStyle.setParEffectIndent(peIndent->isChecked()); |
||
18051 | craig | 381 | handleChanges(m_item, newStyle); |
382 | } |
||
383 | |||
384 | void PropertyWidget_ParEffect::handleBulletStr(QString bulStr) |
||
385 | { |
||
386 | if (!m_doc || !m_item) |
||
387 | return; |
||
388 | ParagraphStyle newStyle; |
||
389 | if (bulStr.isEmpty()) |
||
390 | bulStr = QChar(0x2022); |
||
391 | newStyle.setBulletStr(bulStr); |
||
392 | handleChanges(m_item, newStyle); |
||
393 | } |
||
394 | |||
395 | void PropertyWidget_ParEffect::handleDropCapLines(int dcLines) |
||
396 | { |
||
397 | if (!m_doc || !m_item) |
||
398 | return; |
||
399 | ParagraphStyle newStyle; |
||
400 | newStyle.setDropCapLines(dcLines); |
||
401 | handleChanges(m_item, newStyle); |
||
402 | } |
||
403 | |||
404 | void PropertyWidget_ParEffect::handleNumName(QString numName) |
||
405 | { |
||
406 | if (!m_doc || !m_item) |
||
407 | return; |
||
408 | disconnectSignals(); |
||
409 | ParagraphStyle newStyle; |
||
410 | if (numName == "<local block>") |
||
411 | { |
||
412 | newStyle.setNumOther(true); |
||
413 | newStyle.setNumHigher(true); |
||
414 | newStyle.setNumRestart(NSRstory); |
||
415 | } |
||
416 | else |
||
417 | { |
||
418 | NumStruct * numS = m_doc->numerations.value(numName); |
||
419 | Q_ASSERT(numS); |
||
420 | int level = qMin(numLevelSpin->value(), numS->m_counters.count()) -1; |
||
421 | numLevelSpin->setValue(level +1); |
||
422 | newStyle.setNumLevel(level); |
||
423 | Numeration num = numS->m_nums[level]; |
||
424 | numFormatCombo->setCurrentIndex((int) num.numFormat); |
||
425 | numStart->setValue(num.start); |
||
426 | numPrefix->setText(num.prefix); |
||
427 | numSuffix->setText(num.suffix); |
||
428 | } |
||
429 | newStyle.setNumPrefix(numPrefix->text()); |
||
430 | newStyle.setNumSuffix(numSuffix->text()); |
||
431 | newStyle.setNumName(numName); |
||
432 | newStyle.setNumFormat((NumFormat) numFormatCombo->currentIndex()); |
||
433 | handleChanges(m_item, newStyle); |
||
434 | connectSignals(); |
||
435 | } |
||
436 | |||
437 | void PropertyWidget_ParEffect::handleNumFormat(int style) |
||
438 | { |
||
439 | if (!m_doc || !m_item) |
||
440 | return; |
||
441 | ParagraphStyle newStyle; |
||
442 | newStyle.setNumFormat(style); |
||
443 | handleChanges(m_item, newStyle); |
||
444 | } |
||
445 | |||
446 | void PropertyWidget_ParEffect::handleNumLevel(int level) |
||
447 | { |
||
448 | if (!m_doc || !m_item) |
||
449 | return; |
||
450 | if ((numComboBox->currentText() != "<local block>") && level == numLevelSpin->maximum()) |
||
451 | { |
||
452 | NumStruct * numS = m_doc->numerations.value(numComboBox->currentText()); |
||
453 | Q_ASSERT(numS); |
||
454 | while (level > numS->m_counters.count()) |
||
455 | { |
||
456 | numS->m_counters.append(0); |
||
457 | Numeration num; |
||
458 | num.numFormat = (NumFormat) numFormatCombo->currentIndex(); |
||
459 | num.prefix = numPrefix->text(); |
||
460 | num.suffix = numSuffix->text(); |
||
461 | num.start = numStart->value(); |
||
462 | numS->m_nums.append(num); |
||
463 | } |
||
464 | } |
||
465 | ParagraphStyle newStyle; |
||
466 | newStyle.setNumLevel(level -1); |
||
467 | handleChanges(m_item, newStyle); |
||
468 | } |
||
469 | |||
470 | void PropertyWidget_ParEffect::handleNumPrefix(QString prefix) |
||
471 | { |
||
472 | if (!m_doc || !m_item) |
||
473 | return; |
||
474 | ParagraphStyle newStyle; |
||
475 | newStyle.setNumPrefix(prefix); |
||
476 | handleChanges(m_item, newStyle); |
||
477 | } |
||
478 | |||
479 | void PropertyWidget_ParEffect::handleNumSuffix(QString suffix) |
||
480 | { |
||
481 | if (!m_doc || !m_item) |
||
482 | return; |
||
483 | ParagraphStyle newStyle; |
||
484 | newStyle.setNumSuffix(suffix); |
||
485 | handleChanges(m_item, newStyle); |
||
486 | } |
||
487 | |||
488 | void PropertyWidget_ParEffect::handleNumStart(int start) |
||
489 | { |
||
490 | if (!m_doc || !m_item) |
||
491 | return; |
||
492 | ParagraphStyle newStyle; |
||
493 | newStyle.setNumStart(start); |
||
494 | handleChanges(m_item, newStyle); |
||
495 | } |
||
496 | |||
497 | void PropertyWidget_ParEffect::handlePEOffset(double offset) |
||
498 | { |
||
499 | if (!m_doc || !m_item) |
||
500 | return; |
||
501 | ParagraphStyle newStyle; |
||
18063 | jghali | 502 | newStyle.setParEffectOffset(offset / m_unitRatio); |
18051 | craig | 503 | handleChanges(m_item, newStyle); |
504 | } |
||
505 | |||
506 | void PropertyWidget_ParEffect::handlePEIndent(bool indent) |
||
507 | { |
||
508 | if (!m_doc || !m_item) |
||
509 | return; |
||
510 | ParagraphStyle newStyle; |
||
511 | newStyle.setParEffectIndent(indent); |
||
512 | handleChanges(m_item, newStyle); |
||
513 | } |
||
514 | |||
515 | void PropertyWidget_ParEffect::handlePECharStyle(QString name) |
||
516 | { |
||
517 | if (!m_doc || !m_item) |
||
518 | return; |
||
519 | ParagraphStyle newStyle; |
||
520 | if (!name.isEmpty()) |
||
521 | newStyle.setPeCharStyleName(name); |
||
522 | handleChanges(m_item, newStyle); |
||
523 | } |
||
524 | |||
525 | void PropertyWidget_ParEffect::changeEvent(QEvent *e) |
||
526 | { |
||
527 | if (e->type() == QEvent::LanguageChange) |
||
528 | { |
||
529 | languageChange(); |
||
530 | return; |
||
531 | } |
||
532 | QWidget::changeEvent(e); |
||
533 | } |
||
534 | |||
535 | void PropertyWidget_ParEffect::handleChanges(PageItem *item, ParagraphStyle &newStyle) |
||
536 | { |
||
537 | if (m_doc->appMode == modeEditTable) |
||
538 | item = item->asTable()->activeCell().textFrame(); |
||
539 | if (item != NULL) |
||
540 | { |
||
541 | disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
542 | disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
543 | |||
544 | Selection tempSelection(this, false); |
||
545 | tempSelection.addItem(item, true); |
||
546 | m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); |
||
547 | m_doc->updateNumbers(); |
||
548 | |||
549 | connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); |
||
550 | connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); |
||
551 | } |
||
552 | } |
||
553 | |||
554 | void PropertyWidget_ParEffect::languageChange() |
||
555 | { |
||
556 | fillPECombo(); |
||
557 | dropCapLinesLabel->setText(tr("Lines")); |
||
558 | dropCapsGroup->setTitle(tr("Drop Caps")); |
||
559 | bullGroup->setTitle(tr("Bulleted List")); |
||
560 | bulletCharLabel->setText(tr("Bullet Char(s)")); |
||
18534 | jghali | 561 | bulletCharTableButton->setToolTip(tr("Enhanced char table to choose bullet chars")); |
562 | bulletCharTableButton->setText(tr("Char Table")); |
||
18051 | craig | 563 | numGroup->setTitle(tr("Numbered List")); |
564 | numLevelLabel->setText(tr("Level")); |
||
565 | numComboLabel->setText(tr("Set")); |
||
566 | numFormatLabel->setText(tr("Format")); |
||
567 | numStartLabel->setText(tr("Start")); |
||
568 | numPrefixLabel->setText(tr("Prefix")); |
||
569 | numSuffixLabel->setText(tr("Suffix")); |
||
570 | peOffsetLabel->setText(tr("Offset")); |
||
18534 | jghali | 571 | peIndent->setText(tr("Auto-Indent")); |
18051 | craig | 572 | peCharStyleLabel->setText(tr("Char Style")); |
573 | peCharStyleCombo->setToolTip(tr("Choose chracter style or leave blank for use default paragraph style")); |
||
574 | } |
||
575 | |||
576 | void PropertyWidget_ParEffect::openEnhanced() |
||
577 | { |
||
578 | if (m_enhanced) |
||
579 | return; |
||
580 | |||
581 | QApplication::changeOverrideCursor(QCursor(Qt::WaitCursor)); |
||
582 | m_enhanced = new CharSelectEnhanced(this); |
||
583 | m_enhanced->setModal(true); |
||
584 | connect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)), this, SLOT(insertSpecialChars(const QString &))); |
||
18534 | jghali | 585 | connect(m_enhanced, SIGNAL(paletteShown(bool)), bulletCharTableButton, SLOT(setChecked(bool))); |
18051 | craig | 586 | m_enhanced->setDoc(m_doc); |
587 | m_enhanced->setEnabled(true); |
||
588 | QString styleName = peCharStyleCombo->currentText(); |
||
589 | setCurrentComboItem(m_enhanced->fontSelector, m_item->currentStyle().charStyle().font().scName()); |
||
590 | m_enhanced->newFont(m_enhanced->fontSelector->currentIndex()); |
||
591 | m_enhanced->show(); |
||
592 | QApplication::changeOverrideCursor(Qt::ArrowCursor); |
||
593 | } |
||
594 | |||
595 | void PropertyWidget_ParEffect::closeEnhanced(bool show) |
||
596 | { |
||
597 | if (!m_enhanced || show) |
||
598 | return; |
||
599 | disconnect(m_enhanced, SIGNAL(insertSpecialChars(const QString &)), this, SLOT(insertSpecialChars(const QString &))); |
||
18534 | jghali | 600 | disconnect(m_enhanced, SIGNAL(paletteShown(bool)), bulletCharTableButton, SLOT(setChecked(bool))); |
18051 | craig | 601 | m_enhanced->close(); |
602 | delete m_enhanced; |
||
603 | m_enhanced = NULL; |
||
604 | } |
||
605 | |||
18534 | jghali | 606 | void PropertyWidget_ParEffect::on_bulletCharTableButton_toggled(bool checked) |
18051 | craig | 607 | { |
608 | if (m_enhanced && !checked) |
||
609 | closeEnhanced(); |
||
610 | else if (!m_enhanced && checked) |
||
611 | openEnhanced(); |
||
612 | } |
||
613 | void PropertyWidget_ParEffect::insertSpecialChars(const QString &chars) |
||
614 | { |
||
18534 | jghali | 615 | bulletStrEdit->lineEdit()->setText(chars); |
18051 | craig | 616 | } |