Exemple #1
0
 def dropEvent(self, evt):
     oldmime = evt.mimeData()
     # coming from this program?
     if evt.source():
         if oldmime.hasHtml():
             mime = QMimeData()
             mime.setHtml(_filterHTML(oldmime.html()))
         else:
             # old qt on linux won't give us html when dragging an image;
             # in that case just do the default action (which is to ignore
             # the drag)
             return AnkiWebView.dropEvent(self, evt)
     else:
         mime = self._processMime(oldmime)
     # create a new event with the new mime data and run it
     new = QDropEvent(evt.pos(), evt.possibleActions(), mime,
                      evt.mouseButtons(), evt.keyboardModifiers())
     evt.accept()
     QWebView.dropEvent(self, new)
     # tell the drop target to take focus so the drop contents are saved
     self.eval("dropTarget.focus();")
Exemple #2
0
 def dropEvent(self, evt):
     oldmime = evt.mimeData()
     # coming from this program?
     if evt.source():
         if oldmime.hasHtml():
             mime = QMimeData()
             mime.setHtml(self.editor._filterHTML(oldmime.html()))
         else:
             # old qt on linux won't give us html when dragging an image;
             # in that case just do the default action (which is to ignore
             # the drag)
             return AnkiWebView.dropEvent(self, evt)
     else:
         mime = self._processMime(oldmime)
     # create a new event with the new mime data and run it
     new = QDropEvent(evt.pos(), evt.possibleActions(), mime,
                      evt.mouseButtons(), evt.keyboardModifiers())
     evt.accept()
     QWebView.dropEvent(self, new)
     # tell the drop target to take focus so the drop contents are saved
     self.eval("dropTarget.focus();")
     self.setFocus()