/*ÜeffectLists["audio"]=audioEffectList;
effectLists["video"]=videoEffectList;
effectLists["custom"]=customEffectList;*/
-
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
ui.infoBox->hide();
updateButtonStatus();
#include <QVariant>
#include <KPlotObject>
#include <QMouseEvent>
+#include <QPen>
#include <KDebug>
#include <KPlotPoint>
}
if (defaults[i].toDouble()>max_y)
defaults[i]=max_y;
- plot->addPoint(startframe,defaults[i].toInt()*stretchFactors[i]);
+ plot->addPoint(startframe,defaults[i].toInt()*stretchFactors[i],parameterNameList[i]);
//add keyframes here
plot->addPoint(endframe,defaults[i].toInt()*stretchFactors[i]);
foreach (KPlotObject *o, plotObjects() ){
QList<KPlotPoint*> points=o->points();
for(int p=0;p<points.size();p++){
- if (points[p]==movepoint){
+ if (points[p]==movepoint && (activeIndexPlot==-1 || activeIndexPlot==i ) ){
QPoint delta=event->pos()-oldmousepoint;
double newy=movepoint->y()-delta.y()*dataRect().height()/pixRect().height();
if (m_moveY && newy>min_y && newy<max_y)
int i=0;
bool drawAll=name.isEmpty() || name=="all";
activeIndexPlot=-1;
- foreach (KPlotObject* p,plotObjects() ){
+
+ foreach (KPlotObject* p, plotObjects() ){
p->setShowPoints(drawAll || parameterNameList[i]==name);
p->setShowLines(drawAll || parameterNameList[i]==name);
+ QPen pen=(drawAll || parameterNameList[i]==name ? QPen(Qt::SolidLine) : QPen(Qt::NoPen) );
+ pen.setColor(p->linePen().color());
+ p->setLabelPen(pen);
if ( parameterNameList[i]==name )
activeIndexPlot = i;
replacePlotObject(i++,p);
--- /dev/null
+/***************************************************************************
+ titledocument.h - description
+ -------------------
+ begin : Feb 28 2008
+ copyright : (C) 2008 by Marco Gittler
+ email : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "titledocument.h"
+#include <QGraphicsScene>
+#include <QDomDocument>
+#include <QDomElement>
+#include <QGraphicsItem>
+#include <QGraphicsRectItem>
+#include <QGraphicsTextItem>
+#include <KDebug>
+#include <QFile>
+#include <kio/netaccess.h>
+
+TitleDocument::TitleDocument(){
+ scene=NULL;
+}
+
+void TitleDocument::setScene(QGraphicsScene* _scene){
+ scene=_scene;
+}
+
+bool TitleDocument::saveDocument(const KUrl& url,QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv){
+ QDomDocument doc;
+
+ if (!scene)
+ return false;
+
+ QDomElement main=doc.createElement("kdenlivetitle");
+ doc.appendChild(main);
+
+ foreach(QGraphicsItem* item, scene->items()){
+ QDomElement e=doc.createElement("item");
+ QDomElement content=doc.createElement("content");
+
+ switch (item->type()){
+ case 3:
+ e.setAttribute("type","QGraphicsRectItem");
+ content.setAttribute("rect",rectFToString(((QGraphicsRectItem*)item)->rect() ));
+ content.setAttribute("pencolor",colorToString(((QGraphicsRectItem*)item)->pen().color()) );
+ content.setAttribute("penwidth",((QGraphicsRectItem*)item)->pen().width() );
+ content.setAttribute("brushcolor",colorToString(((QGraphicsRectItem*)item)->brush().color()) );
+ break;
+ case 8:
+ e.setAttribute("type","QGraphicsTextItem");
+ content.appendChild(doc.createTextNode( ((QGraphicsTextItem*)item)->toHtml() ) );
+ break;
+ default:
+ continue;
+ }
+ QDomElement pos=doc.createElement("position");
+ pos.setAttribute("x",item->pos().x());
+ pos.setAttribute("y",item->pos().y());
+ QTransform transform=item->transform();
+ QDomElement tr=doc.createElement("transform");
+ tr.appendChild(doc.createTextNode(
+ QString("%1,%2,%3,%4,%5,%6,%7,%8,%9").arg(
+ transform.m11()).arg(transform.m12()).arg(transform.m13()).arg(transform.m21()).arg(transform.m22()).arg(transform.m23()).arg(transform.m31()).arg(transform.m32()).arg(transform.m33())
+ )
+ );
+ pos.appendChild(tr);
+
+
+ e.appendChild(pos);
+ e.appendChild(content);
+ main.appendChild(e);
+ }
+ if (startv && endv){
+ QDomElement endp=doc.createElement("endviewport");
+ QDomElement startp=doc.createElement("startviewport");
+ endp.setAttribute("x",endv->pos().x());
+ endp.setAttribute("y",endv->pos().y());
+ endp.setAttribute("size",endv->sceneBoundingRect().width()/2);
+
+ startp.setAttribute("x",startv->pos().x());
+ startp.setAttribute("y",startv->pos().y());
+ startp.setAttribute("size",startv->sceneBoundingRect().width()/2);
+
+ main.appendChild(startp);
+ main.appendChild(endp);
+ }
+ QDomElement backgr=doc.createElement("background");
+ backgr.setAttribute("color",colorToString(scene->backgroundBrush().color()));
+ main.appendChild(backgr);
+
+ QString tmpfile="/tmp/newtitle";
+ QFile xmlf(tmpfile);
+ xmlf.open(QIODevice::WriteOnly);
+ xmlf.write(doc.toString().toAscii());
+ xmlf.close();
+ kDebug() << KIO::NetAccess::upload(tmpfile,url,0);
+}
+
+bool TitleDocument::loadDocument(const KUrl& url ,QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv) {
+ QString tmpfile;
+ QDomDocument doc;
+ double aspect_ratio=4.0/3.0;
+ if (!scene)
+ return false;
+
+ if (KIO::NetAccess::download(url, tmpfile, 0)) {
+ QFile file(tmpfile);
+ if (file.open(QIODevice::ReadOnly)) {
+ doc.setContent(&file, false);
+ file.close();
+ }else
+ return false;
+ KIO::NetAccess::removeTempFile(tmpfile);
+ QDomNodeList titles=doc.elementsByTagName("kdenlivetitle");
+ if (titles.size()){
+
+ QDomNodeList items=titles.item(0).childNodes();
+ for(int i=0;i<items.count();i++){
+ QGraphicsItem *gitem=NULL;
+ kDebug() << items.item(i).attributes().namedItem("type").nodeValue();
+ if (items.item(i).attributes().namedItem("type").nodeValue()=="QGraphicsTextItem"){
+ QGraphicsTextItem *txt=scene->addText("");
+ txt->setHtml(items.item(i).namedItem("content").firstChild().nodeValue());
+ gitem=txt;
+ }else
+ if (items.item(i).attributes().namedItem("type").nodeValue()=="QGraphicsRectItem"){
+ QString rect=items.item(i).namedItem("content").attributes().namedItem("rect").nodeValue();
+ QString br_str=items.item(i).namedItem("content").attributes().namedItem("brushcolor").nodeValue();
+ QString pen_str=items.item(i).namedItem("content").attributes().namedItem("pencolor").nodeValue();
+ double penwidth=items.item(i).namedItem("content").attributes().namedItem("penwidth").nodeValue().toDouble();
+ QGraphicsRectItem *rec=scene->addRect(stringToRect(rect),QPen(QBrush(stringToColor(pen_str)),penwidth),QBrush(stringToColor(br_str) ) );
+ gitem=rec;
+ }
+ //pos and transform
+ if (gitem ){
+ QPointF p(items.item(i).namedItem("position").attributes().namedItem("x").nodeValue().toDouble(),
+ items.item(i).namedItem("position").attributes().namedItem("y").nodeValue().toDouble());
+ gitem->setPos(p);
+ gitem->setTransform(stringToTransform(items.item(i).namedItem("position").firstChild().firstChild().nodeValue()));
+ }
+ if (items.item(i).nodeName()=="background"){
+ kDebug() << items.item(i).attributes().namedItem("color").nodeValue();
+ scene->setBackgroundBrush(QBrush(stringToColor(items.item(i).attributes().namedItem("color").nodeValue())));
+ }else if (items.item(i).nodeName()=="startviewport" && startv){
+ QPointF p(items.item(i).attributes().namedItem("x").nodeValue().toDouble(),items.item(i).attributes().namedItem("y").nodeValue().toDouble());
+ double width=items.item(i).attributes().namedItem("size").nodeValue().toDouble();
+ QRectF rect(-width,-width/aspect_ratio,width*2.0,width/aspect_ratio*2.0);
+ kDebug() << width << rect;
+ startv->setPolygon(rect);
+ startv->setPos(p);
+ }else if (items.item(i).nodeName()=="endviewport" && endv){
+ QPointF p(items.item(i).attributes().namedItem("x").nodeValue().toDouble(),items.item(i).attributes().namedItem("y").nodeValue().toDouble());
+ double width=items.item(i).attributes().namedItem("size").nodeValue().toDouble();
+ QRectF rect(-width,-width/aspect_ratio,width*2.0,width/aspect_ratio*2.0);
+ kDebug() << width << rect;
+ endv->setPolygon(rect);
+ endv->setPos(p);
+ }
+
+ }
+
+
+ }
+
+
+ }
+ return true;
+}
+
+QString TitleDocument::colorToString(const QColor& c){
+ QString ret="%1,%2,%3,%4";
+ ret=ret.arg(c.red()).arg(c.green()).arg(c.blue()).arg(c.alpha());
+ return ret;
+}
+
+QString TitleDocument::rectFToString(const QRectF& c){
+ QString ret="%1,%2,%3,%4";
+ ret=ret.arg(c.x()).arg(c.y()).arg(c.width()).arg(c.height());
+ return ret;
+}
+
+QRectF TitleDocument::stringToRect(const QString & s){
+
+ QStringList l=s.split(",");
+ if (l.size()<4)
+ return QRectF();
+ return QRectF(l[0].toDouble(),l[1].toDouble(),l[2].toDouble(),l[3].toDouble());
+}
+
+QColor TitleDocument::stringToColor(const QString & s){
+ QStringList l=s.split(",");
+ if (l.size()<4)
+ return QColor();
+ return QColor(l[0].toInt(),l[1].toInt(),l[2].toInt(),l[3].toInt());;
+}
+QTransform TitleDocument::stringToTransform(const QString& s){
+ QStringList l=s.split(",");
+ if (l.size()<9)
+ return QTransform();
+ return QTransform(
+ l[0].toDouble(),l[1].toDouble(),l[2].toDouble(),
+ l[3].toDouble(),l[4].toDouble(),l[5].toDouble(),
+ l[6].toDouble(),l[7].toDouble(),l[8].toDouble()
+ );
+}
--- /dev/null
+/***************************************************************************
+ titledocument.h - description
+ -------------------
+ begin : Feb 28 2008
+ copyright : (C) 2008 by Marco Gittler
+ email : g.marco@freenet.de
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef TITLEDOCUMENT_H
+#define TITLEDOCUMENT_H
+#include <KUrl>
+
+class QGraphicsScene;
+class QGraphicsPolygonItem;
+
+class TitleDocument {
+ QGraphicsScene* scene;
+ public:
+ TitleDocument();
+ void setScene(QGraphicsScene* scene);
+ bool saveDocument(const KUrl& url,QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
+ bool loadDocument(const KUrl& url,QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
+ private:
+ QString colorToString(const QColor&);
+ QString rectFToString(const QRectF&);
+ QRectF stringToRect(const QString &);
+ QColor stringToColor(const QString &);
+ QTransform stringToTransform(const QString &);
+};
+
+#endif
+
+
#include "titlewidget.h"
#include "graphicsscenerectmove.h"
#include <QGraphicsView>
+#include <QDomDocument>
#include <KDebug>
#include <QGraphicsItem>
#include <QGraphicsSvgItem>
+#include <KFileDialog>
int settingUp=false;
connect (ktextedit, SIGNAL(textChanged()), this , SLOT (textChanged()));
connect (fontColorButton, SIGNAL ( clicked()), this, SLOT( textChanged()) ) ;
//connect (fontBold, SIGNAL ( clicked()), this, SLOT( setBold()) ) ;
+ connect (loadButton, SIGNAL ( clicked()), this, SLOT( loadTitle() ) ) ;
+ connect (saveButton, SIGNAL ( clicked()), this, SLOT( saveTitle() ) ) ;
+
connect (kfontrequester, SIGNAL ( fontSelected(const QFont &)), this, SLOT( textChanged()) ) ;
connect(textAlpha, SIGNAL( valueChanged(int) ), this, SLOT (textChanged()));
//scene->setBackgroundBrush(*gradient);
graphicsView->setScene(scene);
+ m_titledocument.setScene(scene);
connect (graphicsView->scene(), SIGNAL (selectionChanged()), this , SLOT( selectionChanged()));
initViewports();
else{
//toolBox->setCurrentIndex(0);
}
- zValue->setValue(l[0]->zValue());
- itemzoom->setValue(transformations[l[0]].scalex*100);
- itemrotate->setValue(transformations[l[0]].rotate);
+ zValue->setValue((int)l[0]->zValue());
+ itemzoom->setValue((int)transformations[l[0]].scalex*100);
+ itemrotate->setValue((int)transformations[l[0]].rotate);
}
}
void TitleWidget::setupViewports(){
double aspect_ratio=4.0/3.0;//read from project
- QRectF sp(startViewportX->value(), startViewportY->value(),0,0);
- QRectF ep(endViewportX->value(),endViewportY->value(),0,0);
+ QRectF sp(0,0,0,0);
+ QRectF ep(0,0,0,0);
double sv_size=startViewportSize->value();
double ev_size=endViewportSize->value();
sp.adjust(-sv_size,-sv_size/aspect_ratio,sv_size,sv_size/aspect_ratio);
ep.adjust(-ev_size,-ev_size/aspect_ratio,ev_size,ev_size/aspect_ratio);
+ startViewport->setPos(startViewportX->value(), startViewportY->value());
+ endViewport->setPos(endViewportX->value(),endViewportY->value());
+
startViewport->setPolygon(QPolygonF(sp));
endViewport->setPolygon(QPolygonF(ep));
}
+
+void TitleWidget::loadTitle(){
+ KUrl url= KFileDialog::getOpenUrl( KUrl(), "*.kdenlivetitle",this,tr("Save Title"));
+ m_titledocument.loadDocument(url,startViewport,endViewport);
+}
+
+void TitleWidget::saveTitle(){
+ KUrl url= KFileDialog::getSaveUrl( KUrl(), "*.kdenlivetitle",this,tr("Save Title"));
+ m_titledocument.saveDocument(url,startViewport,endViewport);
+}
+
#include "moc_titlewidget.cpp"
#define TITLEWIDGET_H
#include "ui_titlewidget_ui.h"
+#include "titledocument.h"
#include <QDialog>
#include <QMap>
QGraphicsPolygonItem *startViewport,*endViewport;
void initViewports();
QMap<QGraphicsItem*,Transform > transformations;
+ TitleDocument m_titledocument;
public slots:
void slotNewText();
void slotNewRect();
void svgSelected(const KUrl&);
void itemScaled(int);
void itemRotate(int);
+ void saveTitle();
+ void loadTitle();
};
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
- <widget class="QSplitter" name="splitter" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <widget class="ParameterPlotter" name="kplotwidget" />
- <widget class="QWidget" name="" >
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="ParameterPlotter" name="kplotwidget" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>150</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" >
<item>
<widget class="QToolButton" name="buttonLeftRight" >
</widget>
</item>
</layout>
- </widget>
- <widget class="KTextEdit" name="infoBox" />
- </widget>
+ </item>
+ <item>
+ <widget class="KTextEdit" name="infoBox" />
+ </item>
+ </layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
- <widget class="QPushButton" name="pushButton" >
+ <widget class="QPushButton" name="loadButton" >
<property name="text" >
<string>Load Title</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="pushButton_2" >
+ <widget class="QPushButton" name="saveButton" >
<property name="text" >
<string>Save Title</string>
</property>
</sizepolicy>
</property>
<property name="currentIndex" >
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="BasicOperations" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>339</width>
+ <width>488</width>
<height>304</height>
</rect>
</property>
</attribute>
<layout class="QGridLayout" >
<item row="0" column="0" >
- <layout class="QVBoxLayout" >
- <item>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
<widget class="KColorButton" name="kcolorbutton" />
</item>
- <item>
+ <item row="1" column="0" >
<widget class="QSlider" name="horizontalSlider" >
<property name="maximum" >
<number>255</number>
</property>
</widget>
</item>
- <item>
+ <item row="2" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<rect>
<x>0</x>
<y>0</y>
- <width>208</width>
- <height>167</height>
+ <width>488</width>
+ <height>304</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>152</width>
- <height>229</height>
+ <width>488</width>
+ <height>304</height>
</rect>
</property>
<attribute name="label" >