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

Fix title clip multiple selection

CTRL + click + mouse move scrolls the view in zoomed mode in title widget and monitor scene
BUG: 358178
parent c4f1aa9d
......@@ -174,7 +174,11 @@ Item {
}
onPositionChanged: {
if (pressed && root.requestedKeyFrame != -1) {
if (!pressed) {
mouse.accepted = false
return
}
if (root.requestedKeyFrame != -1) {
isMoving = true
root.centerPoints[root.requestedKeyFrame].x = (mouseX - frame.x) / root.scalex;
root.centerPoints[root.requestedKeyFrame].y = (mouseY - frame.y) / root.scaley;
......@@ -183,7 +187,7 @@ Item {
}
}
onClicked: {
onPressed: {
if (mouse.button & Qt.MidButton) {
root.showToolbar = !root.showToolbar
toolBarChanged(root.showToolbar)
......
......@@ -466,7 +466,8 @@ GraphicsSceneRectMove::GraphicsSceneRectMove(QObject *parent) :
m_possibleAction(NoResize),
m_tool(TITLE_RECTANGLE),
m_gridSize(20),
m_createdText(false)
m_createdText(false),
m_pan(false)
{
//grabMouse();
m_zoom = 1.0;
......@@ -576,7 +577,6 @@ void GraphicsSceneRectMove::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e)
void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
if (m_tool == TITLE_RECTANGLE && m_selectedItem) setSelectedItem(m_selectedItem);
QGraphicsScene::mouseReleaseEvent(e);
if (m_createdText) {
m_selectedItem->setSelected(true);
MyTextItem *newText = static_cast<MyTextItem*>(m_selectedItem);
......@@ -585,6 +585,15 @@ void GraphicsSceneRectMove::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
newText->setTextCursor(cur);
m_createdText = false;
}
if (e->modifiers() & Qt::ShiftModifier) {
e->accept();
} else {
QGraphicsScene::mouseReleaseEvent(e);
}
QList<QGraphicsView*> viewlist = views();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::RubberBandDrag);
}
emit actionFinished();
}
......@@ -597,11 +606,24 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
m_resizeMode = m_possibleAction;
const QList <QGraphicsItem *> list = items(e->scenePos());
QGraphicsItem *item = NULL;
if (e->modifiers() != Qt::ControlModifier) {
clearSelection();
}
if (m_tool == TITLE_SELECT) {
QList<QGraphicsView*> viewlist = views();
if (e->modifiers() & Qt::ControlModifier) {
m_selectedItem = NULL;
clearSelection();
if (!viewlist.isEmpty()) {
viewlist.first()->setDragMode(QGraphicsView::ScrollHandDrag);
e->ignore();
//QGraphicsScene::mousePressEvent(e);
return;
}
} else {
if (!viewlist.isEmpty()) {
viewlist.first()->setRubberBandSelectionMode(Qt::IntersectsItemShape);
}
}
QList<QGraphicsItem *> selected = selectedItems();
bool alreadySelected = false;
foreach(QGraphicsItem *g, list) {
//qDebug() << " - - CHECKING ITEM Z:" << g->zValue() << ", TYPE: " << g->type();
// check is there is a selected item in list
......@@ -609,31 +631,15 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
continue;
}
if (g->zValue() > -1000/* && g->isSelected()*/) {
alreadySelected = g->isSelected();
g->setSelected(true);
item = g;
break;
}
}
if (item == NULL || m_selectedItem != item) {
if (m_selectedItem && m_selectedItem->type() == QGraphicsTextItem::Type) {
// disable text editing
MyTextItem *t = static_cast<MyTextItem *>(m_selectedItem);
t->textCursor().setPosition(0);
QTextBlock cur = t->textCursor().block();
t->setTextCursor(QTextCursor(cur));
t->setTextInteractionFlags(Qt::NoTextInteraction);
}
}
if (item == NULL || !(item->flags() & QGraphicsItem::ItemIsSelectable)) {
m_selectedItem = NULL;
foreach(QGraphicsItem* g, list) {
if (g->zValue() > -1000) {
item = g;
break;
}
}
}
if (item != NULL && item->flags() & QGraphicsItem::ItemIsMovable) {
if (item == NULL || (e->modifiers() != Qt::ShiftModifier && !alreadySelected)) {
clearTextSelection();
} else if (item && item->flags() & QGraphicsItem::ItemIsMovable) {
m_sceneClickPoint = e->scenePos();
m_selectedItem = item;
//qDebug() << "///////// ITEM TYPE: " << item->type();
......@@ -699,7 +705,6 @@ void GraphicsSceneRectMove::mousePressEvent(QGraphicsSceneMouseEvent* e)
m_createdText = true;
}
//qDebug() << "////// MOUSE CLICK, RESIZE MODE: " << m_resizeMode;
}
void GraphicsSceneRectMove::clearTextSelection()
......@@ -732,7 +737,6 @@ void GraphicsSceneRectMove::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
return;
} else {
m_moveStarted = true;
e->accept();
}
}
if (m_selectedItem && (e->buttons() & Qt::LeftButton)) {
......
......@@ -147,6 +147,7 @@ private:
int m_gridSize;
bool m_createdText;
bool m_moveStarted;
bool m_pan;
signals:
void itemMoved();
......
......@@ -572,40 +572,53 @@ void GLWidget::wheelEvent(QWheelEvent * event)
void GLWidget::mousePressEvent(QMouseEvent* event)
{
QQuickView::mousePressEvent(event);
if (event->isAccepted()) return;
if (rootObject() && rootObject()->objectName() != QLatin1String("root")) {
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier)) {
event->ignore();
QQuickView::mousePressEvent(event);
return;
}
if (event->button() & Qt::LeftButton) {
m_dragStart = event->pos();
if (event->modifiers() & Qt::ControlModifier) {
// 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();
}
QQuickView::mousePressEvent(event);
}
void GLWidget::mouseMoveEvent(QMouseEvent* event)
{
QQuickView::mouseMoveEvent(event);
if (event->isAccepted()) return;
if (rootObject() && rootObject()->objectName() != QLatin1String("root")) {
if (rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier)) {
event->ignore();
QQuickView::mouseMoveEvent(event);
return;
}
if (event->isAccepted()) return;
/* if (event->modifiers() == Qt::ShiftModifier && m_producer) {
emit seekTo(m_producer->get_length() * event->x() / width());
return;
}*/
if (!(event->buttons() & Qt::LeftButton))
if (!(event->buttons() & Qt::LeftButton)) {
QQuickView::mouseMoveEvent(event);
return;
}
if (!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)
......@@ -1119,17 +1132,16 @@ void GLWidget::onFrameDisplayed(const SharedFrame &frame)
void GLWidget::mouseReleaseEvent(QMouseEvent * event)
{
QQuickView::mouseReleaseEvent(event);
if (m_dragStart.isNull() || event->isAccepted()) {
// we are dragging
return;
}
if (rootObject() && rootObject()->objectName() != QLatin1String("root")) {
if (m_dragStart.isNull() && m_panStart.isNull() && rootObject() && rootObject()->objectName() != QLatin1String("root") && !(event->modifiers() & Qt::ControlModifier)) {
event->ignore();
return;
}
m_dragStart = QPoint();
if (event->button() != Qt::RightButton) {
if (m_dragStart.isNull() && m_panStart.isNull() && event->button() & Qt::LeftButton) {
emit monitorPlay();
}
m_dragStart = QPoint();
m_panStart = QPoint();
setCursor(Qt::ArrowCursor);
}
void GLWidget::mouseDoubleClickEvent(QMouseEvent * event)
......
......@@ -131,6 +131,7 @@ signals:
void showContextMenu(const QPoint);
void lockMonitor(bool);
void passKeyEvent(QKeyEvent *);
void panView(QPoint diff);
private:
int m_id;
......@@ -138,6 +139,7 @@ private:
QRect m_effectRect;
GLuint m_texture[3];
QOpenGLShaderProgram* m_shader;
QPoint m_panStart;
QPoint m_dragStart;
Mlt::Filter* m_glslManager;
Mlt::Consumer* m_consumer;
......
......@@ -161,6 +161,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
// Create QML OpenGL widget
m_glMonitor = new GLWidget((int) id);
connect(m_glMonitor, SIGNAL(passKeyEvent(QKeyEvent*)), this, SLOT(doKeyPressEvent(QKeyEvent*)));
connect(m_glMonitor, &GLWidget::panView, this, &Monitor::panView);
m_videoWidget = QWidget::createWindowContainer(qobject_cast<QWindow*>(m_glMonitor));
m_videoWidget->setAcceptDrops(true);
QuickEventEater *leventEater = new QuickEventEater(this);
......@@ -2084,3 +2085,14 @@ void Monitor::clearDisplay()
{
m_glMonitor->clear();
}
void Monitor::panView(QPoint diff)
{
if (m_glMonitor->zoom() > 0.0f) {
// Only pan if scrollbars are visible
m_horizontalScroll->setValue(m_horizontalScroll->value() + diff.x());
m_verticalScroll->setValue(m_verticalScroll->value() + diff.y());
}
}
......@@ -275,6 +275,8 @@ private slots:
void setOffsetY(int y);
/** @brief Show/hide monitor zoom */
void slotEnableSceneZoom(bool enable);
/** @brief Pan monitor view */
void panView(QPoint diff);
public slots:
void slotOpenDvdFile(const QString &);
......
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