change cursor on timeline ruler for better feedback

svn path=/branches/KDE4/; revision=2298
parent bb55c11c
......@@ -22,6 +22,7 @@
#include <KDebug>
#include <KIcon>
#include <KCursor>
#include <KGlobalSettings>
#include "customruler.h"
......@@ -93,6 +94,7 @@ CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent)
connect(delGuide, SIGNAL(triggered()), m_view, SLOT(slotDeleteGuide()));
QAction *editGuide = m_contextMenu->addAction(KIcon("document-new"), i18n("Edit Guide"));
connect(editGuide, SIGNAL(triggered()), m_view, SLOT(slotEditGuide()));
setMouseTracking(true);
}
// virtual
......@@ -115,19 +117,29 @@ void CustomRuler::mousePressEvent(QMouseEvent * event) {
// virtual
void CustomRuler::mouseMoveEvent(QMouseEvent * event) {
int pos = (int)((event->x() + offset()) / pixelPerMark() / FRAME_SIZE);
if (pos < 0) pos = 0;
if (m_moveCursor == RULER_CURSOR) {
m_view->setCursorPos(pos);
return;
} else if (m_moveCursor == RULER_START) m_zoneStart = pos;
else if (m_moveCursor == RULER_END) m_zoneEnd = pos;
else if (m_moveCursor == RULER_MIDDLE) {
int move = pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2);
m_zoneStart += move;
m_zoneEnd += move;
if (event->buttons() == Qt::LeftButton) {
int pos = (int)((event->x() + offset()) / pixelPerMark() / FRAME_SIZE);
if (pos < 0) pos = 0;
if (m_moveCursor == RULER_CURSOR) {
m_view->setCursorPos(pos);
return;
} else if (m_moveCursor == RULER_START) m_zoneStart = pos;
else if (m_moveCursor == RULER_END) m_zoneEnd = pos;
else if (m_moveCursor == RULER_MIDDLE) {
int move = pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2);
m_zoneStart += move;
m_zoneEnd += move;
}
update();
}
else {
int pos = (int)((event->x() + offset()));
if (event->y() <= 10) setCursor(Qt::ArrowCursor);
else if (qAbs(pos - m_zoneStart * pixelPerMark() * FRAME_SIZE) < 4) setCursor(KCursor("left_side", Qt::SizeHorCursor));
else if (qAbs(pos - m_zoneEnd * pixelPerMark() * FRAME_SIZE) < 4) setCursor(KCursor("right_side", Qt::SizeHorCursor));
else if (qAbs(pos - (m_zoneStart + (m_zoneEnd - m_zoneStart) / 2) * pixelPerMark() * FRAME_SIZE) < 4) setCursor(Qt::SizeHorCursor);
else setCursor(Qt::ArrowCursor);
}
update();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment