+#include <QMenu>
+#include <QInputDialog>
+#include <QTimer>
+
+
+Geometryval::Geometryval(const MltVideoProfile &profile, const Timecode &t, const QPoint &frame_size, int startPoint, QWidget* parent) :
+ QWidget(parent),
+ m_profile(profile),
+ m_paramRect(NULL),
+ m_geom(NULL),
+ m_path(NULL),
+ m_fixedMode(false),
+ m_frameSize(frame_size),
+ m_startPoint(startPoint),
+ m_timePos(t)
+{
+ setupUi(this);
+ toolbarlayout->addWidget(&m_timePos);
+ toolbarlayout->insertStretch(-1);
+
+ QVBoxLayout* vbox = new QVBoxLayout(widget);
+ m_sceneview = new QGraphicsView(this);
+ m_sceneview->setBackgroundBrush(QBrush(Qt::black));
+ vbox->addWidget(m_sceneview);
+ vbox->setContentsMargins(0, 0, 0, 0);
+
+ QVBoxLayout* vbox2 = new QVBoxLayout(keyframeWidget);
+ m_helper = new KeyframeHelper(this);
+ vbox2->addWidget(m_helper);
+ vbox2->setContentsMargins(0, 0, 0, 0);
+
+ connect(m_helper, SIGNAL(positionChanged(int)), this, SLOT(slotPositionChanged(int)));
+ connect(m_helper, SIGNAL(keyframeMoved(int)), this, SLOT(slotKeyframeMoved(int)));
+ connect(m_helper, SIGNAL(addKeyframe(int)), this, SLOT(slotAddFrame(int)));
+ connect(m_helper, SIGNAL(removeKeyframe(int)), this, SLOT(slotDeleteFrame(int)));
+
+ m_scene = new GraphicsSceneRectMove(this);
+ m_scene->setTool(TITLE_SELECT);
+ m_sceneview->setScene(m_scene);
+ m_dar = (m_profile.height * m_profile.display_aspect_num / (double) m_profile.display_aspect_den) / (double) m_profile.width;
+
+ m_realWidth = (int)(profile.height * profile.display_aspect_num / (double) profile.display_aspect_den + 0.5);
+ QGraphicsRectItem *frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_realWidth, profile.height));
+ frameBorder->setZValue(-1100);
+ frameBorder->setBrush(QColor(255, 255, 0, 30));
+ frameBorder->setPen(QPen(QBrush(QColor(255, 255, 255, 255)), 1.0, Qt::DashLine));
+ m_scene->addItem(frameBorder);
+
+ buttonNext->setIcon(KIcon("media-skip-forward"));
+ buttonNext->setToolTip(i18n("Go to next keyframe"));
+ buttonPrevious->setIcon(KIcon("media-skip-backward"));
+ buttonPrevious->setToolTip(i18n("Go to previous keyframe"));
+ buttonAdd->setIcon(KIcon("document-new"));
+ buttonAdd->setToolTip(i18n("Add keyframe"));
+ buttonDelete->setIcon(KIcon("edit-delete"));
+ buttonDelete->setToolTip(i18n("Delete keyframe"));
+
+ m_configMenu = new QMenu(i18n("Misc..."), this);
+ buttonMenu->setMenu(m_configMenu);
+ buttonMenu->setPopupMode(QToolButton::MenuButtonPopup);
+
+ m_editOptions = m_configMenu->addAction(KIcon("system-run"), i18n("Show/Hide options"));
+ m_editOptions->setCheckable(true);
+ buttonMenu->setDefaultAction(m_editOptions);
+ connect(m_editOptions, SIGNAL(triggered()), this, SLOT(slotSwitchOptions()));
+ slotSwitchOptions();
+
+ m_reset = m_configMenu->addAction(KIcon("view-refresh"), i18n("Reset"), this, SLOT(slotResetPosition()));
+
+ m_syncAction = m_configMenu->addAction(i18n("Sync timeline cursor"), this, SLOT(slotSyncCursor()));
+ m_syncAction->setCheckable(true);
+ m_syncAction->setChecked(KdenliveSettings::transitionfollowcursor());
+
+ //scene->setSceneRect(0, 0, profile.width * 2, profile.height * 2);
+ //view->fitInView(m_frameBorder, Qt::KeepAspectRatio);
+ const double sc = 100.0 / profile.height * 0.8;
+ QRectF srect = m_sceneview->sceneRect();
+ m_sceneview->setSceneRect(srect.x(), -srect.height() / 3 + 10, srect.width(), srect.height() + srect.height() / 3 * 2 - 10);
+ m_scene->setZoom(sc);
+ m_sceneview->centerOn(frameBorder);
+ m_sceneview->setMouseTracking(true);
+ connect(buttonNext , SIGNAL(clicked()) , this , SLOT(slotNextFrame()));
+ connect(buttonPrevious , SIGNAL(clicked()) , this , SLOT(slotPreviousFrame()));
+ connect(buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame()));
+ connect(buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame()));
+ connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties()));
+
+ buttonhcenter->setIcon(KIcon("kdenlive-align-hor"));
+ buttonhcenter->setToolTip(i18n("Align item horizontally"));
+ buttonvcenter->setIcon(KIcon("kdenlive-align-vert"));
+ buttonvcenter->setToolTip(i18n("Align item vertically"));
+ buttontop->setIcon(KIcon("kdenlive-align-top"));
+ buttontop->setToolTip(i18n("Align item to top"));
+ buttonbottom->setIcon(KIcon("kdenlive-align-bottom"));
+ buttonbottom->setToolTip(i18n("Align item to bottom"));
+ buttonright->setIcon(KIcon("kdenlive-align-right"));
+ buttonright->setToolTip(i18n("Align item to right"));
+ buttonleft->setIcon(KIcon("kdenlive-align-left"));
+ buttonleft->setToolTip(i18n("Align item to left"));
+
+ connect(buttonhcenter, SIGNAL(clicked()), this, SLOT(slotAlignHCenter()));
+ connect(buttonvcenter, SIGNAL(clicked()), this, SLOT(slotAlignVCenter()));
+ connect(buttontop, SIGNAL(clicked()), this, SLOT(slotAlignTop()));
+ connect(buttonbottom, SIGNAL(clicked()), this, SLOT(slotAlignBottom()));
+ connect(buttonright, SIGNAL(clicked()), this, SLOT(slotAlignRight()));
+ connect(buttonleft, SIGNAL(clicked()), this, SLOT(slotAlignLeft()));
+ connect(spinX, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryX(int)));
+ connect(spinY, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryY(int)));
+ connect(spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryWidth(int)));
+ connect(spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotGeometryHeight(int)));
+ connect(spinResize, SIGNAL(editingFinished()), this, SLOT(slotResizeCustom()));
+ connect(buttonResize, SIGNAL(clicked()), this, SLOT(slotResizeOriginal()));
+
+ connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateGeometry()));
+}
+
+
+Geometryval::~Geometryval()
+{
+ m_scene->disconnect();
+ delete m_syncAction;
+ delete m_configMenu;
+ delete m_paramRect;
+ delete m_path;
+ delete m_helper;
+ delete m_geom;
+ delete m_sceneview;
+ delete m_scene;
+}
+
+
+void Geometryval::slotAlignHCenter()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos((m_realWidth - m_paramRect->rect().width()) / 2, m_paramRect->pos().y());
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotAlignVCenter()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos(m_paramRect->pos().x(), (m_profile.height - m_paramRect->rect().height()) / 2);
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotAlignTop()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos(m_paramRect->pos().x(), 0);
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotAlignBottom()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos(m_paramRect->pos().x(), m_profile.height - m_paramRect->rect().height());
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotAlignLeft()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos(0, m_paramRect->pos().y());
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotAlignRight()
+{
+ if (!keyframeSelected())
+ return;
+ m_paramRect->setPos(m_realWidth - m_paramRect->rect().width(), m_paramRect->pos().y());
+ slotUpdateTransitionProperties();
+}
+
+void Geometryval::slotResizeOriginal()
+{
+ if (!keyframeSelected())
+ return;
+ if (m_frameSize.isNull())
+ m_paramRect->setRect(0, 0, m_realWidth, m_profile.height);
+ else
+ m_paramRect->setRect(0, 0, m_frameSize.x(), m_frameSize.y());
+ slotUpdateTransitionProperties();
+}