]> git.sesse.net Git - kdenlive/blobdiff - src/simplekeyframes/simplekeyframewidget.cpp
Use KLocalizedString (for i18n only, in kf5 it will necessary => use a script for...
[kdenlive] / src / simplekeyframes / simplekeyframewidget.cpp
index 9221549ad5c4c81ffb3d8a6885d047a81759290d..85cbece7d1d0cad40aff0705d71bae903006b77d 100644 (file)
@@ -16,7 +16,7 @@
  *   along with Kdenlive.  If not, see <http://www.gnu.org/licenses/>.     *
  ***************************************************************************/
 
-#include "simplekeyframes/simplekeyframewidget.h"
+#include "simplekeyframewidget.h"
 #include "simpletimelinewidget.h"
 #include "timecodedisplay.h"
 
@@ -24,9 +24,9 @@
 #include <QGridLayout>
 
 #include <KIcon>
-#include <KLocale>
+#include <KLocalizedString>
 
-SimpleKeyframeWidget::SimpleKeyframeWidget(Timecode t, int duration, QWidget *parent) :
+SimpleKeyframeWidget::SimpleKeyframeWidget(const Timecode &t, int duration, QWidget *parent) :
         QWidget(parent)
 {
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
@@ -60,14 +60,19 @@ SimpleKeyframeWidget::SimpleKeyframeWidget(Timecode t, int duration, QWidget *pa
     l->addWidget(m_buttonNext, 1, 2);
     l->addWidget(m_time, 1, 3, Qt::AlignRight);
 
-    connect(m_time, SIGNAL(editingFinished()), this, SLOT(slotSetPosition()));
+    connect(m_time, SIGNAL(timeCodeEditingFinished()), this, SLOT(slotSetPosition()));
     connect(m_timeline, SIGNAL(positionChanged(int)), this, SLOT(slotSetPosition(int)));
+    connect(m_timeline, SIGNAL(atKeyframe(bool)), this, SLOT(slotAtKeyframe(bool)));
     connect(m_timeline, SIGNAL(keyframeAdded(int)), this, SIGNAL(keyframeAdded(int)));
     connect(m_timeline, SIGNAL(keyframeRemoved(int)), this, SIGNAL(keyframeRemoved(int)));
+    connect(m_timeline, SIGNAL(keyframeMoved(int,int)), this, SIGNAL(keyframeMoved(int,int)));
 
     connect(m_buttonAddDelete, SIGNAL(pressed()), m_timeline, SLOT(slotAddRemove()));
     connect(m_buttonPrevious, SIGNAL(pressed()), m_timeline, SLOT(slotGoToPrev()));
     connect(m_buttonNext, SIGNAL(pressed()), m_timeline, SLOT(slotGoToNext()));
+
+    // no keyframes yet
+    setEnabled(false);
 }
 
 SimpleKeyframeWidget::~SimpleKeyframeWidget()
@@ -76,7 +81,6 @@ SimpleKeyframeWidget::~SimpleKeyframeWidget()
     delete m_buttonAddDelete;
     delete m_buttonPrevious;
     delete m_buttonNext;
-    //delete m_buttonSync;
     delete m_time;
 }
 
@@ -94,7 +98,7 @@ void SimpleKeyframeWidget::slotSetPosition(int pos, bool update)
         emit positionChanged(pos);
 }
 
-int SimpleKeyframeWidget::getPosition()
+int SimpleKeyframeWidget::getPosition() const
 {
     return m_time->getValue();
 }
@@ -102,6 +106,7 @@ int SimpleKeyframeWidget::getPosition()
 void SimpleKeyframeWidget::setKeyframes(const QList< int >& keyframes)
 {
     m_timeline->setKeyframes(keyframes);
+    setEnabled(true);
 }
 
 void SimpleKeyframeWidget::addKeyframe(int pos)
@@ -109,7 +114,23 @@ void SimpleKeyframeWidget::addKeyframe(int pos)
     blockSignals(true);
     m_timeline->slotAddKeyframe(pos);
     blockSignals(false);
+    setEnabled(true);
+}
+
+void SimpleKeyframeWidget::updateTimecodeFormat()
+{
+    m_time->slotUpdateTimeCodeFormat();
 }
 
+void SimpleKeyframeWidget::slotAtKeyframe(bool atKeyframe)
+{
+    if (atKeyframe) {
+        m_buttonAddDelete->setIcon(KIcon("edit-delete"));
+        m_buttonAddDelete->setToolTip(i18n("Delete keyframe"));
+    } else {
+        m_buttonAddDelete->setIcon(KIcon("document-new"));
+        m_buttonAddDelete->setToolTip(i18n("Add keyframe"));
+    }
+}
 
 #include "simplekeyframewidget.moc"