1 /***************************************************************************
2 titlewidget.cpp - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
18 #include "titlewidget.h"
19 #include "kdenlivesettings.h"
22 #include <KGlobalSettings>
23 #include <KFileDialog>
24 #include <KStandardDirs>
25 #include <KMessageBox>
27 #include <QDomDocument>
28 #include <QGraphicsItem>
29 #include <QGraphicsSvgItem>
33 #include <QTextBlockFormat>
34 #include <QTextCursor>
36 int settingUp = false;
38 const int IMAGEITEM = 7;
39 const int RECTITEM = 3;
40 const int TEXTITEM = 8;
42 TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWidget *parent) :
45 m_startViewport(NULL),
49 m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
50 m_projectTitlePath(projectTitlePath)
53 setFont(KGlobalSettings::toolBarFont());
54 //toolBox->setFont(KGlobalSettings::toolBarFont());
55 frame_properties->setEnabled(false);
56 rect_properties->setFixedHeight(frame_properties->height() + 4);
57 text_properties->setFixedHeight(frame_properties->height() + 4);
58 m_frameWidth = render->renderWidth();
59 m_frameHeight = render->renderHeight();
60 connect(kcolorbutton, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
61 connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
64 connect(fontColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
65 connect(font_family, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotUpdateText())) ;
66 connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
67 connect(textAlpha, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
69 connect(rectFAlpha, SIGNAL(valueChanged(int)), this, SLOT(rectChanged()));
70 connect(rectBAlpha, SIGNAL(valueChanged(int)), this, SLOT(rectChanged()));
71 connect(rectFColor, SIGNAL(clicked()), this, SLOT(rectChanged()));
72 connect(rectBColor, SIGNAL(clicked()), this, SLOT(rectChanged()));
73 connect(rectLineWidth, SIGNAL(valueChanged(int)), this, SLOT(rectChanged()));
75 connect(startViewportX, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
76 connect(startViewportY, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
77 connect(startViewportSize, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
78 connect(endViewportX, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
79 connect(endViewportY, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
80 connect(endViewportSize, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
82 connect(zValue, SIGNAL(valueChanged(int)), this, SLOT(zIndexChanged(int)));
83 connect(itemzoom, SIGNAL(valueChanged(int)), this, SLOT(itemScaled(int)));
84 connect(itemrotate, SIGNAL(valueChanged(int)), this, SLOT(itemRotate(int)));
85 connect(itemhcenter, SIGNAL(clicked()), this, SLOT(itemHCenter()));
86 connect(itemvcenter, SIGNAL(clicked()), this, SLOT(itemVCenter()));
88 connect(origin_x_left, SIGNAL(clicked()), this, SLOT(slotOriginXClicked()));
89 connect(origin_y_top, SIGNAL(clicked()), this, SLOT(slotOriginYClicked()));
91 connect(value_x, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
92 connect(value_y, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
93 connect(value_w, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
94 connect(value_h, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
95 connect(buttonFitZoom, SIGNAL(clicked()), this, SLOT(slotAdjustZoom()));
96 connect(buttonRealSize, SIGNAL(clicked()), this, SLOT(slotZoomOneToOne()));
97 connect(buttonBold, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
98 connect(buttonItalic, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
99 connect(buttonUnder, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
100 connect(buttonAlignLeft, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
101 connect(buttonAlignRight, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
102 connect(buttonAlignCenter, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
103 connect(buttonAlignNone, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
104 connect(buttonInsertUnicode, SIGNAL(clicked()), this, SLOT(slotInsertUnicode()));
105 connect(displayBg, SIGNAL(stateChanged(int)), this, SLOT(displayBackgroundFrame()));
107 connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
110 connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
112 buttonFitZoom->setIcon(KIcon("zoom-fit-best"));
113 buttonRealSize->setIcon(KIcon("zoom-original"));
114 buttonBold->setIcon(KIcon("format-text-bold"));
115 buttonItalic->setIcon(KIcon("format-text-italic"));
116 buttonUnder->setIcon(KIcon("format-text-underline"));
117 buttonAlignCenter->setIcon(KIcon("format-justify-center"));
118 buttonAlignLeft->setIcon(KIcon("format-justify-left"));
119 buttonAlignRight->setIcon(KIcon("format-justify-right"));
120 buttonAlignNone->setIcon(KIcon("kdenlive-align-none"));
121 buttonInsertUnicode->setIcon(KIcon("kdenlive-insert-unicode"));
123 buttonAlignNone->setToolTip(i18n("No alignment"));
124 buttonAlignRight->setToolTip(i18n("Align right"));
125 buttonAlignLeft->setToolTip(i18n("Align left"));
126 buttonAlignCenter->setToolTip(i18n("Align center"));
127 buttonInsertUnicode->setToolTip(i18n("Insert Unicode character (Shift+Ctrl+U)"));
128 buttonInsertUnicode->setShortcut(Qt::SHIFT + Qt::CTRL + Qt::Key_U);
129 origin_x_left->setToolTip(i18n("Invert x axis and change 0 point"));
130 origin_y_top->setToolTip(i18n("Invert y axis and change 0 point"));
131 rectBColor->setToolTip(i18n("Select fill color"));
132 rectFColor->setToolTip(i18n("Select border color"));
133 rectBAlpha->setToolTip(i18n("Fill transparency"));
134 rectFAlpha->setToolTip(i18n("Border transparency"));
135 zoom_slider->setToolTip(i18n("Zoom"));
136 buttonRealSize->setToolTip(i18n("Original size (1:1)"));
137 buttonFitZoom->setToolTip(i18n("Fit zoom"));
138 kcolorbutton->setToolTip(i18n("Select background color"));
139 horizontalSlider->setToolTip(i18n("Background Transparency"));
141 itemhcenter->setIcon(KIcon("kdenlive-align-hor"));
142 itemhcenter->setToolTip(i18n("Align item horizontally"));
143 itemvcenter->setIcon(KIcon("kdenlive-align-vert"));
144 itemvcenter->setToolTip(i18n("Align item vertically"));
146 QHBoxLayout *layout = new QHBoxLayout;
147 frame_toolbar->setLayout(layout);
148 layout->setContentsMargins(2, 2, 2, 2);
149 QToolBar *m_toolbar = new QToolBar("titleToolBar", this);
151 m_buttonRect = m_toolbar->addAction(KIcon("kdenlive-insert-rect"), i18n("Add Rectangle (Alt+R)"));
152 m_buttonRect->setCheckable(true);
153 m_buttonRect->setShortcut(Qt::ALT + Qt::Key_R);
154 connect(m_buttonRect, SIGNAL(triggered()), this, SLOT(slotRectTool()));
156 m_buttonText = m_toolbar->addAction(KIcon("insert-text"), i18n("Add Text (Alt+T)"));
157 m_buttonText->setCheckable(true);
158 m_buttonText->setShortcut(Qt::ALT + Qt::Key_T);
159 connect(m_buttonText, SIGNAL(triggered()), this, SLOT(slotTextTool()));
161 m_buttonImage = m_toolbar->addAction(KIcon("insert-image"), i18n("Add Image (Alt+I)"));
162 m_buttonImage->setCheckable(false);
163 m_buttonImage->setShortcut(Qt::ALT + Qt::Key_I);
164 connect(m_buttonImage, SIGNAL(triggered()), this, SLOT(slotImageTool()));
166 m_buttonCursor = m_toolbar->addAction(KIcon("transform-move"), i18n("Selection Tool (Alt+S)"));
167 m_buttonCursor->setCheckable(true);
168 m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
169 connect(m_buttonCursor, SIGNAL(triggered()), this, SLOT(slotSelectTool()));
171 m_toolbar->addSeparator();
173 m_buttonLoad = m_toolbar->addAction(KIcon("document-open"), i18n("Open Document"));
174 m_buttonLoad->setCheckable(false);
175 m_buttonLoad->setShortcut(Qt::CTRL + Qt::Key_O);
176 connect(m_buttonLoad, SIGNAL(triggered()), this, SLOT(loadTitle()));
178 m_buttonSave = m_toolbar->addAction(KIcon("document-save-as"), i18n("Save As"));
179 m_buttonSave->setCheckable(false);
180 m_buttonSave->setShortcut(Qt::CTRL + Qt::Key_S);
181 connect(m_buttonSave, SIGNAL(triggered()), this, SLOT(saveTitle()));
183 layout->addWidget(m_toolbar);
185 // initialize graphic scene
186 m_scene = new GraphicsSceneRectMove(this);
187 graphicsView->setScene(m_scene);
188 m_titledocument.setScene(m_scene);
189 connect(m_scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(slotChanged()));
191 // a gradient background
192 /*QRadialGradient *gradient = new QRadialGradient(0, 0, 10);
193 gradient->setSpread(QGradient::ReflectSpread);
194 scene->setBackgroundBrush(*gradient);*/
196 m_frameImage = new QGraphicsPixmapItem();
198 qtrans.scale(2.0, 2.0);
199 m_frameImage->setTransform(qtrans);
200 m_frameImage->setZValue(-1200);
201 m_frameImage->setFlags(QGraphicsItem::ItemClipsToShape);
202 displayBackgroundFrame();
203 graphicsView->scene()->addItem(m_frameImage);
205 connect(m_scene, SIGNAL(selectionChanged()), this , SLOT(selectionChanged()));
206 connect(m_scene, SIGNAL(itemMoved()), this , SLOT(selectionChanged()));
207 connect(m_scene, SIGNAL(sceneZoom(bool)), this , SLOT(slotZoom(bool)));
208 connect(m_scene, SIGNAL(actionFinished()), this , SLOT(slotSelectTool()));
209 //connect(m_scene, SIGNAL(actionFinished()), this , SLOT(selectionChanged()));
210 connect(m_scene, SIGNAL(newRect(QGraphicsRectItem *)), this , SLOT(slotNewRect(QGraphicsRectItem *)));
211 connect(m_scene, SIGNAL(newText(QGraphicsTextItem *)), this , SLOT(slotNewText(QGraphicsTextItem *)));
212 connect(zoom_slider, SIGNAL(valueChanged(int)), this , SLOT(slotUpdateZoom(int)));
214 QPen framepen(Qt::DotLine);
215 framepen.setColor(Qt::red);
217 m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_frameWidth, m_frameHeight));
218 m_frameBorder->setPen(framepen);
219 m_frameBorder->setZValue(-1100);
220 m_frameBorder->setBrush(Qt::transparent);
221 m_frameBorder->setFlags(QGraphicsItem::ItemClipsToShape);
222 graphicsView->scene()->addItem(m_frameBorder);
224 // mbd: load saved settings
228 QTimer::singleShot(500, this, SLOT(slotAdjustZoom()));
229 graphicsView->show();
230 //graphicsView->setRenderHint(QPainter::Antialiasing);
231 graphicsView->setInteractive(true);
232 //graphicsView->resize(400, 300);
233 kDebug() << "// TITLE WIDGWT: " << graphicsView->viewport()->width() << "x" << graphicsView->viewport()->height();
234 toolBox->setItemEnabled(2, false);
235 if (!url.isEmpty()) {
236 m_count = m_titledocument.loadDocument(url, m_startViewport, m_endViewport) + 1;
242 showToolbars(TITLE_NONE);
245 TitleWidget::~TitleWidget()
249 delete m_buttonImage;
250 delete m_buttonCursor;
254 delete m_unicodeDialog;
255 delete m_frameBorder;
257 delete m_startViewport;
258 delete m_endViewport;
263 QStringList TitleWidget::getFreeTitleInfo(const KUrl &projectUrl, bool isClone)
266 QString titlePath = projectUrl.path(KUrl::AddTrailingSlash) + "titles/";
267 KStandardDirs::makeDir(titlePath);
268 titlePath.append((isClone == false) ? "title" : "clone");
271 while (path.isEmpty() || QFile::exists(path)) {
273 path = titlePath + QString::number(counter).rightJustified(3, '0', false) + ".png";
275 result.append(((isClone == false) ? i18n("Title") : i18n("Clone")) + ' ' + QString::number(counter).rightJustified(3, '0', false));
280 QString TitleWidget::getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName)
283 QString titlePath = projectUrl.path(KUrl::AddTrailingSlash) + "titles/";
284 KStandardDirs::makeDir(titlePath);
285 return titlePath + titleName + ".png";
289 void TitleWidget::resizeEvent(QResizeEvent * /*event*/)
294 void TitleWidget::slotTextTool()
296 m_scene->setTool(TITLE_TEXT);
297 showToolbars(TITLE_TEXT);
298 m_buttonRect->setChecked(false);
299 m_buttonCursor->setChecked(false);
302 void TitleWidget::slotRectTool()
304 m_scene->setTool(TITLE_RECTANGLE);
305 showToolbars(TITLE_RECTANGLE);
306 m_buttonText->setChecked(false);
307 m_buttonCursor->setChecked(false);
308 m_buttonRect->setChecked(true);
311 void TitleWidget::slotSelectTool()
313 m_scene->setTool(TITLE_SELECT);
315 // Find out which toolbars need to be shown, depending on selected item
316 TITLETOOL t = TITLE_SELECT;
317 QList<QGraphicsItem *> l = graphicsView->scene()->selectedItems();
319 switch (l.at(0)->type()) {
334 m_buttonCursor->setChecked(true);
335 m_buttonText->setChecked(false);
336 m_buttonRect->setChecked(false);
339 void TitleWidget::slotImageTool()
341 KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.svg *.png *.jpg *.jpeg *.gif *.raw", this, i18n("Load Image"));
342 if (!url.isEmpty()) {
343 if (url.path().endsWith(".svg")) {
344 QGraphicsSvgItem *svg = new QGraphicsSvgItem(url.toLocalFile());
345 svg->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
346 svg->setZValue(m_count++);
347 svg->setData(Qt::UserRole, url.path());
348 graphicsView->scene()->addItem(svg);
350 QPixmap pix(url.path());
351 QGraphicsPixmapItem *image = new QGraphicsPixmapItem(pix);
352 image->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
353 image->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
354 image->setData(Qt::UserRole, url.path());
355 image->setZValue(m_count++);
356 graphicsView->scene()->addItem(image);
359 m_scene->setTool(TITLE_SELECT);
360 showToolbars(TITLE_SELECT);
361 m_buttonRect->setChecked(false);
362 m_buttonCursor->setChecked(true);
363 m_buttonText->setChecked(false);
366 void TitleWidget::showToolbars(TITLETOOL toolType)
376 case TITLE_RECTANGLE:
379 case TITLE_IMAGE: //fall through
384 text_properties->setHidden(!bText);
385 rect_properties->setHidden(!bRect);
386 no_properties->setHidden(!bNone);
389 void TitleWidget::enableToolbars(TITLETOOL toolType)
391 // TITLETOOL is defined in graphicsscenerectmove.h
395 bool bValue_w = false;
396 bool bValue_h = false;
405 case TITLE_RECTANGLE:
417 frame_properties->setEnabled(bFrame);
418 text_properties->setEnabled(bText);
419 rect_properties->setEnabled(bRect);
420 value_w->setEnabled(bValue_w);
421 value_h->setEnabled(bValue_h);
424 void TitleWidget::displayBackgroundFrame()
426 if (!displayBg->isChecked()) {
427 QPixmap bg(m_frameWidth / 2, m_frameHeight / 2);
428 QPixmap pattern(20, 20);
432 p.fillRect(QRect(0, 0, 10, 10), QColor(210, 210, 210));
433 p.fillRect(QRect(10, 10, 20, 20), QColor(210, 210, 210));
438 p.fillRect(bg.rect(), br);
440 m_frameImage->setPixmap(bg);
442 m_frameImage->setPixmap(m_render->extractFrame((int) m_render->seekPosition().frames(m_render->fps()), m_frameWidth / 2, m_frameHeight / 2));
446 void TitleWidget::initViewports()
448 m_startViewport = new QGraphicsPolygonItem(QPolygonF(QRectF(0, 0, 0, 0)));
449 m_endViewport = new QGraphicsPolygonItem(QPolygonF(QRectF(0, 0, 0, 0)));
451 QPen startpen(Qt::DotLine);
452 QPen endpen(Qt::DashDotLine);
453 startpen.setColor(QColor(100, 200, 100, 140));
454 endpen.setColor(QColor(200, 100, 100, 140));
456 m_startViewport->setPen(startpen);
457 m_endViewport->setPen(endpen);
459 startViewportSize->setValue(40);
460 endViewportSize->setValue(40);
462 m_startViewport->setZValue(-1000);
463 m_endViewport->setZValue(-1000);
465 m_startViewport->setFlags(/*QGraphicsItem::ItemIsMovable|*/QGraphicsItem::ItemIsSelectable);
466 m_endViewport->setFlags(/*QGraphicsItem::ItemIsMovable|*/QGraphicsItem::ItemIsSelectable);
468 graphicsView->scene()->addItem(m_startViewport);
469 graphicsView->scene()->addItem(m_endViewport);
472 void TitleWidget::slotUpdateZoom(int pos)
474 m_scene->setZoom((double) pos / 100);
475 zoom_label->setText(QString::number(pos) + '%');
478 void TitleWidget::slotZoom(bool up)
480 int pos = zoom_slider->value();
483 zoom_slider->setValue(pos);
486 void TitleWidget::slotAdjustZoom()
488 /*double scalex = graphicsView->width() / (double)(m_frameWidth * 1.2);
489 double scaley = graphicsView->height() / (double)(m_frameHeight * 1.2);
490 if (scalex > scaley) scalex = scaley;
491 int zoompos = (int)(scalex * 7 + 0.5);*/
492 graphicsView->fitInView(m_frameBorder, Qt::KeepAspectRatio);
493 int zoompos = graphicsView->matrix().m11() * 100;
494 zoom_slider->setValue(zoompos);
495 graphicsView->centerOn(m_frameBorder);
498 void TitleWidget::slotZoomOneToOne()
500 zoom_slider->setValue(100);
501 graphicsView->centerOn(m_frameBorder);
504 void TitleWidget::slotNewRect(QGraphicsRectItem * rect)
506 QColor f = rectFColor->color();
507 f.setAlpha(rectFAlpha->value());
509 penf.setWidth(rectLineWidth->value());
511 QColor b = rectBColor->color();
512 b.setAlpha(rectBAlpha->value());
513 rect->setBrush(QBrush(b));
514 rect->setZValue(m_count++);
515 //setCurrentItem(rect);
516 //graphicsView->setFocus();
519 void TitleWidget::slotNewText(QGraphicsTextItem *tt)
521 QFont font = font_family->currentFont();
522 font.setPixelSize(font_size->value());
524 font.setBold(buttonBold->isChecked());
525 font.setItalic(buttonItalic->isChecked());
526 font.setUnderline(buttonUnder->isChecked());
529 QColor color = fontColorButton->color();
530 color.setAlpha(textAlpha->value());
531 tt->setDefaultTextColor(color);
532 tt->setZValue(m_count++);
536 void TitleWidget::setCurrentItem(QGraphicsItem *item)
538 m_scene->setSelectedItem(item);
541 void TitleWidget::zIndexChanged(int v)
543 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
549 void TitleWidget::selectionChanged()
551 if (m_scene->tool() != TITLE_SELECT) return;
552 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
553 //toolBox->setItemEnabled(2, false);
554 //toolBox->setItemEnabled(3, false);
555 value_x->blockSignals(true);
556 value_y->blockSignals(true);
557 value_w->blockSignals(true);
558 value_h->blockSignals(true);
559 itemzoom->blockSignals(true);
560 itemrotate->blockSignals(true);
562 bool blockX = !origin_x_left->signalsBlocked();
563 bool blockY = !origin_y_top->signalsBlocked();
564 if (blockX) origin_x_left->blockSignals(true);
565 if (blockY) origin_y_top->blockSignals(true);
566 origin_x_left->setChecked(false);
567 origin_y_top->setChecked(false);
570 enableToolbars(TITLE_NONE);
571 if (blockX) origin_x_left->blockSignals(false);
572 if (blockY) origin_y_top->blockSignals(false);
573 } else if (l.size() == 1) {
574 if (l.at(0)->type() == TEXTITEM) {
575 showToolbars(TITLE_TEXT);
576 QGraphicsTextItem* i = static_cast <QGraphicsTextItem *>(l.at(0));
577 //if (l[0]->hasFocus())
578 toolBox->setCurrentIndex(0);
579 //toolBox->setItemEnabled(2, true);
580 font_size->blockSignals(true);
581 font_family->blockSignals(true);
582 buttonBold->blockSignals(true);
583 buttonItalic->blockSignals(true);
584 buttonUnder->blockSignals(true);
585 fontColorButton->blockSignals(true);
586 textAlpha->blockSignals(true);
587 buttonAlignLeft->blockSignals(true);
588 buttonAlignRight->blockSignals(true);
589 buttonAlignNone->blockSignals(true);
590 buttonAlignCenter->blockSignals(true);
592 QFont font = i->font();
593 font_family->setCurrentFont(font);
594 font_size->setValue(font.pixelSize());
595 buttonBold->setChecked(font.bold());
596 buttonItalic->setChecked(font.italic());
597 buttonUnder->setChecked(font.underline());
599 QColor color = i->defaultTextColor();
600 fontColorButton->setColor(color);
601 textAlpha->setValue(color.alpha());
603 QTextCursor cur = i->textCursor();
604 QTextBlockFormat format = cur.blockFormat();
605 if (i->textWidth() == -1) buttonAlignNone->setChecked(true);
606 else if (format.alignment() == Qt::AlignHCenter) buttonAlignCenter->setChecked(true);
607 else if (format.alignment() == Qt::AlignRight) buttonAlignRight->setChecked(true);
608 else if (format.alignment() == Qt::AlignLeft) buttonAlignLeft->setChecked(true);
610 font_size->blockSignals(false);
611 font_family->blockSignals(false);
612 buttonBold->blockSignals(false);
613 buttonItalic->blockSignals(false);
614 buttonUnder->blockSignals(false);
615 fontColorButton->blockSignals(false);
616 textAlpha->blockSignals(false);
617 buttonAlignLeft->blockSignals(false);
618 buttonAlignRight->blockSignals(false);
619 buttonAlignNone->blockSignals(false);
620 buttonAlignCenter->blockSignals(false);
622 updateAxisButtons(i);
623 updateCoordinates(i);
625 enableToolbars(TITLE_TEXT);
627 } else if ((l.at(0))->type() == RECTITEM) {
628 showToolbars(TITLE_RECTANGLE);
630 QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
631 toolBox->setCurrentIndex(0);
632 //toolBox->setItemEnabled(3, true);
633 rectFAlpha->setValue(rec->pen().color().alpha());
634 rectBAlpha->setValue(rec->brush().color().alpha());
635 //kDebug() << rec->brush().color().alpha();
636 QColor fcol = rec->pen().color();
637 QColor bcol = rec->brush().color();
638 //fcol.setAlpha(255);
639 //bcol.setAlpha(255);
640 rectFColor->setColor(fcol);
641 rectBColor->setColor(bcol);
643 rectLineWidth->setValue(rec->pen().width());
645 updateAxisButtons(l.at(0));
646 updateCoordinates(rec);
647 updateDimension(rec);
648 enableToolbars(TITLE_RECTANGLE);
650 } else if (l.at(0)->type() == IMAGEITEM) {
651 updateCoordinates(l.at(0));
652 updateDimension(l.at(0));
654 enableToolbars(TITLE_IMAGE);
657 //toolBox->setCurrentIndex(0);
658 enableToolbars(TITLE_NONE);
659 /*frame_properties->setEnabled(false);
660 text_properties->setEnabled(false);
661 rect_properties->setEnabled(false);*/
663 zValue->setValue((int)l.at(0)->zValue());
664 itemzoom->setValue((int)(m_transformations.value(l.at(0)).scalex * 100.0 + 0.5));
665 itemrotate->setValue((int)(m_transformations.value(l.at(0)).rotate));
666 value_x->blockSignals(false);
667 value_y->blockSignals(false);
668 value_w->blockSignals(false);
669 value_h->blockSignals(false);
670 itemzoom->blockSignals(false);
671 itemrotate->blockSignals(false);
675 /** \brief Updates position/size of the selected item when a value
676 * of an item (coordinates, size) has changed */
677 void TitleWidget::slotAdjustSelectedItem()
679 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
681 if (l.at(0)->type() == RECTITEM) {
683 QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(l.at(0));
685 rec->setRect(QRect(0, 0, value_w->value(), value_h->value()));
686 } else if (l.at(0)->type() == TEXTITEM) {
688 updatePosition(l.at(0));
689 } else if (l.at(0)->type() == IMAGEITEM) {
691 updatePosition(l.at(0));
696 /** \brief Updates width/height int the text fields, regarding transformation matrix */
697 void TitleWidget::updateDimension(QGraphicsItem *i)
699 bool blockW = !value_w->signalsBlocked();
700 bool blockH = !value_h->signalsBlocked();
702 if (blockW) value_w->blockSignals(true);
703 if (blockH) value_h->blockSignals(true);
706 if (i->type() == IMAGEITEM) {
707 // Get multipliers for rotation/scaling
709 /*Transform t = m_transformations.value(i);
710 QRectF r = i->boundingRect();
711 int width = (int) ( abs(r.width()*t.scalex * cos(t.rotate/180.0*M_PI))
712 + abs(r.height()*t.scaley * sin(t.rotate/180.0*M_PI)) );
713 int height = (int) ( abs(r.height()*t.scaley * cos(t.rotate/180*M_PI))
714 + abs(r.width()*t.scalex * sin(t.rotate/180*M_PI)) );*/
716 value_w->setValue(i->sceneBoundingRect().width());
717 value_h->setValue(i->sceneBoundingRect().height());
718 } else if (i->type() == RECTITEM) {
719 QGraphicsRectItem *r = static_cast <QGraphicsRectItem *>(i);
720 value_w->setValue((int) r->rect().width());
721 value_h->setValue((int) r->rect().height());
722 } else if (i->type() == TEXTITEM) {
723 QGraphicsTextItem *t = static_cast <QGraphicsTextItem *>(i);
724 value_w->setValue((int) t->boundingRect().width());
725 value_h->setValue((int) t->boundingRect().height());
728 if (blockW) value_w->blockSignals(false);
729 if (blockH) value_h->blockSignals(false);
732 /** \brief Updates the coordinates in the text fields from the item */
733 void TitleWidget::updateCoordinates(QGraphicsItem *i)
735 // Block signals emitted by this method
736 value_x->blockSignals(true);
737 value_y->blockSignals(true);
739 if (i->type() == TEXTITEM) {
741 QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
743 // Set the correct x coordinate value
744 if (origin_x_left->isChecked()) {
745 // Origin (0 point) is at m_frameWidth, coordinate axis is inverted
746 value_x->setValue((int)(m_frameWidth - rec->pos().x() - rec->boundingRect().width()));
748 // Origin is at 0 (default)
749 value_x->setValue((int) rec->pos().x());
753 if (origin_y_top->isChecked()) {
754 value_y->setValue((int)(m_frameHeight - rec->pos().y() - rec->boundingRect().height()));
756 value_y->setValue((int) rec->pos().y());
759 } else if (i->type() == RECTITEM) {
761 QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(i);
763 if (origin_x_left->isChecked()) {
764 // Origin (0 point) is at m_frameWidth
765 value_x->setValue((int)(m_frameWidth - rec->pos().x() - rec->rect().width()));
767 // Origin is at 0 (default)
768 value_x->setValue((int) rec->pos().x());
771 if (origin_y_top->isChecked()) {
772 value_y->setValue((int)(m_frameHeight - rec->pos().y() - rec->rect().height()));
774 value_y->setValue((int) rec->pos().y());
777 } else if (i->type() == IMAGEITEM) {
779 if (origin_x_left->isChecked()) {
780 value_x->setValue((int)(m_frameWidth - i->pos().x() - i->sceneBoundingRect().width()));
782 value_x->setValue((int) i->pos().x());
785 if (origin_y_top->isChecked()) {
786 value_y->setValue((int)(m_frameHeight - i->pos().y() - i->sceneBoundingRect().height()));
788 value_y->setValue((int) i->pos().y());
793 // Stop blocking signals now
794 value_x->blockSignals(false);
795 value_y->blockSignals(false);
798 /** \brief Updates the position of an item by reading coordinates from the text fields */
799 void TitleWidget::updatePosition(QGraphicsItem *i)
801 if (i->type() == TEXTITEM) {
802 QGraphicsTextItem *rec = static_cast <QGraphicsTextItem *>(i);
805 if (origin_x_left->isChecked()) {
806 /* Origin of the x axis is at m_frameWidth,
807 * and distance from right border of the item to the right
808 * border of the frame is taken.
809 * See comment to slotOriginXClicked().
811 posX = m_frameWidth - value_x->value() - rec->boundingRect().width();
813 posX = value_x->value();
817 if (origin_y_top->isChecked()) {
818 /* Same for y axis */
819 posY = m_frameHeight - value_y->value() - rec->boundingRect().height();
821 posY = value_y->value();
824 rec->setPos(posX, posY);
826 } else if (i->type() == RECTITEM) {
828 QGraphicsRectItem *rec = static_cast <QGraphicsRectItem *>(i);
831 if (origin_x_left->isChecked()) {
832 posX = m_frameWidth - value_x->value() - rec->rect().width();
834 posX = value_x->value();
838 if (origin_y_top->isChecked()) {
839 posY = m_frameHeight - value_y->value() - rec->rect().height();
841 posY = value_y->value();
844 rec->setPos(posX, posY);
846 } else if (i->type() == IMAGEITEM) {
848 if (origin_x_left->isChecked()) {
849 // Use the sceneBoundingRect because this also regards transformations like zoom
850 posX = m_frameWidth - value_x->value() - i->sceneBoundingRect().width();
852 posX = value_x->value();
856 if (origin_y_top->isChecked()) {
857 posY = m_frameHeight - value_y->value() - i->sceneBoundingRect().height();
859 posY = value_y->value();
862 i->setPos(posX, posY);
868 void TitleWidget::updateTextOriginX()
870 if (origin_x_left->isChecked()) {
871 origin_x_left->setText(i18n("\u2212X"));
873 origin_x_left->setText(i18n("+X"));
877 void TitleWidget::slotOriginXClicked()
879 // Update the text displayed on the button.
882 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
884 updateCoordinates(l.at(0));
886 // Remember x axis setting
887 l.at(0)->setData(TitleDocument::OriginXLeft, origin_x_left->isChecked() ?
888 TitleDocument::AxisInverted : TitleDocument::AxisDefault);
890 graphicsView->setFocus();
893 void TitleWidget::updateTextOriginY()
895 if (origin_y_top->isChecked()) {
896 origin_y_top->setText(i18n("\u2212Y"));
898 origin_y_top->setText(i18n("+Y"));
902 void TitleWidget::slotOriginYClicked()
904 // Update the text displayed on the button.
907 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
909 updateCoordinates(l.at(0));
911 l.at(0)->setData(TitleDocument::OriginYTop, origin_y_top->isChecked() ?
912 TitleDocument::AxisInverted : TitleDocument::AxisDefault);
915 graphicsView->setFocus();
918 void TitleWidget::updateAxisButtons(QGraphicsItem *i)
920 int xAxis = i->data(TitleDocument::OriginXLeft).toInt();
921 int yAxis = i->data(TitleDocument::OriginYTop).toInt();
922 origin_x_left->blockSignals(true);
923 origin_y_top->blockSignals(true);
925 if (xAxis == TitleDocument::AxisInverted) {
926 origin_x_left->setChecked(true);
928 origin_x_left->setChecked(false);
932 if (yAxis == TitleDocument::AxisInverted) {
933 origin_y_top->setChecked(true);
935 origin_y_top->setChecked(false);
939 origin_x_left->blockSignals(false);
940 origin_y_top->blockSignals(false);
943 void TitleWidget::slotChangeBackground()
945 QColor color = kcolorbutton->color();
946 color.setAlpha(horizontalSlider->value());
947 m_frameBorder->setBrush(QBrush(color));
951 * Something (yeah) has changed in our QGraphicsScene.
953 void TitleWidget::slotChanged()
955 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
956 if (l.size() >= 1 && l.at(0)->type() == TEXTITEM) {
957 textChanged(static_cast <QGraphicsTextItem *>(l.at(0)));
962 * If the user has set origin_x_left (everything also for y),
963 * we need to look whether a text element has been selected. If yes,
964 * we need to ensure that the right border of the text field
965 * remains fixed also when some text has been entered.
967 * This is also known as right-justified, with the difference that
968 * it is not valid for text but for its boundingRect. Text may still
971 void TitleWidget::textChanged(QGraphicsTextItem *i)
976 if (origin_x_left->isChecked() || origin_y_top->isChecked()) {
978 if (!i->toPlainText().isEmpty()) {
982 * Don't do anything if the string is empty. If the position
983 * would be updated here, a newly created text field would
984 * be set to the position of the last selected text field.
990 void TitleWidget::slotInsertUnicode()
992 m_unicodeDialog->exec();
995 void TitleWidget::slotInsertUnicodeString(QString text)
997 QList<QGraphicsItem *> l = graphicsView->scene()->selectedItems();
999 if (l.at(0)->type() == TEXTITEM) {
1000 QGraphicsTextItem *t = static_cast <QGraphicsTextItem *>(l.at(0));
1001 t->textCursor().insertText(text);
1006 void TitleWidget::slotUpdateText()
1008 QFont font = font_family->currentFont();
1009 font.setPixelSize(font_size->value());
1010 font.setBold(buttonBold->isChecked());
1011 font.setItalic(buttonItalic->isChecked());
1012 font.setUnderline(buttonUnder->isChecked());
1013 QColor color = fontColorButton->color();
1014 color.setAlpha(textAlpha->value());
1016 QGraphicsTextItem* item = NULL;
1017 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1018 if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
1019 item = static_cast <QGraphicsTextItem *>(l.at(0));
1022 //if (item->textCursor().selection ().isEmpty())
1023 QTextCursor cur = item->textCursor();
1024 QTextBlockFormat format = cur.blockFormat();
1025 if (buttonAlignLeft->isChecked() || buttonAlignCenter->isChecked() || buttonAlignRight->isChecked()) {
1026 item->setTextWidth(item->boundingRect().width());
1027 if (buttonAlignCenter->isChecked()) format.setAlignment(Qt::AlignHCenter);
1028 else if (buttonAlignRight->isChecked()) format.setAlignment(Qt::AlignRight);
1029 else if (buttonAlignLeft->isChecked()) format.setAlignment(Qt::AlignLeft);
1031 format.setAlignment(Qt::AlignLeft);
1032 item->setTextWidth(-1);
1036 item->setFont(font);
1037 item->setDefaultTextColor(color);
1038 cur.select(QTextCursor::Document);
1039 cur.setBlockFormat(format);
1040 item->setTextCursor(cur);
1041 cur.clearSelection();
1042 item->setTextCursor(cur);
1047 void TitleWidget::rectChanged()
1049 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1050 if (l.size() == 1 && l.at(0)->type() == RECTITEM && !settingUp) {
1051 QGraphicsRectItem *rec = static_cast<QGraphicsRectItem *>(l.at(0));
1052 QColor f = rectFColor->color();
1053 f.setAlpha(rectFAlpha->value());
1055 penf.setWidth(rectLineWidth->value());
1057 QColor b = rectBColor->color();
1058 b.setAlpha(rectBAlpha->value());
1059 rec->setBrush(QBrush(b));
1063 void TitleWidget::itemScaled(int val)
1065 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1066 if (l.size() == 1) {
1067 Transform x = m_transformations.value(l.at(0));
1068 x.scalex = (double)val / 100.0;
1069 x.scaley = (double)val / 100.0;
1071 qtrans.scale(x.scalex, x.scaley);
1072 qtrans.rotate(x.rotate);
1073 l[0]->setTransform(qtrans);
1074 m_transformations[l.at(0)] = x;
1075 updateDimension(l.at(0));
1079 void TitleWidget::itemRotate(int val)
1081 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1082 if (l.size() == 1) {
1083 Transform x = m_transformations[l.at(0)];
1084 x.rotate = (double)val;
1086 qtrans.scale(x.scalex, x.scaley);
1087 qtrans.rotate(x.rotate);
1088 l[0]->setTransform(qtrans);
1089 m_transformations[l.at(0)] = x;
1090 updateDimension(l.at(0));
1094 void TitleWidget::itemHCenter()
1096 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1097 if (l.size() == 1) {
1098 QGraphicsItem *item = l.at(0);
1100 br = item->sceneBoundingRect();
1101 int width = (int)br.width();
1102 int newPos = (int)((m_frameWidth - width) / 2);
1103 newPos += item->pos().x() - br.left(); // Check item transformation
1104 item->setPos(newPos, item->pos().y());
1105 updateCoordinates(item);
1109 void TitleWidget::itemVCenter()
1111 QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
1112 if (l.size() == 1) {
1113 QGraphicsItem *item = l.at(0);
1115 br = item->sceneBoundingRect();
1116 int height = (int)br.height();
1117 int newPos = (int)((m_frameHeight - height) / 2);
1118 newPos += item->pos().y() - br.top(); // Check item transformation
1119 item->setPos(item->pos().x(), newPos);
1120 updateCoordinates(item);
1124 void TitleWidget::setupViewports()
1126 double aspect_ratio = 4.0 / 3.0;//read from project
1128 QRectF sp(0, 0, 0, 0);
1129 QRectF ep(0, 0, 0, 0);
1131 double sv_size = startViewportSize->value();
1132 double ev_size = endViewportSize->value();
1133 sp.adjust(-sv_size, -sv_size / aspect_ratio, sv_size, sv_size / aspect_ratio);
1134 ep.adjust(-ev_size, -ev_size / aspect_ratio, ev_size, ev_size / aspect_ratio);
1136 m_startViewport->setPos(startViewportX->value(), startViewportY->value());
1137 m_endViewport->setPos(endViewportX->value(), endViewportY->value());
1139 m_startViewport->setPolygon(QPolygonF(sp));
1140 m_endViewport->setPolygon(QPolygonF(ep));
1144 void TitleWidget::loadTitle()
1146 KUrl url = KFileDialog::getOpenUrl(KUrl(m_projectTitlePath), "*.kdenlivetitle", this, i18n("Load Title"));
1147 if (!url.isEmpty()) {
1148 QList<QGraphicsItem *> items = m_scene->items();
1149 for (int i = 0; i < items.size(); i++) {
1150 if (items.at(i)->zValue() > -1000) delete items.at(i);
1152 m_count = m_titledocument.loadDocument(url, m_startViewport, m_endViewport) + 1;
1157 void TitleWidget::saveTitle(KUrl url)
1159 if (url.isEmpty()) url = KFileDialog::getSaveUrl(KUrl(m_projectTitlePath), "*.kdenlivetitle", this, i18n("Save Title"));
1160 if (!url.isEmpty()) {
1161 if (m_titledocument.saveDocument(url, m_startViewport, m_endViewport) == false)
1162 KMessageBox::error(this, i18n("Cannot write to file %1", url.path()));
1166 QDomDocument TitleWidget::xml()
1168 QDomDocument doc = m_titledocument.xml(m_startViewport, m_endViewport);
1169 if (cropImage->isChecked()) {
1170 doc.documentElement().setAttribute("crop", 1);
1175 void TitleWidget::setXml(QDomDocument doc)
1177 m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport);
1178 QDomElement e = doc.documentElement();
1179 cropImage->setChecked(e.hasAttribute("crop"));
1180 m_transformations.clear();
1181 QList <QGraphicsItem *> items = graphicsView->scene()->items();
1182 const double PI = 4.0 * atan(1.0);
1183 for (int i = 0; i < items.count(); i++) {
1184 QTransform t = items.at(i)->transform();
1188 x.rotate = 180. / PI * atan2(-t.m21(), t.m11());
1189 m_transformations[items.at(i)] = x;
1191 // mbd: Update the GUI color selectors to match the stuff from the loaded document
1192 QColor background_color = m_titledocument.getBackgroundColor();
1193 horizontalSlider->blockSignals(true);
1194 kcolorbutton->blockSignals(true);
1195 horizontalSlider->setValue(background_color.alpha());
1196 background_color.setAlpha(255);
1197 kcolorbutton->setColor(background_color);
1198 horizontalSlider->blockSignals(false);
1199 kcolorbutton->blockSignals(false);
1204 const QRect TitleWidget::renderedRect()
1208 int maxX = m_frameWidth;
1209 int maxY = m_frameHeight;
1210 if (!cropImage->isChecked()) {
1211 m_scene->removeItem(m_startViewport);
1212 m_scene->removeItem(m_endViewport);
1213 QRect boundingRect = m_scene->itemsBoundingRect().toRect();
1214 if (boundingRect.left() < 0) minX = boundingRect.left();
1215 if (boundingRect.top() < 0) minY = boundingRect.top();
1216 if (boundingRect.right() > maxX) maxX = boundingRect.right();
1217 if (boundingRect.bottom() > maxY) maxY = boundingRect.bottom();
1225 QRect rect(minX, minY, maxX, maxY);
1229 QImage TitleWidget::renderedPixmap()
1231 QRect rect = renderedRect();
1232 QImage pix(rect.width(), rect.height(), QImage::Format_ARGB32);
1233 pix.fill(Qt::transparent);
1234 QPainter painter(&pix);
1235 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::HighQualityAntialiasing);
1236 m_scene->clearTextSelection();
1237 QPen framepen = m_frameBorder->pen();
1238 m_frameBorder->setPen(Qt::NoPen);
1239 m_startViewport->setVisible(false);
1240 m_endViewport->setVisible(false);
1241 m_frameImage->setVisible(false);
1243 m_scene->render(&painter, QRectF(), rect); //QRectF(minX, minY, maxX - minX, maxY - minY));
1245 m_frameBorder->setPen(framepen);
1246 m_startViewport->setVisible(true);
1247 m_endViewport->setVisible(true);
1248 m_frameImage->setVisible(true);
1252 /** \brief Connected to the accepted signal - calls writeChoices */
1253 void TitleWidget::slotAccepted()
1258 /** \brief Store the current choices of font, background and rect values */
1259 void TitleWidget::writeChoices()
1261 // Get a pointer to a shared configuration instance, then get the TitleWidget group.
1262 KSharedConfigPtr config = KGlobal::config();
1263 KConfigGroup titleConfig(config, "TitleWidget");
1264 // Write the entries
1265 titleConfig.writeEntry("font_family", font_family->currentFont());
1266 //titleConfig.writeEntry("font_size", font_size->value());
1267 titleConfig.writeEntry("font_pixel_size", font_size->value());
1268 titleConfig.writeEntry("font_color", fontColorButton->color());
1269 titleConfig.writeEntry("font_alpha", textAlpha->value());
1270 titleConfig.writeEntry("font_bold", buttonBold->isChecked());
1271 titleConfig.writeEntry("font_italic", buttonItalic->isChecked());
1272 titleConfig.writeEntry("font_underlined", buttonUnder->isChecked());
1274 titleConfig.writeEntry("rect_foreground_color", rectFColor->color());
1275 titleConfig.writeEntry("rect_foreground_alpha", rectFAlpha->value());
1276 titleConfig.writeEntry("rect_background_color", rectBColor->color());
1277 titleConfig.writeEntry("rect_background_alpha", rectBAlpha->value());
1278 titleConfig.writeEntry("rect_line_width", rectLineWidth->value());
1280 titleConfig.writeEntry("background_color", kcolorbutton->color());
1281 titleConfig.writeEntry("background_alpha", horizontalSlider->value());
1283 titleConfig.writeEntry("crop_image", cropImage->isChecked());
1285 //! \todo Not sure if I should sync - it is probably safe to do it
1290 /** \brief Read the last stored choices into the dialog */
1291 void TitleWidget::readChoices()
1293 // Get a pointer to a shared configuration instance, then get the TitleWidget group.
1294 KSharedConfigPtr config = KGlobal::config();
1295 KConfigGroup titleConfig(config, "TitleWidget");
1297 font_family->setCurrentFont(titleConfig.readEntry("font_family", font_family->currentFont()));
1298 font_size->setValue(titleConfig.readEntry("font_pixel_size", font_size->value()));
1299 fontColorButton->setColor(titleConfig.readEntry("font_color", fontColorButton->color()));
1300 textAlpha->setValue(titleConfig.readEntry("font_alpha", textAlpha->value()));
1301 buttonBold->setChecked(titleConfig.readEntry("font_bold", buttonBold->isChecked()));
1302 buttonItalic->setChecked(titleConfig.readEntry("font_italic", buttonItalic->isChecked()));
1303 buttonUnder->setChecked(titleConfig.readEntry("font_underlined", buttonUnder->isChecked()));
1305 rectFColor->setColor(titleConfig.readEntry("rect_foreground_color", rectFColor->color()));
1306 rectFAlpha->setValue(titleConfig.readEntry("rect_foreground_alpha", rectFAlpha->value()));
1307 rectBColor->setColor(titleConfig.readEntry("rect_background_color", rectBColor->color()));
1308 rectBAlpha->setValue(titleConfig.readEntry("rect_background_alpha", rectBAlpha->value()));
1309 rectLineWidth->setValue(titleConfig.readEntry("rect_line_width", rectLineWidth->value()));
1311 kcolorbutton->setColor(titleConfig.readEntry("background_color", kcolorbutton->color()));
1312 horizontalSlider->setValue(titleConfig.readEntry("background_alpha", horizontalSlider->value()));
1314 cropImage->setChecked(titleConfig.readEntry("crop_image", cropImage->isChecked()));