]> git.sesse.net Git - kdenlive/commitdiff
Title clips:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Jun 2008 20:46:28 +0000 (20:46 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 3 Jun 2008 20:46:28 +0000 (20:46 +0000)
* add item horizontal/vertical align
* fix bugs with rectangles that had borders

svn path=/branches/KDE4/; revision=2229

src/graphicsscenerectmove.cpp
src/kdenlivedoc.cpp
src/titlewidget.cpp
src/titlewidget.h
src/widgets/titlewidget_ui.ui

index 658871fe4e8ee332c2efc3bf054167bfe3a10cdc..8702acd3f4feedd9bb6a193c2c74ec3a692684d8 100644 (file)
@@ -145,7 +145,11 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e) {
                 t->setTextInteractionFlags(Qt::NoTextInteraction);
                 setCursor(Qt::ClosedHandCursor);
             } else if (item->type() == 3 || item->type() == 13 || item->type() == 7) {
-                QRectF r = item->boundingRect();
+                QRectF r;
+                if (m_selectedItem->type() == 3) {
+                    r = ((QGraphicsRectItem*)m_selectedItem)->rect();
+                } else r = m_selectedItem->boundingRect();
+
                 r.translate(item->scenePos());
                 if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
                     resizeMode = TopLeft;
@@ -189,7 +193,11 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
 
     if (m_selectedItem && e->buttons() & Qt::LeftButton) {
         if (m_selectedItem->type() == 3 || m_selectedItem->type() == 13 || m_selectedItem->type() == 7) {
-            QRectF newrect = m_selectedItem->boundingRect();
+            QRectF newrect;
+            if (m_selectedItem->type() == 3) {
+                newrect = ((QGraphicsRectItem*)m_selectedItem)->rect();
+            } else newrect = m_selectedItem->boundingRect();
+
             QPointF newpoint = e->scenePos();
             //newpoint -= m_selectedItem->scenePos();
             switch (resizeMode) {
@@ -228,7 +236,7 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
                 m_selectedItem->moveBy(diff.x(), diff.y());
                 break;
             }
-            if (m_selectedItem->type() == 3) {
+            if (m_selectedItem->type() == 3 && resizeMode != NoResize) {
                 QGraphicsRectItem *gi = (QGraphicsRectItem*)m_selectedItem;
                 gi->setRect(newrect);
             }
@@ -267,7 +275,7 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
                 setCursor(Qt::OpenHandCursor);
                 break;
             } else if (g->type() == 3 && g->zValue() > -1000) {
-                QRectF r = g->boundingRect();
+                QRectF r = ((QGraphicsRectItem*)g)->rect();
                 r.translate(g->scenePos());
                 itemFound = true;
                 if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
index ad5ab426351ebd1c407eab14dcf32afc1d9e72b2..9c350ca51e44de66a621bf260ba07acaa953ee66 100644 (file)
@@ -23,7 +23,7 @@
 #include <KLocale>
 #include <KFileDialog>
 #include <KIO/NetAccess>
-
+#include <KApplication>
 
 #include "kdenlivedoc.h"
 #include "docclipbase.h"
@@ -592,7 +592,7 @@ void KdenliveDoc::slotAddSlideshowClipFile(const QString name, const QString pat
 void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
     QString titlesFolder = projectFolder().path() + "/titles/";
     KStandardDirs::makeDir(titlesFolder);
-    TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, 0);
+    TitleWidget *dia_ui = new TitleWidget(KUrl(), titlesFolder, m_render, kapp->activeWindow());
     if (dia_ui->exec() == QDialog::Accepted) {
         QString titleName = "title";
         int counter = 0;
@@ -610,7 +610,7 @@ void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
 }
 
 void KdenliveDoc::editTextClip(QString path, int id) {
-    TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, 0);
+    TitleWidget *dia_ui = new TitleWidget(KUrl(path + ".kdenlivetitle"), path, m_render, kapp->activeWindow());
     if (dia_ui->exec() == QDialog::Accepted) {
         QPixmap pix = dia_ui->renderedPixmap();
         pix.save(path + ".png");
index a79cdba5710401a84a15173b87a6bac40feaae5a..f4cbb5940272387776eb700681ff37771065fac1 100644 (file)
@@ -74,6 +74,8 @@ TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget
     connect(zValue, SIGNAL(valueChanged(int)), this, SLOT(zIndexChanged(int)));
     connect(itemzoom, SIGNAL(valueChanged(int)), this, SLOT(itemScaled(int)));
     connect(itemrotate, SIGNAL(valueChanged(int)), this, SLOT(itemRotate(int)));
+    connect(itemhcenter, SIGNAL(clicked()), this, SLOT(itemHCenter()));
+    connect(itemvcenter, SIGNAL(clicked()), this, SLOT(itemVCenter()));
 
     connect(value_x, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
     connect(value_y, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
@@ -545,6 +547,33 @@ void TitleWidget::itemRotate(int val) {
     }
 }
 
+void TitleWidget::itemHCenter() {
+    QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+    if (l.size() == 1) {
+        QGraphicsItem *item = l[0];
+        QRectF br;
+        if (item->type() == 3) {
+            br = ((QGraphicsRectItem*)item)->rect();
+        } else br = item->boundingRect();
+        int width = (int) br.width();
+        int newPos = (int)((m_frameWidth - width) / 2);
+        item->setPos(newPos, item->pos().y());
+    }
+}
+
+void TitleWidget::itemVCenter() {
+    QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+    if (l.size() == 1) {
+        QGraphicsItem *item = l[0];
+        QRectF br;
+        if (item->type() == 3) {
+            br = ((QGraphicsRectItem*)item)->rect();
+        } else br = item->boundingRect();
+        int height = (int) br.height();
+        int newPos = (int)((m_frameHeight - height) / 2);
+        item->setPos(item->pos().x(), newPos);
+    }
+}
 
 void TitleWidget::setupViewports() {
     double aspect_ratio = 4.0 / 3.0;//read from project
index e6c837d1dc616145a3b8d460127ced82aab1d172..1fcc6de504a65ec5759acf7e161779ce95f28bd6 100644 (file)
@@ -82,6 +82,8 @@ public slots:
     void zIndexChanged(int);
     void itemScaled(int);
     void itemRotate(int);
+    void itemHCenter();
+    void itemVCenter();
     void saveTitle(KUrl url = KUrl());
     void loadTitle();
     QPixmap renderedPixmap();
index a9d5fa69064676240300dd238a5943d74b54917f..9efb70da2621d45007534b0e06c86541c565d5a5 100644 (file)
@@ -16,7 +16,7 @@
    </sizepolicy>
   </property>
   <property name="windowTitle" >
-   <string>Dialog</string>
+   <string>Title Clip</string>
   </property>
   <layout class="QGridLayout" name="gridLayout_2" >
    <item row="2" column="1" colspan="8" >
      <widget class="QGraphicsView" name="graphicsView" />
      <widget class="QToolBox" name="toolBox" >
       <property name="currentIndex" >
-       <number>1</number>
+       <number>0</number>
       </property>
       <widget class="QWidget" name="BasicOperations" >
        <property name="geometry" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>309</width>
-         <height>140</height>
+         <width>227</width>
+         <height>154</height>
         </rect>
        </property>
        <attribute name="label" >
         <string>BasicOperations</string>
        </attribute>
        <layout class="QGridLayout" >
-        <item row="0" column="0" >
+        <item row="2" column="0" colspan="3" >
          <layout class="QVBoxLayout" >
           <item>
            <layout class="QHBoxLayout" >
           </item>
          </layout>
         </item>
+        <item row="0" column="1" >
+         <widget class="QToolButton" name="itemvcenter" >
+          <property name="text" >
+           <string>...</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="0" >
+         <widget class="QToolButton" name="itemhcenter" >
+          <property name="text" >
+           <string>...</string>
+          </property>
+         </widget>
+        </item>
        </layout>
       </widget>
       <widget class="QWidget" name="Background" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>309</width>
-         <height>140</height>
+         <width>227</width>
+         <height>154</height>
         </rect>
        </property>
        <attribute name="label" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>273</width>
-         <height>224</height>
+         <width>229</width>
+         <height>212</height>
         </rect>
        </property>
        <attribute name="label" >