]> git.sesse.net Git - kdenlive/commitdiff
outline-text
authorMarco Gittler <marco@gitma.de>
Tue, 5 Jan 2010 10:54:43 +0000 (10:54 +0000)
committerMarco Gittler <marco@gitma.de>
Tue, 5 Jan 2010 10:54:43 +0000 (10:54 +0000)
svn path=/trunk/kdenlive/; revision=4203

src/titledocument.cpp
src/titlewidget.cpp
src/widgets/titlewidget_ui.ui

index 2486b5446c7160c4bcd4025295b6d0511489ff7b..c959e04bbc1c0f8c62319b11c0d58a6913cac44d 100644 (file)
@@ -273,7 +273,22 @@ int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsRectItem* startv, QGra
                         font.setPixelSize(txtProperties.namedItem("font-pixel-size").nodeValue().toInt());
                     QColor col(stringToColor(txtProperties.namedItem("font-color").nodeValue()));
                     QGraphicsTextItem *txt = m_scene->addText(items.item(i).namedItem("content").firstChild().nodeValue(), font);
-                    txt->setDefaultTextColor(col);
+               if (txtProperties.namedItem("font-outline").nodeValue().toDouble()>0.0){
+               txt->setData(101,txtProperties.namedItem("font-outline").nodeValue().toDouble());
+               txt->setData(102,stringToColor( txtProperties.namedItem( "font-outline-color" ).nodeValue() ));
+                                       QTextCursor cursor(txt->document());
+                                       cursor.select(QTextCursor::Document);
+                                       QTextCharFormat format;
+                                       format.setTextOutline(
+                                                       QPen(QColor( stringToColor( txtProperties.namedItem( "font-outline-color" ).nodeValue() ) ),
+                                                       txtProperties.namedItem("font-outline").nodeValue().toDouble())
+                                       );
+                                       format.setForeground(QBrush(col));
+                                       cursor.mergeCharFormat(format);
+                               } else {
+                                       txt->setDefaultTextColor( col );
+                               }
                     txt->setTextInteractionFlags(Qt::NoTextInteraction);
                     if (txtProperties.namedItem("alignment").isNull() == false) {
                         txt->setTextWidth(txt->boundingRect().width());
index ce337e796d1c36aa64a1187714161c4b149200fc..9cf416fb52230353444429d24179b0816e6903d1 100644 (file)
@@ -83,9 +83,12 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
     connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
 
     connect(fontColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
+    connect(textOutlineColor, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
     connect(font_family, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotUpdateText())) ;
     connect(font_size, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText())) ;
     connect(textAlpha, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
+    connect(textOutline, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
+    connect(textOutlineAlpha, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
     connect(font_weight_box, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateText()));
 
     connect(font_family, SIGNAL(editTextChanged(const QString &)), this, SLOT(slotFontText(const QString&)));
@@ -802,9 +805,25 @@ void TitleWidget::selectionChanged()
             setFontBoxWeight(font.weight());
 
             QColor color = i->defaultTextColor();
+           QTextCursor cursor(i->document());
+           cursor.select(QTextCursor::Document);
+           color=cursor.charFormat().foreground().color();
             fontColorButton->setColor(color);
             textAlpha->setValue(color.alpha());
 
+           if (!i->data(101).isNull()){
+                       textOutline->blockSignals(true);
+               textOutline->setValue(i->data(101).toDouble()*10);
+                       textOutline->blockSignals(false);
+           }
+           if (!i->data(102).isNull()){
+                       textOutlineColor->blockSignals(true);
+                       textOutlineAlpha->blockSignals(true);
+               textOutlineColor->setColor(i->data(102).toString());
+               textOutlineAlpha->setValue(QColor(i->data(102).toString()).alpha());
+                       textOutlineColor->blockSignals(false);
+                       textOutlineAlpha->blockSignals(false);
+           }
             QTextCursor cur = i->textCursor();
             QTextBlockFormat format = cur.blockFormat();
             if (i->textWidth() == -1) buttonAlignNone->setChecked(true);
@@ -1293,6 +1312,9 @@ void TitleWidget::slotUpdateText()
     QColor color = fontColorButton->color();
     color.setAlpha(textAlpha->value());
 
+    QColor outlineColor=textOutlineColor->color();
+    outlineColor.setAlpha(textOutlineAlpha->value());
+    double outlineWidth=textOutline->value()/10.0;
     QGraphicsTextItem* item = NULL;
     QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
     if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
@@ -1314,7 +1336,18 @@ void TitleWidget::slotUpdateText()
 
     {
         item->setFont(font);
-        item->setDefaultTextColor(color);
+       if (outlineWidth>0.0){
+                                       item->setData(101,outlineWidth);
+                                       item->setData(102,outlineColor);
+                                       QTextCursor cursor(item->document());
+                                       cursor.select(QTextCursor::Document);
+                                       QTextCharFormat format;
+                                       format.setTextOutline( QPen(outlineColor,outlineWidth ));
+                                       format.setForeground(QBrush(color));
+                                       cursor.mergeCharFormat(format); 
+       }else{
+               item->setDefaultTextColor(color);
+       }
         cur.select(QTextCursor::Document);
         cur.setBlockFormat(format);
         item->setTextCursor(cur);
index 5b43801e1c8877323c1eef6ca0ad657c681dc297..74c6482f3e6e532617da577069836b86934fc71d 100644 (file)
            </property>
           </widget>
          </item>
+         <item>
+          <widget class="KColorButton" name="textOutlineColor"/>
+         </item>
+         <item>
+          <widget class="QSlider" name="textOutline">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QSlider" name="textOutlineAlpha">
+           <property name="maximum">
+            <number>255</number>
+           </property>
+           <property name="value">
+            <number>255</number>
+           </property>
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+          </widget>
+         </item>
          <item>
           <widget class="QComboBox" name="font_weight_box"/>
          </item>