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