QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutviewtooltemporarykeyzoom.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutviewtooltemporarykeyzoom.cpp
3 -------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgslayoutview.h"
20
21#include <QApplication>
22#include <QScrollBar>
23
24#include "moc_qgslayoutviewtooltemporarykeyzoom.cpp"
25
30
32{
34 if ( !event->isAccepted() )
35 return;
36
37 //end of temporary zoom tool
38 if ( mDeactivateOnMouseRelease )
39 view()->setTool( mPreviousViewTool );
40}
41
43{
44 if ( event->isAutoRepeat() )
45 {
46 event->ignore();
47 return;
48 }
49
50 //respond to changes in ctrl key status
51 if ( !( event->modifiers() & Qt::ControlModifier ) )
52 {
53 if ( !mMarqueeZoom )
54 {
55 //space pressed, but control key was released, end of temporary zoom tool
56 view()->setTool( mPreviousViewTool );
57 }
58 else
59 {
60 mDeactivateOnMouseRelease = true;
61 }
62 }
63 else
64 {
65 //both control and space pressed
66 //set cursor to zoom in/out depending on alt key status
67 updateCursor( event->modifiers() );
68 if ( event->key() == Qt::Key_Space )
69 {
70 mDeactivateOnMouseRelease = false;
71 }
72 }
73}
74
76{
77 if ( event->isAutoRepeat() )
78 {
79 event->ignore();
80 return;
81 }
82
83 if ( event->key() == Qt::Key_Space )
84 {
85 //temporary keyboard-based zoom tool is active and space key has been released
86 if ( !mMarqueeZoom )
87 {
88 //not mid-way through an operation, so immediately switch tool back
89 view()->setTool( mPreviousViewTool );
90 }
91 else
92 {
93 mDeactivateOnMouseRelease = true;
94 }
95 }
96 else
97 {
98 updateCursor( event->modifiers() );
99 event->ignore();
100 }
101}
102
104{
105 mDeactivateOnMouseRelease = false;
106 mPreviousViewTool = view()->tool();
108 updateCursor( QApplication::keyboardModifiers() );
109}
110
111void QgsLayoutViewToolTemporaryKeyZoom::updateCursor( Qt::KeyboardModifiers modifiers )
112{
114}
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
@ ZoomOut
Zoom out.
A mouse event which is the result of a user interaction with a QgsLayoutView.
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
void keyPressEvent(QKeyEvent *event) override
Key press event for overriding.
void keyReleaseEvent(QKeyEvent *event) override
Key release event for overriding.
QgsLayoutViewToolTemporaryKeyZoom(QgsLayoutView *view)
Constructor for QgsLayoutViewToolTemporaryKeyZoom.
void activate() override
Called when tool is set as the currently active layout tool.
void layoutReleaseEvent(QgsLayoutViewMouseEvent *event) override
Mouse release event for overriding.
QgsLayoutViewToolZoom(QgsLayoutView *view)
Constructor for QgsLayoutViewToolZoom.
bool mMarqueeZoom
Will be true will marquee zoom operation is in progress.
QgsLayoutView * view() const
Returns the view associated with the tool.
virtual void activate()
Called when tool is set as the currently active layout tool.
A graphical widget to display and interact with QgsLayouts.
void setTool(QgsLayoutViewTool *tool)
Sets the tool currently being used in the view.
QgsLayoutViewTool * tool