+void CustomRuler::mouseMoveEvent(QMouseEvent * event)
+{
+ int mappedXPos = (int)((event->x() + offset()) / m_factor);
+ emit mousePosition(mappedXPos);
+ if (event->buttons() == Qt::LeftButton) {
+ int pos;
+ if (m_moveCursor == RULER_START || m_moveCursor == RULER_END) {
+ pos = m_view->getSnapPointForPos(mappedXPos);
+ } else pos = mappedXPos;
+ int zoneStart = m_zoneStart;
+ int zoneEnd = m_zoneEnd;
+ if (pos < 0) pos = 0;
+ if (m_moveCursor == RULER_CURSOR) {
+ QPoint diff = event->pos() - m_clickPoint;
+ if (m_mouseMove == NO_MOVE) {
+ if (qAbs(diff.x()) >= QApplication::startDragDistance()) {
+ m_mouseMove = HORIZONTAL_MOVE;
+ } else if (KdenliveSettings::verticalzoom() && qAbs(diff.y()) >= QApplication::startDragDistance()) {
+ m_mouseMove = VERTICAL_MOVE;
+ } else return;
+ }
+ if (m_mouseMove == HORIZONTAL_MOVE) {
+ if (pos != m_lastSeekPosition && pos != m_view->cursorPos()) {
+ m_view->seekCursorPos(pos);
+ m_view->slotCheckPositionScrolling();
+ }
+ } else {
+ int verticalDiff = m_startRate - (diff.y()) / 7;
+ if (verticalDiff != m_rate) emit adjustZoom(verticalDiff);
+ }
+ return;
+ } else if (m_moveCursor == RULER_START) m_zoneStart = qMin(pos, m_zoneEnd - 1);
+ else if (m_moveCursor == RULER_END) m_zoneEnd = qMax(pos, m_zoneStart + 1);
+ else if (m_moveCursor == RULER_MIDDLE) {
+ int move = pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2);
+ if (move + m_zoneStart < 0) move = - m_zoneStart;
+ m_zoneStart += move;
+ m_zoneEnd += move;
+ }
+ int min = qMin(m_zoneStart, zoneStart);
+ int max = qMax(m_zoneEnd, zoneEnd);
+ update(min * m_factor - m_offset - 2, 0, (max - min) * m_factor + 4, height());
+
+ } else {
+ int pos = (int)((event->x() + m_offset));
+ if (m_cursorColor == palette().text() && qAbs(pos - m_view->cursorPos() * m_factor) < 7) {
+ // Mouse is over cursor
+ m_cursorColor = palette().link();
+ update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
+ }
+ else if (m_cursorColor == palette().link() && qAbs(pos - m_view->cursorPos() * m_factor) >= 7) {
+ m_cursorColor = palette().text();
+ update(m_view->cursorPos() * m_factor - m_offset - 10, LABEL_SIZE + 2, 20, MAX_HEIGHT - LABEL_SIZE - 2);
+ }
+
+ if (event->y() <= 10) setCursor(Qt::ArrowCursor);
+ else if (qAbs(pos - m_zoneStart * m_factor) < 4) {
+ setCursor(KCursor("left_side", Qt::SizeHorCursor));
+ if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone start: %1", m_zoneStart));
+ else setToolTip(i18n("Zone start: %1", m_timecode.getTimecodeFromFrames(m_zoneStart)));
+ } else if (qAbs(pos - m_zoneEnd * m_factor) < 4) {
+ setCursor(KCursor("right_side", Qt::SizeHorCursor));
+ if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone end: %1", m_zoneEnd));
+ else setToolTip(i18n("Zone end: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd)));
+ } else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2.0) * m_factor) < 4) {
+ setCursor(Qt::SizeHorCursor);
+ if (KdenliveSettings::frametimecode()) setToolTip(i18n("Zone duration: %1", m_zoneEnd - m_zoneStart));
+ else setToolTip(i18n("Zone duration: %1", m_timecode.getTimecodeFromFrames(m_zoneEnd - m_zoneStart)));
+ } else {
+ setCursor(Qt::ArrowCursor);
+ if (KdenliveSettings::frametimecode()) setToolTip(i18n("Position: %1", (int)(pos / m_factor)));
+ else setToolTip(i18n("Position: %1", m_timecode.getTimecodeFromFrames(pos / m_factor)));
+ }