From: <j-...@us...> - 2008-03-31 22:43:06
|
Revision: 2154 http://kdenlive.svn.sourceforge.net/kdenlive/?rev=2154&view=rev Author: j-b-m Date: 2008-03-31 15:43:10 -0700 (Mon, 31 Mar 2008) Log Message: ----------- More work on title widget: *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 Modified Paths: -------------- branches/KDE4/src/graphicsscenerectmove.cpp branches/KDE4/src/kdenlivedoc.cpp branches/KDE4/src/kdenlivedoc.h branches/KDE4/src/projectlist.cpp branches/KDE4/src/titlewidget.cpp branches/KDE4/src/titlewidget.h branches/KDE4/src/widgets/titlewidget_ui.ui Modified: branches/KDE4/src/graphicsscenerectmove.cpp =================================================================== --- branches/KDE4/src/graphicsscenerectmove.cpp 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/graphicsscenerectmove.cpp 2008-03-31 22:43:10 UTC (rev 2154) @@ -91,7 +91,7 @@ } } } - if (!hasSelected) QGraphicsScene::mousePressEvent(e); + QGraphicsScene::mousePressEvent(e); kDebug() << "////// MOUSE CLICK, RESIZE MODE: " << resizeMode; @@ -170,15 +170,13 @@ 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) { @@ -196,8 +194,9 @@ } 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); } Modified: branches/KDE4/src/kdenlivedoc.cpp =================================================================== --- branches/KDE4/src/kdenlivedoc.cpp 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/kdenlivedoc.cpp 2008-03-31 22:43:10 UTC (rev 2154) @@ -33,6 +33,7 @@ #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); @@ -367,5 +368,13 @@ 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" Modified: branches/KDE4/src/kdenlivedoc.h =================================================================== --- branches/KDE4/src/kdenlivedoc.h 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/kdenlivedoc.h 2008-03-31 22:43:10 UTC (rev 2154) @@ -106,6 +106,7 @@ bool m_modified; public slots: + void slotCreateTextClip(QString group, int groupId); signals: void addProjectClip(DocClipBase *); Modified: branches/KDE4/src/projectlist.cpp =================================================================== --- branches/KDE4/src/projectlist.cpp 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/projectlist.cpp 2008-03-31 22:43:10 UTC (rev 2154) @@ -42,7 +42,6 @@ #include "ui_colorclip_ui.h" #include "definitions.h" -#include "titlewidget.h" #include "clipmanager.h" #include "docclipbase.h" #include "kdenlivedoc.h" @@ -411,21 +410,21 @@ } 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(); Modified: branches/KDE4/src/titlewidget.cpp =================================================================== --- branches/KDE4/src/titlewidget.cpp 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/titlewidget.cpp 2008-03-31 22:43:10 UTC (rev 2154) @@ -19,10 +19,13 @@ #include <QGraphicsView> #include <QDomDocument> +#include <QGraphicsItem> +#include <QGraphicsSvgItem> +#include <QTextDocumentFragment> +#include <QTimer> + #include <KDebug> #include <KGlobalSettings> -#include <QGraphicsItem> -#include <QGraphicsSvgItem> #include <KFileDialog> #include "titlewidget.h" @@ -33,20 +36,22 @@ 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())); @@ -96,17 +101,27 @@ 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); @@ -189,7 +204,9 @@ 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); @@ -283,7 +300,7 @@ void TitleWidget::slotChangeBackground() { QColor color = kcolorbutton->color(); color.setAlpha(horizontalSlider->value()); - graphicsView->scene()->setBackgroundBrush(QBrush(color)); + m_frameBorder->setBrush(QBrush(color)); } void TitleWidget::textChanged() { @@ -294,6 +311,38 @@ } } +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) { Modified: branches/KDE4/src/titlewidget.h =================================================================== --- branches/KDE4/src/titlewidget.h 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/titlewidget.h 2008-03-31 22:43:10 UTC (rev 2154) @@ -78,6 +78,7 @@ void slotZoom(bool up); void slotAdjustZoom(); void slotZoomOneToOne(); + void slotUpdateText(); }; Modified: branches/KDE4/src/widgets/titlewidget_ui.ui =================================================================== --- branches/KDE4/src/widgets/titlewidget_ui.ui 2008-03-31 19:46:41 UTC (rev 2153) +++ branches/KDE4/src/widgets/titlewidget_ui.ui 2008-03-31 22:43:10 UTC (rev 2154) @@ -5,8 +5,8 @@ <rect> <x>0</x> <y>0</y> - <width>794</width> - <height>598</height> + <width>771</width> + <height>510</height> </rect> </property> <property name="sizePolicy" > @@ -18,8 +18,8 @@ <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" > @@ -71,7 +71,7 @@ </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> @@ -183,9 +183,10 @@ </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" > @@ -199,15 +200,15 @@ <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" > @@ -306,8 +307,8 @@ <rect> <x>0</x> <y>0</y> - <width>287</width> - <height>265</height> + <width>297</width> + <height>185</height> </rect> </property> <attribute name="label" > @@ -354,136 +355,112 @@ <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" > @@ -491,8 +468,8 @@ <rect> <x>0</x> <y>0</y> - <width>287</width> - <height>265</height> + <width>278</width> + <height>249</height> </rect> </property> <attribute name="label" > @@ -622,8 +599,8 @@ <rect> <x>0</x> <y>0</y> - <width>287</width> - <height>265</height> + <width>297</width> + <height>185</height> </rect> </property> <attribute name="label" > @@ -677,8 +654,8 @@ <rect> <x>0</x> <y>0</y> - <width>287</width> - <height>265</height> + <width>278</width> + <height>224</height> </rect> </property> <attribute name="label" > @@ -897,19 +874,6 @@ </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> @@ -928,11 +892,6 @@ <header>kcolorbutton.h</header> </customwidget> <customwidget> - <class>KFontRequester</class> - <extends>QWidget</extends> - <header>kfontrequester.h</header> - </customwidget> - <customwidget> <class>KIntSpinBox</class> <extends>QSpinBox</extends> <header>knuminput.h</header> @@ -983,22 +942,6 @@ </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> <receiver>ktextedit</receiver> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |