]> git.sesse.net Git - kdenlive/blobdiff - src/geometrywidget.cpp
Do not hide render profile list when there is only one item:
[kdenlive] / src / geometrywidget.cpp
index 350d273a977de0ab90310baa7e10b5e4980c8c6e..66bc4e983191cb9ef08cf991f6fec3f9ecdc4192 100644 (file)
@@ -70,17 +70,24 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     m_timeline = new KeyframeHelper(m_ui.frameTimeline);
     layout->addWidget(m_timeline);
     layout->setContentsMargins(0, 0, 0, 0);
+    
+    int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
+    QSize iconSize(size, size);
 
     m_ui.buttonPrevious->setIcon(KIcon("media-skip-backward"));
     m_ui.buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
+    m_ui.buttonPrevious->setIconSize(iconSize);
     m_ui.buttonNext->setIcon(KIcon("media-skip-forward"));
     m_ui.buttonNext->setToolTip(i18n("Go to next keyframe"));
+    m_ui.buttonNext->setIconSize(iconSize);
     m_ui.buttonAddDelete->setIcon(KIcon("document-new"));
     m_ui.buttonAddDelete->setToolTip(i18n("Add keyframe"));
+    m_ui.buttonAddDelete->setIconSize(iconSize);
 
     m_ui.buttonSync->setIcon(KIcon("insert-link"));
     m_ui.buttonSync->setToolTip(i18n("Synchronize with timeline cursor"));
     m_ui.buttonSync->setChecked(KdenliveSettings::transitionfollowcursor());
+    m_ui.buttonSync->setIconSize(iconSize);
 
     connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
     connect(m_timeline, SIGNAL(keyframeMoved(int)),   this, SLOT(slotKeyframeMoved(int)));
@@ -92,20 +99,16 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
     connect(m_ui.buttonSync,      SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
 
-    m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -1, QString(), false, this);
-    m_spinX->setRange(-99000, 99000);
+    m_spinX = new DragValue(i18nc("x axis position", "X"), 0, 0, -99000, 99000, -1, QString(), false, this);
     m_ui.horizontalLayout->addWidget(m_spinX);
     
-    m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -1, QString(), false, this);
-    m_spinY->setRange(-99000, 99000);
+    m_spinY = new DragValue(i18nc("y axis position", "Y"), 0, 0, -99000, 99000, -1, QString(), false, this);
     m_ui.horizontalLayout->addWidget(m_spinY);
     
-    m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, -1, QString(), false, this);
-    m_spinWidth->setRange(1, 99000);
+    m_spinWidth = new DragValue(i18nc("Frame width", "W"), m_monitor->render->frameRenderWidth(), 0, 1, 99000, -1, QString(), false, this);
     m_ui.horizontalLayout->addWidget(m_spinWidth);
     
-    m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, -1, QString(), false, this);
-    m_spinHeight->setRange(1, 99000);
+    m_spinHeight = new DragValue(i18nc("Frame height", "H"), m_monitor->render->renderHeight(), 0, 1, 99000, -1, QString(), false, this);
     m_ui.horizontalLayout->addWidget(m_spinHeight);
 
     QMenu *menu = new QMenu(this);
@@ -175,44 +178,40 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     m_ui.horizontalLayout->addLayout(alignLayout);
     m_ui.horizontalLayout->addStretch(10);
     
-    m_spinSize = new DragValue(i18n("Size"), 100, 2, -1, i18n("%"), false, this);
-    m_spinSize->setRange(1, 99000);
+    m_spinSize = new DragValue(i18n("Size"), 100, 2, 1, 99000, -1, i18n("%"), false, this);
     m_ui.horizontalLayout2->addWidget(m_spinSize);
     
-    m_opacity = new DragValue(i18n("Opacity"), 100, 0, -1, i18n("%"), true, this);
+    m_opacity = new DragValue(i18n("Opacity"), 100, 0, 0, 100, -1, i18n("%"), true, this);
     m_ui.horizontalLayout2->addWidget(m_opacity);
 
 
     if (showRotation) {
-        m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1, QString(), true, this);
-        m_rotateX->setRange(-1800, 1800);
+        m_rotateX = new DragValue(i18n("Rotate X"), 0, 0, -1800, 1800, -1, QString(), true, this);
         m_rotateX->setObjectName("rotate_x");
         m_ui.horizontalLayout3->addWidget(m_rotateX);
-        m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1, QString(), true, this);
-        m_rotateY->setRange(-1800, 1800);
+        m_rotateY = new DragValue(i18n("Rotate Y"), 0, 0, -1800, 1800,  -1, QString(), true, this);
         m_rotateY->setObjectName("rotate_y");
         m_ui.horizontalLayout3->addWidget(m_rotateY);
-        m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1, QString(), true, this);
-        m_rotateZ->setRange(-1800, 1800);
+        m_rotateZ = new DragValue(i18n("Rotate Z"), 0, 0, -1800, 1800,  -1, QString(), true, this);
         m_rotateZ->setObjectName("rotate_z");
         m_ui.horizontalLayout3->addWidget(m_rotateZ);
