From: Jean-Baptiste Mardelle Date: Mon, 31 Mar 2008 22:43:10 +0000 (+0000) Subject: More work on title widget: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=168b0f89b86996f312e60dda73e2795a54a3c899;p=kdenlive 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 svn path=/branches/KDE4/; revision=2154 --- diff --git a/src/graphicsscenerectmove.cpp b/src/graphicsscenerectmove.cpp index d6bd3188..e5590cba 100644 --- a/src/graphicsscenerectmove.cpp +++ b/src/graphicsscenerectmove.cpp @@ -91,7 +91,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e) { } } } - if (!hasSelected) QGraphicsScene::mousePressEvent(e); + QGraphicsScene::mousePressEvent(e); kDebug() << "////// MOUSE CLICK, RESIZE MODE: " << resizeMode; @@ -170,15 +170,13 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) { 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 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) { } 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); } diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index e94b0ccd..69250019 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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 @@ void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color, 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" diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index cd8c5afd..85761018 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -106,6 +106,7 @@ private: bool m_modified; public slots: + void slotCreateTextClip(QString group, int groupId); signals: void addProjectClip(DocClipBase *); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 6b5c37ff..6c7d3f63 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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::slotAddColorClip() { } 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 (listView->currentItem()); + if (item && item->clipType() != FOLDER) { + while (item->parent()) { + item = static_cast (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(); diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index 6e457bd6..6e19ff1f 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -19,10 +19,13 @@ #include #include -#include -#include #include #include +#include +#include + +#include +#include #include #include "titlewidget.h" @@ -33,20 +36,22 @@ int settingUp = false; 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 @@ TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent) { 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 @@ void TitleWidget::slotNewText() { 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::slotAdjustSelectedItem() { 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::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 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 l = graphicsView->scene()->selectedItems(); + if (l.size() == 1 && (l[0])->type() == 8 && l[0]->hasFocus()) { + QGraphicsTextItem* item = static_cast (l[0]); + //item- + }*/ +} + void TitleWidget::rectChanged() { QList l = graphicsView->scene()->selectedItems(); if (l.size() == 1 && (l[0])->type() == 3 && !settingUp) { diff --git a/src/titlewidget.h b/src/titlewidget.h index 02e4a463..59b0f820 100644 --- a/src/titlewidget.h +++ b/src/titlewidget.h @@ -78,6 +78,7 @@ private slots: void slotZoom(bool up); void slotAdjustZoom(); void slotZoomOneToOne(); + void slotUpdateText(); }; diff --git a/src/widgets/titlewidget_ui.ui b/src/widgets/titlewidget_ui.ui index 5caa8a96..ce90114f 100644 --- a/src/widgets/titlewidget_ui.ui +++ b/src/widgets/titlewidget_ui.ui @@ -5,8 +5,8 @@ 0 0 - 794 - 598 + 771 + 510 @@ -18,8 +18,8 @@ Dialog - - + + @@ -71,7 +71,7 @@ - + QFrame::StyledPanel @@ -183,9 +183,10 @@ + splitter - + @@ -199,15 +200,15 @@ - 3 + 2 0 0 - 287 - 265 + 297 + 185 @@ -306,8 +307,8 @@ 0 0 - 287 - 265 + 297 + 185 @@ -354,136 +355,112 @@ 0 0 - 358 - 246 + 267 + 177 Text - + - + + + + - - - - - ... - - - - - - - ... - - - - - - - ... - - - - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + 8 + + + 1000 + + + 20 + + - - - - - ... - - - - - - - ... - - - - - - - ... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - Sans Serif - 20 - 50 - false - false - + + + 255 + + + 255 + + + Qt::Horizontal + + + + - + + + ... + + - - - Qt::Vertical + + + ... - - QSizePolicy::Expanding + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + Qt::Horizontal - 20 - 40 + 52 + 20 + + + @@ -491,8 +468,8 @@ 0 0 - 287 - 265 + 278 + 249 @@ -622,8 +599,8 @@ 0 0 - 287 - 265 + 297 + 185 @@ -677,8 +654,8 @@ 0 0 - 287 - 265 + 278 + 224 @@ -897,19 +874,6 @@ - - - Qt::Horizontal - - - - 387 - 20 - - - - - Qt::Horizontal @@ -927,11 +891,6 @@ QPushButton
kcolorbutton.h
- - KFontRequester - QWidget -
kfontrequester.h
-
KIntSpinBox QSpinBox @@ -982,22 +941,6 @@ - - kfontrequester - fontSelected(QFont) - ktextedit - setCurrentFont(QFont) - - - 715 - 184 - - - 713 - 240 - - - fontColorButton changed(QColor)