Commit 8fc9b014 authored by Rafał Lalik's avatar Rafał Lalik Committed by Julius Künzel
Browse files

Fix setting frame background color

Issue reported in Merge Request !156.
parent 7baf737f
Pipeline #55751 passed with stage
in 10 minutes and 18 seconds
......@@ -67,7 +67,7 @@ QPixmap PatternsModel::paintScene(const QString & pattern)
QList<QGraphicsItem *> items;
int width, height, duration, missing;
TitleDocument::loadFromXml(doc, items, width, height, nullptr, nullptr, &duration, missing);
TitleDocument::loadFromXml(doc, items, width, height, nullptr, nullptr, nullptr, &duration, missing);
QGraphicsScene scene(0, 0, width, height);
......
......@@ -396,13 +396,14 @@ bool TitleDocument::saveDocument(const QUrl &url, QGraphicsRectItem *startv, QGr
return result;
}
int TitleDocument::loadFromXml(const QDomDocument &doc, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, const QString &projectpath)
int TitleDocument::loadFromXml(const QDomDocument &doc, GraphicsSceneRectMove * scene, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, const QString &projectpath)
{
m_projectPath = projectpath;
QList<QGraphicsItem *> items;
int width, height;
int res = loadFromXml(doc, items, width, height, startv, endv, duration, m_missingElements);
int res = loadFromXml(doc, items, width, height, scene, startv, endv, duration, m_missingElements);
if (m_width != width || m_height != height) {
KMessageBox::information(QApplication::activeWindow(), i18n("This title clip was created with a different frame size."), i18n("Title Profile"));
......@@ -417,7 +418,7 @@ int TitleDocument::loadFromXml(const QDomDocument &doc, QGraphicsRectItem *start
return res;
}
int TitleDocument::loadFromXml(const QDomDocument &doc, QList<QGraphicsItem *> & gitems, int & width, int & height, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, int & missingElements)
int TitleDocument::loadFromXml(const QDomDocument &doc, QList<QGraphicsItem *> & gitems, int & width, int & height, GraphicsSceneRectMove * scene, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, int & missingElements)
{
for (auto * i : gitems) {
delete i;
......@@ -710,11 +711,15 @@ int TitleDocument::loadFromXml(const QDomDocument &doc, QList<QGraphicsItem *> &
// qCDebug(KDENLIVE_LOG) << items.item(i).attributes().namedItem("color").nodeValue();
QColor color = QColor(stringToColor(itemNode.attributes().namedItem(QStringLiteral("color")).nodeValue()));
// color.setAlpha(itemNode.attributes().namedItem("alpha").nodeValue().toInt());
for (auto sceneItem : qAsConst(gitems)) {
if (int(sceneItem->zValue()) == -1100) {
static_cast<QGraphicsRectItem *>(sceneItem)->setBrush(QBrush(color));
break;
if (scene) {
QList<QGraphicsItem *> sceneItems = scene->items();
for (auto sceneItem : qAsConst(sceneItems)) {
if (int(sceneItem->zValue()) == -1100) {
static_cast<QGraphicsRectItem *>(sceneItem)->setBrush(QBrush(color));
break;
}
}
scene->setBackgroundBrush(QBrush(color));
}
} else if (itemNode.nodeName() == QLatin1String("startviewport") && (startv != nullptr)) {
QString rect = itemNode.attributes().namedItem(QStringLiteral("rect")).nodeValue();
......
......@@ -34,6 +34,7 @@
class QGraphicsScene;
class QGraphicsRectItem;
class QGraphicsItem;
class GraphicsSceneRectMove;
class TitleDocument
{
......@@ -48,7 +49,7 @@ public:
QDomDocument xml(QGraphicsRectItem *startv, QGraphicsRectItem *endv, bool embed_images = false);
/** @brief Load XML for this title. It calls static version for the function.
*/
int loadFromXml(const QDomDocument &doc, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, const QString &projectpath = QString());
int loadFromXml(const QDomDocument &doc, GraphicsSceneRectMove *scene, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, const QString &projectpath = QString());
/** \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() const;
......@@ -71,7 +72,7 @@ public:
/**
* @brief General static function to load items into list from a xml file.
*/
static int loadFromXml(const QDomDocument &doc, QList<QGraphicsItem *> & gitems, int & width, int & height, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, int & missingElements);
static int loadFromXml(const QDomDocument &doc, QList<QGraphicsItem *> & gitems, int & width, int & height, GraphicsSceneRectMove * scene, QGraphicsRectItem *startv, QGraphicsRectItem *endv, int *duration, int & missingElements);
private:
QGraphicsScene *m_scene;
......
......@@ -2269,7 +2269,7 @@ void TitleWidget::setXml(const QDomDocument &doc, const QString &id)
delete m_missingMessage;
m_missingMessage = nullptr;
}
m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport, &duration, m_projectTitlePath);
m_count = m_titledocument.loadFromXml(doc, m_scene, m_startViewport, m_endViewport, &duration, m_projectTitlePath);
adjustFrameSize();
if (m_titledocument.invalidCount() > 0) {
m_missingMessage = new KMessageWidget(this);
......@@ -3474,7 +3474,7 @@ void TitleWidget::slotPatternDblClicked(const QModelIndex& idx)
QList<QGraphicsItem *> items;
int width, height, duration, missing;
TitleDocument::loadFromXml(doc, items, width, height, nullptr, nullptr, &duration, missing);
TitleDocument::loadFromXml(doc, items, width, height, nullptr, nullptr, nullptr, &duration, missing);
for (QGraphicsItem *item : qAsConst(items)) {
item->setZValue(m_count++);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment