Changeset View
Changeset View
Standalone View
Standalone View
tools/selection/kpAbstractSelectionTool_KeyboardEvents.cpp
Show All 19 Lines | 2 | /* | |||
---|---|---|---|---|---|
20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | 26 | */ | ||
27 | 27 | | |||
28 | | ||||
29 | #define DEBUG_KP_TOOL_SELECTION 0 | | |||
30 | | ||||
31 | | ||||
32 | #include "kpAbstractSelectionTool.h" | 28 | #include "kpAbstractSelectionTool.h" | ||
33 | #include "kpAbstractSelectionToolPrivate.h" | 29 | #include "kpAbstractSelectionToolPrivate.h" | ||
34 | 30 | | |||
35 | #include "document/kpDocument.h" | 31 | #include "document/kpDocument.h" | ||
36 | #include "environments/tools/selection/kpToolSelectionEnvironment.h" | 32 | #include "environments/tools/selection/kpToolSelectionEnvironment.h" | ||
37 | #include "commands/tools/selection/kpToolSelectionMoveCommand.h" | 33 | #include "commands/tools/selection/kpToolSelectionMoveCommand.h" | ||
38 | #include "layers/selections/kpAbstractSelection.h" | 34 | #include "layers/selections/kpAbstractSelection.h" | ||
39 | 35 | | |||
40 | #include <QKeyEvent> | 36 | #include <QKeyEvent> | ||
41 | 37 | | |||
42 | #include "kpLogCategories.h" | 38 | #include "kpLogCategories.h" | ||
43 | 39 | | |||
44 | //--------------------------------------------------------------------- | 40 | //--------------------------------------------------------------------- | ||
45 | 41 | | |||
46 | // protected virtual [base kpTool] | 42 | // protected virtual [base kpTool] | ||
47 | void kpAbstractSelectionTool::keyPressEvent (QKeyEvent *e) | 43 | void kpAbstractSelectionTool::keyPressEvent (QKeyEvent *e) | ||
48 | { | 44 | { | ||
49 | #if DEBUG_KP_TOOL_SELECTION && 0 | | |||
50 | qCDebug(kpLogTools) << "kpAbstractSelectionTool::keyPressEvent(e->text='" | 45 | qCDebug(kpLogTools) << "kpAbstractSelectionTool::keyPressEvent(e->text='" | ||
51 | << e->text () << "')" << endl; | 46 | << e->text () << "')"; | ||
52 | #endif | | |||
53 | 47 | | |||
54 | e->ignore (); | 48 | e->ignore (); | ||
55 | 49 | | |||
56 | if (document ()->selection () && | 50 | if (document ()->selection () && | ||
57 | !hasBegunDraw () && | 51 | !hasBegunDraw () && | ||
58 | e->key () == Qt::Key_Escape) | 52 | e->key () == Qt::Key_Escape) | ||
59 | { | 53 | { | ||
60 | #if DEBUG_KP_TOOL_SELECTION && 0 | 54 | qCDebug(kpLogTools) << "\tescape pressed with sel when not begun draw - deselecting"; | ||
61 | qCDebug(kpLogTools) << "\tescape pressed with sel when not begun draw - deselecting" | | |||
62 | << endl; | | |||
63 | #endif | | |||
64 | | ||||
65 | pushOntoDocument (); | 55 | pushOntoDocument (); | ||
66 | e->accept (); | 56 | e->accept (); | ||
67 | } | 57 | } | ||
68 | else | 58 | else | ||
69 | { | 59 | { | ||
70 | #if DEBUG_KP_TOOL_SELECTION && 0 | | |||
71 | qCDebug(kpLogTools) << "\tkey processing did not accept (text was '" | 60 | qCDebug(kpLogTools) << "\tkey processing did not accept (text was '" | ||
72 | << e->text () | 61 | << e->text () | ||
73 | << "') - passing on event to kpTool" | 62 | << "') - passing on event to kpTool"; | ||
74 | << endl; | | |||
75 | #endif | | |||
76 | 63 | | |||
77 | if ( document()->selection() && !hasBegunDraw() && | 64 | if ( document()->selection() && !hasBegunDraw() && | ||
78 | ((e->key() == Qt::Key_Left) || | 65 | ((e->key() == Qt::Key_Left) || | ||
79 | (e->key() == Qt::Key_Right) || | 66 | (e->key() == Qt::Key_Right) || | ||
80 | (e->key() == Qt::Key_Up) || | 67 | (e->key() == Qt::Key_Up) || | ||
81 | (e->key() == Qt::Key_Down)) ) | 68 | (e->key() == Qt::Key_Down)) ) | ||
82 | { | 69 | { | ||
83 | // move selection with cursor keys pixel-wise | 70 | // move selection with cursor keys pixel-wise | ||
Show All 21 Lines |