Handle the key press event (if this widgets handles it). If not, return false.
| 94 | |
| 95 | // Handle the key press event (if this widgets handles it). If not, return false. |
| 96 | bool MoveAndZoomableView::handleKeyPress(QKeyEvent *event) |
| 97 | { |
| 98 | DEBUG_VIEW(QTime::currentTime().toString("hh:mm:ss.zzz") << "Key: " << event); |
| 99 | |
| 100 | int key = event->key(); |
| 101 | bool controlOnly = event->modifiers() == Qt::ControlModifier; |
| 102 | |
| 103 | if (key == Qt::Key_0 && controlOnly) |
| 104 | { |
| 105 | this->resetView(false); |
| 106 | return true; |
| 107 | } |
| 108 | else if (key == Qt::Key_9 && controlOnly) |
| 109 | { |
| 110 | this->zoomToFitInternal(); |
| 111 | return true; |
| 112 | } |
| 113 | else if (key == Qt::Key_Plus && controlOnly) |
| 114 | { |
| 115 | this->zoom(ZoomMode::IN); |
| 116 | return true; |
| 117 | } |
| 118 | else if (key == Qt::Key_BracketRight && controlOnly) |
| 119 | { |
| 120 | // This seems to be a bug in the Qt localization routine. On the German keyboard layout this key |
| 121 | // is returned if Ctrl + is pressed. |
| 122 | this->zoom(ZoomMode::IN); |
| 123 | return true; |
| 124 | } |
| 125 | else if (key == Qt::Key_Minus && controlOnly) |
| 126 | { |
| 127 | this->zoom(ZoomMode::OUT); |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | return false; |
| 132 | } |
| 133 | |
| 134 | void MoveAndZoomableView::resetViewInternal() |
| 135 | { |
nothing calls this directly
no test coverage detected