]> git.sesse.net Git - kdenlive/commitdiff
http://www.kdenlive.org/mantis/view.php?id=916 fixed.
authorSimon A. Eugster <simon.eu@gmail.com>
Fri, 26 Jun 2009 10:02:07 +0000 (10:02 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Fri, 26 Jun 2009 10:02:07 +0000 (10:02 +0000)
* At the moment the aspect ratio is being kept
* Fixed dimensions/coordinates not being updated after drawing a rect
* http://doc.trolltech.com/4.5/signalsandslots.html#advanced-signals-and-slots-usage :)

svn path=/trunk/kdenlive/; revision=3670

src/titlewidget.cpp
src/titlewidget.h

index c8580fe16788357857879b838659e8e794b4cb94..af2944c900923a026afe02b11df2a69bab3f3a99 100644 (file)
@@ -19,7 +19,6 @@
 #include "kdenlivesettings.h"
 
 #include <cmath>
-#include <iostream>
 
 #include <KDebug>
 #include <KGlobalSettings>
@@ -33,6 +32,7 @@
 #include <QTimer>
 #include <QToolBar>
 #include <QMenu>
+#include <QSignalMapper>
 #include <QTextBlockFormat>
 #include <QTextCursor>
 
@@ -60,10 +60,10 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     text_properties->setFixedHeight(frame_properties->height() + 4);
     m_frameWidth = render->renderWidth();
     m_frameHeight = render->renderHeight();
+
     connect(kcolorbutton, SIGNAL(clicked()), this, SLOT(slotChangeBackground())) ;
     connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeBackground())) ;
 
-
     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())) ;
@@ -91,11 +91,16 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     connect(origin_x_left, SIGNAL(clicked()), this, SLOT(slotOriginXClicked()));
     connect(origin_y_top, SIGNAL(clicked()), this, SLOT(slotOriginYClicked()));
 
+    m_signalMapper = new QSignalMapper(this);
+    m_signalMapper->setMapping(value_w, ValueWidth);
+    m_signalMapper->setMapping(value_h, ValueHeight);
+    connect(value_w, SIGNAL(valueChanged(int)), m_signalMapper, SLOT(map()));
+    connect(value_h, SIGNAL(valueChanged(int)), m_signalMapper, SLOT(map()));
+    connect(m_signalMapper, SIGNAL(mapped(int)), this, SLOT(slotValueChanged(int)));
+
     connect(value_x, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
     connect(value_y, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
-    connect(value_w, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(ValueWidth, int)));
     connect(value_w, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
-    connect(value_h, SIGNAL(valueChanged(int)), this, SLOT(slotValueChanged(ValueHeight, int)));
     connect(value_h, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustSelectedItem()));
     connect(buttonFitZoom, SIGNAL(clicked()), this, SLOT(slotAdjustZoom()));
     connect(buttonRealSize, SIGNAL(clicked()), this, SLOT(slotZoomOneToOne()));
@@ -153,26 +158,26 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
     layout->setContentsMargins(2, 2, 2, 2);
     QToolBar *m_toolbar = new QToolBar("titleToolBar", this);
 
-    m_buttonRect = m_toolbar->addAction(KIcon("kdenlive-insert-rect"), i18n("Add Rectangle (Alt+R)"));
-    m_buttonRect->setCheckable(true);
-    m_buttonRect->setShortcut(Qt::ALT + Qt::Key_R);
-    connect(m_buttonRect, SIGNAL(triggered()), this, SLOT(slotRectTool()));
+    m_buttonCursor = m_toolbar->addAction(KIcon("transform-move"), i18n("Selection Tool (Alt+S)"));
+    m_buttonCursor->setCheckable(true);
+    m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
+    connect(m_buttonCursor, SIGNAL(triggered()), this, SLOT(slotSelectTool()));
 
     m_buttonText = m_toolbar->addAction(KIcon("insert-text"), i18n("Add Text (Alt+T)"));
     m_buttonText->setCheckable(true);
     m_buttonText->setShortcut(Qt::ALT + Qt::Key_T);
     connect(m_buttonText, SIGNAL(triggered()), this, SLOT(slotTextTool()));
 
+    m_buttonRect = m_toolbar->addAction(KIcon("kdenlive-insert-rect"), i18n("Add Rectangle (Alt+R)"));
+    m_buttonRect->setCheckable(true);
+    m_buttonRect->setShortcut(Qt::ALT + Qt::Key_R);
+    connect(m_buttonRect, SIGNAL(triggered()), this, SLOT(slotRectTool()));
+
     m_buttonImage = m_toolbar->addAction(KIcon("insert-image"), i18n("Add Image (Alt+I)"));
     m_buttonImage->setCheckable(false);
     m_buttonImage->setShortcut(Qt::ALT + Qt::Key_I);
     connect(m_buttonImage, SIGNAL(triggered()), this, SLOT(slotImageTool()));
 
-    m_buttonCursor = m_toolbar->addAction(KIcon("transform-move"), i18n("Selection Tool (Alt+S)"));
-    m_buttonCursor->setCheckable(true);
-    m_buttonCursor->setShortcut(Qt::ALT + Qt::Key_S);
-    connect(m_buttonCursor, SIGNAL(triggered()), this, SLOT(slotSelectTool()));
-
     m_toolbar->addSeparator();
 
     m_buttonLoad = m_toolbar->addAction(KIcon("document-open"), i18n("Open Document"));
@@ -241,7 +246,7 @@ TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWi
         m_count = m_titledocument.loadDocument(url, m_startViewport, m_endViewport) + 1;
         slotSelectTool();
     } else {
-        slotRectTool();
+        slotTextTool();
     }
 
     showToolbars(TITLE_NONE);
