From: Jean-Baptiste Mardelle Date: Sun, 2 Aug 2009 20:10:58 +0000 (+0000) Subject: Fix opening of title with profile different than current one X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=33b512d9309f5d4efbe08fbb9ba6f44aacae12e4;p=kdenlive Fix opening of title with profile different than current one svn path=/trunk/kdenlive/; revision=3795 --- diff --git a/src/titledocument.cpp b/src/titledocument.cpp index 5c077a0a..9ff9e6d5 100644 --- a/src/titledocument.cpp +++ b/src/titledocument.cpp @@ -220,8 +220,10 @@ int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsPolygonItem* startv, Q int doc_width = doc.documentElement().attribute("width").toInt(); int doc_height = doc.documentElement().attribute("height").toInt(); if (doc_width != m_width || doc_height != m_height) { - KMessageBox::information(kapp->activeWindow(), i18n("This title clip was created with a different frame size. It will now be converted to the current project's size."), i18n("Resizing Title Clip")); + KMessageBox::information(kapp->activeWindow(), i18n("This title clip was created with a different frame size."), i18n("Title Profile")); //TODO: convert using QTransform + m_width = doc_width; + m_height = doc_height; } } //TODO: get default title duration instead of hardcoded one @@ -395,3 +397,15 @@ QTransform TitleDocument::stringToTransform(const QString& s) l.at(6).toDouble(), l.at(7).toDouble(), l.at(8).toDouble() ); } + +int TitleDocument::frameWidth() const +{ + return m_width; +} + +int TitleDocument::frameHeight() const +{ + return m_height; +} + + diff --git a/src/titledocument.h b/src/titledocument.h index cc669f70..cc5d838e 100644 --- a/src/titledocument.h +++ b/src/titledocument.h @@ -37,6 +37,8 @@ public: /** \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(); + int frameWidth() const; + int frameHeight() const; enum ItemOrigin {OriginXLeft = 0, OriginYTop = 1}; enum AxisPosition {AxisDefault = 0, AxisInverted = 1}; diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index 938ff35a..dec833f3 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -261,7 +261,6 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render readChoices(); initViewports(); - QTimer::singleShot(500, this, SLOT(slotAdjustZoom())); graphicsView->show(); //graphicsView->setRenderHint(QPainter::Antialiasing); graphicsView->setInteractive(true); @@ -271,11 +270,13 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render if (!url.isEmpty()) { double out; m_count = m_titledocument.loadDocument(url, m_startViewport, m_endViewport, &out) + 1; + adjustFrameSize(); title_duration->setText(m_tc.getTimecode(GenTime(out), m_render->fps())); slotSelectTool(); } else { slotTextTool(); } + QTimer::singleShot(200, this, SLOT(slotAdjustZoom())); } TitleWidget::~TitleWidget() @@ -1314,6 +1315,7 @@ void TitleWidget::loadTitle() m_scene->clearTextSelection(); double out; m_count = m_titledocument.loadDocument(url, m_startViewport, m_endViewport, &out) + 1; + adjustFrameSize(); title_duration->setText(m_tc.getTimecode(GenTime(out / 1000.0), m_render->fps())); insertingValues = true; startViewportX->setValue(m_startViewport->data(0).toInt()); @@ -1324,6 +1326,7 @@ void TitleWidget::loadTitle() endViewportSize->setValue(m_endViewport->data(2).toInt()); insertingValues = false; slotSelectTool(); + slotAdjustZoom(); } } @@ -1355,7 +1358,7 @@ void TitleWidget::setXml(QDomDocument doc) { double out; m_count = m_titledocument.loadFromXml(doc, m_startViewport, m_endViewport, &out); - kDebug() << "\n\n// TITLE OUT: " << out; + adjustFrameSize(); title_duration->setText(m_tc.getTimecode(GenTime(out / 1000.0), m_render->fps())); /*if (doc.documentElement().hasAttribute("out")) { GenTime duration = GenTime(doc.documentElement().attribute("out").toDouble() / 1000.0); @@ -1385,7 +1388,7 @@ void TitleWidget::setXml(QDomDocument doc) kcolorbutton->setColor(background_color); horizontalSlider->blockSignals(false); kcolorbutton->blockSignals(false); - + QTimer::singleShot(200, this, SLOT(slotAdjustZoom())); slotSelectTool(); } @@ -1505,3 +1508,14 @@ void TitleWidget::readChoices() cropImage->setChecked(titleConfig.readEntry("crop_image", cropImage->isChecked())); } +void TitleWidget::adjustFrameSize() +{ + m_frameWidth = m_titledocument.frameWidth(); + m_frameHeight = m_titledocument.frameHeight(); + m_frameBorder->setRect(0, 0, m_frameWidth, m_frameHeight); + displayBackgroundFrame(); +} + + + + diff --git a/src/titlewidget.h b/src/titlewidget.h index 26e7e84a..ac60a325 100644 --- a/src/titlewidget.h +++ b/src/titlewidget.h @@ -144,6 +144,8 @@ private: /** \brief Check a tool button. */ void checkButton(TITLETOOL toolType); + void adjustFrameSize(); + public slots: void slotNewText(QGraphicsTextItem *tt); void slotNewRect(QGraphicsRectItem *rect);