Merge master with conflicts resolved

This commit is contained in:
manongjohn 2021-03-14 23:49:21 -04:00
commit a084e3ed39
18 changed files with 325 additions and 114 deletions

View file

@ -397,7 +397,7 @@ T_Finger=
T_FlipX=
T_FlipY=
T_Geometric=G
T_Hand=
T_Hand=Space
T_Hook=O
T_Iron=
T_Magnet=
@ -407,7 +407,7 @@ T_Plastic=X
T_PositionReset=
T_Pump=
T_RGBPicker=R
T_Rotate=
T_Rotate=Ctrl+Space
T_RotateReset=
T_Ruler=
T_Selection=S
@ -418,7 +418,7 @@ T_Tape=T
T_Tracker=
T_Type=Y
T_ViewReset=Alt+0
T_Zoom=
T_Zoom=Shift+Space
T_ZoomFit=Alt+9
T_Zoomin=+
T_Zoomout=-

View file

@ -76,7 +76,7 @@ private:
QPoint m_startPos, m_oldPos; // mouse click position, last mouse click/drag
// position (window coords)
bool m_isFloating = true;
bool m_spacePressed = false;
bool m_panningArmed = false;
struct Gadget {
Handle m_handle;
int m_kIndex;
@ -213,6 +213,7 @@ protected:
void drawCurrentCurve(QPainter &);
void drawGroupKeyframes(QPainter &);
bool event(QEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
@ -222,7 +223,6 @@ protected:
void openContextMenu(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e) override;
void keyReleaseEvent(QKeyEvent *e) override;
void enterEvent(QEvent *) override;
void leaveEvent(QEvent *) override;

View file

@ -470,11 +470,11 @@ public:
void ensureVisibleCol(int col);
protected:
bool event(QEvent *e) override;
void showEvent(QShowEvent *) override;
void hideEvent(QHideEvent *) override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
void wheelEvent(QWheelEvent *event) override;
void timerEvent(QTimerEvent *) override;
void enterEvent(QEvent *) override;

View file

@ -2629,12 +2629,12 @@ void MainWindow::defineActions() {
createToolAction(T_Tracker, "radar", QT_TR_NOOP("Tracker Tool"), "",
tr("Tracker Tool: Tracks specific regions in a sequence of images"));
createToolAction(T_Hook, "hook", QT_TR_NOOP("Hook Tool"), "O");
createToolAction(T_Zoom, "zoom", QT_TR_NOOP("Zoom Tool"), "",
createToolAction(T_Zoom, "zoom", QT_TR_NOOP("Zoom Tool"), "Shift+Space",
tr("Zoom Tool: Zooms viewer"));
createToolAction(T_Rotate, "rotate", QT_TR_NOOP("Rotate Tool"), "",
createToolAction(T_Rotate, "rotate", QT_TR_NOOP("Rotate Tool"), "Ctrl+Space",
tr("Rotate Tool: Rotate the viewer"));
createToolAction(T_Hand, "hand", QT_TR_NOOP("Hand Tool"), "",
tr("Hand Tool: Pans the workspace (Space)"));
createToolAction(T_Hand, "hand", QT_TR_NOOP("Hand Tool"), "Space",
tr("Hand Tool: Pans the workspace"));
createToolAction(T_Plastic, "plastic", QT_TR_NOOP("Plastic Tool"), "X",
tr("Plastic Tool: Builds a mesh that allows to deform and "
"animate a level"));

View file

@ -796,7 +796,11 @@ SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
, m_editPreviewSubCamera(false)
, m_locator(NULL)
, m_isLocator(false)
, m_isBusyOnTabletMove(false) {
, m_isBusyOnTabletMove(false)
, m_mousePanning(0)
, m_mouseZooming(0)
, m_mouseRotating(0)
, m_keyAction(0) {
m_visualSettings.m_sceneProperties =
TApp::instance()->getCurrentScene()->getScene()->getProperties();
m_stopMotion = StopMotion::instance();

View file

@ -215,6 +215,8 @@ class SceneViewer final : public GLWidgetForHighDpi,
bool m_firstInitialized = true;
QAction *m_keyAction;
public:
enum ReferenceMode {
NORMAL_REFERENCE = 1,
@ -484,7 +486,7 @@ public slots:
void onContextAboutToBeDestroyed();
void onNewStopMotionImageReady();
void onStopMotionLiveViewStopped();
void onPreferenceChanged(const QString& prefName);
void onPreferenceChanged(const QString &prefName);
signals:

View file

@ -887,9 +887,14 @@ void SceneViewer::onRelease(const TMouseEvent &event) {
m_dragging = false;
if (m_mousePanning > 0 || m_mouseRotating > 0 || m_mouseZooming > 0) {
if (m_resetOnRelease) {
m_mousePanning = 0;
m_mouseRotating = 0;
m_mouseZooming = 0;
m_mousePanning = 0;
m_mouseRotating = 0;
m_mouseZooming = 0;
if (m_keyAction) {
m_keyAction->setEnabled(true);
m_keyAction = 0;
invalidateToolStatus();
}
m_resetOnRelease = false;
} else if (m_mousePanning > 0)
m_mousePanning = 1;
@ -1295,8 +1300,28 @@ bool SceneViewer::event(QEvent *e) {
break;
case QEvent::MouseButtonDblClick:
qDebug() << "[enter] ============================== MouseButtonDblClick";
qDebug() << "[enter] ************************** MouseButtonDblClick";
break;
case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
QString keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString();
qDebug() << "[enter] ************************** KeyPress key=" <<
keyStr;
}
break;
case QEvent::KeyRelease: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
QString keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString();
qDebug() << "[enter] ************************** KeyRelease key=" <<
keyStr;
}
break;
default:
qDebug() << "[enter] ************************** Event: "<< e;
}
*/
@ -1375,53 +1400,49 @@ bool SceneViewer::event(QEvent *e) {
if (tool && tool->isActive()) toolActive = true;
if (tool && tool->isDragging()) toolDragging = true;
if (!isTyping && !m_dragging && (e->type() == QEvent::ShortcutOverride ||
e->type() == QEvent::KeyPress)) {
if (!isTyping && (e->type() == QEvent::ShortcutOverride ||
e->type() == QEvent::KeyPress)) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (keyEvent->key() == Qt::Key_Space) {
if (keyEvent->modifiers() & Qt::ControlModifier) {
if (m_mouseRotating == 0) {
m_mouseRotating = 1;
setToolCursor(this, ToolCursor::RotateCursor);
}
} else if (keyEvent->modifiers() & Qt::ShiftModifier) {
if (m_mouseZooming == 0) {
m_mouseZooming = 1;
setToolCursor(this, ToolCursor::ZoomCursor);
}
} else if (m_mousePanning == 0) {
if (!keyEvent->isAutoRepeat()) {
TApp::instance()->getCurrentTool()->storeTool();
}
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId == T_Hand) {
if (m_mousePanning == 0) {
m_mousePanning = 1;
m_keyAction = action;
m_keyAction->setEnabled(false);
setToolCursor(this, ToolCursor::PanCursor);
}
e->accept();
return true;
} else if (actionId == T_Zoom) {
if (m_mouseZooming == 0) {
m_mouseZooming = 1;
m_keyAction = action;
m_keyAction->setEnabled(false);
setToolCursor(this, ToolCursor::ZoomCursor);
}
e->accept();
return true;
} else if (actionId == T_Rotate) {
if (m_mouseRotating == 0) {
m_mouseRotating = 1;
m_keyAction = action;
m_keyAction->setEnabled(false);
setToolCursor(this, ToolCursor::RotateCursor);
}
e->accept();
return true;
}
}
if (!isTyping && e->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (keyEvent->key() == Qt::Key_Space) {
if (keyEvent->isAutoRepeat()) {
e->accept();
return true;
} else {
if (m_dragging)
m_resetOnRelease = true;
else {
m_mousePanning = 0;
m_mouseZooming = 0;
m_mouseRotating = 0;
if (tool) setToolCursor(this, tool->getCursorId());
}
e->accept();
return true;
}
}
}
if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::KeyPress) {
if (!((QKeyEvent *)e)->isAutoRepeat()) {
TApp::instance()->getCurrentTool()->storeTool();
}
}
if (e->type() == QEvent::ShortcutOverride) {
if (tool && tool->isEnabled() && tool->getName() == T_Type &&
tool->isActive())
@ -1439,7 +1460,8 @@ bool SceneViewer::event(QEvent *e) {
TTool::getTool("T_ShiftTrace", TTool::ToonzImage)
->isEventAcceptable(e)) {
e->accept();
}
} else if (m_keyAction)
e->accept();
// Disable keyboard shortcuts while the tool is busy with a mouse drag
// operation.
@ -1449,14 +1471,32 @@ bool SceneViewer::event(QEvent *e) {
return true;
}
if (e->type() == QEvent::KeyRelease) {
if (!((QKeyEvent *)e)->isAutoRepeat() &&
((QKeyEvent *)e)->key() != Qt::Key_Space) {
if (!isTyping && e->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (!keyEvent->isAutoRepeat() && !m_keyAction) {
QWidget *focusWidget = QApplication::focusWidget();
if (focusWidget == 0 ||
QString(focusWidget->metaObject()->className()) == "SceneViewer")
TApp::instance()->getCurrentTool()->restoreTool();
}
if (m_keyAction) {
if (keyEvent->isAutoRepeat()) {
e->accept();
return true;
} else {
m_mousePanning = 0;
m_mouseZooming = 0;
m_mouseRotating = 0;
m_keyAction->setEnabled(true);
m_keyAction = 0;
invalidateToolStatus();
e->accept();
return true;
}
}
}
// discard too frequent move events
@ -1991,5 +2031,10 @@ void SceneViewer::resetNavigation() {
m_mousePanning = 0;
m_mouseZooming = 0;
m_mouseRotating = 0;
if (m_keyAction) {
m_keyAction->setEnabled(true);
m_keyAction = 0;
invalidateToolStatus();
}
}
}

View file

@ -142,11 +142,11 @@ void ShortcutViewer::keyPressEvent(QKeyEvent *event) {
modifiers = 0;
}
// Block the arrows and space
// Block the arrows
int ctl = modifiers | Qt::CTRL;
if (key == Qt::Key_Space || ((modifiers == Qt::NoModifier) &&
(key == Qt::Key_Left || key == Qt::Key_Right ||
key == Qt::Key_Up || key == Qt::Key_Down))) {
if ((modifiers == Qt::NoModifier) &&
(key == Qt::Key_Left || key == Qt::Key_Right || key == Qt::Key_Up ||
key == Qt::Key_Down)) {
event->ignore();
return;
}

View file

@ -794,7 +794,12 @@ bool TApp::eventFilter(QObject *watched, QEvent *e) {
}
if (e->type() == QEvent::KeyRelease) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (keyEvent->key() == Qt::Key_Space) {
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId == T_Hand || actionId == T_Zoom || actionId == T_Rotate) {
if (!keyEvent->isAutoRepeat()) {
SceneViewer *viewer = getActiveViewer();
if (viewer) {

View file

@ -19,7 +19,9 @@
#include "orientation.h"
// TnzTools includes
#include "tools/toolcommandids.h"
#include "tools/cursormanager.h"
#include "tools/cursors.h"
#include "tools/toolhandle.h"
// TnzQt includes
@ -2917,7 +2919,10 @@ void CellArea::mouseMoveEvent(QMouseEvent *event) {
int frameAdj = m_viewer->getFrameZoomAdjustment();
m_viewer->setQtModifiers(event->modifiers());
setCursor(Qt::ArrowCursor);
if (m_viewer->m_panningArmed)
setToolCursor(this, ToolCursor::PanCursor);
else
setCursor(Qt::ArrowCursor);
QPoint pos = event->pos();
QRect visibleRect = visibleRegion().boundingRect();
if (m_isPanning) {
@ -3760,4 +3765,13 @@ void CellArea::onStepChanged(QAction *act) {
//-----------------------------------------------------------------------------
void CellArea::updateCursor() {
if (m_viewer->m_panningArmed)
setToolCursor(this, ToolCursor::PanCursor);
else
setCursor(Qt::ArrowCursor);
}
//-----------------------------------------------------------------------------
} // namespace XsheetGUI

View file

@ -145,6 +145,8 @@ public:
return m_renameCell && m_renameCell->isRenamingCell();
}
void updateCursor();
protected:
void paintEvent(QPaintEvent *) override;

View file

@ -37,6 +37,10 @@
#include "tenv.h"
#include "tools/toolcommandids.h"
#include "tools/cursormanager.h"
#include "tools/cursors.h"
#include <QPainter>
#include <QScrollBar>
#include <QMouseEvent>
@ -1285,9 +1289,6 @@ void XsheetViewer::keyPressEvent(QKeyEvent *event) {
locals.scrollHorizTo(x, visibleRect);
}
break;
case Qt::Key_Space:
m_panningArmed = true;
break;
}
break;
}
@ -1302,8 +1303,6 @@ void XsheetViewer::keyReleaseEvent(QKeyEvent *event) {
m_columnArea->onControlPressed(false);
m_layerFooterPanel->onControlPressed(false);
}
if (event->key() == Qt::Key_Space && !event->isAutoRepeat())
m_panningArmed = false;
}
//-----------------------------------------------------------------------------
@ -1835,6 +1834,39 @@ QColor XsheetViewer::getSelectedColumnTextColor() const {
return currentColumnColor;
}
//-----------------------------------------------------------------------------
bool XsheetViewer::event(QEvent *e) {
if (e->type() != QEvent::KeyPress && e->type() != QEvent::ShortcutOverride &&
e->type() != QEvent::KeyRelease)
return QFrame::event(e);
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId != T_Hand) return QFrame::event(e);
if (e->type() == QEvent::KeyPress || e->type() == QEvent::ShortcutOverride) {
m_panningArmed = true;
action->setEnabled(false);
m_cellArea->updateCursor();
e->accept();
return true;
} else if (e->type() == QEvent::KeyRelease) {
if (!keyEvent->isAutoRepeat()) m_panningArmed = false;
action->setEnabled(true);
m_cellArea->updateCursor();
e->accept();
return true;
}
return QFrame::event(e);
}
//=============================================================================
// XSheetViewerCommand
//-----------------------------------------------------------------------------

View file

@ -1291,6 +1291,7 @@ protected:
void leaveEvent(QEvent *) override;
void wheelEvent(QWheelEvent *event) override;
void timerEvent(QTimerEvent *) override;
bool event(QEvent *) override;
void disconnectScrollBars();
void connectScrollBars();

View file

@ -22,6 +22,10 @@
// TnzCore includes
#include "tcommon.h"
#include "tools/toolcommandids.h"
#include "tools/cursormanager.h"
#include "tools/cursors.h"
// Qt includes
#include <QPainter>
#include <QPainterPath>
@ -1187,7 +1191,7 @@ void FunctionPanel::mousePressEvent(QMouseEvent *e) {
m_dragTool = 0;
if (e->button() == Qt::MidButton ||
(e->button() == Qt::LeftButton && m_spacePressed)) {
(e->button() == Qt::LeftButton && m_panningArmed)) {
// mid mouse click => panning
bool xLocked = e->pos().x() <= m_valueAxisX;
bool yLocked = e->pos().y() <= m_valueAxisX;
@ -1425,26 +1429,14 @@ void FunctionPanel::mouseDoubleClickEvent(QMouseEvent *) { fitGraphToWindow(); }
//-----------------------------------------------------------------------------
void FunctionPanel::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key::Key_Space) {
m_spacePressed = true;
e->accept();
return;
}
FunctionPanelZoomer(this).exec(e);
}
//-----------------------------------------------------------------------------
void FunctionPanel::keyReleaseEvent(QKeyEvent *e) {
if (e->key() == Qt::Key::Key_Space && !e->isAutoRepeat())
m_spacePressed = false;
// accept intentionally not called here.
}
//-----------------------------------------------------------------------------
void FunctionPanel::enterEvent(QEvent *) {
m_cursor.visible = true;
m_panningArmed = false;
update();
}
@ -1452,7 +1444,8 @@ void FunctionPanel::enterEvent(QEvent *) {
void FunctionPanel::leaveEvent(QEvent *) {
m_cursor.visible = false;
m_spacePressed = false;
m_panningArmed = false;
setCursor(Qt::ArrowCursor);
update();
}
@ -1800,3 +1793,36 @@ QColor FunctionPanel::getChannelColor(QString name, bool active) {
if (!active) color.setAlpha(180);
return color;
}
//-----------------------------------------------------------------------------
bool FunctionPanel::event(QEvent *e) {
if (e->type() != QEvent::KeyPress && e->type() != QEvent::ShortcutOverride &&
e->type() != QEvent::KeyRelease)
return QDialog::event(e);
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId != T_Hand) return QDialog::event(e);
if (e->type() == QEvent::KeyPress || e->type() == QEvent::ShortcutOverride) {
m_panningArmed = true;
action->setEnabled(false);
setToolCursor(this, ToolCursor::PanCursor);
e->accept();
return true;
} else if (e->type() == QEvent::KeyRelease) {
if (!keyEvent->isAutoRepeat()) m_panningArmed = false;
action->setEnabled(true);
setCursor(Qt::ArrowCursor);
e->accept();
return true;
}
return QDialog::event(e);
}

View file

@ -507,10 +507,12 @@ void FunctionViewer::toggleMode() {
if (m_functionGraph->isVisible()) {
m_functionGraph->hide();
m_numericalColumns->show();
m_numericalColumns->setFocus();
m_leftLayout->setSpacing(m_spacing);
m_toggleStatus = 0;
} else {
m_functionGraph->show();
m_functionGraph->setFocus();
m_numericalColumns->hide();
m_leftLayout->setSpacing(0);
m_toggleStatus = 1;
@ -697,7 +699,21 @@ void FunctionViewer::addParameter(TParam *parameter, const TFilePath &folder) {
//-----------------------------------------------------------------------------
void FunctionViewer::setFocusColumnsOrGraph() {
m_numericalColumns->setFocus();
if (m_toggleStart ==
Preferences::FunctionEditorToggle::ToggleBetweenGraphAndSpreadsheet) {
if (m_toggleStatus ==
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
m_functionGraph->setFocus();
else if (m_toggleStatus ==
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
m_numericalColumns->setFocus();
} else if (m_toggleStart ==
Preferences::FunctionEditorToggle::ShowGraphEditorInPopup)
m_numericalColumns->setFocus();
else if (m_toggleStart ==
Preferences::FunctionEditorToggle::ShowFunctionSpreadsheetInPopup)
m_functionGraph->setFocus();
}
//-----------------------------------------------------------------------------

View file

@ -149,8 +149,8 @@ void CommandManager::define(CommandId id, CommandType type,
bool CommandManager::canUseShortcut(QString shortcut) {
shortcut = shortcut.toLower();
if (shortcut == "space" || shortcut == "left" || shortcut == "up" ||
shortcut == "right" || shortcut == "down") {
if (shortcut == "left" || shortcut == "up" || shortcut == "right" ||
shortcut == "down") {
return false;
}
return true;

View file

@ -35,6 +35,7 @@
#include "tools/cursormanager.h"
#include "tools/cursors.h"
#include "tools/toolcommandids.h"
// Qt includes
#include <QGraphicsSceneMouseEvent>
@ -242,16 +243,16 @@ void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) {
m_oldScenePos = mapToScene(m_oldWinPos);
if (m_buttonState == Qt::LeftButton) {
if (m_cursorMode == CursorMode::Zoom) {
if (m_cursorMode == CursorMode::Hand || m_panningArmed) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
m_panning = true;
return;
} else if (m_cursorMode == CursorMode::Zoom) {
m_zoomPoint = me->pos();
m_zooming = true;
return;
} else if (m_cursorMode == CursorMode::Hand || m_panningArmed) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
: me->pos() * getDevPixRatio();
m_panning = true;
return;
}
} else if (m_buttonState == Qt::MidButton) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
@ -350,9 +351,6 @@ void SchematicSceneViewer::mouseDoubleClickEvent(QMouseEvent *event) {
//------------------------------------------------------------------
void SchematicSceneViewer::keyPressEvent(QKeyEvent *ke) {
if (ke->key() == Qt::Key_Space) {
m_panningArmed = true;
}
ke->ignore();
QGraphicsView::keyPressEvent(ke);
if (!ke->isAccepted()) SchematicZoomer(this).exec(ke);
@ -361,10 +359,6 @@ void SchematicSceneViewer::keyPressEvent(QKeyEvent *ke) {
//------------------------------------------------------------------
void SchematicSceneViewer::keyReleaseEvent(QKeyEvent *ke) {
if (ke->key() == Qt::Key_Space && !ke->isAutoRepeat()) {
m_panningArmed = false;
}
QGraphicsView::keyReleaseEvent(ke);
}
@ -719,6 +713,45 @@ bool SchematicSceneViewer::event(QEvent *e) {
m_gestureActive = true;
return true;
}
if (e->type() != QEvent::KeyPress && e->type() != QEvent::ShortcutOverride &&
e->type() != QEvent::KeyRelease)
return QGraphicsView::event(e);
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId != T_Hand) return QGraphicsView::event(e);
if (e->type() == QEvent::KeyPress || e->type() == QEvent::ShortcutOverride) {
m_panningArmed = true;
action->setEnabled(false);
setToolCursor(this, ToolCursor::PanCursor);
e->accept();
return true;
} else if (e->type() == QEvent::KeyRelease) {
if (!keyEvent->isAutoRepeat()) m_panningArmed = false;
action->setEnabled(true);
switch (m_cursorMode) {
case CursorMode::Hand:
setToolCursor(this, ToolCursor::PanCursor);
break;
case CursorMode::Zoom:
setToolCursor(this, ToolCursor::ZoomCursor);
break;
default:
setToolCursor(this, ToolCursor::StrokeSelectCursor);
break;
}
e->accept();
return true;
}
return QGraphicsView::event(e);
}

View file

@ -7,6 +7,12 @@
#include "toonz/tframehandle.h"
#include "orientation.h"
#include "toonzqt/menubarcommand.h"
#include "tools/toolcommandids.h"
#include "tools/cursormanager.h"
#include "tools/cursors.h"
#include <QKeyEvent>
#include <QWheelEvent>
#include <QLabel>
@ -833,10 +839,6 @@ m_dragTool->onDrag(&mouseEvent);
void SpreadsheetViewer::keyPressEvent(QKeyEvent *e) {
int frameCount = m_rowCount;
int row = m_frameHandle->getFrame();
if (e->key() == Qt::Key_Space) {
m_panningArmed = true;
return;
}
if (e->key() == Qt::Key_Up &&
row > 0) { // Row = frame precedente a quello settato
m_frameHandle->setFrame(row - 1);
@ -888,18 +890,14 @@ void SpreadsheetViewer::keyPressEvent(QKeyEvent *e) {
//-----------------------------------------------------------------------------
void SpreadsheetViewer::keyReleaseEvent(QKeyEvent *event) {
if (event->key() == Qt::Key_Space && !event->isAutoRepeat())
m_panningArmed = false;
}
//-----------------------------------------------------------------------------
void SpreadsheetViewer::enterEvent(QEvent *) { m_panningArmed = false; }
//-----------------------------------------------------------------------------
void SpreadsheetViewer::leaveEvent(QEvent *) { m_panningArmed = false; }
void SpreadsheetViewer::leaveEvent(QEvent *) {
m_panningArmed = false;
setCursor(Qt::ArrowCursor);
}
//-----------------------------------------------------------------------------
@ -953,3 +951,36 @@ void SpreadsheetViewer::ensureVisibleCol(int col) {
int vertValue = m_cellScrollArea->verticalScrollBar()->value();
m_cellScrollArea->ensureVisible(x, vertValue, m_columnWidth / 2, 0);
}
//-----------------------------------------------------------------------------
bool SpreadsheetViewer::event(QEvent *e) {
if (e->type() != QEvent::KeyPress && e->type() != QEvent::ShortcutOverride &&
e->type() != QEvent::KeyRelease)
return QDialog::event(e);
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
std::string keyStr = QKeySequence(keyEvent->key() + keyEvent->modifiers())
.toString()
.toStdString();
QAction *action = CommandManager::instance()->getActionFromShortcut(keyStr);
std::string actionId = CommandManager::instance()->getIdFromAction(action);
if (actionId != T_Hand) return QDialog::event(e);
if (e->type() == QEvent::KeyPress || e->type() == QEvent::ShortcutOverride) {
m_panningArmed = true;
action->setEnabled(false);
setToolCursor(this, ToolCursor::PanCursor);
e->accept();
return true;
} else if (e->type() == QEvent::KeyRelease) {
if (!keyEvent->isAutoRepeat()) m_panningArmed = false;
action->setEnabled(true);
setCursor(Qt::ArrowCursor);
e->accept();
return true;
}
return QDialog::event(e);
}