MCPcopy Create free account
hub / github.com/IENT/YUView / handleKeyPress

Method handleKeyPress

YUViewLib/src/ui/views/MoveAndZoomableView.cpp:96–132  ·  view source on GitHub ↗

Handle the key press event (if this widgets handles it). If not, return false.

Source from the content-addressed store, hash-verified

94
95// Handle the key press event (if this widgets handles it). If not, return false.
96bool 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
134void MoveAndZoomableView::resetViewInternal()
135{

Callers

nothing calls this directly

Calls 4

resetViewMethod · 0.95
zoomToFitInternalMethod · 0.95
zoomMethod · 0.95
toStringMethod · 0.80

Tested by

no test coverage detected