]> git.sesse.net Git - kdenlive/commitdiff
Title widget improvements:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Apr 2008 21:45:15 +0000 (21:45 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Apr 2008 21:45:15 +0000 (21:45 +0000)
* redesign widget ui
* fix load/save problems
* initial support for title pixmap creation

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

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

index 0f425d1fd27b784052c647f9066e3e3c10dd0ffc..d7e2fb4164eb7a4861c725c5bac2a083c60f0748 100644 (file)
@@ -6,17 +6,39 @@
 #include <QCursor>
 #include <QList>
 #include <QKeyEvent>
+#include <QApplication>
 
 #include "graphicsscenerectmove.h"
 
-GraphicsSceneRectMove::GraphicsSceneRectMove(QObject *parent): QGraphicsScene(parent), m_selectedItem(NULL), resizeMode(NoResize) {
+GraphicsSceneRectMove::GraphicsSceneRectMove(QObject *parent): QGraphicsScene(parent), m_selectedItem(NULL), resizeMode(NoResize), m_tool(TITLE_RECTANGLE) {
     //grabMouse();
     zoom = 1.0;
+    setBackgroundBrush(QBrush(QColor(0, 0, 0, 0)));
 }
 
 void GraphicsSceneRectMove::setSelectedItem(QGraphicsItem *item) {
+    clearSelection();
     m_selectedItem = item;
     item->setSelected(true);
+    update();
+}
+
+TITLETOOL GraphicsSceneRectMove::tool() {
+    return m_tool;
+}
+
+void GraphicsSceneRectMove::setTool(TITLETOOL tool) {
+    m_tool = tool;
+    switch (m_tool) {
+    case TITLE_RECTANGLE:
+        setCursor(Qt::CrossCursor);
+        break;
+    case TITLE_TEXT:
+        setCursor(Qt::IBeamCursor);
+        break;
+    default:
+        setCursor(Qt::ArrowCursor);
+    }
 }
 
 //virtual
@@ -30,20 +52,28 @@ void GraphicsSceneRectMove::keyPressEvent(QKeyEvent * keyEvent) {
     switch (keyEvent->key()) {
     case Qt::Key_Left:
         m_selectedItem->setPos(m_selectedItem->pos() - QPointF(diff, 0));
+        emit itemMoved();
         break;
     case Qt::Key_Right:
         m_selectedItem->setPos(m_selectedItem->pos() + QPointF(diff, 0));
+        emit itemMoved();
         break;
     case Qt::Key_Up:
         m_selectedItem->setPos(m_selectedItem->pos() - QPointF(0, diff));
+        emit itemMoved();
         break;
     case Qt::Key_Down:
         m_selectedItem->setPos(m_selectedItem->pos() + QPointF(0, diff));
+        emit itemMoved();
+        break;
+    case Qt::Key_Delete:
+    case Qt::Key_Backspace:
+        delete m_selectedItem;
+        emit selectionChanged();
         break;
     default:
         QGraphicsScene::keyPressEvent(keyEvent);
     }
-    emit itemMoved();
 }
 
 //virtual
@@ -62,6 +92,12 @@ void GraphicsSceneRectMove::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) {
     QGraphicsScene::mouseDoubleClickEvent(e);
 }
 
+void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
+    if (m_tool == TITLE_RECTANGLE && m_selectedItem) setSelectedItem(m_selectedItem);
+    emit actionFinished();
+    QGraphicsScene::mouseReleaseEvent(e);
+}
+
 void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e) {
     QPointF p = e->scenePos();
     p += QPoint(-2, -2);
@@ -69,72 +105,83 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e) {
     QList <QGraphicsItem *> list = items(QRectF(p , QSizeF(4, 4)).toRect());
     QGraphicsItem *item = NULL;
     bool hasSelected = false;
-    foreach(QGraphicsItem* g, list) {
-        // check is there is a selected item in list
-        if (g->zValue() > -1000 && g->isSelected()) {
-            hasSelected = true;
-            item = g;
-            break;
-        }
-    }
-    if (item == NULL) {
-        if (m_selectedItem && m_selectedItem->type() == 8) {
-            // disable text editing
-            QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
-            t->setTextInteractionFlags(Qt::NoTextInteraction);
-        }
-        m_selectedItem = NULL;
+
+    if (m_tool == TITLE_SELECT) {
         foreach(QGraphicsItem* g, list) {
-            if (g->zValue() > -1000) {
+            kDebug() << " - - CHECKING ITEM Z:" << g->zValue() << ", TYPE: " << g->type();
+            // check is there is a selected item in list
+            if (g->zValue() > -1000 && g->isSelected()) {
+                hasSelected = true;
                 item = g;
                 break;
             }
         }
-    }
-    if (item != NULL) {
-        m_clickPoint = e->scenePos();
-        m_selectedItem = item;
-        if (item->type() == 8) {
-            QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(item);
-            if (t->textInteractionFlags() == Qt::TextEditorInteraction) {
-                QGraphicsScene::mousePressEvent(e);
-                return;
+        if (item == NULL) {
+            if (m_selectedItem && m_selectedItem->type() == 8) {
+                // disable text editing
+                QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(m_selectedItem);
+                t->setTextInteractionFlags(Qt::NoTextInteraction);
             }
-            t->setTextInteractionFlags(Qt::NoTextInteraction);
-        } else if (item->type() == 3) {
-            QGraphicsRectItem *gi = (QGraphicsRectItem*)item;
-            QRectF r = gi->rect();
-            r.translate(gi->scenePos());
-            if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
-                resizeMode = TopLeft;
-            } else if ((r.toRect().bottomLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
-                resizeMode = BottomLeft;
-            } else if ((r.toRect().topRight() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
-                resizeMode = TopRight;
-            } else if ((r.toRect().bottomRight() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
-                resizeMode = BottomRight;
-            } else if (qAbs(r.toRect().left() - e->scenePos().toPoint().x()) < 3 / zoom) {
-                resizeMode = Left;
-            } else if (qAbs(r.toRect().right() - e->scenePos().toPoint().x()) < 3 / zoom) {
-                resizeMode = Right;
-            } else if (qAbs(r.toRect().top() - e->scenePos().toPoint().y()) < 3 / zoom) {
-                resizeMode = Up;
-            } else if (qAbs(r.toRect().bottom() - e->scenePos().toPoint().y()) < 3 / zoom) {
-                resizeMode = Down;
+            m_selectedItem = NULL;
+            foreach(QGraphicsItem* g, list) {
+                if (g->zValue() > -1000) {
+                    item = g;
+                    break;
+                }
             }
         }
+        if (item != NULL) {
+            m_clickPoint = e->scenePos();
+            m_selectedItem = item;
+            kDebug() << "/////////  ITEM TYPE: " << item->type();
+            if (item->type() == 8) {
+                QGraphicsTextItem *t = static_cast<QGraphicsTextItem *>(item);
+                if (t->textInteractionFlags() == Qt::TextEditorInteraction) {
+                    QGraphicsScene::mousePressEvent(e);
+                    return;
+                }
+                t->setTextInteractionFlags(Qt::NoTextInteraction);
+                setCursor(Qt::ClosedHandCursor);
+            } else if (item->type() == 3) {
+                QGraphicsRectItem *gi = (QGraphicsRectItem*)item;
+                QRectF r = gi->rect();
+                r.translate(gi->scenePos());
+                if ((r.toRect().topLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
+                    resizeMode = TopLeft;
+                } else if ((r.toRect().bottomLeft() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
+                    resizeMode = BottomLeft;
+                } else if ((r.toRect().topRight() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
+                    resizeMode = TopRight;
+                } else if ((r.toRect().bottomRight() - e->scenePos().toPoint()).manhattanLength() < 6 / zoom) {
+                    resizeMode = BottomRight;
+                } else if (qAbs(r.toRect().left() - e->scenePos().toPoint().x()) < 3 / zoom) {
+                    resizeMode = Left;
+                } else if (qAbs(r.toRect().right() - e->scenePos().toPoint().x()) < 3 / zoom) {
+                    resizeMode = Right;
+                } else if (qAbs(r.toRect().top() - e->scenePos().toPoint().y()) < 3 / zoom) {
+                    resizeMode = Up;
+                } else if (qAbs(r.toRect().bottom() - e->scenePos().toPoint().y()) < 3 / zoom) {
+                    resizeMode = Down;
+                } else setCursor(Qt::ClosedHandCursor);
+            }
+        }
+        QGraphicsScene::mousePressEvent(e);
+    } else if (m_tool == TITLE_RECTANGLE) {
+        m_clickPoint = e->scenePos();
+        m_selectedItem = NULL;
+    } else if (m_tool == TITLE_TEXT) {
+        m_selectedItem = addText(QString());
+        emit newText((QGraphicsTextItem *) m_selectedItem);
+        m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+        ((QGraphicsTextItem *)m_selectedItem)->setTextInteractionFlags(Qt::TextEditorInteraction);
+        m_selectedItem->setPos(e->scenePos());
+        QGraphicsScene::mousePressEvent(e);
     }
-    QGraphicsScene::mousePressEvent(e);
 
     kDebug() << "//////  MOUSE CLICK, RESIZE MODE: " << resizeMode;
 
 }
 
-//virtual
-void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent* e) {
-    //m_selectedItem = NULL;
-}
-
 
 //virtual
 void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
@@ -198,14 +245,14 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
             m_selectedItem->moveBy(diff.x(), diff.y());
         }
         emit itemMoved();
-    } else {
+    } else if (m_tool == TITLE_SELECT) {
 
         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) {
+            if (g->type() == 3 && g->zValue() > -1000) {
                 QGraphicsRectItem *gi = (QGraphicsRectItem*)g;
                 QRectF r = gi->rect();
                 r.translate(gi->scenePos());
@@ -226,12 +273,22 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e) {
                     setCursor(Qt::SizeVerCursor);
                 } else if (qAbs(r.toRect().bottom() - e->scenePos().toPoint().y()) < 3 / zoom) {
                     setCursor(Qt::SizeVerCursor);
-                } else setCursor(QCursor(Qt::ArrowCursor));
+                } else setCursor(Qt::OpenHandCursor);
                 break;
             }
-            if (!itemFound) setCursor(QCursor(Qt::ArrowCursor));
+            if (!itemFound) setCursor(Qt::ArrowCursor);
         }
         QGraphicsScene::mouseMoveEvent(e);
+    } else if (m_tool == TITLE_RECTANGLE && e->buttons() & Qt::LeftButton) {
+        if (m_selectedItem == NULL && (m_clickPoint.toPoint() - e->scenePos().toPoint()).manhattanLength() >= QApplication::startDragDistance()) {
+            // create new rect item
+            m_selectedItem = addRect(0, 0, e->scenePos().x() - m_clickPoint.x(), e->scenePos().y() - m_clickPoint.y());
+            emit newRect((QGraphicsRectItem *) m_selectedItem);
+            m_selectedItem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
+            m_selectedItem->setPos(m_clickPoint);
+            resizeMode = BottomRight;
+            QGraphicsScene::mouseMoveEvent(e);
+        }
     }
 }
 
index 6549a8b12916da9e3c4192f1fa309923d02e118f..091702434c0b52ac97e96a67e90f92c1fa861420 100644 (file)
@@ -4,6 +4,7 @@
 #include <QGraphicsScene>
 
 enum resizeModes {NoResize, TopLeft, BottomLeft, TopRight, BottomRight, Left, Right, Up, Down};
+enum TITLETOOL { TITLE_SELECT = 0, TITLE_RECTANGLE = 1, TITLE_TEXT = 2, TITLE_IMAGE = 3 };
 
 class GraphicsSceneRectMove: public QGraphicsScene {
     Q_OBJECT
@@ -13,13 +14,15 @@ public:
     void setSelectedItem(QGraphicsItem *item);
     void setScale(double s);
     void setZoom(double s);
+    void setTool(TITLETOOL tool);
+    TITLETOOL tool();
 
 protected:
     virtual void keyPressEvent(QKeyEvent * keyEvent);
     virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
+    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e);
     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
-    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
     virtual void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
 
 private:
@@ -28,10 +31,14 @@ private:
     QGraphicsItem* m_selectedItem;
     resizeModes resizeMode;
     QPointF m_clickPoint;
+    TITLETOOL m_tool;
 
 signals:
     void itemMoved();
     void sceneZoom(bool);
+    void newRect(QGraphicsRectItem *);
+    void newText(QGraphicsTextItem *);
+    void actionFinished();
 };
 
 #endif
index 692500194c6bd1ca6483ca54de41285912634574..0d7fd96c12314001950de8a9c0d7448614c0f57a 100644 (file)
@@ -371,6 +371,9 @@ void KdenliveDoc::slotAddColorClipFile(const QString name, const QString color,
 void KdenliveDoc::slotCreateTextClip(QString group, int groupId) {
     TitleWidget *dia_ui = new TitleWidget(m_render, 0);
     if (dia_ui->exec() == QDialog::Accepted) {
+        QPixmap p = dia_ui->renderedPixmap();
+        p.save("/tmp/kdenlivetitle.png");
+        slotAddClipFile(KUrl("/tmp/kdenlivetitle.png"), QString(), -1);
     }
     delete dia_ui;
 }
index c334b715e3371eb4bb4a88c882af6990f0191a63..ca30117bb178bfa2e58e658a051ac14a1c09a91d 100644 (file)
@@ -23,6 +23,7 @@
 #include <QGraphicsTextItem>
 #include <KDebug>
 #include <QFile>
+#include <KTemporaryFile>
 #include <kio/netaccess.h>
 
 TitleDocument::TitleDocument() {
@@ -45,6 +46,8 @@ bool TitleDocument::saveDocument(const KUrl& url, QGraphicsPolygonItem* startv,
     foreach(QGraphicsItem* item, scene->items()) {
         QDomElement e = doc.createElement("item");
         QDomElement content = doc.createElement("content");
+        QFont font;
+        QGraphicsTextItem *t;
 
         switch (item->type()) {
         case 3:
@@ -56,7 +59,16 @@ bool TitleDocument::saveDocument(const KUrl& url, QGraphicsPolygonItem* startv,
             break;
         case 8:
             e.setAttribute("type", "QGraphicsTextItem");
-            content.appendChild(doc.createTextNode(((QGraphicsTextItem*)item)->toHtml()));
+            t = static_cast<QGraphicsTextItem *>(item);
+            //content.appendChild(doc.createTextNode(((QGraphicsTextItem*)item)->toHtml()));
+            content.appendChild(doc.createTextNode(t->toPlainText()));
+            font = t->font();
+            e.setAttribute("font", font.family());
+            e.setAttribute("font-bold", font.bold());
+            e.setAttribute("font-size", font.pointSize());
+            e.setAttribute("font-italic", font.italic());
+            e.setAttribute("font-underline", font.underline());
+            e.setAttribute("font-color", colorToString(t->defaultTextColor()));
             break;
         default:
             continue;
@@ -77,7 +89,7 @@ bool TitleDocument::saveDocument(const KUrl& url, QGraphicsPolygonItem* startv,
 
         e.appendChild(pos);
         e.appendChild(content);
-        main.appendChild(e);
+        if (item->zValue() > -1100) main.appendChild(e);
     }
     if (startv && endv) {
         QDomElement endp = doc.createElement("endviewport");
@@ -96,23 +108,34 @@ bool TitleDocument::saveDocument(const KUrl& url, QGraphicsPolygonItem* startv,
         main.appendChild(endp);
     }
     QDomElement backgr = doc.createElement("background");
-    backgr.setAttribute("color", colorToString(scene->backgroundBrush().color()));
+    QList<QGraphicsItem *> items = scene->items();
+    QColor color(0, 0, 0, 0);
+    for (int i = 0; i < items.size(); i++) {
+        if (items.at(i)->zValue() == -1100) {
+            color = ((QGraphicsRectItem *)items.at(i))->brush().color();
+            break;
+        }
+    }
+    backgr.setAttribute("color", colorToString(color));
     main.appendChild(backgr);
 
-    QString tmpfile = "/tmp/newtitle";
-    QFile xmlf(tmpfile);
+    KTemporaryFile tmpfile;
+    if (!tmpfile.open()) kWarning() << "/////  CANNOT CREATE TMP FILE in: " << tmpfile.fileName();
+    QFile xmlf(tmpfile.fileName());
     xmlf.open(QIODevice::WriteOnly);
     xmlf.write(doc.toString().toAscii());
     xmlf.close();
-    kDebug() << KIO::NetAccess::upload(tmpfile, url, 0);
+    kDebug() << KIO::NetAccess::upload(tmpfile.fileName(), url, 0);
+
 }
 
-bool TitleDocument::loadDocument(const KUrl& url , QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv) {
+int TitleDocument::loadDocument(const KUrl& url , QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv) {
     QString tmpfile;
     QDomDocument doc;
+    int maxZValue = 0;
     double aspect_ratio = 4.0 / 3.0;
     if (!scene)
-        return false;
+        return -1;
 
     if (KIO::NetAccess::download(url, tmpfile, 0)) {
         QFile file(tmpfile);
@@ -120,7 +143,7 @@ bool TitleDocument::loadDocument(const KUrl& url , QGraphicsPolygonItem* startv,
             doc.setContent(&file, false);
             file.close();
         } else
-            return false;
+            return -1;
         KIO::NetAccess::removeTempFile(tmpfile);
         QDomNodeList titles = doc.elementsByTagName("kdenlivetitle");
         if (titles.size()) {
@@ -129,30 +152,51 @@ bool TitleDocument::loadDocument(const KUrl& url , QGraphicsPolygonItem* startv,
             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;
-                    }
+                int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
+                if (zValue > -1000)
+                    if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsTextItem") {
+                        QFont font(items.item(i).attributes().namedItem("font").nodeValue());
+                        font.setBold(items.item(i).attributes().namedItem("font-bold").nodeValue().toInt());
+                        font.setItalic(items.item(i).attributes().namedItem("font-italic").nodeValue().toInt());
+                        font.setUnderline(items.item(i).attributes().namedItem("font-underline").nodeValue().toInt());
+                        font.setPointSize(items.item(i).attributes().namedItem("font-size").nodeValue().toInt());
+                        QColor col(stringToColor(items.item(i).attributes().namedItem("font-color").nodeValue()));
+                        QGraphicsTextItem *txt = scene->addText(items.item(i).namedItem("content").firstChild().nodeValue(), font);
+                        txt->setDefaultTextColor(col);
+                        txt->setTextInteractionFlags(Qt::NoTextInteraction);
+                        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()));
+                    int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
+                    if (zValue > maxZValue) maxZValue = zValue;
+                    gitem->setZValue(zValue);
+                    gitem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
                 }
                 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) {
+                    QColor color = QColor(stringToColor(items.item(i).attributes().namedItem("color").nodeValue()));
+                    //color.setAlpha(items.item(i).attributes().namedItem("alpha").nodeValue().toInt());
+                    QList<QGraphicsItem *> items = scene->items();
+                    for (int i = 0; i < items.size(); i++) {
+                        if (items.at(i)->zValue() == -1100) {
+                            ((QGraphicsRectItem *)items.at(i))->setBrush(QBrush(color));
+                            break;
+                        }
+                    }
+                } /*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);
@@ -166,16 +210,11 @@ bool TitleDocument::loadDocument(const KUrl& url , QGraphicsPolygonItem* startv,
                     kDebug() << width << rect;
                     endv->setPolygon(rect);
                     endv->setPos(p);
-                }
-
+                }*/
             }
-
-
         }
-
-
     }
-    return true;
+    return maxZValue;
 }
 
 QString TitleDocument::colorToString(const QColor& c) {
index fab51a5e63a642ee78446571a4983f216d7b4e84..5fcc3d0350d794684aeab2e358746f8e309ef479 100644 (file)
@@ -27,7 +27,7 @@ public:
     TitleDocument();
     void setScene(QGraphicsScene* scene);
     bool saveDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
-    bool loadDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
+    int loadDocument(const KUrl& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv);
 private:
     QString colorToString(const QColor&);
     QString rectFToString(const QRectF&);
index 4a71f114e5e65bde1b71c61123db5e1a36d179d2..918ff2c14633a534f8eb56b1c22a28d9b67b12a2 100644 (file)
@@ -35,19 +35,20 @@ int settingUp = false;
 
 TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_frameImage(NULL), m_render(render), m_count(0) {
     setupUi(this);
-    frame_properties->setFont(KGlobalSettings::toolBarFont());
-    toolBox->setFont(KGlobalSettings::toolBarFont());
+    //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(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(ktextedit, SIGNAL(textChanged()), 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(buttonLoad, SIGNAL(clicked()), this, SLOT(loadTitle())) ;
+    connect(buttonSave, SIGNAL(clicked()), this, SLOT(saveTitle())) ;
 
-    ktextedit->setHidden(true);
+    //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())) ;
@@ -89,6 +90,20 @@ TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_fr
     buttonItalic->setIcon(KIcon("format-text-italic"));
     buttonUnder->setIcon(KIcon("format-text-underline"));
 
+    buttonRect->setIcon(KIcon("insert-rect"));
+    buttonText->setIcon(KIcon("insert-text"));
+    buttonImage->setIcon(KIcon("insert-image"));
+    buttonCursor->setIcon(KIcon("select-rectangular"));
+    buttonSave->setIcon(KIcon("document-save"));
+    buttonLoad->setIcon(KIcon("document-open"));
+
+    connect(buttonRect,  SIGNAL(clicked()), this, SLOT(slotRectTool()));
+    connect(buttonText,  SIGNAL(clicked()), this, SLOT(slotTextTool()));
+    connect(buttonImage,  SIGNAL(clicked()), this, SLOT(slotImageTool()));
+    connect(buttonCursor,  SIGNAL(clicked()), this, SLOT(slotSelectTool()));
+
+    text_properties->setHidden(true);
+
     m_scene = new GraphicsSceneRectMove(this);
 
     // a gradient background
@@ -96,31 +111,33 @@ TitleWidget::TitleWidget(Render *render, QWidget *parent): QDialog(parent), m_fr
     gradient->setSpread(QGradient::ReflectSpread);
     //scene->setBackgroundBrush(*gradient);
 
-
-    graphicsView->setScene(m_scene);
-    m_titledocument.setScene(m_scene);
-    connect(graphicsView->scene(), SIGNAL(selectionChanged()), this , SLOT(selectionChanged()));
+    connect(m_scene, SIGNAL(selectionChanged()), this , SLOT(selectionChanged()));
     connect(m_scene, SIGNAL(itemMoved()), this , SLOT(selectionChanged()));
     connect(m_scene, SIGNAL(sceneZoom(bool)), this , SLOT(slotZoom(bool)));
+    connect(m_scene, SIGNAL(actionFinished()), this , SLOT(slotSelectTool()));
+    connect(m_scene, SIGNAL(actionFinished()), this , SLOT(selectionChanged()));
+    connect(m_scene, SIGNAL(newRect(QGraphicsRectItem *)), this , SLOT(slotNewRect(QGraphicsRectItem *)));
+    connect(m_scene, SIGNAL(newText(QGraphicsTextItem *)), this , SLOT(slotNewText(QGraphicsTextItem *)));
     connect(zoom_slider, SIGNAL(valueChanged(int)), this , SLOT(slotUpdateZoom(int)));
 
+    graphicsView->setScene(m_scene);
+    m_titledocument.setScene(m_scene);
 
     QPen framepen(Qt::DotLine);
     framepen.setColor(Qt::red);
     m_frameWidth = render->renderWidth();
     m_frameHeight = render->renderHeight();
-
+    slotRectTool();
 
     m_frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_frameWidth, m_frameHeight));
     m_frameBorder->setPen(framepen);
-    m_frameBorder->setZValue(-1000);
+    m_frameBorder->setZValue(-1100);
+    m_frameBorder->setBrush(QColor(0, 0, 0, 0));
     m_frameBorder->setFlags(QGraphicsItem::ItemClipsToShape);
     graphicsView->scene()->addItem(m_frameBorder);
 
     initViewports();
 
-
-
     graphicsView->show();
     graphicsView->setRenderHint(QPainter::Antialiasing);
     graphicsView->setInteractive(true);
@@ -137,6 +154,32 @@ void TitleWidget::resizeEvent(QResizeEvent * event) {
     //slotAdjustZoom();
 }
 
+void TitleWidget::slotTextTool() {
+    rect_properties->setHidden(true);
+    text_properties->setHidden(false);
+    m_scene->setTool(TITLE_TEXT);
+    buttonRect->setChecked(false);
+    buttonCursor->setChecked(false);
+    buttonImage->setChecked(false);
+}
+
+void TitleWidget::slotRectTool() {
+    rect_properties->setHidden(false);
+    text_properties->setHidden(true);
+    m_scene->setTool(TITLE_RECTANGLE);
+    buttonText->setChecked(false);
+    buttonCursor->setChecked(false);
+    buttonImage->setChecked(false);
+}
+
+void TitleWidget::slotSelectTool() {
+    m_scene->setTool(TITLE_SELECT);
+    buttonCursor->setChecked(true);
+    buttonText->setChecked(false);
+    buttonRect->setChecked(false);
+    buttonImage->setChecked(false);
+}
+
 void TitleWidget::displayBackgroundFrame() {
     if (m_frameImage) delete m_frameImage;
     m_frameImage = NULL;
@@ -146,7 +189,7 @@ void TitleWidget::displayBackgroundFrame() {
     QTransform qtrans;
     qtrans.scale(2.0, 2.0);
     m_frameImage->setTransform(qtrans);
-    m_frameImage->setZValue(-1100);
+    m_frameImage->setZValue(-1200);
     m_frameImage->setFlags(QGraphicsItem::ItemClipsToShape);
     graphicsView->scene()->addItem(m_frameImage);
 }
@@ -202,46 +245,32 @@ void TitleWidget::slotZoomOneToOne() {
     graphicsView->centerOn(m_frameBorder);
 }
 
-void TitleWidget::slotNewRect() {
-    QGraphicsRectItem * ri = graphicsView->scene()->addRect(0, 0, 100, 100);
-    ri->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
-    ri->setPos(m_frameWidth / 2, m_frameHeight / 2);
+void TitleWidget::slotNewRect(QGraphicsRectItem * rect) {
     QColor f = rectFColor->color();
     f.setAlpha(rectFAlpha->value());
     QPen penf(f);
     penf.setWidth(rectLineWidth->value());
-    ri->setPen(penf);
+    rect->setPen(penf);
     QColor b = rectBColor->color();
     b.setAlpha(rectBAlpha->value());
-    ri->setBrush(QBrush(b));
-    ri->setZValue(m_count++);
-    setCurrentItem(ri);
-    graphicsView->setFocus();
+    rect->setBrush(QBrush(b));
+    rect->setZValue(m_count++);
+    //setCurrentItem(rect);
+    //graphicsView->setFocus();
 }
 
-void TitleWidget::slotNewText() {
-    QGraphicsTextItem *tt = graphicsView->scene()->addText("Text here");
-    tt->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
-    tt->setTextInteractionFlags(Qt::NoTextInteraction);
-    tt->setPos(m_frameWidth / 2, m_frameHeight / 2);
+void TitleWidget::slotNewText(QGraphicsTextItem *tt) {
     QFont font = font_family->currentFont();
     font.setPointSize(font_size->value());
     tt->setFont(font);
+    QColor color = fontColorButton->color();
+    color.setAlpha(textAlpha->value());
+    tt->setDefaultTextColor(color);
     tt->setZValue(m_count++);
     setCurrentItem(tt);
-    graphicsView->setFocus();
-    //connect(tt->document(), SIGNAL(contentsChanged()), this, SLOT(selectionChanged()));
-    kDebug() << tt->metaObject()->className();
-    /*QGraphicsRectItem * ri=graphicsView->scene()->addRect(-50,-50,100,100);
-    ri->setFlags(QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemIsSelectable);*/
-
 }
 
 void TitleWidget::setCurrentItem(QGraphicsItem *item) {
-    QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
-    if (l.size() >= 1) {
-        l[0]->setSelected(false);
-    }
     m_scene->setSelectedItem(item);
 }
 
@@ -253,21 +282,31 @@ void TitleWidget::zIndexChanged(int v) {
 }
 
 void TitleWidget::selectionChanged() {
+    if (m_scene->tool() != TITLE_SELECT) return;
     QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
-    toolBox->setItemEnabled(2, false);
-    toolBox->setItemEnabled(3, false);
+    //toolBox->setItemEnabled(2, false);
+    //toolBox->setItemEnabled(3, false);
     value_x->blockSignals(true);
     value_y->blockSignals(true);
     value_w->blockSignals(true);
     value_h->blockSignals(true);
+    kDebug() << "////////  SELECTION CHANGED; ITEMS: " << l.size();
     if (l.size() == 1) {
         if ((l[0])->type() == 8) {
+            rect_properties->setHidden(true);
+            text_properties->setHidden(false);
             QGraphicsTextItem* i = ((QGraphicsTextItem*)l[0]);
-            if (l[0]->hasFocus())
-                ktextedit->setHtml(i->toHtml());
-            toolBox->setCurrentIndex(2);
-            toolBox->setItemEnabled(2, true);
-
+            //if (l[0]->hasFocus())
+            //ktextedit->setHtml(i->toHtml());
+            toolBox->setCurrentIndex(0);
+            //toolBox->setItemEnabled(2, true);
+            font_size->blockSignals(true);
+            font_family->blockSignals(true);
+            buttonBold->blockSignals(true);
+            buttonItalic->blockSignals(true);
+            buttonUnder->blockSignals(true);
+            fontColorButton->blockSignals(true);
+            textAlpha->blockSignals(true);
 
             QFont font = i->font();
             font_family->setCurrentFont(font);
@@ -280,6 +319,14 @@ void TitleWidget::selectionChanged() {
             fontColorButton->setColor(color);
             textAlpha->setValue(color.alpha());
 
+            font_size->blockSignals(false);
+            font_family->blockSignals(false);
+            buttonBold->blockSignals(false);
+            buttonItalic->blockSignals(false);
+            buttonUnder->blockSignals(false);
+            fontColorButton->blockSignals(false);
+            textAlpha->blockSignals(false);
+
             value_x->setValue((int) i->pos().x());
             value_y->setValue((int) i->pos().y());
             value_w->setValue((int) i->boundingRect().width());
@@ -287,34 +334,35 @@ void TitleWidget::selectionChanged() {
             frame_properties->setEnabled(true);
             value_w->setEnabled(false);
             value_h->setEnabled(false);
-        } else
-            if ((l[0])->type() == 3) {
-                settingUp = true;
-                QGraphicsRectItem *rec = ((QGraphicsRectItem*)l[0]);
-                toolBox->setCurrentIndex(3);
-                toolBox->setItemEnabled(3, true);
-                rectFAlpha->setValue(rec->pen().color().alpha());
-                rectBAlpha->setValue(rec->brush().color().alpha());
-                kDebug() << rec->brush().color().alpha();
-                QColor fcol = rec->pen().color();
-                QColor bcol = rec->brush().color();
-                //fcol.setAlpha(255);
-                //bcol.setAlpha(255);
-                rectFColor->setColor(fcol);
-                rectBColor->setColor(bcol);
-                settingUp = false;
-                rectLineWidth->setValue(rec->pen().width());
-                value_x->setValue((int) rec->pos().x());
-                value_y->setValue((int) rec->pos().y());
-                value_w->setValue((int) rec->rect().width());
-                value_h->setValue((int) rec->rect().height());
-                frame_properties->setEnabled(true);
-                value_w->setEnabled(true);
-                value_h->setEnabled(true);
-            } else {
-                //toolBox->setCurrentIndex(0);
-                frame_properties->setEnabled(false);
-            }
+        } else if ((l[0])->type() == 3) {
+            rect_properties->setHidden(false);
+            text_properties->setHidden(true);
+            settingUp = true;
+            QGraphicsRectItem *rec = ((QGraphicsRectItem*)l[0]);
+            toolBox->setCurrentIndex(0);
+            //toolBox->setItemEnabled(3, true);
+            rectFAlpha->setValue(rec->pen().color().alpha());
+            rectBAlpha->setValue(rec->brush().color().alpha());
+            kDebug() << rec->brush().color().alpha();
+            QColor fcol = rec->pen().color();
+            QColor bcol = rec->brush().color();
+            //fcol.setAlpha(255);
+            //bcol.setAlpha(255);
+            rectFColor->setColor(fcol);
+            rectBColor->setColor(bcol);
+            settingUp = false;
+            rectLineWidth->setValue(rec->pen().width());
+            value_x->setValue((int) rec->pos().x());
+            value_y->setValue((int) rec->pos().y());
+            value_w->setValue((int) rec->rect().width());
+            value_h->setValue((int) rec->rect().height());
+            frame_properties->setEnabled(true);
+            value_w->setEnabled(true);
+            value_h->setEnabled(true);
+        } else {
+            //toolBox->setCurrentIndex(0);
+            frame_properties->setEnabled(false);
+        }
         zValue->setValue((int)l[0]->zValue());
         itemzoom->setValue((int)transformations[l[0]].scalex*100);
         itemrotate->setValue((int)transformations[l[0]].rotate);
@@ -322,7 +370,7 @@ void TitleWidget::selectionChanged() {
         value_y->blockSignals(false);
         value_w->blockSignals(false);
         value_h->blockSignals(false);
-    }
+    } else frame_properties->setEnabled(false);
 }
 
 void TitleWidget::slotAdjustSelectedItem() {
@@ -350,8 +398,8 @@ void TitleWidget::slotChangeBackground() {
 void TitleWidget::textChanged() {
     QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
     if (l.size() == 1 && (l[0])->type() == 8 && !l[0]->hasFocus()) {
-        kDebug() << ktextedit->document()->toHtml();
-        ((QGraphicsTextItem*)l[0])->setHtml(ktextedit->toHtml());
+        //kDebug() << ktextedit->document()->toHtml();
+        //((QGraphicsTextItem*)l[0])->setHtml(ktextedit->toHtml());
     }
 }
 
@@ -467,7 +515,14 @@ void TitleWidget::setupViewports() {
 
 void TitleWidget::loadTitle() {
     KUrl url = KFileDialog::getOpenUrl(KUrl(), "*.kdenlivetitle", this, tr("Save Title"));
-    m_titledocument.loadDocument(url, startViewport, endViewport);
+    if (!url.isEmpty()) {
+        QList<QGraphicsItem *> items = m_scene->items();
+        for (int i = 0; i < items.size(); i++) {
+            if (items.at(i)->zValue() > -1000) delete items.at(i);
+        }
+        m_count = m_titledocument.loadDocument(url, startViewport, endViewport) + 1;
+        slotSelectTool();
+    }
 }
 
 void TitleWidget::saveTitle() {
@@ -475,5 +530,27 @@ void TitleWidget::saveTitle() {
     m_titledocument.saveDocument(url, startViewport, endViewport);
 }
 
+QPixmap TitleWidget::renderedPixmap() {
+    QPixmap pix(m_frameWidth, m_frameHeight);
+    pix.fill(Qt::transparent);
+    QPainter painter(&pix);
+
+    m_scene->clearSelection();
+    QPen framepen = m_frameBorder->pen();
+    m_frameBorder->setPen(Qt::NoPen);
+    QPen startpen = startViewport->pen();
+    QPen endpen = endViewport->pen();
+    startViewport->setPen(Qt::NoPen);
+    endViewport->setPen(Qt::NoPen);
+    if (m_frameImage) delete m_frameImage;
+    m_frameImage = NULL;
+    m_scene->render(&painter, QRectF(), QRectF(0, 0, m_frameWidth, m_frameHeight));
+    m_frameBorder->setPen(framepen);
+    startViewport->setPen(startpen);
+    endViewport->setPen(endpen);
+    displayBackgroundFrame();
+    return pix;
+}
+
 #include "moc_titlewidget.cpp"
 
index 6a1771cdcc673125c1b12946ea0d3e44ec2e2d6c..42113f38903a4e7765eb00fd3352191ccfb41fb8 100644 (file)
@@ -28,6 +28,8 @@
 #include "renderer.h"
 #include "graphicsscenerectmove.h"
 
+
+
 class Transform {
 public:
     Transform() {
@@ -61,8 +63,8 @@ private:
     int m_count;
 
 public slots:
-    void slotNewText();
-    void slotNewRect();
+    void slotNewText(QGraphicsTextItem *tt);
+    void slotNewRect(QGraphicsRectItem *rect);
     void slotChangeBackground();
     void selectionChanged();
     void textChanged();
@@ -75,6 +77,7 @@ public slots:
     void itemRotate(int);
     void saveTitle();
     void loadTitle();
+    QPixmap renderedPixmap();
 
 private slots:
     void slotAdjustSelectedItem();
@@ -85,6 +88,9 @@ private slots:
     void slotUpdateText();
     void displayBackgroundFrame();
     void setCurrentItem(QGraphicsItem *item);
+    void slotTextTool();
+    void slotRectTool();
+    void slotSelectTool();
 };
 
 
index 418552489684dacde1f4a11dd2a3abd220bacf5f..06977efa5ee2ff43cb6fbe8a2fbdbdf12e6e03ad 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>771</width>
-    <height>612</height>
+    <width>850</width>
+    <height>575</height>
    </rect>
   </property>
   <property name="sizePolicy" >
   <property name="windowTitle" >
    <string>Dialog</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_4" >
-   <item row="0" column="0" colspan="6" >
-    <layout class="QHBoxLayout" >
-     <item>
-      <widget class="QPushButton" name="newRectButton" >
-       <property name="text" >
-        <string>New Rect</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="newTextButton" >
-       <property name="text" >
-        <string>New Text</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="loadButton" >
-       <property name="text" >
-        <string>Load Title</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="saveButton" >
-       <property name="text" >
-        <string>Save Title</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="previewButton" >
-       <property name="text" >
-        <string>Preview</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>
+  <layout class="QGridLayout" name="gridLayout_2" >
+   <item row="0" column="0" >
+    <widget class="QToolButton" name="buttonRect" >
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+     <property name="checked" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" >
+    <widget class="QToolButton" name="buttonText" >
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2" >
+    <widget class="QToolButton" name="buttonImage" >
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3" >
+    <widget class="QToolButton" name="buttonCursor" >
+     <property name="checkable" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="4" >
+    <widget class="QToolButton" name="buttonLoad" >
+     <property name="checkable" >
+      <bool>false</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="5" >
+    <widget class="QToolButton" name="buttonSave" >
+     <property name="checkable" >
+      <bool>false</bool>
+     </property>
+    </widget>
    </item>
-   <item row="1" column="0" colspan="6" >
+   <item row="0" column="6" colspan="4" >
     <widget class="QFrame" name="frame_properties" >
      <property name="frameShape" >
       <enum>QFrame::StyledPanel</enum>
      </layout>
     </widget>
    </item>
-   <item row="3" column="0" >
-    <widget class="QToolButton" name="buttonFitZoom" >
-     <property name="text" >
-      <string>V</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="1" >
-    <widget class="QToolButton" name="buttonRealSize" >
-     <property name="text" >
-      <string>V</string>
-     </property>
-    </widget>
-   </item>
-   <item row="3" column="2" >
-    <widget class="QSlider" name="zoom_slider" >
-     <property name="minimumSize" >
-      <size>
-       <width>100</width>
-       <height>0</height>
-      </size>
-     </property>
-     <property name="maximumSize" >
-      <size>
-       <width>150</width>
-       <height>16777215</height>
-      </size>
-     </property>
-     <property name="minimum" >
-      <number>1</number>
-     </property>
-     <property name="maximum" >
-      <number>10</number>
-     </property>
-     <property name="pageStep" >
-      <number>2</number>
-     </property>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
+   <item row="1" column="0" colspan="10" >
+    <widget class="QFrame" name="rect_properties" >
+     <property name="frameShape" >
+      <enum>QFrame::StyledPanel</enum>
      </property>
-    </widget>
-   </item>
-   <item row="3" column="3" >
-    <widget class="QLabel" name="zoom_label" >
-     <property name="text" >
-      <string>x1</string>
+     <property name="frameShadow" >
+      <enum>QFrame::Sunken</enum>
      </property>
+     <layout class="QGridLayout" name="gridLayout_4" >
+      <item row="0" column="0" >
+       <layout class="QHBoxLayout" name="horizontalLayout_3" >
+        <item>
+         <widget class="QLabel" name="label_2" >
+          <property name="text" >
+           <string>Fill color</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="KColorButton" name="rectBColor" />
+        </item>
+        <item>
+         <widget class="QSlider" name="rectBAlpha" >
+          <property name="maximum" >
+           <number>255</number>
+          </property>
+          <property name="value" >
+           <number>255</number>
+          </property>
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="Line" name="line_2" >
+          <property name="orientation" >
+           <enum>Qt::Vertical</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_11" >
+          <property name="text" >
+           <string>Border color</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="KColorButton" name="rectFColor" />
+        </item>
+        <item>
+         <widget class="QSlider" name="rectFAlpha" >
+          <property name="maximum" >
+           <number>255</number>
+          </property>
+          <property name="value" >
+           <number>0</number>
+          </property>
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QLabel" name="label_4" >
+          <property name="text" >
+           <string>Width</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QSpinBox" name="rectLineWidth" />
+        </item>
+        <item>
+         <spacer name="horizontalSpacer" >
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0" >
+           <size>
+            <width>241</width>
+            <height>28</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="3" column="5" >
-    <widget class="QDialogButtonBox" name="buttonBox" >
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
+   <item row="2" column="0" colspan="10" >
+    <widget class="QFrame" name="text_properties" >
+     <property name="frameShape" >
+      <enum>QFrame::StyledPanel</enum>
      </property>
-     <property name="standardButtons" >
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     <property name="frameShadow" >
+      <enum>QFrame::Sunken</enum>
      </property>
+     <layout class="QGridLayout" name="gridLayout_5" >
+      <item row="0" column="0" >
+       <layout class="QHBoxLayout" name="horizontalLayout_4" >
+        <item>
+         <widget class="QFontComboBox" name="font_family" />
+        </item>
+        <item>
+         <widget class="QLabel" name="label_20" >
+          <property name="text" >
+           <string>Width</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <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>
+         <widget class="KColorButton" name="fontColorButton" >
+          <property name="sizePolicy" >
+           <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <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>
+        <item>
+         <widget class="QToolButton" name="buttonBold" >
+          <property name="text" >
+           <string>...</string>
+          </property>
+          <property name="checkable" >
+           <bool>true</bool>
+          </property>
+          <property name="checked" >
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonItalic" >
+          <property name="text" >
+           <string>...</string>
+          </property>
+          <property name="checkable" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QToolButton" name="buttonUnder" >
+          <property name="text" >
+           <string>...</string>
+          </property>
+          <property name="checkable" >
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_2" >
+          <property name="orientation" >
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0" >
+           <size>
+            <width>52</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
     </widget>
    </item>
-   <item row="2" column="0" colspan="6" >
+   <item row="3" column="0" colspan="10" >
     <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>2</number>
+       <number>0</number>
       </property>
       <widget class="QWidget" name="BasicOperations" >
        <property name="geometry" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>395</width>
-         <height>279</height>
+         <width>465</width>
+         <height>241</height>
         </rect>
        </property>
        <attribute name="label" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>395</width>
-         <height>279</height>
+         <width>465</width>
+         <height>241</height>
         </rect>
        </property>
        <attribute name="label" >
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="Text" >
-       <property name="geometry" >
-        <rect>
-         <x>0</x>
-         <y>0</y>
-         <width>395</width>
-         <height>279</height>
-        </rect>
-       </property>
-       <attribute name="label" >
-        <string>Text</string>
-       </attribute>
-       <layout class="QGridLayout" name="gridLayout_2" >
-        <item row="0" column="0" >
-         <widget class="QFontComboBox" name="font_family" />
-        </item>
-        <item row="3" column="0" >
-         <widget class="KTextEdit" name="ktextedit" />
-        </item>
-        <item row="2" column="0" >
-         <layout class="QHBoxLayout" name="horizontalLayout_2" >
-          <item>
-           <widget class="QToolButton" name="buttonBold" >
-            <property name="text" >
-             <string>...</string>
-            </property>
-            <property name="checkable" >
-             <bool>true</bool>
-            </property>
-            <property name="checked" >
-             <bool>false</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QToolButton" name="buttonItalic" >
-            <property name="text" >
-             <string>...</string>
-            </property>
-            <property name="checkable" >
-             <bool>true</bool>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QToolButton" name="buttonUnder" >
-            <property name="text" >
-             <string>...</string>
-            </property>
-            <property name="checkable" >
-             <bool>true</bool>
-            </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>52</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </item>
-        <item row="1" column="0" >
-         <layout class="QHBoxLayout" name="horizontalLayout" >
-          <item>
-           <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>
-           <widget class="KColorButton" name="fontColorButton" />
-          </item>
-          <item>
-           <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="4" column="0" >
-         <spacer name="verticalSpacer" >
-          <property name="orientation" >
-           <enum>Qt::Vertical</enum>
-          </property>
-          <property name="sizeHint" stdset="0" >
-           <size>
-            <width>20</width>
-            <height>40</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </widget>
-      <widget class="QWidget" name="Rectangle" >
-       <property name="geometry" >
-        <rect>
-         <x>0</x>
-         <y>0</y>
-         <width>395</width>
-         <height>279</height>
-        </rect>
-       </property>
-       <attribute name="label" >
-        <string>Rectangle</string>
-       </attribute>
-       <layout class="QGridLayout" name="gridLayout_3" >
-        <item row="0" column="0" >
-         <layout class="QVBoxLayout" >
-          <item>
-           <widget class="QGroupBox" name="groupBox" >
-            <property name="title" >
-             <string>Border</string>
-            </property>
-            <layout class="QGridLayout" >
-             <item row="0" column="0" >
-              <layout class="QGridLayout" >
-               <item row="0" column="0" >
-                <widget class="QLabel" name="label_3" >
-                 <property name="text" >
-                  <string>Alpha</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="1" >
-                <widget class="QLabel" name="label_4" >
-                 <property name="text" >
-                  <string>Linewidth</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="0" >
-                <widget class="QSlider" name="rectFAlpha" >
-                 <property name="maximum" >
-                  <number>255</number>
-                 </property>
-                 <property name="orientation" >
-                  <enum>Qt::Horizontal</enum>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="1" >
-                <widget class="QSpinBox" name="rectLineWidth" />
-               </item>
-               <item row="2" column="0" >
-                <widget class="QLabel" name="label_11" >
-                 <property name="text" >
-                  <string>Color</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="2" column="1" >
-                <widget class="KColorButton" name="rectFColor" />
-               </item>
-              </layout>
-             </item>
-            </layout>
-           </widget>
-          </item>
-          <item>
-           <widget class="QGroupBox" name="groupBox_2" >
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="title" >
-             <string>Background</string>
-            </property>
-            <layout class="QGridLayout" >
-             <item row="0" column="0" >
-              <layout class="QGridLayout" >
-               <item row="0" column="0" >
-                <widget class="QLabel" name="label" >
-                 <property name="text" >
-                  <string>Alpha:</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="0" column="1" >
-                <widget class="QLabel" name="label_2" >
-                 <property name="text" >
-                  <string>Color</string>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="0" >
-                <widget class="QSlider" name="rectBAlpha" >
-                 <property name="maximum" >
-                  <number>255</number>
-                 </property>
-                 <property name="value" >
-                  <number>255</number>
-                 </property>
-                 <property name="orientation" >
-                  <enum>Qt::Horizontal</enum>
-                 </property>
-                </widget>
-               </item>
-               <item row="1" column="1" >
-                <widget class="KColorButton" name="rectBColor" />
-               </item>
-              </layout>
-             </item>
-            </layout>
-           </widget>
-          </item>
-          <item>
-           <spacer>
-            <property name="orientation" >
-             <enum>Qt::Vertical</enum>
-            </property>
-            <property name="sizeHint" stdset="0" >
-             <size>
-              <width>20</width>
-              <height>40</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </item>
-       </layout>
-      </widget>
       <widget class="QWidget" name="SVG" >
        <property name="geometry" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>395</width>
-         <height>279</height>
+         <width>465</width>
+         <height>241</height>
         </rect>
        </property>
        <attribute name="label" >
         <rect>
          <x>0</x>
          <y>0</y>
-         <width>395</width>
-         <height>279</height>
+         <width>465</width>
+         <height>241</height>
         </rect>
        </property>
        <attribute name="label" >
      </widget>
     </widget>
    </item>
-   <item row="3" column="4" >
+   <item row="4" column="0" >
+    <widget class="QToolButton" name="buttonFitZoom" >
+     <property name="text" >
+      <string>V</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1" >
+    <widget class="QToolButton" name="buttonRealSize" >
+     <property name="text" >
+      <string>V</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2" colspan="4" >
+    <widget class="QSlider" name="zoom_slider" >
+     <property name="minimumSize" >
+      <size>
+       <width>100</width>
+       <height>0</height>
+      </size>
+     </property>
+     <property name="maximumSize" >
+      <size>
+       <width>150</width>
+       <height>16777215</height>
+      </size>
+     </property>
+     <property name="minimum" >
+      <number>1</number>
+     </property>
+     <property name="maximum" >
+      <number>10</number>
+     </property>
+     <property name="pageStep" >
+      <number>2</number>
+     </property>
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="6" >
+    <widget class="QLabel" name="zoom_label" >
+     <property name="text" >
+      <string>x1</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="7" >
     <widget class="QCheckBox" name="displayBg" >
      <property name="text" >
       <string>Show background</string>
      </property>
     </widget>
    </item>
+   <item row="4" column="8" >
+    <spacer name="horizontalSpacer_3" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>235</width>
+       <height>28</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="4" column="9" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
    <extends>QSpinBox</extends>
    <header>knuminput.h</header>
   </customwidget>
-  <customwidget>
-   <class>KTextEdit</class>
-   <extends>QTextEdit</extends>
-   <header>ktextedit.h</header>
-  </customwidget>
   <customwidget>
    <class>KUrlRequester</class>
    <extends>QFrame</extends>
     </hint>
    </hints>
   </connection>
-  <connection>
-   <sender>fontColorButton</sender>
-   <signal>changed(QColor)</signal>
-   <receiver>ktextedit</receiver>
-   <slot>setColor(QColor)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>599</x>
-     <y>120</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>621</x>
-     <y>256</y>
-    </hint>
-   </hints>
-  </connection>
  </connections>
 </ui>