Rev 19168 | Rev 22638 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
19153 | craig | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | |||
8 | #include <QDebug> |
||
9 | #include <QDropEvent> |
||
10 | #include <QKeyEvent> |
||
11 | #include <QMimeData> |
||
12 | |||
13 | #include "filedialogeventcatcher.h" |
||
14 | |||
15 | FileDialogEventCatcher::FileDialogEventCatcher(QObject* parent) |
||
16 | : QObject(parent) |
||
17 | { |
||
18 | } |
||
19 | |||
20 | bool FileDialogEventCatcher::eventFilter(QObject *o, QEvent *e) |
||
21 | { |
||
22 | if (e->type() == QEvent::KeyPress) |
||
23 | { |
||
24 | QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e); |
||
19180 | craig | 25 | switch (keyEvent->key()) |
19153 | craig | 26 | { |
19180 | craig | 27 | case Qt::Key_Escape: |
28 | emit escapePressed(); |
||
29 | return true; |
||
30 | case Qt::Key_D: |
||
31 | if (keyEvent->modifiers() & Qt::ControlModifier) |
||
32 | { |
||
33 | emit desktopPressed(); |
||
34 | return true; |
||
35 | } |
||
36 | break; |
||
37 | case Qt::Key_H: |
||
38 | if (keyEvent->modifiers() & (Qt::ControlModifier|Qt::ShiftModifier)) |
||
39 | { |
||
40 | emit homePressed(); |
||
41 | return true; |
||
42 | } |
||
43 | break; |
||
44 | case Qt::Key_Up: |
||
45 | if (keyEvent->modifiers() & Qt::ControlModifier) |
||
46 | { |
||
47 | emit parentPressed(); |
||
48 | return true; |
||
49 | } |
||
50 | break; |
||
51 | case Qt::Key_Down: |
||
52 | if (keyEvent->modifiers() & Qt::ControlModifier) |
||
53 | { |
||
54 | emit enterSelectedPressed(); |
||
55 | return true; |
||
56 | } |
||
57 | break; |
||
19153 | craig | 58 | } |
59 | } |
||
60 | else |
||
61 | if (e->type() == QEvent::DragEnter) |
||
62 | { |
||
63 | e->accept(); |
||
64 | return true; |
||
65 | } |
||
66 | else |
||
67 | if (e->type() == QEvent::Drop) |
||
68 | { |
||
69 | QDropEvent *dropEvent = static_cast<QDropEvent *>(e); |
||
70 | if (dropEvent) |
||
71 | { |
||
72 | if ( dropEvent->mimeData()->hasFormat("text/uri-list")) |
||
73 | { |
||
74 | QString fileUrl; |
||
75 | QList<QUrl> fileUrls = dropEvent->mimeData()->urls(); |
||
76 | if (fileUrls.count()>0) |
||
77 | { |
||
78 | fileUrl = fileUrls[0].toLocalFile(); |
||
79 | if (fileUrls[0].isLocalFile()) |
||
80 | { |
||
19168 | craig | 81 | emit dropLocation(fileUrl); |
19153 | craig | 82 | } |
83 | } |
||
84 | } |
||
85 | } |
||
86 | e->accept(); |
||
87 | return true; |
||
88 | } |
||
89 | return QObject::eventFilter(o, e); |
||
90 | } |