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