From: Mads Bondo Dydensborg Date: Fri, 2 Jan 2009 00:16:16 +0000 (+0000) Subject: Fix 551: The titlewidget (add/edit text clip dialog) should remember the last used... X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=4e221ad4ed9c2a269bd564bdd4b8680741df4997;p=kdenlive Fix 551: The titlewidget (add/edit text clip dialog) should remember the last used values when adding a new clip (http://www.kdenlive.org/mantis/view.php?id=551) svn path=/branches/KDE4/; revision=2864 --- diff --git a/src/titledocument.cpp b/src/titledocument.cpp index 000ab0ac..ef67ec36 100644 --- a/src/titledocument.cpp +++ b/src/titledocument.cpp @@ -113,20 +113,29 @@ QDomDocument TitleDocument::xml(QGraphicsPolygonItem* startv, QGraphicsPolygonIt main.appendChild(endp); } QDomElement backgr = doc.createElement("background"); - QList 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 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) diff --git a/src/titledocument.h b/src/titledocument.h index 8c4fd53c..19c1b9db 100644 --- a/src/titledocument.h +++ b/src/titledocument.h @@ -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&); diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index 145377b4..7494281b 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -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(); }