Commit 0e8f6e7f authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Middle-click + move now pans title and monitor scene

Fix various issue with zoom
CCBUG: 358178
parent 2b7a70dd
......@@ -30,14 +30,6 @@ Item {
signal editCurrentMarker()
signal toolBarChanged(bool doAccept)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.MidButton
onClicked: {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
}
}
SceneToolBar {
id: sceneToolBar
anchors {
......
......@@ -29,14 +29,6 @@ Item {
signal editCurrentMarker()
signal toolBarChanged(bool doAccept)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.MidButton
onClicked: {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
}
}
SceneToolBar {
id: sceneToolBar
anchors {
......
......@@ -159,13 +159,6 @@ Item {
root.addKeyframe()
}
onClicked: {
if (mouse.button & Qt.MidButton) {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
}
}
onPositionChanged: {
if (root.iskeyframe == false) return;
if (pressed && root.requestedKeyFrame >= 0) {
......
......@@ -154,7 +154,7 @@ Item {
property bool isMoving : false
anchors.centerIn: root
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
readonly property bool containsMouse: {
......@@ -188,10 +188,7 @@ Item {
}
onPressed: {
if (mouse.button & Qt.MidButton) {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
} else {
if (mouse.button & Qt.LeftButton) {
if (root.requestedKeyFrame >= 0 && !isMoving) {
root.seekToKeyframe();
}
......
......@@ -182,10 +182,6 @@ Item {
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (mouse.button & Qt.MidButton) {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
}
if (!root.isDefined) {
if (mouse.button == Qt.RightButton) {
// close shape, define control points
......
......@@ -25,6 +25,7 @@ Item {
anchors.centerIn: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
acceptedButtons: Qt.LeftButton
onPressed: {
root.percentage = mouseX / width
root.splitterPos = mouseX
......
......@@ -26,6 +26,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsRectItem>
#include <QGraphicsSvgItem>
#include <QScrollBar>
#include <QGraphicsView>
#include <QCursor>
#include <QTextCursor>
......@@ -576,6 +577,7 @@ void GraphicsSceneRectMove::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e)
void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
m_pan = false;
if (m_tool == TITLE_RECTANGLE && m_selectedItem) setSelectedItem(m_selectedItem);
if (m_createdText) {
m_selectedItem->setSelected(true);
......@@ -599,6 +601,17 @@ void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
{
if (e->buttons() & Qt::MiddleButton) {
clearTextSelection();
QList<QGraphicsView*> viewlist = views();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::ScrollHandDrag);
m_pan = true;
e->accept();
QGraphicsScene::mousePressEvent(e);
return;
}
}
int xPos = ((int) e->scenePos().x() / m_gridSize) * m_gridSize;
int yPos = ((int) e->scenePos().y() / m_gridSize) * m_gridSize;
m_moveStarted = false;
......@@ -609,8 +622,7 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
if (m_tool == TITLE_SELECT) {
QList<QGraphicsView*> viewlist = views();
if (e->modifiers() & Qt::ControlModifier) {
m_selectedItem = NULL;
clearSelection();
clearTextSelection();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::ScrollHandDrag);
e->ignore();
......@@ -723,14 +735,21 @@ void GraphicsSceneRectMove::clearTextSelection()
void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
{
QList<QGraphicsView*> viewlist = views();
if (viewlist.isEmpty()) {
e->ignore();
return;
}
QGraphicsView *view = viewlist.first();
if (m_pan) {
QPoint diff = e->lastScreenPos() - e->screenPos();
view->horizontalScrollBar()->setValue(view->horizontalScrollBar()->value() + diff.x());
view->verticalScrollBar()->setValue(view->verticalScrollBar()->value() + diff.y());
e->accept();
QGraphicsScene::mouseMoveEvent(e);
return;
}
if (e->buttons() != Qt::NoButton && !m_moveStarted) {
QList<QGraphicsView*> viewlist = views();
if (viewlist.isEmpty()) {
// invalid
e->accept();
return;
}
QGraphicsView *view = viewlist.at(0);
if ((view->mapFromScene(e->scenePos()) - view->mapFromScene(m_clickPoint)).manhattanLength() < QApplication::startDragDistance()) {
e->ignore();
QGraphicsScene::mouseMoveEvent(e);
......@@ -798,10 +817,6 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
}
emit itemMoved();
} else if (m_tool == TITLE_SELECT) {
QList<QGraphicsView*> viewlist = views();
QGraphicsView *view = NULL;
if (viewlist.size() > 0) view = viewlist[0];
QPointF p = e->scenePos();
p += QPoint(-2, -2);
m_resizeMode = NoResize;
......
......@@ -572,7 +572,7 @@ void GLWidget::wheelEvent(QWheelEvent * event)
void GLWidget::mousePressEvent(QMouseEvent* event)
{
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier)) {
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier) && !(event->buttons() & Qt::MiddleButton)) {
event->ignore();
QQuickView::mousePressEvent(event);
return;
......@@ -582,43 +582,47 @@ void GLWidget::mousePressEvent(QMouseEvent* event)
// Pan view
m_panStart = event->pos();
setCursor(Qt::ClosedHandCursor);
event->accept();
} else {
m_dragStart = event->pos();
}
}
else if (event->button() & Qt::RightButton) {
emit showContextMenu(event->globalPos());
event->accept();
} else if (event->button() & Qt::MiddleButton) {
m_panStart = event->pos();
setCursor(Qt::ClosedHandCursor);
}
event->accept();
QQuickView::mousePressEvent(event);
}
void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier)) {
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier) && !(event->buttons() & Qt::MiddleButton)) {
event->ignore();
QQuickView::mouseMoveEvent(event);
return;
}
/* if (event->modifiers() == Qt::ShiftModifier && m_producer) {
/* if (event->modifiers() == Qt::ShiftModifier && m_producer) {
emit seekTo(m_producer->get_length() * event->x() / width());
return;
}*/
QQuickView::mouseMoveEvent(event);
if (!m_panStart.isNull()) {
emit panView(m_panStart - event->pos());
m_panStart = event->pos();
event->accept();
QQuickView::mouseMoveEvent(event);
return;
}
if (!(event->buttons() & Qt::LeftButton)) {
QQuickView::mouseMoveEvent(event);
return;
}
if (!m_dragStart.isNull() && (event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) {
if (!event->isAccepted() && !m_dragStart.isNull() && (event->pos() - m_dragStart).manhattanLength() >= QApplication::startDragDistance()) {
m_dragStart = QPoint();
emit startDrag();
}
if (!m_panStart.isNull()) {
emit panView(m_panStart - event->pos());
m_panStart = event->pos();
event->accept();
}
QQuickView::mouseMoveEvent(event);
}
void GLWidget::keyPressEvent(QKeyEvent* event)
......@@ -1136,7 +1140,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent * event)
event->ignore();
return;
}
if (!m_dragStart.isNull() && m_panStart.isNull() && event->button() & Qt::LeftButton) {
if (!m_dragStart.isNull() && m_panStart.isNull() && event->button() & Qt::LeftButton && !event->isAccepted()) {
emit monitorPlay();
}
m_dragStart = QPoint();
......
......@@ -500,6 +500,7 @@ void Monitor::setupMenu(QMenu *goMenu, QMenu *overlayMenu, QAction *playZone, QA
switchAudioMonitor->setChecked(KdenliveSettings::monitoraudio() & m_id);
m_configMenu->addAction(overlayAudio);
m_configMenu->addAction(m_zoomVisibilityAction);
m_contextMenu->addAction(m_zoomVisibilityAction);
// For some reason, the frame in QAbstracSpinBox (base class of TimeCodeDisplay) needs to be displayed once, then hidden
// or it will never appear (supposed to appear on hover).
m_timePos->setFrame(false);
......@@ -2088,9 +2089,11 @@ void Monitor::clearDisplay()
void Monitor::panView(QPoint diff)
{
if (m_glMonitor->zoom() > 0.0f) {
// Only pan if scrollbars are visible
// Only pan if scrollbars are visible
if (m_horizontalScroll->isVisible()) {
m_horizontalScroll->setValue(m_horizontalScroll->value() + diff.x());
}
if (m_verticalScroll->isVisible()) {
m_verticalScroll->setValue(m_verticalScroll->value() + diff.y());
}
}
......
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