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