@@ -262,6 +267,7 @@ TitleWidget::~TitleWidget()
     delete m_startViewport;
     delete m_endViewport;
     delete m_scene;
+    delete m_signalMapper;
 }
 
 //static
@@ -336,6 +342,12 @@ void TitleWidget::slotSelectTool()
     enableToolbars(t);
     showToolbars(t);
 
+    if (l.size() > 0) {
+        updateCoordinates(l.at(0));
+        updateDimension(l.at(0));
+        updateRotZoom(l.at(0));
+    }
+
     m_buttonCursor->setChecked(true);
     m_buttonText->setChecked(false);
     m_buttonRect->setChecked(false);
@@ -679,12 +691,21 @@ void TitleWidget::selectionChanged()
     }
 }
 
-void TitleWidget::slotValueChanged(ValueType type, int val)
+void TitleWidget::slotValueChanged(int type)
 {
-    std::cerr << "v";
     QList<QGraphicsItem *> l = graphicsView->scene()->selectedItems();
     if (l.size() > 0 && l.at(0)->type() == IMAGEITEM) {
-        std::cerr << "i";
+
+        int val = 0;
+        switch (type) {
+        case ValueWidth:
+            val = value_w->value();
+            break;
+        case ValueHeight:
+            val = value_h->value();
+            break;
+        }
+
         QGraphicsItem *i = l.at(0);
         Transform t = m_transformations.value(i);
 
@@ -703,7 +724,6 @@ void TitleWidget::slotValueChanged(ValueType type, int val)
             // Add 0.5 because otherwise incrementing by 1 might have no effect
             length = val / (cos(alpha) + 1 / phi * sin(alpha)) + 0.5;
             scale = length / i->boundingRect().width();
-            std::cerr << "w";
             break;
         case ValueHeight:
             length = val / (phi * sin(alpha) + cos(alpha)) + 0.5;
index 4b08a983fdbd2d48a8014fa0b8af33346732fd75..7cd3ae63c9677d3319f6ff8967764a8bde88b1d3 100644 (file)
@@ -26,6 +26,7 @@
 #include "unicodedialog.h"
 
 #include <QMap>
+#include <QSignalMapper>
 
 
 class Transform
@@ -100,7 +101,10 @@ private:
     /** project path for storing title clips */
     QString m_projectTitlePath;
 
-    enum ValueType { ValueWidth, ValueHeight };
+    /** See http://doc.trolltech.com/4.5/signalsandslots.html#advanced-signals-and-slots-usage */
+    QSignalMapper *m_signalMapper;
+
+    enum ValueType { ValueWidth = 0, ValueHeight = 1 };
 
     /** \brief Store the current choices of font, background and rect values */
     void writeChoices();
@@ -189,7 +193,8 @@ private slots:
     /** \brief Update coorinates of text fields if necessary and text has changed */
     void slotChanged();
 
-    void slotValueChanged(ValueType type, int val);
+    /** \param valueType Of type ValueType */
+    void slotValueChanged(int valueType);
 
     void slotZoom(bool up);
     void slotUpdateZoom(int pos);