still listen to key press events when focus on Thumbnails view

preferencesAboutTextFull
Clément Fauconnier 4 years ago
parent 497e826476
commit 3b166d5298
  1. 115
      src/gui/UBDocumentNavigator.cpp
  2. 2
      src/gui/UBDocumentNavigator.h

@ -39,6 +39,7 @@
#include "core/UBApplication.h"
#include "UBDocumentNavigator.h"
#include "board/UBBoardController.h"
#include "board/UBBoardView.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBSvgSubsetAdaptor.h"
#include "document/UBDocumentController.h"
@ -354,6 +355,120 @@ void UBDocumentNavigator::mouseReleaseEvent(QMouseEvent *event)
mLongPressTimer.stop();
}
void UBDocumentNavigator::keyPressEvent(QKeyEvent *event)
{
return;
UBBoardController* controller = UBApplication::boardController;
// send to the scene anyway
QApplication::sendEvent (scene (), event);
if (!event->isAccepted ())
{
switch (event->key ())
{
case Qt::Key_Up:
case Qt::Key_PageUp:
case Qt::Key_Left:
{
controller->previousScene ();
break;
}
case Qt::Key_Down:
case Qt::Key_PageDown:
case Qt::Key_Right:
case Qt::Key_Space:
{
controller->nextScene ();
break;
}
case Qt::Key_Home:
{
controller->firstScene ();
break;
}
case Qt::Key_End:
{
controller->lastScene ();
break;
}
case Qt::Key_Insert:
{
controller->addScene ();
break;
}
case Qt::Key_Control:
case Qt::Key_Shift:
{
controller->controlView()->setMultiselection(true);
}break;
}
if (event->modifiers () & Qt::ControlModifier) // keep only ctrl/cmd keys
{
switch (event->key ())
{
case Qt::Key_Plus:
case Qt::Key_I:
{
controller->zoomIn ();
event->accept ();
break;
}
case Qt::Key_Minus:
case Qt::Key_O:
{
controller->zoomOut ();
event->accept ();
break;
}
case Qt::Key_0:
{
controller->zoomRestore ();
event->accept ();
break;
}
case Qt::Key_Left:
{
controller->handScroll (-100, 0);
event->accept ();
break;
}
case Qt::Key_Right:
{
controller->handScroll (100, 0);
event->accept ();
break;
}
case Qt::Key_Up:
{
controller->handScroll (0, -100);
event->accept ();
break;
}
case Qt::Key_Down:
{
controller->handScroll (0, 100);
event->accept ();
break;
}
default:
{
// NOOP
}
}
}
}
// if ctrl of shift was pressed combined with other keys - we need to disable multiple selection.
if (event->isAccepted())
controller->controlView()->setMultiselection(false);
}
void UBDocumentNavigator::longPressTimeout()
{
if (QApplication::mouseButtons() != Qt::NoButton)

@ -72,6 +72,8 @@ protected:
virtual void dragMoveEvent(QDragMoveEvent* event);
virtual void dropEvent(QDropEvent* event);
virtual void keyPressEvent(QKeyEvent *event);
signals:
void mousePressAndHoldEventRequired();
void moveThumbnailRequired(int from, int to);

Loading…
Cancel
Save