| 142 | } |
| 143 | |
| 144 | bool XcaApplication::eventFilter(QObject *watched, QEvent *ev) |
| 145 | { |
| 146 | static int mctr; |
| 147 | QMouseEvent *me; |
| 148 | QStringList l; |
| 149 | XcaTreeView *treeview; |
| 150 | int key; |
| 151 | |
| 152 | switch (ev->type()) { |
| 153 | case QEvent::FileOpen: |
| 154 | l << static_cast<QFileOpenEvent *>(ev)->file(); |
| 155 | mainw->openURLs(l); |
| 156 | return true; |
| 157 | case QEvent::MouseMove: |
| 158 | case QEvent::NonClientAreaMouseMove: |
| 159 | if (mctr++ > 8) { |
| 160 | me = static_cast<QMouseEvent *>(ev); |
| 161 | #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) |
| 162 | QPoint p = me->globalPosition().toPoint(); |
| 163 | #else |
| 164 | QPoint p = me->globalPos(); |
| 165 | #endif |
| 166 | Entropy::add(p.x()); |
| 167 | Entropy::add(p.y()); |
| 168 | mctr = 0; |
| 169 | } |
| 170 | break; |
| 171 | case QEvent::KeyPress: |
| 172 | key = static_cast<QKeyEvent *>(ev)->key(); |
| 173 | if (key < 0x100) { |
| 174 | Entropy::add(key); |
| 175 | } |
| 176 | break; |
| 177 | case QEvent::MouseButtonPress: |
| 178 | me = static_cast<QMouseEvent *>(ev); |
| 179 | treeview = watched ? |
| 180 | dynamic_cast<XcaTreeView*>(watched->parent()) : NULL; |
| 181 | |
| 182 | if ((watched == mainw || treeview) && |
| 183 | me->button() == Qt::MiddleButton && |
| 184 | QApplication::clipboard()->supportsSelection()) |
| 185 | { |
| 186 | mainw->pastePem(); |
| 187 | return true; |
| 188 | } |
| 189 | break; |
| 190 | default: |
| 191 | break; |
| 192 | } |
| 193 | return false; |
| 194 | } |
| 195 | |
| 196 | bool XcaApplication::notify(QObject* receiver, QEvent* event) |
| 197 | { |