Rev 11360 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
102 | Franz | 7 | /*************************************************************************** |
8 | story.cpp - description |
||
9 | ------------------- |
||
10 | begin : Tue Nov 11 2003 |
||
11 | copyright : (C) 2003 by Franz Schmid |
||
12 | email : Franz.Schmid@altmuehlnet.de |
||
13 | ***************************************************************************/ |
||
14 | |||
15 | /*************************************************************************** |
||
16 | * * |
||
17 | * This program is free software; you can redistribute it and/or modify * |
||
18 | * it under the terms of the GNU General Public License as published by * |
||
19 | * the Free Software Foundation; either version 2 of the License, or * |
||
20 | * (at your option) any later version. * |
||
21 | * * |
||
22 | ***************************************************************************/ |
||
10644 | cbradney | 23 | |
24 | #include <QApplication> |
||
25 | #include <QCloseEvent> |
||
26 | #include <QColorDialog> |
||
10220 | cbradney | 27 | #include <QComboBox> |
28 | #include <QCursor> |
||
8601 | jghali | 29 | #include <QDesktopWidget> |
10644 | cbradney | 30 | #include <QEvent> |
8501 | cbradney | 31 | #include <QFocusEvent> |
10644 | cbradney | 32 | #include <QFontDialog> |
33 | #include <QFrame> |
||
34 | #include <QGridLayout> |
||
10180 | fschmid | 35 | #include <QHBoxLayout> |
8501 | cbradney | 36 | #include <QHideEvent> |
10644 | cbradney | 37 | #include <QKeyEvent> |
38 | #include <QLabel> |
||
39 | #include <QList> |
||
40 | #include <QMouseEvent> |
||
8501 | cbradney | 41 | #include <QPaintEvent> |
9525 | fschmid | 42 | #include <QPalette> |
10644 | cbradney | 43 | #include <QPixmap> |
44 | #include <QRegExp> |
||
45 | #include <QShowEvent> |
||
46 | #include <QTextBlock> |
||
47 | #include <QTextCodec> |
||
48 | #include <QTextLayout> |
||
49 | #include <QToolTip> |
||
3732 | cbradney | 50 | |
4557 | cbradney | 51 | #include "actionmanager.h" |
3732 | cbradney | 52 | #include "alignselect.h" |
53 | #include "charselect.h" |
||
10644 | cbradney | 54 | #include "colorcombo.h" |
7747 | jghali | 55 | #include "colorlistbox.h" |
3732 | cbradney | 56 | #include "commonstrings.h" |
162 | Franz | 57 | #include "customfdialog.h" |
3732 | cbradney | 58 | #include "fontcombo.h" |
4550 | cbradney | 59 | #include "menumanager.h" |
3732 | cbradney | 60 | #include "pageitem.h" |
10601 | mrdocs | 61 | #include "pageitem_textframe.h" |
3732 | cbradney | 62 | #include "pluginmanager.h" |
415 | Franz | 63 | #include "prefscontext.h" |
10644 | cbradney | 64 | #include "prefsfile.h" |
3252 | craig | 65 | #include "prefsmanager.h" |
10644 | cbradney | 66 | #include "scfonts.h" |
3732 | cbradney | 67 | #include "scmessagebox.h" |
10644 | cbradney | 68 | #include "scplugin.h" |
3732 | cbradney | 69 | #include "scraction.h" |
5781 | cbradney | 70 | #include "scribuscore.h" |
10644 | cbradney | 71 | #include "scrspinbox.h" |
3732 | cbradney | 72 | #include "search.h" |
3135 | cbradney | 73 | #include "serializer.h" |
3732 | cbradney | 74 | #include "shadebutton.h" |
3252 | craig | 75 | #include "spalette.h" |
10644 | cbradney | 76 | #include "story.h" |
8448 | jghali | 77 | #include "styleitem.h" |
10644 | cbradney | 78 | #include "stylemanager.h" |
3252 | craig | 79 | #include "styleselect.h" |
10644 | cbradney | 80 | #include "text/nlsconfig.h" |
3809 | cbradney | 81 | #include "util.h" |
10200 | cbradney | 82 | #include "util_icon.h" |
10965 | fschmid | 83 | |
11360 | jghali | 84 | class StyledTextMimeData : public QMimeData |
85 | { |
||
86 | protected: |
||
87 | StoryText m_styledText; |
||
88 | |||
89 | public: |
||
90 | const StoryText& styledText(void) const { return m_styledText; } |
||
91 | void setStyledText(const StoryText& text) |
||
92 | { |
||
93 | QByteArray styledTextData (sizeof(void*), 0); |
||
94 | m_styledText.clear(); |
||
95 | m_styledText.insert(0, text, true); |
||
96 | styledTextData.setNum((quintptr)((quintptr*) &m_styledText)); |
||
11361 | jghali | 97 | setData("application/x-scribus-styledtext", styledTextData); |
11360 | jghali | 98 | }; |
99 | }; |
||
100 | |||
371 | Franz | 101 | SideBar::SideBar(QWidget *pa) : QLabel(pa) |
102 | { |
||
9525 | fschmid | 103 | QPalette pal; |
104 | pal.setColor(QPalette::Window, QColor(255,255,255)); |
||
105 | setAutoFillBackground(true); |
||
106 | setPalette(pal); |
||
371 | Franz | 107 | offs = 0; |
108 | editor = 0; |
||
372 | Franz | 109 | noUpdt = true; |
373 | Franz | 110 | inRep = false; |
9525 | fschmid | 111 | pmen = new QMenu(this); |
373 | Franz | 112 | setMinimumWidth(fontMetrics().width( tr("No Style") )+30); |
371 | Franz | 113 | } |
114 | |||
374 | Franz | 115 | void SideBar::mouseReleaseEvent(QMouseEvent *m) |
116 | { |
||
10643 | fschmid | 117 | int p = editor->cursorForPosition(QPoint(2, m->y()+offs)).position(); |
118 | CurrentPar = editor->StyledText.nrOfParagraph(p); |
||
119 | int pos = editor->StyledText.startOfParagraph(p); |
||
120 | |||
7990 | cbradney | 121 | ParaStyleComboBox* paraStyleCombo = new ParaStyleComboBox(this); |
7992 | cbradney | 122 | paraStyleCombo->setDoc(editor->doc); |
6900 | avox | 123 | if ((CurrentPar < static_cast<int>(editor->StyledText.nrOfParagraphs())) && (editor->StyledText.length() != 0)) |
374 | Franz | 124 | { |
7087 | subik | 125 | int len = editor->StyledText.endOfParagraph(CurrentPar) - editor->StyledText.startOfParagraph(CurrentPar); |
6900 | avox | 126 | if (len > 0) |
7990 | cbradney | 127 | paraStyleCombo->setFormat(editor->StyledText.paragraphStyle(pos).displayName()); |
374 | Franz | 128 | else |
7990 | cbradney | 129 | paraStyleCombo->setFormat(""); |
374 | Franz | 130 | } |
131 | else |
||
7990 | cbradney | 132 | paraStyleCombo->setFormat(""); |
9067 | avox | 133 | connect(paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setPStyle(const QString&))); |
8601 | jghali | 134 | pmen->clear(); |
9525 | fschmid | 135 | paraStyleAct = new QWidgetAction(this); |
136 | paraStyleAct->setDefaultWidget(paraStyleCombo); |
||
10643 | fschmid | 137 | pmen->addAction(paraStyleAct); |
138 | pmen->addAction( tr("Edit Styles..."), this, SLOT(editStyles())); |
||
139 | pmen->exec(QCursor::pos()); |
||
374 | Franz | 140 | } |
141 | |||
1893 | subik | 142 | void SideBar::editStyles() |
143 | { |
||
144 | emit sigEditStyles(); |
||
145 | } |
||
146 | |||
9067 | avox | 147 | void SideBar::setPStyle(const QString& name) |
374 | Franz | 148 | { |
9067 | avox | 149 | emit ChangeStyle(CurrentPar, name); |
10643 | fschmid | 150 | pmen->close(); |
374 | Franz | 151 | } |
152 | |||
371 | Franz | 153 | void SideBar::paintEvent(QPaintEvent *e) |
154 | { |
||
373 | Franz | 155 | inRep = true; |
371 | Franz | 156 | QLabel::paintEvent(e); |
10643 | fschmid | 157 | QList<QRect> paraList; |
10965 | fschmid | 158 | for (uint pr = 0; pr < editor->StyledText.nrOfParagraphs(); ++pr) |
10643 | fschmid | 159 | { |
10965 | fschmid | 160 | int pos = editor->StyledText.startOfParagraph(pr); |
161 | QTextCursor cur(editor->document()); |
||
162 | cur.setPosition(pos); |
||
163 | QTextBlock tb = cur.block(); |
||
10643 | fschmid | 164 | paraList.append(tb.layout()->boundingRect().toRect()); |
165 | } |
||
166 | QPainter p; |
||
371 | Franz | 167 | p.begin(this); |
372 | Franz | 168 | if ((editor != 0) && (noUpdt)) |
371 | Franz | 169 | { |
10643 | fschmid | 170 | int gesY = 0; |
6900 | avox | 171 | for (uint pa = 0; pa < editor->StyledText.nrOfParagraphs(); ++pa) |
371 | Franz | 172 | { |
10643 | fschmid | 173 | QRect re = paraList[pa]; |
373 | Franz | 174 | if (!re.isValid()) |
175 | break; |
||
10965 | fschmid | 176 | int hh = re.height(); |
371 | Franz | 177 | re.setWidth(width()-5); |
10965 | fschmid | 178 | re.setHeight(re.height()-2); |
179 | re.translate(5, 2); |
||
10643 | fschmid | 180 | if (((re.y()+re.height())-offs + gesY < height()) && ((re.y()+re.height())-offs + gesY >= 0)) |
181 | p.drawLine(0, (re.y()+re.height())-offs + gesY, width()-1, (re.y()+re.height())-offs + gesY); |
||
182 | if ((re.y()-offs + gesY < height()) && (re.y()-offs + gesY >= 0)) |
||
371 | Franz | 183 | { |
10965 | fschmid | 184 | re.moveTop(gesY-offs+2); |
6900 | avox | 185 | QString parname = editor->StyledText.paragraphStyle(editor->StyledText.startOfParagraph(pa)).parent(); |
186 | if (parname.isEmpty()) |
||
187 | parname = tr("No Style"); |
||
188 | p.drawText(re, Qt::AlignLeft | Qt::AlignTop, parname); |
||
371 | Franz | 189 | } |
10965 | fschmid | 190 | gesY += hh; |
371 | Franz | 191 | } |
192 | } |
||
10643 | fschmid | 193 | p.end(); |
373 | Franz | 194 | inRep = false; |
371 | Franz | 195 | } |
196 | |||
795 | fschmid | 197 | void SideBar::doMove(int, int y) |
371 | Franz | 198 | { |
10643 | fschmid | 199 | offs -= y; |
373 | Franz | 200 | if (!inRep) |
201 | update(); |
||
371 | Franz | 202 | } |
203 | |||
204 | void SideBar::doRepaint() |
||
205 | { |
||
373 | Franz | 206 | if (!inRep) |
207 | update(); |
||
371 | Franz | 208 | } |
209 | |||
372 | Franz | 210 | void SideBar::setRepaint(bool r) |
211 | { |
||
212 | noUpdt = r; |
||
213 | } |
||
10965 | fschmid | 214 | |
10628 | fschmid | 215 | SEditor::SEditor(QWidget* parent, ScribusDoc *docc, StoryEditor* parentSE) : QTextEdit(parent) |
102 | Franz | 216 | { |
2494 | cbradney | 217 | setCurrentDocument(docc); |
4552 | cbradney | 218 | parentStoryEditor=parentSE; |
353 | Franz | 219 | wasMod = false; |
385 | Franz | 220 | StoredSel = false; |
8239 | avox | 221 | SelCharStart = 0; |
222 | SelParaStart = 0; |
||
351 | Franz | 223 | StyledText.clear(); |
10628 | fschmid | 224 | document()->setUndoRedoEnabled(true); |
355 | Franz | 225 | viewport()->setAcceptDrops(false); |
376 | Franz | 226 | ClipData = 0; |
3034 | cbradney | 227 | unicodeTextEditMode = false; |
10628 | fschmid | 228 | setAutoFillBackground(true); |
376 | Franz | 229 | connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
102 | Franz | 230 | } |
231 | |||
2494 | cbradney | 232 | void SEditor::setCurrentDocument(ScribusDoc *docc) |
233 | { |
||
234 | doc = docc; |
||
7369 | avox | 235 | StyledText = StoryText(docc); |
2494 | cbradney | 236 | } |
237 | |||
8637 | cbradney | 238 | void SEditor::inputMethodEvent(QInputMethodEvent *event) |
2233 | fschmid | 239 | { |
8637 | cbradney | 240 | QString uc = event->commitString(); |
5980 | avox | 241 | if ((!uc.isEmpty()) && ((*doc->AllFonts)[CurrFont].canRender(uc[0]))) |
2233 | fschmid | 242 | { |
8637 | cbradney | 243 | insChars(event->commitString()); |
10628 | fschmid | 244 | QTextEdit::inputMethodEvent(event); |
10965 | fschmid | 245 | emit SideBarUp(true); |
246 | emit SideBarUpdate(); |
||
2233 | fschmid | 247 | } |
248 | } |
||
249 | |||
351 | Franz | 250 | void SEditor::keyPressEvent(QKeyEvent *k) |
113 | Franz | 251 | { |
10965 | fschmid | 252 | emit SideBarUp(false); |
10628 | fschmid | 253 | int pos = textCursor().position(); |
2369 | cbradney | 254 | int keyMod=0; |
10390 | cbradney | 255 | if (k->modifiers() & Qt::ShiftModifier) |
8523 | cbradney | 256 | keyMod |= Qt::SHIFT; |
10390 | cbradney | 257 | if (k->modifiers() & Qt::ControlModifier) |
8523 | cbradney | 258 | keyMod |= Qt::CTRL; |
10390 | cbradney | 259 | if (k->modifiers() & Qt::AltModifier) |
8523 | cbradney | 260 | keyMod |= Qt::ALT; |
3767 | subik | 261 | |
926 | fschmid | 262 | QString uc = k->text(); |
10390 | cbradney | 263 | if ((k->modifiers() == Qt::ControlModifier) || |
10918 | jghali | 264 | (k->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) || |
265 | (k->modifiers() == (Qt::ControlModifier | Qt::KeypadModifier)) || |
||
266 | (k->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier | Qt::KeypadModifier)) |
||
10390 | cbradney | 267 | ) |
351 | Franz | 268 | { |
10390 | cbradney | 269 | switch (k->key()) |
270 | { |
||
271 | case Qt::Key_Delete: |
||
10628 | fschmid | 272 | moveCursor(QTextCursor::NextWord, QTextCursor::KeepAnchor); |
10390 | cbradney | 273 | deleteSel(); |
274 | break; |
||
275 | case Qt::Key_Backspace: |
||
10628 | fschmid | 276 | moveCursor(QTextCursor::PreviousWord, QTextCursor::KeepAnchor); |
10390 | cbradney | 277 | deleteSel(); |
278 | break; |
||
279 | case Qt::Key_K: |
||
10628 | fschmid | 280 | moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); |
10390 | cbradney | 281 | deleteSel(); |
282 | break; |
||
283 | case Qt::Key_D: |
||
10628 | fschmid | 284 | moveCursor(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); |
10390 | cbradney | 285 | deleteSel(); |
10628 | fschmid | 286 | textCursor().removeSelectedText(); |
10390 | cbradney | 287 | break; |
288 | case Qt::Key_H: |
||
10628 | fschmid | 289 | moveCursor(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); |
10390 | cbradney | 290 | deleteSel(); |
10628 | fschmid | 291 | textCursor().removeSelectedText(); |
10390 | cbradney | 292 | break; |
293 | case Qt::Key_X: |
||
294 | cut(); |
||
295 | return; |
||
296 | break; |
||
297 | case Qt::Key_V: |
||
298 | paste(); |
||
299 | return; |
||
300 | break; |
||
301 | case Qt::Key_Y: |
||
302 | case Qt::Key_Z: |
||
10965 | fschmid | 303 | emit SideBarUp(true); |
10390 | cbradney | 304 | return; |
305 | break; |
||
306 | } |
||
307 | } |
||
308 | if ((k->modifiers() == Qt::NoModifier) || |
||
309 | (k->modifiers() == Qt::KeypadModifier) || |
||
310 | (k->modifiers() == Qt::ShiftModifier) || |
||
10918 | jghali | 311 | (k->modifiers() == (Qt::ControlModifier | Qt::AltModifier)) || |
312 | (k->modifiers() == (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier)) // Shift + AltGr on Windows for polish characters |
||
10390 | cbradney | 313 | ) |
314 | { |
||
315 | if (unicodeTextEditMode) |
||
316 | { |
||
317 | int conv = 0; |
||
318 | bool ok = false; |
||
319 | unicodeInputString += k->text(); |
||
320 | conv = unicodeInputString.toInt(&ok, 16); |
||
321 | if (!ok) |
||
1866 | fschmid | 322 | { |
10390 | cbradney | 323 | unicodeTextEditMode = false; |
324 | unicodeInputCount = 0; |
||
325 | unicodeInputString = ""; |
||
326 | return; |
||
327 | } |
||
328 | unicodeInputCount++; |
||
329 | if (unicodeInputCount == 4) |
||
330 | { |
||
331 | unicodeTextEditMode = false; |
||
332 | unicodeInputCount = 0; |
||
333 | unicodeInputString = ""; |
||
334 | if (ok) |
||
335 | { |
||
336 | if (conv < 31) |
||
337 | conv = 32; |
||
338 | insChars(QString(QChar(conv))); |
||
10628 | fschmid | 339 | insertPlainText(QString(QChar(conv))); |
10965 | fschmid | 340 | emit SideBarUp(true); |
341 | emit SideBarUpdate(); |
||
1866 | fschmid | 342 | return; |
10390 | cbradney | 343 | } |
1866 | fschmid | 344 | } |
10390 | cbradney | 345 | else |
351 | Franz | 346 | { |
10965 | fschmid | 347 | emit SideBarUp(true); |
348 | emit SideBarUpdate(); |
||
10390 | cbradney | 349 | return; |
350 | } |
||
351 | } |
||
352 | wasMod = false; |
||
353 | switch (k->key()) |
||
354 | { |
||
355 | case Qt::Key_Escape: |
||
356 | k->ignore(); |
||
357 | break; |
||
358 | case Qt::Key_Shift: |
||
359 | case Qt::Key_Control: |
||
360 | case Qt::Key_Alt: |
||
361 | wasMod = true; |
||
362 | break; |
||
363 | case Qt::Key_F12: |
||
364 | unicodeTextEditMode = true; |
||
365 | unicodeInputCount = 0; |
||
366 | unicodeInputString = ""; |
||
367 | return; |
||
368 | break; |
||
369 | case Qt::Key_Delete: |
||
10628 | fschmid | 370 | if (!textCursor().hasSelection()) |
351 | Franz | 371 | { |
10390 | cbradney | 372 | if (pos < StyledText.length()) |
373 | StyledText.removeChars(pos, 1); |
||
351 | Franz | 374 | } |
10390 | cbradney | 375 | else |
376 | deleteSel(); |
||
377 | break; |
||
378 | case Qt::Key_Backspace: |
||
10628 | fschmid | 379 | if (!textCursor().hasSelection()) |
351 | Franz | 380 | { |
10390 | cbradney | 381 | if (pos > 0) |
382 | StyledText.removeChars(pos-1, 1); |
||
351 | Franz | 383 | } |
384 | else |
||
10390 | cbradney | 385 | deleteSel(); |
386 | break; |
||
387 | case Qt::Key_Return: |
||
388 | case Qt::Key_Enter: |
||
372 | Franz | 389 | { |
10628 | fschmid | 390 | if (textCursor().hasSelection()) |
391 | { |
||
10390 | cbradney | 392 | pos = StyledText.startOfSelection(); |
393 | deleteSel(); |
||
394 | } |
||
10671 | fschmid | 395 | StyledText.insertChars(pos, SpecialChars::PARSEP, true); |
10390 | cbradney | 396 | } |
397 | break; |
||
398 | case Qt::Key_Left: |
||
399 | case Qt::Key_Right: |
||
10581 | cbradney | 400 | case Qt::Key_PageUp: |
401 | case Qt::Key_PageDown: |
||
10390 | cbradney | 402 | case Qt::Key_Up: |
403 | case Qt::Key_Down: |
||
404 | case Qt::Key_Home: |
||
405 | case Qt::Key_End: |
||
406 | break; |
||
407 | default: |
||
408 | if ((!k->text().isEmpty()) && ((*doc->AllFonts)[CurrFont].canRender(uc[0]))) |
||
409 | { |
||
410 | insChars(k->text()); |
||
10628 | fschmid | 411 | QTextEdit::keyPressEvent(k); |
10965 | fschmid | 412 | emit SideBarUp(true); |
413 | emit SideBarUpdate(); |
||
372 | Franz | 414 | } |
10390 | cbradney | 415 | return; |
416 | break; |
||
417 | } |
||
351 | Franz | 418 | } |
10628 | fschmid | 419 | QTextEdit::keyPressEvent(k); |
10965 | fschmid | 420 | emit SideBarUp(true); |
421 | emit SideBarUpdate(); |
||
113 | Franz | 422 | } |
423 | |||
385 | Franz | 424 | void SEditor::focusOutEvent(QFocusEvent *e) |
425 | { |
||
10628 | fschmid | 426 | if (textCursor().hasSelection()) |
385 | Franz | 427 | { |
10628 | fschmid | 428 | SelParaStart = textCursor().selectionStart(); |
429 | SelParaEnd = textCursor().selectionEnd(); |
||
385 | Franz | 430 | StoredSel = true; |
431 | } |
||
10628 | fschmid | 432 | else |
433 | { |
||
434 | SelParaStart = textCursor().position(); |
||
385 | Franz | 435 | StoredSel = false; |
7888 | avox | 436 | } |
10628 | fschmid | 437 | QTextEdit::focusOutEvent(e); |
385 | Franz | 438 | } |
439 | |||
7395 | fschmid | 440 | void SEditor::focusInEvent(QFocusEvent *e) |
441 | { |
||
442 | if (StoredSel) |
||
443 | { |
||
10628 | fschmid | 444 | textCursor().setPosition(SelParaStart); |
10671 | fschmid | 445 | textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor); |
7395 | fschmid | 446 | StoredSel = false; |
447 | } |
||
10628 | fschmid | 448 | else |
449 | { |
||
450 | textCursor().setPosition(SelParaStart); |
||
8239 | avox | 451 | StoredSel = false; |
452 | } |
||
453 | |||
10628 | fschmid | 454 | QTextEdit::focusInEvent(e); |
7395 | fschmid | 455 | } |
456 | |||
351 | Franz | 457 | void SEditor::insChars(QString t) |
102 | Franz | 458 | { |
10628 | fschmid | 459 | if (textCursor().hasSelection()) |
351 | Franz | 460 | deleteSel(); |
10628 | fschmid | 461 | int pos = qMin(textCursor().position(), StyledText.length()); |
9646 | avox | 462 | StyledText.insertChars(pos, t, true); |
351 | Franz | 463 | } |
464 | |||
11360 | jghali | 465 | void SEditor::insStyledText(const StoryText& styledText) |
362 | Franz | 466 | { |
11360 | jghali | 467 | if (styledText.length() == 0) |
362 | Franz | 468 | return; |
10628 | fschmid | 469 | if (textCursor().hasSelection()) |
362 | Franz | 470 | deleteSel(); |
10628 | fschmid | 471 | int pos = qMin(textCursor().position(), StyledText.length()); |
11360 | jghali | 472 | StyledText.insert(pos, styledText); |
362 | Franz | 473 | } |
474 | |||
1957 | cbradney | 475 | void SEditor::saveItemText(PageItem *currItem) |
351 | Franz | 476 | { |
1957 | cbradney | 477 | currItem->CPos = 0; |
478 | currItem->itemText.clear(); |
||
9613 | avox | 479 | currItem->itemText.setDefaultStyle(StyledText.defaultStyle()); |
6900 | avox | 480 | currItem->itemText.append(StyledText); |
481 | /* uh... FIXME |
||
482 | if (ch == SpecialChars::OBJECT) |
||
253 | Franz | 483 | { |
5184 | avox | 484 | PageItem* embedded = chars->at(c)->cembedded; |
5781 | cbradney | 485 | currItem->doc()->FrameItems.append(embedded); |
5184 | avox | 486 | if (embedded->Groups.count() != 0) |
2955 | fschmid | 487 | { |
488 | for (uint ga=0; ga<FrameItems.count(); ++ga) |
||
489 | { |
||
490 | if (FrameItems.at(ga)->Groups.count() != 0) |
||
491 | { |
||
5184 | avox | 492 | if (FrameItems.at(ga)->Groups.top() == embedded->Groups.top()) |
2955 | fschmid | 493 | { |
5184 | avox | 494 | if (FrameItems.at(ga)->ItemNr != embedded->ItemNr) |
2955 | fschmid | 495 | { |
5781 | cbradney | 496 | if (currItem->doc()->FrameItems.find(FrameItems.at(ga)) == -1) |
497 | currItem->doc()->FrameItems.append(FrameItems.at(ga)); |
||
2955 | fschmid | 498 | } |
499 | } |
||
500 | } |
||
501 | } |
||
502 | } |
||
5184 | avox | 503 | currItem->itemText.insertObject(pos, embedded); |
2499 | fschmid | 504 | } |
6900 | avox | 505 | */ |
351 | Franz | 506 | } |
507 | |||
6904 | avox | 508 | void SEditor::setAlign(int align) |
351 | Franz | 509 | { |
510 | switch (align) |
||
167 | Franz | 511 | { |
351 | Franz | 512 | case 0: |
513 | setAlignment(Qt::AlignLeft); |
||
514 | break; |
||
515 | case 1: |
||
516 | setAlignment(Qt::AlignCenter); |
||
517 | break; |
||
518 | case 2: |
||
519 | setAlignment(Qt::AlignRight); |
||
520 | break; |
||
521 | case 3: |
||
522 | case 4: |
||
523 | setAlignment(Qt::AlignJustify); |
||
524 | break; |
||
525 | default: |
||
526 | break; |
||
167 | Franz | 527 | } |
351 | Franz | 528 | } |
529 | |||
5184 | avox | 530 | |
1957 | cbradney | 531 | void SEditor::loadItemText(PageItem *currItem) |
351 | Franz | 532 | { |
533 | StyledText.clear(); |
||
2499 | fschmid | 534 | FrameItems.clear(); |
6900 | avox | 535 | StyledText.append(currItem->itemText); |
536 | updateAll(); |
||
7045 | avox | 537 | int npars = currItem->itemText.nrOfParagraphs(); |
8239 | avox | 538 | SelParaStart = 0; |
539 | while (currItem->CPos >= (SelCharStart = currItem->itemText.endOfParagraph(SelParaStart)) |
||
540 | && SelParaStart < npars) |
||
541 | ++SelParaStart; |
||
542 | if (currItem->CPos < SelCharStart) |
||
543 | SelCharStart = currItem->CPos; |
||
544 | SelCharStart -= currItem->itemText.startOfParagraph(SelParaStart); |
||
545 | StoredSel = false; |
||
546 | //qDebug("SE::loadItemText: cursor"); |
||
10628 | fschmid | 547 | // setCursorPosition(SelParaStart, SelCharStart); |
8239 | avox | 548 | emit setProps(SelParaStart, SelCharStart); |
10671 | fschmid | 549 | SelParaStart = 0; |
102 | Franz | 550 | } |
551 | |||
1957 | cbradney | 552 | void SEditor::loadText(QString tx, PageItem *currItem) |
102 | Franz | 553 | { |
1915 | fschmid | 554 | setUpdatesEnabled(false); |
351 | Franz | 555 | QString Text = ""; |
556 | StyledText.clear(); |
||
6900 | avox | 557 | StyledText.setDefaultStyle(currItem->itemText.defaultStyle()); |
7087 | subik | 558 | StyledText.insertChars(0, tx); |
6900 | avox | 559 | updateAll(); |
560 | if (StyledText.length() != 0) |
||
351 | Franz | 561 | emit setProps(0, 0); |
8239 | avox | 562 | //qDebug("SE::loadText: cursor"); |
10628 | fschmid | 563 | textCursor().setPosition(0); |
102 | Franz | 564 | } |
565 | |||
366 | Franz | 566 | void SEditor::updateAll() |
567 | { |
||
6900 | avox | 568 | clear(); |
569 | if (StyledText.length() == 0) |
||
366 | Franz | 570 | return; |
1915 | fschmid | 571 | setUpdatesEnabled(false); |
10628 | fschmid | 572 | int pos = textCursor().position(); |
366 | Franz | 573 | QString Text = ""; |
6900 | avox | 574 | QString chars; |
575 | int Csty = StyledText.charStyle(0).effects(); |
||
576 | int Ali = StyledText.paragraphStyle(0).alignment(); |
||
366 | Franz | 577 | setAlign(Ali); |
578 | setStyle(Csty); |
||
6900 | avox | 579 | for (uint pa = 0; pa < StyledText.nrOfParagraphs(); ++pa) |
366 | Franz | 580 | { |
6900 | avox | 581 | int start = StyledText.startOfParagraph(pa); |
582 | int end = StyledText.endOfParagraph(pa); |
||
583 | const ParagraphStyle& pstyle(StyledText.paragraphStyle(start)); |
||
584 | Ali = pstyle.alignment(); |
||
585 | setAlign(Ali); |
||
586 | if (start >= end && pa < StyledText.nrOfParagraphs()-1) |
||
366 | Franz | 587 | { |
588 | Text += "\n"; |
||
589 | continue; |
||
590 | } |
||
6900 | avox | 591 | for (int a = start; a < end; ++a) |
366 | Franz | 592 | { |
6900 | avox | 593 | const CharStyle& cstyle(StyledText.charStyle(a)); |
594 | const QChar ch = StyledText.text(a); |
||
595 | if (Csty != cstyle.effects() || |
||
596 | ch == SpecialChars::OBJECT || |
||
597 | ch == SpecialChars::PAGENUMBER || |
||
598 | ch == SpecialChars::NBSPACE || |
||
599 | ch == SpecialChars::FRAMEBREAK || |
||
600 | ch == SpecialChars::COLBREAK || |
||
601 | ch == SpecialChars::NBHYPHEN || |
||
602 | ch == SpecialChars::LINEBREAK) |
||
2499 | fschmid | 603 | { |
604 | setAlign(Ali); |
||
605 | setStyle(Csty); |
||
10628 | fschmid | 606 | insertPlainText(Text); |
6900 | avox | 607 | Text = ""; |
608 | Csty = cstyle.effects(); |
||
609 | } |
||
610 | |||
611 | if (ch == SpecialChars::OBJECT) |
||
612 | { |
||
11333 | jghali | 613 | setColor(true); |
10628 | fschmid | 614 | insertPlainText("@"); |
11333 | jghali | 615 | setColor(false); |
2499 | fschmid | 616 | } |
6900 | avox | 617 | else if (ch == SpecialChars::PAGENUMBER) |
366 | Franz | 618 | { |
11333 | jghali | 619 | setColor(true); |
10628 | fschmid | 620 | insertPlainText("#"); |
11333 | jghali | 621 | setColor(false); |
366 | Franz | 622 | } |
6900 | avox | 623 | else if (ch == SpecialChars::NBSPACE) |
366 | Franz | 624 | { |
11333 | jghali | 625 | setColor(true); |
10628 | fschmid | 626 | insertPlainText("_"); |
11333 | jghali | 627 | setColor(false); |
366 | Franz | 628 | } |
6900 | avox | 629 | else if (ch == SpecialChars::FRAMEBREAK) |
630 | { |
||
11333 | jghali | 631 | setColor(true); |
10628 | fschmid | 632 | insertPlainText("|"); |
11333 | jghali | 633 | setColor(false); |
6900 | avox | 634 | } |
635 | else if (ch == SpecialChars::COLBREAK) |
||
636 | { |
||
11333 | jghali | 637 | setColor(true); |
10628 | fschmid | 638 | insertPlainText("^"); |
11333 | jghali | 639 | setColor(false); |
6900 | avox | 640 | } |
641 | else if (ch == SpecialChars::NBHYPHEN) |
||
642 | { |
||
11333 | jghali | 643 | setColor(true); |
10628 | fschmid | 644 | insertPlainText("="); |
11333 | jghali | 645 | setColor(false); |
6900 | avox | 646 | } |
647 | else if (ch == SpecialChars::LINEBREAK) |
||
648 | { |
||
11333 | jghali | 649 | setColor(true); |
10628 | fschmid | 650 | insertPlainText("*"); |
11333 | jghali | 651 | setColor(false); |
6900 | avox | 652 | } |
653 | else |
||
654 | Text += ch; |
||
366 | Franz | 655 | } |
6900 | avox | 656 | if (pa < StyledText.nrOfParagraphs()-1) |
366 | Franz | 657 | Text += "\n"; |
658 | } |
||
659 | setAlign(Ali); |
||
660 | setStyle(Csty); |
||
10628 | fschmid | 661 | insertPlainText(Text); |
662 | textCursor().setPosition(pos); |
||
1915 | fschmid | 663 | setUpdatesEnabled(true); |
3608 | cbradney | 664 | //CB Removed to fix 2083 setCursorPosition(p, i); |
366 | Franz | 665 | } |
666 | |||
6900 | avox | 667 | |
351 | Franz | 668 | void SEditor::updateFromChars(int pa) |
102 | Franz | 669 | { |
6900 | avox | 670 | int start = StyledText.startOfParagraph(pa); |
671 | int end = StyledText.endOfParagraph(pa); |
||
672 | if (start >= end) |
||
351 | Franz | 673 | return; |
1915 | fschmid | 674 | setUpdatesEnabled(false); |
10628 | fschmid | 675 | int SelStart = start; |
351 | Franz | 676 | int SelEnd = 0; |
10628 | fschmid | 677 | int pos = textCursor().position(); |
678 | textCursor().clearSelection(); |
||
6900 | avox | 679 | int Csty = StyledText.charStyle(start).effects(); |
680 | for (int a = start; a < end; ++a) |
||
167 | Franz | 681 | { |
6900 | avox | 682 | if (Csty == StyledText.charStyle(a).effects()) |
351 | Franz | 683 | SelEnd++; |
684 | else |
||
167 | Franz | 685 | { |
10628 | fschmid | 686 | textCursor().setPosition(SelStart); |
687 | textCursor().setPosition(SelEnd, QTextCursor::KeepAnchor); |
||
351 | Franz | 688 | setStyle(Csty); |
10628 | fschmid | 689 | textCursor().clearSelection(); |
6900 | avox | 690 | Csty = StyledText.charStyle(a).effects(); |
362 | Franz | 691 | SelStart = SelEnd; |
351 | Franz | 692 | SelEnd++; |
167 | Franz | 693 | } |
351 | Franz | 694 | } |
10628 | fschmid | 695 | textCursor().setPosition(SelStart); |
696 | textCursor().setPosition(SelEnd, QTextCursor::KeepAnchor); |
||
351 | Franz | 697 | setStyle(Csty); |
10628 | fschmid | 698 | textCursor().clearSelection(); |
6900 | avox | 699 | setAlign(StyledText.paragraphStyle(start).alignment()); |
1915 | fschmid | 700 | setUpdatesEnabled(true); |
10628 | fschmid | 701 | textCursor().setPosition(pos); |
351 | Franz | 702 | } |
703 | |||
6900 | avox | 704 | /* updates the internal StyledText structure, applies 'newStyle' to the selection */ |
705 | void SEditor::updateSel(const ParagraphStyle& newStyle) |
||
351 | Franz | 706 | { |
6900 | avox | 707 | int PStart, PEnd, SelStart, SelEnd, start; |
385 | Franz | 708 | if (StoredSel) |
709 | { |
||
10628 | fschmid | 710 | textCursor().setPosition(SelParaStart); |
711 | textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor); |
||
385 | Franz | 712 | StoredSel = false; |
713 | } |
||
10628 | fschmid | 714 | SelStart = textCursor().selectionStart(); |
715 | PStart = StyledText.nrOfParagraph(SelStart); |
||
716 | SelEnd = textCursor().selectionEnd(); |
||
717 | PEnd = StyledText.nrOfParagraph(SelEnd); |
||
718 | for (int pa = PStart; pa <= PEnd; ++pa) |
||
351 | Franz | 719 | { |
10628 | fschmid | 720 | start = StyledText.startOfParagraph(pa); |
6900 | avox | 721 | StyledText.applyStyle(start, newStyle); |
167 | Franz | 722 | } |
102 | Franz | 723 | } |
724 | |||
6900 | avox | 725 | void SEditor::updateSel(const CharStyle& newStyle) |
726 | { |
||
727 | if (StoredSel) |
||
728 | { |
||
10628 | fschmid | 729 | textCursor().setPosition(SelParaStart); |
730 | textCursor().setPosition(SelParaEnd, QTextCursor::KeepAnchor); |
||
6900 | avox | 731 | StoredSel = false; |
732 | } |
||
10628 | fschmid | 733 | int start = textCursor().selectionStart(); |
734 | int end = textCursor().selectionEnd(); |
||
7623 | avox | 735 | if (start >= 0 && start < end) |
736 | StyledText.applyCharStyle(start, end-start, newStyle); |
||
6900 | avox | 737 | } |
738 | |||
739 | |||
351 | Franz | 740 | void SEditor::deleteSel() |
102 | Franz | 741 | { |
10628 | fschmid | 742 | int start = textCursor().selectionStart(); |
743 | int end = textCursor().selectionEnd(); |
||
6902 | avox | 744 | if (end > start) |
745 | StyledText.removeChars(start, end-start); |
||
10628 | fschmid | 746 | textCursor().setPosition(start); |
10671 | fschmid | 747 | StoredSel = false; |
102 | Franz | 748 | } |
749 | |||
351 | Franz | 750 | void SEditor::setStyle(int Csty) |
102 | Franz | 751 | { |
10628 | fschmid | 752 | QTextCharFormat charF; |
351 | Franz | 753 | if (Csty & 8) |
10628 | fschmid | 754 | charF.setFontUnderline(true); |
351 | Franz | 755 | else |
10628 | fschmid | 756 | charF.setFontUnderline(false); |
374 | Franz | 757 | if (Csty & 16) |
10628 | fschmid | 758 | charF.setFontStrikeOut(true); |
374 | Franz | 759 | else |
10628 | fschmid | 760 | charF.setFontStrikeOut(false); |
351 | Franz | 761 | if (Csty & 1) |
10628 | fschmid | 762 | charF.setVerticalAlignment(QTextCharFormat::AlignSuperScript); |
351 | Franz | 763 | else if (Csty & 2) |
10628 | fschmid | 764 | charF.setVerticalAlignment(QTextCharFormat::AlignSubScript); |
351 | Franz | 765 | else |
10628 | fschmid | 766 | charF.setVerticalAlignment(QTextCharFormat::AlignNormal); |
767 | textCursor().setCharFormat(charF); |
||
351 | Franz | 768 | } |
769 | |||
11333 | jghali | 770 | void SEditor::setColor(bool marker) |
351 | Franz | 771 | { |
772 | QColor tmp; |
||
2407 | fschmid | 773 | if (marker) |
8522 | cbradney | 774 | tmp = QColor(Qt::red); |
351 | Franz | 775 | else |
8522 | cbradney | 776 | tmp = QColor(Qt::black); |
10671 | fschmid | 777 | setTextColor(tmp); |
351 | Franz | 778 | } |
103 | Franz | 779 | |
362 | Franz | 780 | void SEditor::copy() |
781 | { |
||
10965 | fschmid | 782 | emit SideBarUp(false); |
10628 | fschmid | 783 | if ((textCursor().hasSelection()) && (!textCursor().selectedText().isEmpty())) |
362 | Franz | 784 | { |
376 | Franz | 785 | disconnect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
11360 | jghali | 786 | QMimeData* mimeData = createMimeDataFromSelection(); |
787 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); |
||
376 | Franz | 788 | connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(ClipChange())); |
789 | emit PasteAvail(); |
||
362 | Franz | 790 | } |
10965 | fschmid | 791 | emit SideBarUp(true); |
362 | Franz | 792 | } |
793 | |||
351 | Franz | 794 | void SEditor::cut() |
795 | { |
||
362 | Franz | 796 | copy(); |
10965 | fschmid | 797 | emit SideBarUp(false); |
10628 | fschmid | 798 | if (textCursor().hasSelection()) |
362 | Franz | 799 | { |
800 | deleteSel(); |
||
10628 | fschmid | 801 | textCursor().removeSelectedText(); |
362 | Franz | 802 | } |
10965 | fschmid | 803 | emit SideBarUp(true); |
804 | emit SideBarUpdate(); |
||
351 | Franz | 805 | } |
806 | |||
807 | void SEditor::paste() |
||
808 | { |
||
10965 | fschmid | 809 | emit SideBarUp(false); |
399 | Franz | 810 | QString data = ""; |
3605 | cbradney | 811 | int newParaCount, lengthLastPara; |
7394 | fschmid | 812 | int advanceLen = 0; |
10628 | fschmid | 813 | int pos = textCursor().position(); |
11360 | jghali | 814 | const QMimeData* mimeData = QApplication::clipboard()->mimeData(QClipboard::Clipboard); |
11361 | jghali | 815 | if (mimeData->hasFormat("application/x-scribus-styledtext")) |
7394 | fschmid | 816 | { |
11360 | jghali | 817 | const StyledTextMimeData* styledData = dynamic_cast<const StyledTextMimeData*>(mimeData); |
818 | if (mimeData) |
||
819 | { |
||
820 | const StoryText& styledText = styledData->styledText(); |
||
821 | advanceLen = styledText.length(); |
||
822 | insStyledText(styledText); |
||
823 | } |
||
7394 | fschmid | 824 | } |
399 | Franz | 825 | else |
376 | Franz | 826 | { |
7337 | fschmid | 827 | // QString data = QApplication::clipboard()->text(QClipboard::Selection); |
828 | // if (data.isNull()) |
||
829 | data = QApplication::clipboard()->text(QClipboard::Clipboard); |
||
11360 | jghali | 830 | if (!data.isEmpty()) |
376 | Franz | 831 | { |
832 | data.replace(QRegExp("\r"), ""); |
||
8637 | cbradney | 833 | newParaCount=data.count("\n"); |
10427 | cbradney | 834 | lengthLastPara=data.length()-data.lastIndexOf("\n"); |
6900 | avox | 835 | data.replace(QRegExp("\n"), SpecialChars::PARSEP); |
7394 | fschmid | 836 | // inserted=true; |
837 | advanceLen = data.length() - newParaCount; |
||
376 | Franz | 838 | insChars(data); |
399 | Franz | 839 | ClipData = 2; |
840 | emit PasteAvail(); |
||
376 | Franz | 841 | } |
399 | Franz | 842 | else |
843 | { |
||
10965 | fschmid | 844 | emit SideBarUp(true); |
399 | Franz | 845 | return; |
846 | } |
||
376 | Franz | 847 | } |
374 | Franz | 848 | updateAll(); |
7394 | fschmid | 849 | setUpdatesEnabled(false); |
8239 | avox | 850 | //qDebug("SE::paste: cursor"); |
10628 | fschmid | 851 | // setCursorPosition(currentPara, currentCharPos); |
852 | textCursor().setPosition(pos); |
||
7394 | fschmid | 853 | for (int a = 0; a < advanceLen; ++a) |
854 | { |
||
10628 | fschmid | 855 | moveCursor(QTextCursor::Right, QTextCursor::MoveAnchor); |
7394 | fschmid | 856 | } |
857 | setUpdatesEnabled(true); |
||
858 | // if (inserted) |
||
859 | // setCursorPosition(currentPara+newParaCount,(newParaCount==0?currentCharPos:0)+lengthLastPara-1); |
||
10628 | fschmid | 860 | repaint(); |
10965 | fschmid | 861 | emit SideBarUp(true); |
862 | emit SideBarUpdate(); |
||
351 | Franz | 863 | } |
11360 | jghali | 864 | |
865 | bool SEditor::canInsertFromMimeData( const QMimeData * source ) const |
||
866 | { |
||
11361 | jghali | 867 | if (source->hasText() || source->hasFormat("application/x-scribus-styledtext")) |
11360 | jghali | 868 | return true; |
869 | return false; |
||
870 | } |
||
871 | |||
872 | QMimeData* SEditor::createMimeDataFromSelection () const |
||
873 | { |
||
874 | StyledTextMimeData* mimeData = new StyledTextMimeData(); |
||
875 | int start = textCursor().selectionStart(); |
||
876 | int end = textCursor().selectionEnd(); |
||
877 | if (start < 0 || end <= start) |
||
878 | return mimeData; |
||
879 | StoryText* that = const_cast<StoryText*> (&StyledText); |
||
880 | that->select(start, end-start); |
||
881 | mimeData->setText(textCursor().selectedText()); |
||
882 | mimeData->setStyledText(*that); |
||
883 | return mimeData; |
||
884 | } |
||
885 | |||
886 | void SEditor::insertFromMimeData ( const QMimeData * source ) |
||
887 | { |
||
888 | paste(); |
||
889 | } |
||
890 | |||
10585 | fschmid | 891 | /* |
10718 | avox | 892 | Q_3PopupMenu* SEditor::createPopupMenu(const QPoint & pos) |
374 | Franz | 893 | { |
10718 | avox | 894 | Q_3PopupMenu *p = Q_3TextEdit::createPopupMenu(pos); |
374 | Franz | 895 | p->removeItemAt(0); |
896 | p->removeItemAt(0); |
||
897 | p->removeItemAt(0); |
||
898 | p->removeItemAt(3); |
||
899 | return p; |
||
900 | } |
||
10585 | fschmid | 901 | */ |
399 | Franz | 902 | void SEditor::SelClipChange() |
903 | { |
||
904 | ClipData = 3; |
||
905 | emit PasteAvail(); |
||
906 | } |
||
907 | |||
376 | Franz | 908 | void SEditor::ClipChange() |
909 | { |
||
910 | ClipData = 2; |
||
911 | emit PasteAvail(); |
||
912 | } |
||
913 | |||
10643 | fschmid | 914 | void SEditor::scrollContentsBy(int dx, int dy) |
915 | { |
||
916 | emit contentsMoving(dx, dy); |
||
10965 | fschmid | 917 | QTextEdit::scrollContentsBy(dx, dy); |
10643 | fschmid | 918 | } |
919 | |||
351 | Franz | 920 | /* Toolbar for Fill Colour */ |
10172 | cbradney | 921 | SToolBColorF::SToolBColorF(QMainWindow* parent, ScribusDoc *doc) : QToolBar( tr("Fill Color Settings"), parent) |
351 | Franz | 922 | { |
10172 | cbradney | 923 | FillIcon = new QLabel(this); |
7083 | cbradney | 924 | FillIcon->setPixmap(loadIcon("16/color-fill.png")); |
351 | Franz | 925 | FillIcon->setScaledContents( false ); |
10172 | cbradney | 926 | fillIconAction=addWidget(FillIcon); |
927 | fillIconAction->setVisible(true); |
||
928 | TxFill = new ColorCombo(false, this); |
||
929 | txFillAction=addWidget(TxFill); |
||
930 | txFillAction->setVisible(true); |
||
351 | Franz | 931 | PM2 = new ShadeButton(this); |
10172 | cbradney | 932 | pm2Action=addWidget(PM2); |
933 | pm2Action->setVisible(true); |
||
934 | |||
2494 | cbradney | 935 | setCurrentDocument(doc); |
2504 | cbradney | 936 | //TxFill->listBox()->setMinimumWidth(TxFill->listBox()->maxItemWidth()+24); |
351 | Franz | 937 | connect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
938 | connect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
3767 | subik | 939 | |
2505 | cbradney | 940 | languageChange(); |
351 | Franz | 941 | } |
942 | |||
10859 | cbradney | 943 | void SToolBColorF::changeEvent(QEvent *e) |
944 | { |
||
945 | if (e->type() == QEvent::LanguageChange) |
||
946 | { |
||
947 | languageChange(); |
||
948 | } |
||
10903 | cbradney | 949 | else |
950 | QWidget::changeEvent(e); |
||
10859 | cbradney | 951 | } |
952 | |||
953 | |||
2505 | cbradney | 954 | void SToolBColorF::languageChange() |
955 | { |
||
10397 | cbradney | 956 | TxFill->setToolTip(""); |
957 | PM2->setToolTip(""); |
||
958 | TxFill->setToolTip( tr( "Color of text fill" )); |
||
959 | PM2->setToolTip( tr( "Saturation of color of text fill" )); |
||
2505 | cbradney | 960 | } |
961 | |||
2494 | cbradney | 962 | void SToolBColorF::setCurrentDocument(ScribusDoc *doc) |
963 | { |
||
964 | if (doc!=NULL) |
||
10628 | fschmid | 965 | TxFill->updateBox(doc->PageColors, ColorCombo::smallPixmaps, true); |
966 | else |
||
967 | { |
||
968 | TxFill->clear(); |
||
969 | TxFill->addItem(CommonStrings::tr_NoneColor); |
||
970 | } |
||
971 | // if (doc!=NULL) |
||
972 | // TxFill->insertItems(doc->PageColors, ColorCombo::smallPixmaps); |
||
2504 | cbradney | 973 | resize(minimumSizeHint()); |
2494 | cbradney | 974 | } |
975 | |||
351 | Franz | 976 | void SToolBColorF::SetColor(int c) |
977 | { |
||
978 | disconnect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
10585 | fschmid | 979 | TxFill->setCurrentIndex(c); |
351 | Franz | 980 | connect(TxFill, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
981 | } |
||
982 | |||
9920 | fschmid | 983 | void SToolBColorF::SetShade(double s) |
351 | Franz | 984 | { |
985 | disconnect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
9920 | fschmid | 986 | PM2->setValue(qRound(s)); |
351 | Franz | 987 | connect(PM2, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
988 | } |
||
989 | |||
990 | void SToolBColorF::newShadeHandler() |
||
991 | { |
||
10585 | fschmid | 992 | emit NewColor(TxFill->currentIndex(), PM2->getValue()); |
351 | Franz | 993 | } |
994 | |||
995 | /* Toolbar for Stroke Colour */ |
||
10172 | cbradney | 996 | SToolBColorS::SToolBColorS(QMainWindow* parent, ScribusDoc *doc) : QToolBar( tr("Stroke Color Settings"), parent) |
351 | Franz | 997 | { |
10172 | cbradney | 998 | StrokeIcon = new QLabel( "", this ); |
7083 | cbradney | 999 | StrokeIcon->setPixmap(loadIcon("16/color-stroke.png")); |
351 | Franz | 1000 | StrokeIcon->setScaledContents( false ); |
10172 | cbradney | 1001 | strokeIconAction=addWidget(StrokeIcon); |
1002 | strokeIconAction->setVisible(true); |
||
10469 | cbradney | 1003 | TxStroke = new ColorCombo(false, this); |
10172 | cbradney | 1004 | txStrokeAction=addWidget(TxStroke); |
1005 | txStrokeAction->setVisible(true); |
||
351 | Franz | 1006 | PM1 = new ShadeButton(this); |
10172 | cbradney | 1007 | pm1Action=addWidget(PM1); |
1008 | pm1Action->setVisible(true); |
||
2494 | cbradney | 1009 | setCurrentDocument(doc); |
2504 | cbradney | 1010 | //TxStroke->listBox()->setMinimumWidth(TxStroke->listBox()->maxItemWidth()+24); |
351 | Franz | 1011 | connect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
1012 | connect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
3767 | subik | 1013 | |
2505 | cbradney | 1014 | languageChange(); |
351 | Franz | 1015 | } |
1016 | |||
10859 | cbradney | 1017 | void SToolBColorS::changeEvent(QEvent *e) |
1018 | { |
||
1019 | if (e->type() == QEvent::LanguageChange) |
||
1020 | { |
||
1021 | languageChange(); |
||
1022 | } |
||
10903 | cbradney | 1023 | else |
1024 | QWidget::changeEvent(e); |
||
10859 | cbradney | 1025 | } |
1026 | |||
2505 | cbradney | 1027 | void SToolBColorS::languageChange() |
1028 | { |
||
10397 | cbradney | 1029 | TxStroke->setToolTip(""); |
1030 | PM1->setToolTip(""); |
||
1031 | TxStroke->setToolTip( tr("Color of text stroke")); |
||
1032 | PM1->setToolTip( tr("Saturation of color of text stroke")); |
||
2505 | cbradney | 1033 | } |
1034 | |||
2494 | cbradney | 1035 | void SToolBColorS::setCurrentDocument(ScribusDoc *doc) |
1036 | { |
||
1037 | TxStroke->clear(); |
||
10585 | fschmid | 1038 | TxStroke->addItem(CommonStrings::tr_NoneColor); |
2494 | cbradney | 1039 | if (doc!=NULL) |
7850 | jghali | 1040 | TxStroke->insertItems(doc->PageColors, ColorCombo::smallPixmaps); |
2504 | cbradney | 1041 | resize(minimumSizeHint()); |
2494 | cbradney | 1042 | } |
1043 | |||
351 | Franz | 1044 | void SToolBColorS::SetColor(int c) |
1045 | { |
||
1046 | disconnect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
||
10585 | fschmid | 1047 | TxStroke->setCurrentIndex(c); |
351 | Franz | 1048 | connect(TxStroke, SIGNAL(activated(int)), this, SLOT(newShadeHandler())); |
1049 | } |
||
1050 | |||
9920 | fschmid | 1051 | void SToolBColorS::SetShade(double s) |
351 | Franz | 1052 | { |
1053 | disconnect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
||
9920 | fschmid | 1054 | PM1->setValue(qRound(s)); |
351 | Franz | 1055 | connect(PM1, SIGNAL(clicked()), this, SLOT(newShadeHandler())); |
1056 | } |
||
1057 | |||
1058 | void SToolBColorS::newShadeHandler() |
||
1059 | { |
||
10585 | fschmid | 1060 | emit NewColor(TxStroke->currentIndex(), PM1->getValue()); |
351 | Franz | 1061 | } |
1062 | |||
1063 | /* Toolbar for Character Style Settings */ |
||
10172 | cbradney | 1064 | SToolBStyle::SToolBStyle(QMainWindow* parent) : QToolBar( tr("Character Settings"), parent) |
351 | Franz | 1065 | { |
1066 | SeStyle = new StyleSelect(this); |
||
10172 | cbradney | 1067 | seStyleAction=addWidget(SeStyle); |
1068 | seStyleAction->setVisible(true); |
||
1069 | trackingLabel = new QLabel( this ); |
||
2500 | fschmid | 1070 | trackingLabel->setText(""); |
1071 | trackingLabel->setPixmap(loadIcon("textkern.png")); |
||
10172 | cbradney | 1072 | trackingLabelAction=addWidget(trackingLabel); |
1073 | trackingLabelAction->setVisible(true); |
||
8602 | cbradney | 1074 | Extra = new ScrSpinBox( this, 1 ); |
9061 | cbradney | 1075 | Extra->setValues( -300, 300, 2, 0); |
2382 | fschmid | 1076 | Extra->setSuffix( tr( " %" ) ); |
10172 | cbradney | 1077 | extraAction=addWidget(Extra); |
1078 | extraAction->setVisible(true); |
||
3767 | subik | 1079 | |
716 | cbradney | 1080 | connect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
8687 | cbradney | 1081 | connect(Extra, SIGNAL(valueChanged(double)), this, SLOT(newKernHandler())); |
1082 | connect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
||
1083 | connect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
||
1084 | connect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newOutlineHandler())); |
||
1085 | connect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
||
1086 | connect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
||
1087 | connect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
||
1088 | connect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
||
3767 | subik | 1089 | |
2505 | cbradney | 1090 | languageChange(); |
351 | Franz | 1091 | } |
1092 | |||
10859 | cbradney | 1093 | void SToolBStyle::changeEvent(QEvent *e) |
1094 | { |
||
1095 | if (e->type() == QEvent::LanguageChange) |
||
1096 | { |
||
1097 | languageChange(); |
||
1098 | } |
||
10903 | cbradney | 1099 | else |
1100 | QWidget::changeEvent(e); |
||
10859 | cbradney | 1101 | } |
1102 | |||
2505 | cbradney | 1103 | void SToolBStyle::languageChange() |
1104 | { |
||
10397 | cbradney | 1105 | Extra->setToolTip(""); |
1106 | Extra->setToolTip( tr( "Manual Tracking" )); |
||
2505 | cbradney | 1107 | } |
1108 | |||
2272 | fschmid | 1109 | void SToolBStyle::newStrikeHandler() |
1110 | { |
||
9920 | fschmid | 1111 | double x = SeStyle->StrikeVal->LPos->value() * 10.0; |
1112 | double y = SeStyle->StrikeVal->LWidth->value() * 10.0; |
||
9202 | subik | 1113 | // emit newUnderline(x, y); |
1114 | emit newStrike(x, y); |
||
2272 | fschmid | 1115 | } |
1116 | |||
2262 | fschmid | 1117 | void SToolBStyle::newUnderlineHandler() |
1118 | { |
||
9920 | fschmid | 1119 | double x = SeStyle->UnderlineVal->LPos->value() * 10.0; |
1120 | double y = SeStyle->UnderlineVal->LWidth->value() * 10.0; |
||
2262 | fschmid | 1121 | emit newUnderline(x, y); |
1122 | } |
||
1123 | |||
2257 | fschmid | 1124 | void SToolBStyle::newOutlineHandler() |
1125 | { |
||
9920 | fschmid | 1126 | double x = SeStyle->OutlineVal->LWidth->value() * 10.0; |
2257 | fschmid | 1127 | emit newOutline(x); |
1128 | } |
||
1129 | |||
2254 | fschmid | 1130 | void SToolBStyle::newShadowHandler() |
1131 | { |
||
9920 | fschmid | 1132 | double x = SeStyle->ShadowVal->Xoffset->value() * 10.0; |
1133 | double y = SeStyle->ShadowVal->Yoffset->value() * 10.0; |
||
2254 | fschmid | 1134 | emit NewShadow(x, y); |
1135 | } |
||
1136 | |||
351 | Franz | 1137 | void SToolBStyle::newKernHandler() |
1138 | { |
||
9920 | fschmid | 1139 | emit NewKern(Extra->value() * 10.0); |
351 | Franz | 1140 | } |
1141 | |||
9920 | fschmid | 1142 | void SToolBStyle::setOutline(double x) |
2257 | fschmid | 1143 | { |
8687 | cbradney | 1144 | disconnect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newOutlineHandler())); |
2257 | fschmid | 1145 | SeStyle->OutlineVal->LWidth->setValue(x / 10.0); |
8687 | cbradney | 1146 | connect(SeStyle->OutlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newOutlineHandler())); |
2257 | fschmid | 1147 | } |
1148 | |||
9920 | fschmid | 1149 | void SToolBStyle::setStrike(double p, double w) |
2272 | fschmid | 1150 | { |
8687 | cbradney | 1151 | disconnect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
1152 | disconnect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
||
2272 | fschmid | 1153 | SeStyle->StrikeVal->LWidth->setValue(w / 10.0); |
1154 | SeStyle->StrikeVal->LPos->setValue(p / 10.0); |
||
8687 | cbradney | 1155 | connect(SeStyle->StrikeVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
1156 | connect(SeStyle->StrikeVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newStrikeHandler())); |
||
2272 | fschmid | 1157 | } |
1158 | |||
9920 | fschmid | 1159 | void SToolBStyle::setUnderline(double p, double w) |
2262 | fschmid | 1160 | { |
8687 | cbradney | 1161 | disconnect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
1162 | disconnect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
||
2262 | fschmid | 1163 | SeStyle->UnderlineVal->LWidth->setValue(w / 10.0); |
1164 | SeStyle->UnderlineVal->LPos->setValue(p / 10.0); |
||
8687 | cbradney | 1165 | connect(SeStyle->UnderlineVal->LWidth, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
1166 | connect(SeStyle->UnderlineVal->LPos, SIGNAL(valueChanged(double)), this, SLOT(newUnderlineHandler())); |
||
2262 | fschmid | 1167 | } |
1168 | |||
9920 | fschmid | 1169 | void SToolBStyle::SetShadow(double x, double y) |
2254 | fschmid | 1170 | { |
8687 | cbradney | 1171 | disconnect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
1172 | disconnect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
||
2254 | fschmid | 1173 | SeStyle->ShadowVal->Xoffset->setValue(x / 10.0); |
1174 | SeStyle->ShadowVal->Yoffset->setValue(y / 10.0); |
||
8687 | cbradney | 1175 | connect(SeStyle->ShadowVal->Xoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
1176 | connect(SeStyle->ShadowVal->Yoffset, SIGNAL(valueChanged(double)), this, SLOT(newShadowHandler())); |
||
2254 | fschmid | 1177 | } |
1178 | |||
351 | Franz | 1179 | void SToolBStyle::SetStyle(int s) |
1180 | { |
||
716 | cbradney | 1181 | disconnect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
351 | Franz | 1182 | SeStyle->setStyle(s); |
716 | cbradney | 1183 | connect(SeStyle, SIGNAL(State(int)), this, SIGNAL(newStyle(int))); |
351 | Franz | 1184 | } |
1185 | |||
9920 | fschmid | 1186 | void SToolBStyle::SetKern(double k) |
351 | Franz | 1187 | { |
8687 | cbradney | 1188 | disconnect(Extra, SIGNAL(valueChanged(double)), this, SLOT(newKernHandler())); |
2382 | fschmid | 1189 | Extra->setValue(k / 10.0); |
8687 | cbradney | 1190 | connect(Extra, SIGNAL(valueChanged(double)), this, SLOT(newKernHandler())); |
351 | Franz | 1191 | } |
1192 | |||
1193 | /* Toolbar for alignment of Paragraphs */ |
||
10172 | cbradney | 1194 | SToolBAlign::SToolBAlign(QMainWindow* parent) : QToolBar( tr("Style Settings"), parent) |
351 | Franz | 1195 | { |
1196 | GroupAlign = new AlignSelect(this); |
||
10172 | cbradney | 1197 | groupAlignAction=addWidget(GroupAlign); |
1198 | groupAlignAction->setVisible(true); |
||
7990 | cbradney | 1199 | paraStyleCombo = new ParaStyleComboBox(this); |
10172 | cbradney | 1200 | paraStyleComboAction=addWidget(paraStyleCombo); |
1201 | paraStyleComboAction->setVisible(true); |
||
9067 | avox | 1202 | connect(paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SIGNAL(newParaStyle(const QString& ))); |
6900 | avox | 1203 | connect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(newAlign(int ))); |
3767 | subik | 1204 | |
2505 | cbradney | 1205 | languageChange(); |
351 | Franz | 1206 | } |
1207 | |||
10859 | cbradney | 1208 | void SToolBAlign::changeEvent(QEvent *e) |
1209 | { |
||
1210 | if (e->type() == QEvent::LanguageChange) |
||
1211 | { |
||
1212 | languageChange(); |
||
1213 | } |
||
10903 | cbradney | 1214 | else |
1215 | QWidget::changeEvent(e); |
||
10859 | cbradney | 1216 | } |
1217 | |||
2505 | cbradney | 1218 | void SToolBAlign::languageChange() |
1219 | { |
||
10397 | cbradney | 1220 | paraStyleCombo->setToolTip(""); |
1221 | paraStyleCombo->setToolTip( tr("Style of current paragraph")); |
||
2505 | cbradney | 1222 | } |
1223 | |||
6900 | avox | 1224 | |
1225 | void SToolBAlign::SetAlign(int s) |
||
351 | Franz | 1226 | { |
6900 | avox | 1227 | disconnect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(newAlign(int ))); |
1228 | GroupAlign->setStyle(s); |
||
1229 | connect(GroupAlign, SIGNAL(State(int)), this, SIGNAL(newAlign(int ))); |
||
351 | Franz | 1230 | } |
1231 | |||
10643 | fschmid | 1232 | void SToolBAlign::SetParaStyle(QString s) |
351 | Franz | 1233 | { |
9067 | avox | 1234 | disconnect(paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SIGNAL(newParaStyle(const QString& ))); |
10643 | fschmid | 1235 | paraStyleCombo->setFormat(s); |
9067 | avox | 1236 | connect(paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SIGNAL(newParaStyle(const QString& ))); |
351 | Franz | 1237 | } |
1238 | |||
6900 | avox | 1239 | |
351 | Franz | 1240 | /* Toolbar for Font related Settings */ |
10172 | cbradney | 1241 | SToolBFont::SToolBFont(QMainWindow* parent) : QToolBar( tr("Font Settings"), parent) |
351 | Franz | 1242 | { |
2834 | cbradney | 1243 | Fonts = new FontCombo(this); |
351 | Franz | 1244 | Fonts->setMaximumSize(190, 30); |
10172 | cbradney | 1245 | fontsAction=addWidget(Fonts); |
1246 | fontsAction->setVisible(true); |
||
8602 | cbradney | 1247 | Size = new ScrSpinBox( 0.5, 2048, this, 1 ); |
7772 | subik | 1248 | PrefsManager* prefsManager = PrefsManager::instance(); |
351 | Franz | 1249 | Size->setPrefix( "" ); |
1250 | Size->setSuffix( tr( " pt" ) ); |
||
7772 | subik | 1251 | Size->setValue(prefsManager->appPrefs.toolSettings.defSize / 10.0); |
10172 | cbradney | 1252 | sizeAction=addWidget(Size); |
1253 | sizeAction->setVisible(true); |
||
10581 | cbradney | 1254 | ScaleTxt = new QLabel("", this); |
2230 | fschmid | 1255 | ScaleTxt->setPixmap(loadIcon("textscaleh.png")); |
10172 | cbradney | 1256 | scaleTxtAction=addWidget(ScaleTxt); |
1257 | scaleTxtAction->setVisible(true); |
||
8602 | cbradney | 1258 | ChScale = new ScrSpinBox( 10, 400, this, 1 ); |
351 | Franz | 1259 | ChScale->setValue( 100 ); |
1260 | ChScale->setSuffix( tr( " %" ) ); |
||
10172 | cbradney | 1261 | chScaleAction=addWidget(ChScale); |
1262 | chScaleAction->setVisible(true); |
||
10581 | cbradney | 1263 | ScaleTxtV = new QLabel("", this); |
2230 | fschmid | 1264 | ScaleTxtV->setPixmap(loadIcon("textscalev.png")); |
10172 | cbradney | 1265 | scaleTxtVAction=addWidget(ScaleTxtV); |
1266 | scaleTxtVAction->setVisible(true); |
||
8602 | cbradney | 1267 | ChScaleV = new ScrSpinBox( 10, 400, this, 1 ); |
2230 | fschmid | 1268 | ChScaleV->setValue( 100 ); |
1269 | ChScaleV->setSuffix( tr( " %" ) ); |
||
10172 | cbradney | 1270 | chScaleVAction=addWidget(ChScaleV); |
1271 | chScaleVAction->setVisible(true); |
||
2505 | cbradney | 1272 | |
8687 | cbradney | 1273 | connect(ChScale, SIGNAL(valueChanged(double)), this, SIGNAL(newScale(double))); |
1274 | connect(ChScaleV, SIGNAL(valueChanged(double)), this, SIGNAL(newScaleV(double))); |
||
351 | Franz | 1275 | connect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
9525 | fschmid | 1276 | connect(Size, SIGNAL(valueChanged(double)), this, SIGNAL(NewSize(double))); |
351 | Franz | 1277 | } |
1278 | |||
10859 | cbradney | 1279 | void SToolBFont::changeEvent(QEvent *e) |
1280 | { |
||
1281 | if (e->type() == QEvent::LanguageChange) |
||
1282 | { |
||
1283 | languageChange(); |
||
1284 | } |
||
10903 | cbradney | 1285 | else |
1286 | QWidget::changeEvent(e); |
||
10859 | cbradney | 1287 | } |
1288 | |||
2505 | cbradney | 1289 | void SToolBFont::languageChange() |
1290 | { |
||
10397 | cbradney | 1291 | Fonts->setToolTip(""); |
1292 | Size->setToolTip(""); |
||
1293 | ChScale->setToolTip(""); |
||
1294 | ChScaleV->setToolTip(""); |
||
1295 | Fonts->setToolTip( tr("Font of selected text")); |
||
1296 | Size->setToolTip( tr("Font Size")); |
||
1297 | ChScale->setToolTip( tr("Scaling width of characters")); |
||
1298 | ChScaleV->setToolTip( tr("Scaling height of characters")); |
||
2505 | cbradney | 1299 | } |
1300 | |||
351 | Franz | 1301 | void SToolBFont::SetFont(QString f) |
1302 | { |
||
1303 | disconnect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
||
10648 | fschmid | 1304 | setCurrentComboItem(Fonts, f); |
351 | Franz | 1305 | connect(Fonts, SIGNAL(activated(const QString &)), this, SIGNAL(NewFont(const QString &))); |
1306 | } |
||
1307 | |||
1308 | void SToolBFont::SetSize(double s) |
||
1309 | { |
||
8687 | cbradney | 1310 | disconnect(Size, SIGNAL(valueChanged(double)), this, SLOT(newSizeHandler())); |
2242 | fschmid | 1311 | Size->setValue(s / 10.0); |
8687 | cbradney | 1312 | connect(Size, SIGNAL(valueChanged(double)), this, SLOT(newSizeHandler())); |
351 | Franz | 1313 | } |
1314 | |||
9920 | fschmid | 1315 | void SToolBFont::SetScale(double s) |
351 | Franz | 1316 | { |
8687 | cbradney | 1317 | disconnect(ChScale, SIGNAL(valueChanged(double)), this, SIGNAL(newScale(double))); |
2242 | fschmid | 1318 | ChScale->setValue(s / 10.0); |
8687 | cbradney | 1319 | connect(ChScale, SIGNAL(valueChanged(double)), this, SIGNAL(newScale(double))); |
351 | Franz | 1320 | } |
1321 | |||
9920 | fschmid | 1322 | void SToolBFont::SetScaleV(double s) |
2230 | fschmid | 1323 | { |
8687 | cbradney | 1324 | disconnect(ChScaleV, SIGNAL(valueChanged(double)), this, SIGNAL(newScaleV(double))); |
2242 | fschmid | 1325 | ChScaleV->setValue(s / 10.0); |
8687 | cbradney | 1326 | connect(ChScaleV, SIGNAL(valueChanged(double)), this, SIGNAL(newScaleV(double))); |
2230 | fschmid | 1327 | } |
1328 | |||
351 | Franz | 1329 | void SToolBFont::newSizeHandler() |
1330 | { |
||
1331 | emit NewSize(Size->value()); |
||
1332 | } |
||
1333 | |||
1334 | /* Main Story Editor Class */ |
||
7101 | subik | 1335 | // StoryEditor::StoryEditor(QWidget* parent, ScribusDoc *docc, PageItem *ite) |
1336 | // : QMainWindow(parent, "StoryEditor", WType_TopLevel) // WType_Dialog) //WShowModal | |
||
1337 | // { |
||
1338 | // prefsManager=PrefsManager::instance(); |
||
1339 | // currDoc = docc; |
||
1340 | // seMenuMgr=NULL; |
||
1341 | // buildGUI(); |
||
1342 | // currItem = ite; |
||
1343 | // // charSelect = NULL; |
||
1344 | // firstSet = false; |
||
1345 | // activFromApp = true; |
||
1346 | // Editor->loadItemText(ite); |
||
1347 | // Editor->getCursorPosition(&CurrPara, &CurrChar); |
||
1348 | // EditorBar->setRepaint(true); |
||
1349 | // EditorBar->doRepaint(); |
||
1350 | // updateProps(CurrPara, CurrChar); |
||
1351 | // updateStatus(); |
||
1352 | // textChanged = false; |
||
1353 | // disconnectSignals(); |
||
1354 | // connectSignals(); |
||
1355 | // Editor->setFocus(); |
||
11333 | jghali | 1356 | // Editor->setColor(false); |
7101 | subik | 1357 | // blockUpdate = false; |
1358 | // loadPrefs(); |
||
1359 | // // hack to keep charPalette visible. See destructor too - PV |
||
1360 | // ScCore->primaryMainWindow()->charPalette->reparent(this, QPoint(0, 0)); |
||
1361 | // } |
||
2494 | cbradney | 1362 | |
2505 | cbradney | 1363 | /* Main Story Editor Class, no current document */ |
10585 | fschmid | 1364 | StoryEditor::StoryEditor(QWidget* parent) : QMainWindow(parent, Qt::Window), // WType_Dialog) //WShowModal | |
8185 | subik | 1365 | activFromApp(true), |
1366 | currDoc(NULL), |
||
1367 | currItem(NULL), |
||
1368 | textChanged(false), |
||
1369 | firstSet(false), |
||
1370 | blockUpdate(false), |
||
1371 | CurrPara(0), |
||
1372 | CurrChar(0), |
||
1373 | charSelect(NULL), |
||
1374 | charSelectUsed(false) |
||
2494 | cbradney | 1375 | { |
2834 | cbradney | 1376 | prefsManager=PrefsManager::instance(); |
8185 | subik | 1377 | #ifdef Q_WS_MAC |
4557 | cbradney | 1378 | noIcon = loadIcon("noicon.xpm"); |
8185 | subik | 1379 | #endif |
2494 | cbradney | 1380 | buildGUI(); |
1381 | /* |
||
1382 | //Editor->loadItemText(ite); |
||
1383 | updateProps(0,0); |
||
1384 | updateStatus(); |
||
1385 | */ |
||
1386 | Editor->setFocus(); |
||
11333 | jghali | 1387 | Editor->setColor(false); |
3868 | subik | 1388 | loadPrefs(); |
3767 | subik | 1389 | } |
2494 | cbradney | 1390 | |
3868 | subik | 1391 | StoryEditor::~StoryEditor() |
1392 | { |
||
1393 | savePrefs(); |
||
1394 | } |
||
1395 | |||
8185 | subik | 1396 | void StoryEditor::showEvent(QShowEvent *) |
1397 | { |
||
1398 | charSelect = new CharSelect(this); |
||
10585 | fschmid | 1399 | charSelect->userTableModel()->setCharacters( ScCore->primaryMainWindow()->charPalette->userTableModel()->characters()); |
1400 | connect(charSelect, SIGNAL(insertSpecialChar()), this, SLOT(slot_insertSpecialChar())); |
||
1401 | connect(charSelect, SIGNAL(insertUserSpecialChar(QChar)), this, SLOT(slot_insertUserSpecialChar(QChar))); |
||
8185 | subik | 1402 | } |
1403 | |||
1404 | void StoryEditor::hideEvent(QHideEvent *) |
||
1405 | { |
||
1406 | if (charSelectUsed) |
||
10585 | fschmid | 1407 | ScCore->primaryMainWindow()->charPalette->userTableModel()->setCharacters( charSelect->userTableModel()->characters()); |
1408 | if (charSelect->isVisible()) |
||
8185 | subik | 1409 | charSelect->close(); |
10585 | fschmid | 1410 | disconnect(charSelect, SIGNAL(insertSpecialChar()), this, SLOT(slot_insertSpecialChar())); |
1411 | disconnect(charSelect, SIGNAL(insertUserSpecialChar(QChar)), this, SLOT(slot_insertUserSpecialChar(QChar))); |
||
8185 | subik | 1412 | delete charSelect; |
1413 | charSelect = NULL; |
||
1414 | } |
||
1415 | |||
3868 | subik | 1416 | void StoryEditor::savePrefs() |
1417 | { |
||
1418 | // save prefs |
||
4452 | cbradney | 1419 | QRect geo = geometry(); |
1420 | prefs->set("left", geo.left()); |
||
1421 | prefs->set("top", geo.top()); |
||
3868 | subik | 1422 | prefs->set("width", width()); |
1423 | prefs->set("height", height()); |
||
10965 | fschmid | 1424 | QList<int> splitted = EdSplit->sizes(); |
1425 | prefs->set("side", splitted[0]); |
||
1426 | prefs->set("main", splitted[1]); |
||
10257 | fschmid | 1427 | prefs->set("winstate", QString(saveState().toBase64())); |
3868 | subik | 1428 | } |
1429 | |||
1430 | void StoryEditor::loadPrefs() |
||
1431 | { |
||
1432 | prefs = PrefsManager::instance()->prefsFile->getPluginContext("StoryEditor"); |
||
8562 | jghali | 1433 | int vleft = qMax(-80, prefs->getInt("left", 10)); |
10531 | avox | 1434 | #if defined(Q_OS_MAC) || defined(_WIN32) |
8562 | jghali | 1435 | int vtop = qMax(64, prefs->getInt("top", 10)); |
4452 | cbradney | 1436 | #else |
8562 | jghali | 1437 | int vtop = qMax(-80, prefs->getInt("top", 10)); |
3868 | subik | 1438 | #endif |
8562 | jghali | 1439 | int vwidth = qMax(600, prefs->getInt("width", 600)); |
1440 | int vheight = qMax(400, prefs->getInt("height", 400)); |
||
4802 | cbradney | 1441 | // Check values against current screen size |
4803 | cbradney | 1442 | QRect scr = QApplication::desktop()->screen()->geometry(); |
4802 | cbradney | 1443 | QSize gStrut = QApplication::globalStrut(); |
1444 | if ( vleft >= scr.width() ) |
||
1445 | vleft = 0; |
||
1446 | if ( vtop >= scr.height() ) |
||
1447 | vtop = 64; |
||
1448 | if ( vwidth >= scr.width() ) |
||
8562 | jghali | 1449 | vwidth = qMax( gStrut.width(), scr.width() - vleft ); |
4802 | cbradney | 1450 | if ( vheight >= scr.height() ) |
8562 | jghali | 1451 | vheight = qMax( gStrut.height(), scr.height() - vtop ); |
3868 | subik | 1452 | setGeometry(vleft, vtop, vwidth, vheight); |
10257 | fschmid | 1453 | QByteArray state = ""; |
10585 | fschmid | 1454 | state = prefs->get("winstate","").toAscii(); |
10257 | fschmid | 1455 | if (!state.isEmpty()) |
1456 | restoreState(QByteArray::fromBase64(state)); |
||
10965 | fschmid | 1457 | int side = prefs->getInt("side", -1); |
7245 | fschmid | 1458 | int txtarea = prefs->getInt("main", -1); |
1459 | if ((side != -1) && (txtarea != -1)) |
||
1460 | { |
||
9803 | fschmid | 1461 | QList<int> splitted; |
7245 | fschmid | 1462 | splitted.append(side); |
1463 | splitted.append(txtarea); |
||
1464 | EdSplit->setSizes(splitted); |
||
10965 | fschmid | 1465 | } |
3868 | subik | 1466 | } |
1467 | |||
4557 | cbradney | 1468 | void StoryEditor::initActions() |
4550 | cbradney | 1469 | { |
1470 | //File Menu |
||
9857 | cbradney | 1471 | seActions.insert("fileNew", new ScrAction(loadIcon("16/document-new.png"), loadIcon("22/document-new.png"), "", Qt::CTRL+Qt::Key_N, this)); |
1472 | seActions.insert("fileRevert", new ScrAction(loadIcon("reload16.png"), loadIcon("reload.png"), "", QKeySequence(), this)); |
||
1473 | seActions.insert("fileSaveToFile", new ScrAction(loadIcon("16/document-save.png"), loadIcon("22/document-save.png"), "", QKeySequence(), this)); |
||
1474 | seActions.insert("fileLoadFromFile", new ScrAction(loadIcon("16/document-open.png"), loadIcon("22/document-open.png"), "", QKeySequence(), this)); |
||
1475 | seActions.insert("fileSaveDocument", new ScrAction("", Qt::CTRL+Qt::Key_S, this)); |
||
1476 | seActions.insert("fileUpdateAndExit", new ScrAction(loadIcon("ok.png"), loadIcon("ok22.png"), "", Qt::CTRL+Qt::Key_W, this)); |
||
1477 | seActions.insert("fileExit", new ScrAction(loadIcon("exit.png"), loadIcon("exit22.png"), "", QKeySequence(), this)); |
||
4729 | subik | 1478 | |
10725 | jghali | 1479 | connect( seActions["fileNew"], SIGNAL(triggered()), this, SLOT(Do_new()) ); |
1480 | connect( seActions["fileRevert"], SIGNAL(triggered()), this, SLOT(slotFileRevert()) ); |
||
1481 | connect( seActions["fileSaveToFile"], SIGNAL(triggered()), this, SLOT(SaveTextFile()) ); |
||
1482 | connect( seActions["fileLoadFromFile"], SIGNAL(triggered()), this, SLOT(LoadTextFile()) ); |
||
1483 | connect( seActions["fileSaveDocument"], SIGNAL(triggered()), this, SLOT(Do_saveDocument()) ); |
||
1484 | connect( seActions["fileUpdateAndExit"], SIGNAL(triggered()), this, SLOT(Do_leave2()) ); |
||
1485 | connect( seActions["fileExit"], SIGNAL(triggered()), this, SLOT(Do_leave()) ); |
||
4729 | subik | 1486 | |
4550 | cbradney | 1487 | //Edit Menu |
9857 | cbradney | 1488 | seActions.insert("editSelectAll", new ScrAction(loadIcon("16/edit-select-all.png"), QPixmap(), "", Qt::CTRL+Qt::Key_A, this)); |
1489 | seActions.insert("editCut", new ScrAction(loadIcon("16/edit-cut.png"), QPixmap(), "", Qt::CTRL+Qt::Key_X, this)); |
||
1490 | seActions.insert("editCopy", new ScrAction(loadIcon("16/edit-copy.png"), QPixmap(), "", Qt::CTRL+Qt::Key_C, this)); |
||
1491 | seActions.insert("editPaste", new ScrAction(loadIcon("16/edit-paste.png"), QPixmap(), "", Qt::CTRL+Qt::Key_V, this)); |
||
1492 | seActions.insert("editClear", new ScrAction(loadIcon("16/edit-delete.png"), QPixmap(), "", Qt::Key_Delete, this)); |
||
1493 | seActions.insert("editSearchReplace", new ScrAction(loadIcon("16/edit-find-replace.png"), QPixmap(), "", QKeySequence(), this)); |
||
1494 | seActions.insert("editEditStyle", new ScrAction("", QKeySequence(), this)); |
||
1495 | seActions.insert("editFontPreview", new ScrAction("", QKeySequence(), this)); |
||
1496 | seActions.insert("editUpdateFrame", new ScrAction(loadIcon("compfile16.png"),loadIcon("compfile.png"), "", Qt::CTRL+Qt::Key_U, this)); |
||
4729 | subik | 1497 | |
10725 | jghali | 1498 | connect( seActions["editSelectAll"], SIGNAL(triggered()), this, SLOT(Do_selectAll()) ); |
1499 | connect( seActions["editCut"], SIGNAL(triggered()), this, SLOT(Do_cut()) ); |
||
1500 | connect( seActions["editCopy"], SIGNAL(triggered()), this, SLOT(Do_copy()) ); |
||
1501 | connect( seActions["editPaste"], SIGNAL(triggered()), this, SLOT(Do_paste()) ); |
||
1502 | connect( seActions["editClear"], SIGNAL(triggered()), this, SLOT(Do_del()) ); |
||
1503 | connect( seActions["editSearchReplace"], SIGNAL(triggered()), this, SLOT(SearchText()) ); |
||
1504 | connect( seActions["editEditStyle"], SIGNAL(triggered()), this, SLOT(slotEditStyles()) ); |
||
1505 | connect( seActions["editFontPreview"], SIGNAL(triggered()), this, SLOT(Do_fontPrev()) ); |
||
1506 | connect( seActions["editUpdateFrame"], SIGNAL(triggered()), this, SLOT(updateTextFrame()) ); |
||
4729 | subik | 1507 | |
4552 | cbradney | 1508 | //Insert Menu |
9857 | cbradney | 1509 | seActions.insert("insertGlyph", new ScrAction(QPixmap(), QPixmap(), "", QKeySequence(), this)); |
10725 | jghali | 1510 | connect( seActions["insertGlyph"], SIGNAL(triggered()), this, SLOT(Do_insSp()) ); |
4729 | subik | 1511 | |
4557 | cbradney | 1512 | //Settings Menu |
9857 | cbradney | 1513 | seActions.insert("settingsBackground", new ScrAction("", QKeySequence(), this)); |
1514 | seActions.insert("settingsDisplayFont", new ScrAction("", QKeySequence(), this)); |
||
1515 | seActions.insert("settingsSmartTextSelection", new ScrAction("", QKeySequence(), this)); |
||
4557 | cbradney | 1516 | smartSelection = false; |
10581 | cbradney | 1517 | seActions["settingsSmartTextSelection"]->setChecked(false); |
4557 | cbradney | 1518 | seActions["settingsSmartTextSelection"]->setToggleAction(true); |
4729 | subik | 1519 | |
10725 | jghali | 1520 | connect( seActions["settingsBackground"], SIGNAL(triggered()), this, SLOT(setBackPref()) ); |
1521 | connect( seActions["settingsDisplayFont"], SIGNAL(triggered()), this, SLOT(setFontPref()) ); |
||
4557 | cbradney | 1522 | connect( seActions["settingsSmartTextSelection"], SIGNAL(toggled(bool)), this, SLOT(setSmart(bool)) ); |
4729 | subik | 1523 | |
1524 | |||
4557 | cbradney | 1525 | seActions["fileRevert"]->setEnabled(false); |
1526 | seActions["editCopy"]->setEnabled(false); |
||
1527 | seActions["editCut"]->setEnabled(false); |
||
1528 | seActions["editPaste"]->setEnabled(false); |
||
1529 | seActions["editClear"]->setEnabled(false); |
||
1530 | seActions["editUpdateFrame"]->setEnabled(false); |
||
1531 | } |
||
1532 | |||
4550 | cbradney | 1533 | void StoryEditor::buildMenus() |
1534 | { |
||
5781 | cbradney | 1535 | seMenuMgr = new MenuManager(this->menuBar(), this->menuBar()); |
4550 | cbradney | 1536 | seMenuMgr->createMenu("File", tr("&File")); |
1537 | seMenuMgr->addMenuItem(seActions["fileNew"], "File"); |
||
1538 | seMenuMgr->addMenuItem(seActions["fileRevert"], "File"); |
||
1539 | seMenuMgr->addMenuSeparator("File"); |
||
1540 | seMenuMgr->addMenuItem(seActions["fileSaveToFile"], "File"); |
||
1541 | seMenuMgr->addMenuItem(seActions["fileLoadFromFile"], "File"); |
||
1542 | seMenuMgr->addMenuItem(seActions["fileSaveDocument"], "File"); |
||
1543 | seMenuMgr->addMenuSeparator("File"); |
||
1544 | seMenuMgr->addMenuItem(seActions["fileUpdateAndExit"], "File"); |
||
1545 | seMenuMgr->addMenuItem(seActions["fileExit"], "File"); |
||
1546 | seMenuMgr->createMenu("Edit", tr("&Edit")); |
||
1547 | seMenuMgr->addMenuItem(seActions["editSelectAll"], "Edit"); |
||
1548 | seMenuMgr->addMenuItem(seActions["editCut"], "Edit"); |
||
1549 | seMenuMgr->addMenuItem(seActions["editCopy"], "Edit"); |
||
1550 | seMenuMgr->addMenuItem(seActions["editPaste"], "Edit"); |
||
1551 | seMenuMgr->addMenuItem(seActions["editClear"], "Edit"); |
||
1552 | seMenuMgr->addMenuSeparator("Edit"); |
||
1553 | seMenuMgr->addMenuItem(seActions["editSearchReplace"], "Edit"); |
||
1554 | seMenuMgr->addMenuSeparator("Edit"); |
||
1555 | seMenuMgr->addMenuItem(seActions["editEditStyle"], "Edit"); |
||
1556 | seMenuMgr->addMenuItem(seActions["editFontPreview"], "Edit"); |
||
1557 | seMenuMgr->addMenuItem(seActions["editUpdateFrame"], "Edit"); |
||
4552 | cbradney | 1558 | seMenuMgr->createMenu("Insert", tr("&Insert")); |
1559 | seMenuMgr->addMenuItem(seActions["insertGlyph"], "Insert"); |
||
10558 | cbradney | 1560 | seMenuMgr->createMenu("InsertChar", tr("Character"), "Insert"); |
4564 | cbradney | 1561 | seMenuMgr->addMenuItem(seActions["unicodePageNumber"], "InsertChar"); |
1562 | //seMenuMgr->addMenuItem(seActions["unicodeSmartHyphen"], "InsertChar"); |
||
1563 | seMenuMgr->addMenuItem(seActions["unicodeNonBreakingHyphen"], "InsertChar"); |
||
4552 | cbradney | 1564 | seMenuMgr->addMenuSeparator("InsertChar"); |
4564 | cbradney | 1565 | seMenuMgr->addMenuItem(seActions["unicodeCopyRight"], "InsertChar"); |
1566 | seMenuMgr->addMenuItem(seActions["unicodeRegdTM"], "InsertChar"); |
||
1567 | seMenuMgr->addMenuItem(seActions["unicodeTM"], "InsertChar"); |
||
4720 | cbradney | 1568 | seMenuMgr->addMenuItem(seActions["unicodeSolidus"], "InsertChar"); |
4564 | cbradney | 1569 | seMenuMgr->addMenuItem(seActions["unicodeBullet"], "InsertChar"); |
4720 | cbradney | 1570 | seMenuMgr->addMenuItem(seActions["unicodeMidpoint"], "InsertChar"); |
4552 | cbradney | 1571 | seMenuMgr->addMenuSeparator("InsertChar"); |
4564 | cbradney | 1572 | seMenuMgr->addMenuItem(seActions["unicodeDashEm"], "InsertChar"); |
1573 | seMenuMgr->addMenuItem(seActions["unicodeDashEn"], "InsertChar"); |
||
1574 | seMenuMgr->addMenuItem(seActions["unicodeDashFigure"], "InsertChar"); |
||
1575 | seMenuMgr->addMenuItem(seActions["unicodeDashQuotation"], "InsertChar"); |
||
10558 | cbradney | 1576 | seMenuMgr->createMenu("InsertQuote", tr("Quote"), "Insert"); |
4564 | cbradney | 1577 | seMenuMgr->addMenuItem(seActions["unicodeQuoteApostrophe"], "InsertQuote"); |
1578 | seMenuMgr->addMenuItem(seActions["unicodeQuoteStraight"], "InsertQuote"); |
||
4552 | cbradney | 1579 | seMenuMgr->addMenuSeparator("InsertQuote"); |
4564 | cbradney | 1580 | seMenuMgr->addMenuItem(seActions["unicodeQuoteSingleLeft"], "InsertQuote"); |
1581 | seMenuMgr->addMenuItem(seActions["unicodeQuoteSingleRight"], "InsertQuote"); |
||
1582 | seMenuMgr->addMenuItem(seActions["unicodeQuoteDoubleLeft"], "InsertQuote"); |
||
1583 | seMenuMgr->addMenuItem(seActions["unicodeQuoteDoubleRight"], "InsertQuote"); |
||
4552 | cbradney | 1584 | seMenuMgr->addMenuSeparator("InsertQuote"); |
8755 | cbradney | 1585 | seMenuMgr->addMenuItem(seActions["unicodeQuoteSingleReversed"], "InsertQuote"); |
1586 | seMenuMgr->addMenuItem(seActions["unicodeQuoteDoubleReversed"], "InsertQuote"); |
||
1587 | seMenuMgr->addMenuSeparator("InsertQuote"); |
||
4564 | cbradney | 1588 | seMenuMgr->addMenuItem(seActions["unicodeQuoteLowSingleComma"], "InsertQuote"); |
1589 | seMenuMgr->addMenuItem(seActions["unicodeQuoteLowDoubleComma"], "InsertQuote"); |
||
4552 | cbradney | 1590 | seMenuMgr->addMenuSeparator("InsertQuote"); |
4564 | cbradney | 1591 | seMenuMgr->addMenuItem(seActions["unicodeQuoteSingleLeftGuillemet"], "InsertQuote"); |
1592 | seMenuMgr->addMenuItem(seActions["unicodeQuoteSingleRightGuillemet"], "InsertQuote"); |
||
1593 | seMenuMgr->addMenuItem(seActions["unicodeQuoteDoubleLeftGuillemet"], "InsertQuote"); |
||
1594 | seMenuMgr->addMenuItem(seActions["unicodeQuoteDoubleRightGuillemet"], "InsertQuote"); |
||
4552 | cbradney | 1595 | seMenuMgr->addMenuSeparator("InsertQuote"); |
4564 | cbradney | 1596 | seMenuMgr->addMenuItem(seActions["unicodeQuoteCJKSingleLeft"], "InsertQuote"); |
1597 | seMenuMgr->addMenuItem(seActions["unicodeQuoteCJKSingleRight"], "InsertQuote"); |
||
1598 | seMenuMgr->addMenuItem(seActions["unicodeQuoteCJKDoubleLeft"], "InsertQuote"); |
||
1599 | seMenuMgr->addMenuItem(seActions["unicodeQuoteCJKDoubleRight"], "InsertQuote"); |
||
10558 | cbradney | 1600 | seMenuMgr->createMenu("InsertSpace", tr("Spaces && Breaks"), "Insert"); |
4564 | cbradney | 1601 | seMenuMgr->addMenuItem(seActions["unicodeNonBreakingSpace"], "InsertSpace"); |
4720 | cbradney | 1602 | seMenuMgr->addMenuItem(seActions["unicodeSpaceEN"], "InsertSpace"); |
1603 | seMenuMgr->addMenuItem(seActions["unicodeSpaceEM"], "InsertSpace"); |
||
1604 | seMenuMgr->addMenuItem(seActions["unicodeSpaceThin"], "InsertSpace"); |
||
1605 | seMenuMgr->addMenuItem(seActions["unicodeSpaceThick"], "InsertSpace"); |
||
1606 | seMenuMgr->addMenuItem(seActions["unicodeSpaceMid"], "InsertSpace"); |
||
1607 | seMenuMgr->addMenuItem(seActions["unicodeSpaceHair"], "InsertSpace"); |
||
1608 | seMenuMgr->addMenuSeparator("InsertSpace"); |
||
4564 | cbradney | 1609 | seMenuMgr->addMenuItem(seActions["unicodeNewLine"], "InsertSpace"); |
1610 | seMenuMgr->addMenuItem(seActions["unicodeFrameBreak"], "InsertSpace"); |
||
1611 | seMenuMgr->addMenuItem(seActions["unicodeColumnBreak"], "InsertSpace"); |
||
10558 | cbradney | 1612 | seMenuMgr->createMenu("InsertLigature", tr("Ligature"), "Insert"); |
4564 | cbradney | 1613 | seMenuMgr->addMenuItem(seActions["unicodeLigature_ff"], "InsertLigature"); |
1614 | seMenuMgr->addMenuItem(seActions["unicodeLigature_fi"], "InsertLigature"); |
||
1615 | seMenuMgr->addMenuItem(seActions["unicodeLigature_fl"], "InsertLigature"); |
||
1616 | seMenuMgr->addMenuItem(seActions["unicodeLigature_ffi"], "InsertLigature"); |
||
1617 | seMenuMgr->addMenuItem(seActions["unicodeLigature_ffl"], "InsertLigature"); |
||
1618 | seMenuMgr->addMenuItem(seActions["unicodeLigature_ft"], "InsertLigature"); |
||
1619 | seMenuMgr->addMenuItem(seActions["unicodeLigature_st"], "InsertLigature"); |
||
4729 | subik | 1620 | |
4550 | cbradney | 1621 | seMenuMgr->createMenu("Settings", tr("&Settings")); |
1622 | seMenuMgr->addMenuItem(seActions["settingsBackground"], "Settings"); |
||
1623 | seMenuMgr->addMenuItem(seActions["settingsDisplayFont"], "Settings"); |
||
1624 | seMenuMgr->addMenuItem(seActions["settingsSmartTextSelection"], "Settings"); |
||
4729 | subik | 1625 | |
4550 | cbradney | 1626 | seMenuMgr->addMenuToMenuBar("File"); |
1627 | seMenuMgr->addMenuToMenuBar("Edit"); |
||
4552 | cbradney | 1628 | seMenuMgr->addMenuToMenuBar("Insert"); |
4550 | cbradney | 1629 | seMenuMgr->addMenuToMenuBar("Settings"); |
1630 | } |
||
1631 | |||
2494 | cbradney | 1632 | void StoryEditor::buildGUI() |
1633 | { |
||
4557 | cbradney | 1634 | unicodeCharActionNames.clear(); |
1635 | seActions.clear(); |
||
1636 | initActions(); |
||
1637 | ActionManager::initUnicodeActions(&seActions, this, &unicodeCharActionNames); |
||
4564 | cbradney | 1638 | seActions["unicodeSmartHyphen"]->setEnabled(false);//CB TODO doesnt work in SE yet. |
4550 | cbradney | 1639 | buildMenus(); |
4729 | subik | 1640 | |
10585 | fschmid | 1641 | setWindowIcon(loadIcon("AppIcon.png")); |
10180 | fschmid | 1642 | StoryEd2Layout = new QHBoxLayout; |
1643 | StoryEd2Layout->setSpacing( 5 ); |
||
1644 | StoryEd2Layout->setMargin( 5 ); |
||
124 | Franz | 1645 | |
351 | Franz | 1646 | /* Setting up Toolbars */ |
10172 | cbradney | 1647 | FileTools = new QToolBar(this); |
10691 | fschmid | 1648 | FileTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1649 | FileTools->setObjectName("File"); |
9800 | cbradney | 1650 | FileTools->addAction(seActions["fileNew"]); |
1651 | FileTools->addAction(seActions["fileLoadFromFile"]); |
||
1652 | FileTools->addAction(seActions["fileSaveToFile"]); |
||
1653 | FileTools->addAction(seActions["fileUpdateAndExit"]); |
||
1654 | FileTools->addAction(seActions["fileExit"]); |
||
1655 | FileTools->addAction(seActions["fileRevert"]); |
||
1656 | FileTools->addAction(seActions["editUpdateFrame"]); |
||
1657 | FileTools->addAction(seActions["editSearchReplace"]); |
||
4729 | subik | 1658 | |
10172 | cbradney | 1659 | FileTools->setAllowedAreas(Qt::LeftToolBarArea); |
1660 | FileTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1661 | FileTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1662 | FileTools->setAllowedAreas(Qt::TopToolBarArea); |
351 | Franz | 1663 | FontTools = new SToolBFont(this); |
10691 | fschmid | 1664 | FontTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1665 | FontTools->setObjectName("Font"); |
10172 | cbradney | 1666 | FontTools->setAllowedAreas(Qt::LeftToolBarArea); |
1667 | FontTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1668 | FontTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1669 | FontTools->setAllowedAreas(Qt::TopToolBarArea); |
351 | Franz | 1670 | AlignTools = new SToolBAlign(this); |
10691 | fschmid | 1671 | AlignTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1672 | AlignTools->setObjectName("Align"); |
10172 | cbradney | 1673 | AlignTools->setAllowedAreas(Qt::LeftToolBarArea); |
1674 | AlignTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1675 | AlignTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1676 | AlignTools->setAllowedAreas(Qt::TopToolBarArea); |
7992 | cbradney | 1677 | AlignTools->paraStyleCombo->setDoc(currDoc); |
351 | Franz | 1678 | StyleTools = new SToolBStyle(this); |
10691 | fschmid | 1679 | StyleTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1680 | StyleTools->setObjectName("Style"); |
10172 | cbradney | 1681 | StyleTools->setAllowedAreas(Qt::LeftToolBarArea); |
1682 | StyleTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1683 | StyleTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1684 | StyleTools->setAllowedAreas(Qt::TopToolBarArea); |
2494 | cbradney | 1685 | StrokeTools = new SToolBColorS(this, currDoc); |
10691 | fschmid | 1686 | StrokeTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1687 | StrokeTools->setObjectName("Strok"); |
10172 | cbradney | 1688 | StrokeTools->setAllowedAreas(Qt::LeftToolBarArea); |
1689 | StrokeTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1690 | StrokeTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1691 | StrokeTools->setAllowedAreas(Qt::TopToolBarArea); |
352 | Franz | 1692 | StrokeTools->TxStroke->setEnabled(false); |
1693 | StrokeTools->PM1->setEnabled(false); |
||
2494 | cbradney | 1694 | FillTools = new SToolBColorF(this, currDoc); |
10691 | fschmid | 1695 | FillTools->setIconSize(QSize(16,16)); |
10257 | fschmid | 1696 | FillTools->setObjectName("Fill"); |
10172 | cbradney | 1697 | FillTools->setAllowedAreas(Qt::LeftToolBarArea); |
1698 | FillTools->setAllowedAreas(Qt::RightToolBarArea); |
||
1699 | FillTools->setAllowedAreas(Qt::BottomToolBarArea); |
||
10180 | fschmid | 1700 | FillTools->setAllowedAreas(Qt::TopToolBarArea); |
10172 | cbradney | 1701 | |
1702 | addToolBar(FileTools); |
||
1703 | addToolBar(FontTools); |
||
1704 | addToolBar(AlignTools); |
||
1705 | addToolBar(StyleTools); |
||
1706 | addToolBar(StrokeTools); |
||
1707 | addToolBar(FillTools); |
||
125 | Franz | 1708 | |
10965 | fschmid | 1709 | EdSplit = new QSplitter(this); |
371 | Franz | 1710 | /* SideBar Widget */ |
10965 | fschmid | 1711 | EditorBar = new SideBar(this); |
1712 | EdSplit->addWidget(EditorBar); |
||
351 | Franz | 1713 | /* Editor Widget, subclass of QTextEdit */ |
10671 | fschmid | 1714 | Editor = new SEditor(this, currDoc, this); |
10965 | fschmid | 1715 | EdSplit->addWidget(Editor); |
1716 | StoryEd2Layout->addWidget( EdSplit ); |
||
1549 | subik | 1717 | |
351 | Franz | 1718 | /* Setting up Status Bar */ |
10180 | fschmid | 1719 | ButtonGroup1 = new QFrame( statusBar() ); |
1720 | ButtonGroup1->setFrameShape( QFrame::NoFrame ); |
||
1721 | ButtonGroup1->setFrameShadow( QFrame::Plain ); |
||
1722 | ButtonGroup1Layout = new QGridLayout( ButtonGroup1 ); |
||
125 | Franz | 1723 | ButtonGroup1Layout->setAlignment( Qt::AlignTop ); |
1724 | ButtonGroup1Layout->setSpacing( 2 ); |
||
1725 | ButtonGroup1Layout->setMargin( 0 ); |
||
10581 | cbradney | 1726 | WordCT1 = new QLabel(ButtonGroup1); |
10180 | fschmid | 1727 | ButtonGroup1Layout->addWidget( WordCT1, 0, 0, 1, 3 ); |
10581 | cbradney | 1728 | WordCT = new QLabel(ButtonGroup1); |
125 | Franz | 1729 | ButtonGroup1Layout->addWidget( WordCT, 1, 0 ); |
10581 | cbradney | 1730 | WordC = new QLabel(ButtonGroup1); |
125 | Franz | 1731 | ButtonGroup1Layout->addWidget( WordC, 1, 1 ); |
10581 | cbradney | 1732 | CharCT = new QLabel(ButtonGroup1); |
125 | Franz | 1733 | ButtonGroup1Layout->addWidget( CharCT, 1, 2 ); |
10581 | cbradney | 1734 | CharC = new QLabel(ButtonGroup1); |
125 | Franz | 1735 | ButtonGroup1Layout->addWidget( CharC, 1, 3 ); |
10585 | fschmid | 1736 | statusBar()->addPermanentWidget(ButtonGroup1, 1); |
10581 | cbradney | 1737 | ButtonGroup2 = new QFrame( statusBar() ); |
10180 | fschmid | 1738 | ButtonGroup2->setFrameShape( QFrame::NoFrame ); |
1739 | ButtonGroup2->setFrameShadow( QFrame::Plain ); |
||
1740 | ButtonGroup2Layout = new QGridLayout( ButtonGroup2 ); |
||
125 | Franz | 1741 | ButtonGroup2Layout->setAlignment( Qt::AlignTop ); |
1742 | ButtonGroup2Layout->setSpacing( 2 ); |
||
1743 | ButtonGroup2Layout->setMargin( 0 ); |
||
10581 | cbradney | 1744 | WordCT3 = new QLabel(ButtonGroup2); |
10180 | fschmid | 1745 | ButtonGroup2Layout->addWidget( WordCT3, 0, 0, 1, 5 ); |
10581 | cbradney | 1746 | ParCT = new QLabel(ButtonGroup2); |
125 | Franz | 1747 | ButtonGroup2Layout->addWidget( ParCT, 1, 0 ); |
10581 | cbradney | 1748 | ParC = new QLabel(ButtonGroup2); |
125 | Franz | 1749 | ButtonGroup2Layout->addWidget( ParC, 1, 1 ); |
10581 | cbradney | 1750 | WordCT2 = new QLabel(ButtonGroup2); |
125 | Franz | 1751 | ButtonGroup2Layout->addWidget( WordCT2, 1, 2 ); |
10581 | cbradney | 1752 | WordC2 = new QLabel(ButtonGroup2); |
125 | Franz | 1753 | ButtonGroup2Layout->addWidget( WordC2, 1, 3 ); |
10581 | cbradney | 1754 | CharCT2 = new QLabel(ButtonGroup2); |
125 | Franz | 1755 | ButtonGroup2Layout->addWidget( CharCT2, 1, 4 ); |
10581 | cbradney | 1756 | CharC2 = new QLabel(ButtonGroup2); |
125 | Franz | 1757 | ButtonGroup2Layout->addWidget( CharC2, 1, 5 ); |
10585 | fschmid | 1758 | statusBar()->addPermanentWidget(ButtonGroup2, 1); |
10965 | fschmid | 1759 | setCentralWidget( EdSplit ); |
4551 | cbradney | 1760 | //Final setup |
351 | Franz | 1761 | resize( QSize(660, 500).expandedTo(minimumSizeHint()) ); |
2834 | cbradney | 1762 | if (prefsManager==NULL) |
3240 | fschmid | 1763 | sDebug(QString("%1").arg("prefsmgr null")); |
3767 | subik | 1764 | |
10628 | fschmid | 1765 | // Editor->setPaper(prefsManager->appPrefs.STEcolor); |
357 | Franz | 1766 | QFont fo; |
2834 | cbradney | 1767 | fo.fromString(prefsManager->appPrefs.STEfont); |
357 | Franz | 1768 | Editor->setFont(fo); |
10965 | fschmid | 1769 | EditorBar->setFrameStyle(Editor->frameStyle()); |
1770 | EditorBar->setLineWidth(Editor->lineWidth()); |
||
1771 | EditorBar->editor = Editor; |
||
4194 | fschmid | 1772 | Editor->installEventFilter(this); |
2505 | cbradney | 1773 | languageChange(); |
2494 | cbradney | 1774 | } |
1775 | |||
10859 | cbradney | 1776 | void StoryEditor::changeEvent(QEvent *e) |
1777 | { |
||
1778 | if (e->type() == QEvent::LanguageChange) |
||
1779 | { |
||
1780 | languageChange(); |
||
1781 | } |
||
10903 | cbradney | 1782 | else |
1783 | QWidget::changeEvent(e); |
||
10859 | cbradney | 1784 | } |
1785 | |||
2505 | cbradney | 1786 | void StoryEditor::languageChange() |
1787 | { |
||
10180 | fschmid | 1788 | setWindowTitle( tr( "Story Editor" ) ); |
4550 | cbradney | 1789 | //File Menu |
10427 | cbradney | 1790 | seMenuMgr->setText("File", tr("&File")); |
4550 | cbradney | 1791 | seActions["fileNew"]->setText( tr("Clear All Text")); |
1792 | seActions["fileRevert"]->setTexts( tr("&Reload Text from Frame")); |
||
1793 | seActions["fileSaveToFile"]->setTexts( tr("&Save to File...")); |
||
1794 | seActions["fileLoadFromFile"]->setTexts( tr("&Load from File...")); |
||
1795 | seActions["fileSaveDocument"]->setTexts( tr("Save &Document")); |
||
1796 | seActions["fileUpdateAndExit"]->setTexts( tr("&Update Text Frame and Exit")); |
||
1797 | seActions["fileExit"]->setTexts( tr("&Exit Without Updating Text Frame")); |
||
1798 | //Edit Menu |
||
10427 | cbradney | 1799 | seMenuMgr->setText("Edit", tr("&Edit")); |
4550 | cbradney | 1800 | seActions["editSelectAll"]->setTexts( tr("Select &All")); |
1801 | seActions["editCut"]->setTexts( tr("Cu&t")); |
||
1802 | seActions["editCopy"]->setTexts( tr("&Copy")); |
||
1803 | seActions["editPaste"]->setTexts( tr("&Paste")); |
||
1804 | seActions["editClear"]->setTexts( tr("C&lear")); |
||
1805 | seActions["editSearchReplace"]->setTexts( tr("&Search/Replace...")); |
||
1806 | seActions["editEditStyle"]->setTexts( tr("&Edit Styles...")); |
||
1807 | seActions["editFontPreview"]->setTexts( tr("&Fonts Preview...")); |
||
1808 | seActions["editUpdateFrame"]->setTexts( tr("&Update Text Frame")); |
||
4729 | subik | 1809 | |
4552 | cbradney | 1810 | //Insert menu |
10427 | cbradney | 1811 | seMenuMgr->setText("Insert", tr("&Insert")); |
1812 | seMenuMgr->setText("InsertChar", tr("Character")); |
||
1813 | seMenuMgr->setText("InsertQuote", tr("Quote")); |
||
1814 | seMenuMgr->setText("InsertSpace", tr("Space")); |
||
4552 | cbradney | 1815 | seActions["insertGlyph"]->setTexts( tr("&Insert Glyph...")); |
4729 | subik | 1816 | |
4557 | cbradney | 1817 | //Settings Menu |
10427 | cbradney | 1818 | seMenuMgr->setText("Settings", tr("&Settings")); |
4557 | cbradney | 1819 | seActions["settingsBackground"]->setTexts( tr("&Background...")); |
1820 | seActions["settingsDisplayFont"]->setTexts( tr("&Display Font...")); |
||
1821 | seActions["settingsSmartTextSelection"]->setTexts( tr("&Smart text selection")); |
||
1822 | |||
4558 | cbradney | 1823 | //Unicode Actions |
4557 | cbradney | 1824 | ActionManager::languageChangeUnicodeActions(&seActions); |
4729 | subik | 1825 | |
10581 | cbradney | 1826 | FileTools->setWindowTitle( tr("File")); |
3767 | subik | 1827 | |
2505 | cbradney | 1828 | WordCT1->setText( tr("Current Paragraph:")); |
1829 | WordCT->setText( tr("Words: ")); |
||
1830 | CharCT->setText( tr("Chars: ")); |
||
1831 | WordCT3->setText( tr("Totals:")); |
||
3767 | subik | 1832 | ParCT->setText( tr("Paragraphs: ")); |
2505 | cbradney | 1833 | WordCT2->setText( tr("Words: ")); |
1834 | CharCT2->setText( tr("Chars: ")); |
||
1835 | |||
1836 | } |
||
1837 | |||
2494 | cbradney | 1838 | void StoryEditor::disconnectSignals() |
1839 | { |
||
1840 | disconnect(Editor,0,0,0); |
||
10965 | fschmid | 1841 | disconnect(EditorBar,0,0,0); |
2494 | cbradney | 1842 | disconnect(AlignTools,0,0,0); |
1843 | disconnect(FillTools,0,0,0); |
||
1844 | disconnect(FontTools,0,0,0); |
||
1845 | disconnect(StrokeTools,0,0,0); |
||
1846 | disconnect(StyleTools,0,0,0); |
||
1847 | } |
||
1848 | |||
1849 | void StoryEditor::connectSignals() |
||
1850 | { |
||
351 | Franz | 1851 | connect(Editor, SIGNAL(textChanged()), this, SLOT(modifiedText())); |
10643 | fschmid | 1852 | // connect(Editor, SIGNAL(clicked(int, int)), this, SLOT(updateProps(int, int))); |
351 | Franz | 1853 | connect(Editor, SIGNAL(setProps(int, int)), this, SLOT(updateProps(int, int))); |
10628 | fschmid | 1854 | connect(Editor, SIGNAL(cursorPositionChanged()), this, SLOT(updateProps())); |
360 | Franz | 1855 | connect(Editor, SIGNAL(copyAvailable(bool)), this, SLOT(CopyAvail(bool ))); |
376 | Franz | 1856 | connect(Editor, SIGNAL(PasteAvail()), this, SLOT(PasteAvail())); |
10965 | fschmid | 1857 | connect(Editor, SIGNAL(contentsMoving(int, int)), EditorBar, SLOT(doMove(int, int ))); |
1858 | connect(Editor, SIGNAL(textChanged()), EditorBar, SLOT(doRepaint())); |
||
1859 | connect(Editor, SIGNAL(SideBarUp(bool )), EditorBar, SLOT(setRepaint(bool ))); |
||
1860 | connect(Editor, SIGNAL(SideBarUpdate( )), EditorBar, SLOT(doRepaint())); |
||
445 | fschmid | 1861 | // 10/12/2004 - pv - #1203: wrong selection on double click |
10643 | fschmid | 1862 | // connect(Editor, SIGNAL(doubleClicked(int, int)), this, SLOT(doubleClick(int, int))); |
10965 | fschmid | 1863 | connect(EditorBar, SIGNAL(ChangeStyle(int, const QString& )), this, SLOT(changeStyleSB(int, const QString&))); |
1864 | connect(EditorBar, SIGNAL(sigEditStyles()), this, SLOT(slotEditStyles())); |
||
9067 | avox | 1865 | connect(AlignTools, SIGNAL(newParaStyle(const QString&)), this, SLOT(newStyle(const QString&))); |
6900 | avox | 1866 | connect(AlignTools, SIGNAL(newAlign(int)), this, SLOT(newAlign(int))); |
351 | Franz | 1867 | connect(FillTools, SIGNAL(NewColor(int, int)), this, SLOT(newTxFill(int, int))); |
1868 | connect(StrokeTools, SIGNAL(NewColor(int, int)), this, SLOT(newTxStroke(int, int))); |
||
9525 | fschmid | 1869 | connect(FontTools, SIGNAL(NewSize(double )), this, SLOT(newTxSize(double))); |
351 | Franz | 1870 | connect(FontTools, SIGNAL(NewFont(const QString& )), this, SLOT(newTxFont(const QString& ))); |
9525 | fschmid | 1871 | connect(FontTools, SIGNAL(newScale(double )), this, SLOT(newTxScale())); |
1872 | connect(FontTools, SIGNAL(newScaleV(double )), this, SLOT(newTxScaleV())); |
||
9920 | fschmid | 1873 | connect(StyleTools, SIGNAL(NewKern(double )), this, SLOT(newTxKern(double ))); |
716 | cbradney | 1874 | connect(StyleTools, SIGNAL(newStyle(int )), this, SLOT(newTxStyle(int ))); |
9920 | fschmid | 1875 | connect(StyleTools, SIGNAL(NewShadow(double, double)), this, SLOT(newShadowOffs(double, double))); |
1876 | connect(StyleTools, SIGNAL(newOutline(double )), this, SLOT(newTxtOutline(double ))); |
||
1877 | connect(StyleTools, SIGNAL(newUnderline(double, double)), this, SLOT(newTxtUnderline(double, double))); |
||
1878 | connect(StyleTools, SIGNAL(newStrike(double, double )), this, SLOT(newTxtStrike(double, double))); |
||
351 | Franz | 1879 | } |
1549 | subik | 1880 | |
2494 | cbradney | 1881 | void StoryEditor::setCurrentDocumentAndItem(ScribusDoc *doc, PageItem *item) |
1882 | { |
||
1883 | disconnectSignals(); |
||
1884 | currDoc=doc; |
||
1885 | textChanged=false; |
||
7992 | cbradney | 1886 | AlignTools->paraStyleCombo->setDoc(currDoc); |
2494 | cbradney | 1887 | StrokeTools->setCurrentDocument(currDoc); |
1888 | FillTools->setCurrentDocument(currDoc); |
||
1889 | Editor->setCurrentDocument(currDoc); |
||
1890 | currItem = item; |
||
1891 | if (currItem!=NULL) |
||
1892 | { |
||
10180 | fschmid | 1893 | setWindowTitle( tr("Story Editor - %1").arg(currItem->itemName())); |
2494 | cbradney | 1894 | firstSet = false; |
8104 | fschmid | 1895 | FontTools->Fonts->RebuildList(currDoc, currItem->isAnnotation()); |
2494 | cbradney | 1896 | Editor->loadItemText(currItem); |
10965 | fschmid | 1897 | Editor->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); |
10628 | fschmid | 1898 | Editor->repaint(); |
10965 | fschmid | 1899 | EditorBar->offs = 0; |
1900 | // Editor->textCursor().setPosition(0); |
||
1901 | // Editor->ensureCursorVisible(); |
||
1902 | EditorBar->setRepaint(true); |
||
1903 | EditorBar->doRepaint(); |
||
2494 | cbradney | 1904 | updateProps(0,0); |
1905 | updateStatus(); |
||
1906 | connectSignals(); |
||
1907 | } |
||
1908 | else |
||
2500 | fschmid | 1909 | { |
1910 | Editor->StyledText.clear(); |
||
1911 | Editor->clear(); |
||
10180 | fschmid | 1912 | setWindowTitle( tr( "Story Editor" )); |
2500 | fschmid | 1913 | } |
7962 | fschmid | 1914 | QString data = QApplication::clipboard()->text(QClipboard::Clipboard); |
1915 | if (!data.isNull()) |
||
1916 | seActions["editPaste"]->setEnabled(true); |
||
2494 | cbradney | 1917 | } |
1918 | |||
445 | fschmid | 1919 | /** 10/12/2004 - pv - #1203: wrong selection on double click |
1920 | Catch the double click signal - cut the wrong selection (with |
||
1921 | whitespaces on the tail) - select only one word - return |
||
1922 | controlling back to story editor - have rest */ |
||
1923 | void StoryEditor::doubleClick(int para, int position) |
||
1924 | { |
||
10628 | fschmid | 1925 | int indexFrom=0, indexTo=0; |
10671 | fschmid | 1926 | QString selText = Editor->textCursor().selectedText(); |
461 | fschmid | 1927 | if (selText.length() == 0 || !smartSelection) |
445 | fschmid | 1928 | { |
1929 | updateProps(para, position); |
||
1930 | return; |
||
1931 | } |
||
10628 | fschmid | 1932 | indexFrom = Editor->textCursor().selectionStart(); |
1933 | indexTo = Editor->textCursor().selectionEnd(); |
||
10394 | cbradney | 1934 | selText = selText.trimmed(); |
10628 | fschmid | 1935 | Editor->textCursor().clearSelection(); |
1936 | Editor->textCursor().setPosition(indexFrom); |
||
1937 | Editor->textCursor().setPosition(indexFrom + selText.length(), QTextCursor::KeepAnchor); |
||
445 | fschmid | 1938 | updateProps(para, position); |
1939 | } |
||
1940 | |||
4550 | cbradney | 1941 | void StoryEditor::setSmart(bool newSmartSelection) |
461 | fschmid | 1942 | { |
4550 | cbradney | 1943 | smartSelection = newSmartSelection; |
461 | fschmid | 1944 | } |
1945 | |||
795 | fschmid | 1946 | void StoryEditor::closeEvent(QCloseEvent *) |
351 | Franz | 1947 | { |
2494 | cbradney | 1948 | if (textChanged) |
167 | Franz | 1949 | { |
2500 | fschmid | 1950 | blockUpdate = true; |
3732 | cbradney | 1951 | int t = ScMessageBox::warning(this, CommonStrings::trWarning, |
351 | Franz | 1952 | tr("Do you want to save your changes?"), |
1946 | craig | 1953 | QMessageBox::Yes|QMessageBox::Default, |
1954 | QMessageBox::No, |
||
1955 | QMessageBox::Cancel|QMessageBox::Escape); |
||
2500 | fschmid | 1956 | qApp->processEvents(); |
351 | Franz | 1957 | if (t == QMessageBox::Yes) |
2386 | fschmid | 1958 | { |
1959 | updateTextFrame(); |
||
351 | Franz | 1960 | result = QDialog::Accepted; |
2386 | fschmid | 1961 | } |
351 | Franz | 1962 | else if (t == QMessageBox::Cancel) |
2500 | fschmid | 1963 | { |
1964 | blockUpdate = false; |
||
351 | Franz | 1965 | return; |
2500 | fschmid | 1966 | } |
351 | Franz | 1967 | else if (t == QMessageBox::No) |
1968 | result = QDialog::Rejected; |
||
167 | Franz | 1969 | } |
351 | Franz | 1970 | else |
1971 | result = QDialog::Rejected; |
||
8239 | avox | 1972 | setCurrentDocumentAndItem(NULL, NULL); |
3868 | subik | 1973 | savePrefs(); |
7087 | subik | 1974 | // if (charSelect != NULL) |
1975 | // charSelect->close(); |
||
351 | Franz | 1976 | hide(); |
2500 | fschmid | 1977 | blockUpdate = false; |
351 | Franz | 1978 | } |
1979 | |||
1951 | fschmid | 1980 | void StoryEditor::keyPressEvent (QKeyEvent * e) |
1981 | { |
||
1982 | if (e->key() == Qt::Key_Escape) |
||
1983 | close(); |
||
1984 | else |
||
2500 | fschmid | 1985 | { |
1986 | activFromApp = false; |
||
10172 | cbradney | 1987 | return QMainWindow::keyReleaseEvent(e); |
2500 | fschmid | 1988 | } |
1951 | fschmid | 1989 | } |
1990 | |||
2498 | fschmid | 1991 | bool StoryEditor::eventFilter |