*disable textedit for now, it doesn't seem possible to make it work in sync with the qgraphicstextitem - for example selection in the 2 widgets cannot easily be synced, and the textedit->toHtml does not support color transparency...
* add picture of current project frame as background
svn path=/branches/KDE4/; revision=2154
}
}
}
- if (!hasSelected) QGraphicsScene::mousePressEvent(e);
+ QGraphicsScene::mousePressEvent(e);
kDebug() << "////// MOUSE CLICK, RESIZE MODE: " << resizeMode;
QPointF p = e->scenePos();
p += QPoint(-2, -2);
resizeMode = NoResize;
-
+ bool itemFound = false;
foreach(QGraphicsItem* g, items(QRectF(p , QSizeF(4, 4)).toRect())) {
-
if (g->type() == 3) {
-
QGraphicsRectItem *gi = (QGraphicsRectItem*)g;
QRectF r = gi->rect();
r.translate(gi->scenePos());
-
+ itemFound = true;
if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
setCursor(QCursor(Qt::SizeFDiagCursor));
} else if ((r.toRect().bottomLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
} else if (qAbs(r.toRect().bottom() - e->scenePos().toPoint().y()) < 3 / zoom) {
setCursor(Qt::SizeVerCursor);
} else setCursor(QCursor(Qt::ArrowCursor));
+ break;
}
- break;
+ if (!itemFound) setCursor(QCursor(Qt::ArrowCursor));
}
QGraphicsScene::mouseMoveEvent(e);
}
#include "clipmanager.h"
#include "addfoldercommand.h"
#include "editfoldercommand.h"
+#include "titlewidget.h"
KdenliveDoc::KdenliveDoc(const KUrl &url, MltVideoProfile profile, QUndoGroup *undoGroup, QWidget *parent): QObject(parent), m_render(NULL), m_url(url), m_profile(profile), m_fps((double)profile.frame_rate_num / profile.frame_rate_den), m_width(profile.width), m_height(profile.height), m_commandStack(new KUndoStack(undoGroup)), m_modified(false) {
m_clipManager = new ClipManager(this);
setModified(true);
}
+void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
+ TitleWidget *dia_ui = new TitleWidget(m_render, 0);
+ if (dia_ui->exec() == QDialog::Accepted) {
+ }
+ delete dia_ui;
+}
+
+
#include "kdenlivedoc.moc"
bool m_modified;
public slots:
+ void slotCreateTextClip(QString group, int groupId);
signals:
void addProjectClip(DocClipBase *);
#include "ui_colorclip_ui.h"
#include "definitions.h"
-#include "titlewidget.h"
#include "clipmanager.h"
#include "docclipbase.h"
#include "kdenlivedoc.h"
}
void ProjectList::slotAddTitleClip() {
-
- if (!m_commandStack) kDebug() << "!!!!!!!!!!!!!!!! NO CMD STK";
- //QDialog *dia = new QDialog;
-
- TitleWidget *dia_ui = new TitleWidget(m_render, this);
- //dia_ui->setupUi(dia);
- //dia_ui->clip_name->setText(i18n("Title Clip"));
- //dia_ui->clip_duration->setText(KdenliveSettings::color_duration());
- if (dia_ui->exec() == QDialog::Accepted) {
- //QString color = dia_ui->clip_color->color().name();
- //color = color.replace(0, 1, "0x") + "ff";
- //m_doc->slotAddColorClipFile(dia_ui->clip_name->text(), color, dia_ui->clip_duration->text(), QString::null);
+ QString group = QString();
+ int groupId = -1;
+ ProjectItem *item = static_cast <ProjectItem*>(listView->currentItem());
+ if (item && item->clipType() != FOLDER) {
+ while (item->parent()) {
+ item = static_cast <ProjectItem*>(item->parent());
+ if (item->clipType() == FOLDER) break;
+ }
}
- delete dia_ui;
- //delete dia;
+ if (item && item->clipType() == FOLDER) {
+ group = item->groupName();
+ groupId = item->clipId();
+ }
+
+ m_doc->slotCreateTextClip(group, groupId);
}
void ProjectList::setDocument(KdenliveDoc *doc) {
listView->clear();
#include <QGraphicsView>
#include <QDomDocument>
-#include <KDebug>
-#include <KGlobalSettings>
#include <QGraphicsItem>
#include <QGraphicsSvgItem>
+#include <QTextDocumentFragment>
+#include <QTimer>
+
+#include <KDebug>
+#include <KGlobalSettings>
#include <KFileDialog>
#include "titlewidget.h"
TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent) {
setupUi(this);
frame_properties->setFont(KGlobalSettings::toolBarFont());
+ toolBox->setFont(KGlobalSettings::toolBarFont());
frame_properties->setEnabled(false);
connect(newTextButton, SIGNAL(clicked()), this, SLOT(slotNewText()));
connect(newRectButton, SIGNAL(clicked()), this, SLOT(slotNewRect()));
connect(kcolorbutton, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
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()));
+ ktextedit->setHidden(true);
+ connect(fontColorButton, SIGNAL(clicked()), this, SLOT(slotUpdateText())) ;
+ connect(font_family, SIGNAL(currentFontChanged (const QFont &)), this, SLOT(slotUpdateText())) ;
+ connect(font_size, SIGNAL(valueChanged (int)), this, SLOT(slotUpdateText())) ;
+ connect(textAlpha, SIGNAL(valueChanged(int)), this, SLOT(slotUpdateText()));
//connect (ktextedit, SIGNAL(selectionChanged()), this , SLOT (textChanged()));
connect(rectFAlpha, SIGNAL(valueChanged(int)), this, SLOT(rectChanged()));
framepen.setColor(Qt::red);
m_frameWidth = render->renderWidth();
m_frameHeight = render->renderHeight();
+ QPixmap bg = render->extractFrame((int) render->seekPosition().frames(render->fps()), m_frameWidth, m_frameHeight);
+
+ QGraphicsPixmapItem *fb = new QGraphicsPixmapItem(bg);
+ fb->setZValue(-1000);
+ fb->setFlags(QGraphicsItem::ItemClipsToShape);
+ graphicsView->scene()->addItem(fb);
+
m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_frameWidth, m_frameHeight));
m_frameBorder->setPen(framepen);
m_frameBorder->setZValue(-1000);
m_frameBorder->setFlags(QGraphicsItem::ItemClipsToShape);
graphicsView->scene()->addItem(m_frameBorder);
+
initViewports();
+
+
graphicsView->show();
graphicsView->setRenderHint(QPainter::Antialiasing);
graphicsView->setInteractive(true);
- slotAdjustZoom();
+ QTimer::singleShot(500, this, SLOT(slotAdjustZoom()));
//graphicsView->resize(400, 300);
kDebug() << "// TITLE WIDGWT: " << graphicsView->viewport()->width() << "x" << graphicsView->viewport()->height();
toolBox->setItemEnabled(2, false);
tt->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
tt->setTextInteractionFlags(Qt::NoTextInteraction);
tt->setPos(m_frameWidth / 2, m_frameHeight / 2);
- tt->setFont(kfontrequester->font());
+ QFont font = font_family->currentFont();
+ font.setPointSize (font_size->value());
+ tt->setFont(font);
connect(tt->document(), SIGNAL(contentsChanged()), this, SLOT(selectionChanged()));
kDebug() << tt->metaObject()->className();
/*QGraphicsRectItem * ri=graphicsView->scene()->addRect(-50,-50,100,100);
void TitleWidget::slotChangeBackground() {
QColor color = kcolorbutton->color();
color.setAlpha(horizontalSlider->value());
- graphicsView->scene()->setBackgroundBrush(QBrush(color));
+ m_frameBorder->setBrush(QBrush(color));
}
void TitleWidget::textChanged() {
}
}
+void TitleWidget::slotUpdateText() {
+ QFont font = font_family->currentFont();
+ font.setPointSize (font_size->value());
+ QColor color = fontColorButton->color();
+ color.setAlpha(textAlpha->value());
+
+ QGraphicsTextItem* item = NULL;
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1 && (l[0])->type() == 8) {
+ item = (QGraphicsTextItem*)l[0];
+ }
+ if (!item) return;
+ if (item->textCursor().selection ().isEmpty())
+ {
+ item->setFont(font);
+ item->setDefaultTextColor(color);
+ }
+ /*else {
+ QTextDocumentFragment selec = item->textCursor().selection ();
+ selec.set
+ }*/
+ //if (ktextedit->textCursor().selectedText().isEmpty()) ktextedit->selectAll();
+
+ //ktextedit->setCurrentFont(font);
+ //ktextedit->setTextColor(color);
+ /*QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1 && (l[0])->type() == 8 && l[0]->hasFocus()) {
+ QGraphicsTextItem* item = static_cast <QGraphicsTextItem*> (l[0]);
+ //item-
+ }*/
+}
+
void TitleWidget::rectChanged() {
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1 && (l[0])->type() == 3 && !settingUp) {
void slotZoom(bool up);
void slotAdjustZoom();
void slotZoomOneToOne();
+ void slotUpdateText();
};
<rect>
<x>0</x>
<y>0</y>
- <width>794</width>
- <height>598</height>
+ <width>771</width>
+ <height>510</height>
</rect>
</property>
<property name="sizePolicy" >
<property name="windowTitle" >
<string>Dialog</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2" >
- <item row="0" column="0" colspan="6" >
+ <layout class="QGridLayout" name="gridLayout_4" >
+ <item row="0" column="0" colspan="5" >
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="newRectButton" >
</item>
</layout>
</item>
- <item row="1" column="0" colspan="6" >
+ <item row="1" column="0" colspan="5" >
<widget class="QFrame" name="frame_properties" >
<property name="frameShape" >
<enum>QFrame::StyledPanel</enum>
</layout>
</item>
</layout>
+ <zorder>splitter</zorder>
</widget>
</item>
- <item row="2" column="0" colspan="6" >
+ <item row="2" column="0" colspan="5" >
<widget class="QSplitter" name="splitter" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<widget class="QGraphicsView" name="graphicsView" />
<widget class="QToolBox" name="toolBox" >
<property name="currentIndex" >
- <number>3</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="BasicOperations" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>287</width>
- <height>265</height>
+ <width>297</width>
+ <height>185</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>287</width>
- <height>265</height>
+ <width>297</width>
+ <height>185</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>358</width>
- <height>246</height>
+ <width>267</width>
+ <height>177</height>
</rect>
</property>
<attribute name="label" >
<string>Text</string>
</attribute>
- <layout class="QGridLayout" >
+ <layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
- <layout class="QVBoxLayout" >
+ <widget class="QFontComboBox" name="font_family" />
+ </item>
+ <item row="1" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout" >
<item>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QToolButton" name="toolButton_4" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="toolButton_5" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="toolButton_6" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KColorButton" name="fontColorButton" />
- </item>
- <item>
- <widget class="QSlider" name="textAlpha" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QSpinBox" name="font_size" >
+ <property name="minimum" >
+ <number>8</number>
+ </property>
+ <property name="maximum" >
+ <number>1000</number>
+ </property>
+ <property name="value" >
+ <number>20</number>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout" >
- <item>
- <widget class="QToolButton" name="toolButton" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="fontBold" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="toolButton_3" >
- <property name="text" >
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="KColorButton" name="fontColorButton" />
</item>
<item>
- <widget class="KFontRequester" name="kfontrequester" >
- <property name="font" >
- <font>
- <family>Sans Serif</family>
- <pointsize>20</pointsize>
- <weight>50</weight>
- <italic>false</italic>
- <bold>false</bold>
- </font>
+ <widget class="QSlider" name="textAlpha" >
+ <property name="maximum" >
+ <number>255</number>
+ </property>
+ <property name="value" >
+ <number>255</number>
+ </property>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="2" column="0" >
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
- <widget class="KTextEdit" name="ktextedit" />
+ <widget class="QToolButton" name="toolButton_6" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
</item>
<item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
+ <widget class="QToolButton" name="toolButton_5" >
+ <property name="text" >
+ <string>...</string>
</property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="toolButton_4" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="toolButton_7" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="toolButton_8" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="toolButton_9" >
+ <property name="text" >
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
- <width>20</width>
- <height>40</height>
+ <width>52</width>
+ <height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
+ <item row="3" column="0" >
+ <widget class="KTextEdit" name="ktextedit" />
+ </item>
</layout>
</widget>
<widget class="QWidget" name="Rectangle" >
<rect>
<x>0</x>
<y>0</y>
- <width>287</width>
- <height>265</height>
+ <width>278</width>
+ <height>249</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>287</width>
- <height>265</height>
+ <width>297</width>
+ <height>185</height>
</rect>
</property>
<attribute name="label" >
<rect>
<x>0</x>
<y>0</y>
- <width>287</width>
- <height>265</height>
+ <width>278</width>
+ <height>224</height>
</rect>
</property>
<attribute name="label" >
</widget>
</item>
<item row="3" column="4" >
- <spacer name="horizontalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>387</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="3" column="5" >
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
- <customwidget>
- <class>KFontRequester</class>
- <extends>QWidget</extends>
- <header>kfontrequester.h</header>
- </customwidget>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
</hint>
</hints>
</connection>
- <connection>
- <sender>kfontrequester</sender>
- <signal>fontSelected(QFont)</signal>
- <receiver>ktextedit</receiver>
- <slot>setCurrentFont(QFont)</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>715</x>
- <y>184</y>
- </hint>
- <hint type="destinationlabel" >
- <x>713</x>
- <y>240</y>
- </hint>
- </hints>
- </connection>
<connection>
<sender>fontColorButton</sender>
<signal>changed(QColor)</signal>