]> git.sesse.net Git - kdenlive/commitdiff
Fix 551: The titlewidget (add/edit text clip dialog) should remember the last used...
authorMads Bondo Dydensborg <mads@dydensborg.dk>
Fri, 2 Jan 2009 00:16:16 +0000 (00:16 +0000)
committerMads Bondo Dydensborg <mads@dydensborg.dk>
Fri, 2 Jan 2009 00:16:16 +0000 (00:16 +0000)
svn path=/branches/KDE4/; revision=2864

src/titledocument.cpp
src/titledocument.h
src/titlewidget.cpp

index 000ab0ac1d50ea23cd2831858b4dbe2033e8e0e7..ef67ec3620181e8574f70c4613f89bb19c15ab3d 100644 (file)
@@ -113,20 +113,29 @@ QDomDocument TitleDocument::xml(QGraphicsPolygonItem* startv, QGraphicsPolygonIt
         main.appendChild(endp);
     }
     QDomElement backgr = doc.createElement("background");
-    QList<QGraphicsItem *> items = scene->items();
-    QColor color(0, 0, 0, 0);
-    for (int i = 0; i < items.size(); i++) {
-        if (items.at(i)->zValue() == -1100) {
-            color = ((QGraphicsRectItem *)items.at(i))->brush().color();
-            break;
-        }
-    }
+    QColor color = getBackgroundColor();
     backgr.setAttribute("color", colorToString(color));
     main.appendChild(backgr);
 
     return doc;
 }
 
+/** \brief Get the background color (incl. alpha) from the document, if possibly
+  * \returns The background color of the document, inclusive alpha. If none found, returns (0,0,0,0) */
+QColor TitleDocument::getBackgroundColor() {
+    QColor color(0, 0, 0, 0);
+    if ( scene ) {
+        QList<QGraphicsItem *> items = scene->items();
+        for (int i = 0; i < items.size(); i++) {
+            if (items.at(i)->zValue() == -1100) {
+                color = ((QGraphicsRectItem *)items.at(i))->brush().color();
+                return color;
+            }
+        }
+    }
+    return color;
+}
+
 
 bool TitleDocument::saveDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv) {
     if (!scene)
index 8c4fd53cf3c7d2a840a7df78db398c1feacc9b06..19c1b9dbbc8829383d6f607a57706db880949e04 100644 (file)
@@ -33,6 +33,9 @@ public:
     int loadDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
     QDomDocument xml(QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
     int loadFromXml(QDomDocument doc, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
+    /** \brief Get the background color (incl. alpha) from the document, if possibly
+     * \returns The background color of the document, inclusive alpha. If none found, returns (0,0,0,0) */
+    QColor getBackgroundColor();
 
 private:
     QString colorToString(const QColor&);
index 145377b41e5564f2ae3602233b99256f8f1ea16d..7494281b1c0f28dcf4ceb0427518d69fa1046a5b 100644 (file)
@@ -364,6 +364,11 @@ void TitleWidget::slotNewRect(QGraphicsRectItem * rect) {
 void TitleWidget::slotNewText(QGraphicsTextItem *tt) {
     QFont font = font_family->currentFont();
     font.setPointSize(font_size->value());
+    // mbd: issue 551:
+    font.setBold(buttonBold->isChecked());
+    font.setItalic(buttonItalic->isChecked());
+    font.setUnderline(buttonUnder->isChecked());
+
     tt->setFont(font);
     QColor color = fontColorButton->color();
     color.setAlpha(textAlpha->value());
@@ -659,6 +664,16 @@ QDomDocument TitleWidget::xml() {
 
 void TitleWidget::setXml(QDomDocument doc) {
     m_count = m_titledocument.loadFromXml(doc, startViewport, endViewport);
+    // mbd: Update the GUI color selectors to match the stuff from the loaded document
+    QColor background_color = m_titledocument.getBackgroundColor();
+    horizontalSlider->blockSignals(true);
+    kcolorbutton->blockSignals(true);
+    horizontalSlider->setValue(background_color.alpha());
+    background_color.setAlpha(255);
+    kcolorbutton->setColor(background_color);
+    horizontalSlider->blockSignals(false);
+    kcolorbutton->blockSignals(false);
+    
     slotSelectTool();
 }