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