-        connect(m_rotateX,            SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
-        connect(m_rotateY,            SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
-        connect(m_rotateZ,            SIGNAL(valueChanged(int)), this, SLOT(slotUpdateGeometry()));
+        connect(m_rotateX,            SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
+        connect(m_rotateY,            SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
+        connect(m_rotateZ,            SIGNAL(valueChanged(double)), this, SLOT(slotUpdateGeometry()));
     }
     
     /*
         Setup of geometry controls
     */
 
-    connect(m_spinX,            SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int)));
-    connect(m_spinY,            SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int)));
-    connect(m_spinWidth,        SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int)));
-    connect(m_spinHeight,       SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int)));
+    connect(m_spinX,            SIGNAL(valueChanged(double)), this, SLOT(slotSetX(double)));
+    connect(m_spinY,            SIGNAL(valueChanged(double)), this, SLOT(slotSetY(double)));
+    connect(m_spinWidth,        SIGNAL(valueChanged(double)), this, SLOT(slotSetWidth(double)));
+    connect(m_spinHeight,       SIGNAL(valueChanged(double)), this, SLOT(slotSetHeight(double)));
 
     connect(m_spinSize,         SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
 
-    connect(m_opacity, SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
+    connect(m_opacity, SIGNAL(valueChanged(double)), this, SLOT(slotSetOpacity(double)));
     
     /*connect(m_ui.buttonMoveLeft,   SIGNAL(clicked()), this, SLOT(slotMoveLeft()));
     connect(m_ui.buttonCenterH,    SIGNAL(clicked()), this, SLOT(slotCenterH()));
@@ -279,12 +278,13 @@ QString GeometryWidget::getExtraValue(const QString &name) const
 {
     int ix = m_extraGeometryNames.indexOf(name);
     QString val = m_extraGeometries.at(ix)->serialise();
-    if (!val.contains("=")) val = val.section(',', 0, 0);
+    if (!val.contains("=")) val = val.section('/', 0, 0);
     else {
-        QStringList list = val.split(';');
+        QStringList list = val.split(';', QString::SkipEmptyParts);
         val.clear();
+        val.append(list.takeFirst().section('/', 0, 0));
         foreach (const QString value, list) {
-            val.append(value.section(',', 0, 0) + ';');
+            val.append(';' + value.section('/', 0, 0));
         }
     }
     return val;
@@ -305,9 +305,9 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra
         m_ui.widgetTimeWrapper->setHidden(true);
     } else {
         m_ui.widgetTimeWrapper->setHidden(false);
-        m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint - 1);
+        m_timeline->setKeyGeometry(m_geometry, m_outPoint - m_inPoint);
         m_timeline->update();
-        m_timePos->setRange(0, m_outPoint - m_inPoint - 1);
+        m_timePos->setRange(0, m_outPoint - m_inPoint);
     }
 
     // no opacity
@@ -573,7 +573,6 @@ void GeometryWidget::slotUpdateGeometry()
             geom->insert(item2);
         }
     }
-    
     emit parameterChanged();
 }
 
@@ -607,25 +606,25 @@ void GeometryWidget::slotUpdateProperties()
 }
 
 
-void GeometryWidget::slotSetX(int value)
+void GeometryWidget::slotSetX(double value)
 {
     m_rect->setPos(value, m_spinY->value());
     slotUpdateGeometry();
 }
 
-void GeometryWidget::slotSetY(int value)
+void GeometryWidget::slotSetY(double value)
 {
     m_rect->setPos(m_spinX->value(), value);
     slotUpdateGeometry();
 }
 
-void GeometryWidget::slotSetWidth(int value)
+void GeometryWidget::slotSetWidth(double value)
 {
     m_rect->setRect(0, 0, value, m_spinHeight->value());
     slotUpdateGeometry();
 }
 
-void GeometryWidget::slotSetHeight(int value)
+void GeometryWidget::slotSetHeight(double value)
 {
     m_rect->setRect(0, 0, m_spinWidth->value(), value);
     slotUpdateGeometry();
@@ -647,7 +646,7 @@ void GeometryWidget::slotResize(double value)
 }
 
 
-void GeometryWidget::slotSetOpacity(int value)
+void GeometryWidget::slotSetOpacity(double value)
 {
     int pos = m_timePos->getValue();
     Mlt::GeometryItem item;
@@ -719,7 +718,9 @@ void GeometryWidget::setFrameSize(QPoint size)
 
 void GeometryWidget::slotAdjustToFrameSize()
 {
-    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
+        m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    }
     m_spinWidth->blockSignals(true);
     m_spinHeight->blockSignals(true);
     m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() + 0.5));
@@ -731,7 +732,9 @@ void GeometryWidget::slotAdjustToFrameSize()
 
 void GeometryWidget::slotFitToWidth()
 {
-    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
+        m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    }
     double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
     m_spinWidth->blockSignals(true);
     m_spinHeight->blockSignals(true);
@@ -744,7 +747,9 @@ void GeometryWidget::slotFitToWidth()
 
 void GeometryWidget::slotFitToHeight()
 {
-    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
+        m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    }
     double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
     m_spinWidth->blockSignals(true);
     m_spinHeight->blockSignals(true);