Fix #82 , take photo support now.

master
Andy Stewart 6 years ago
parent 432b2e57ea
commit 3c4485b160
  1. 16
      app/camera/buffer.py
  2. 8
      docs/KEYBINDING.md
  3. 10
      eaf.el

@ -22,11 +22,14 @@
from PyQt5.QtCore import Qt, QSizeF
from PyQt5.QtGui import QBrush
from PyQt5.QtGui import QColor
from PyQt5.QtMultimedia import QCameraInfo, QCamera
from PyQt5.QtMultimedia import QCameraInfo, QCamera, QCameraImageCapture
from PyQt5.QtMultimediaWidgets import QGraphicsVideoItem
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView
from PyQt5.QtWidgets import QWidget, QVBoxLayout
from core.buffer import Buffer
from pathlib import Path
import time
import os
class AppBuffer(Buffer):
def __init__(self, buffer_id, url, arguments):
@ -42,6 +45,9 @@ class AppBuffer(Buffer):
# Re-start camero after some view show.
self.buffer_widget.camera.start()
def take_photo(self):
self.buffer_widget.take_photo()
class CameraWidget(QWidget):
def __init__(self, background_color):
@ -77,6 +83,14 @@ class CameraWidget(QWidget):
self.camera.setCaptureMode(QCamera.CaptureStillImage)
self.camera.start()
def take_photo(self):
photo_path = os.path.join(str(Path.home()), "EAF_Camera_Photo_" + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))))
image_capture = QCameraImageCapture(self.camera)
image_capture.capture(photo_path)
self.message_to_emacs.emit("Save photo at: " + photo_path)
if __name__ == "__main__":
from PyQt5.QtWidgets import QApplication
import sys

@ -70,4 +70,10 @@ You can customize keys with option ```eaf-imageviewer-keybinding```
| C-= | Zoom in |
| C-- | Zoom out |
You can customize keys with option ```eaf-terminal-keybinding```
### Camera
| Browser Key | Event |
| :-----: | :---- |
| j | Take photo |
You can customize keys with option ```eaf-camera-keybinding```

@ -214,6 +214,12 @@ by `dired-find-alternate-file'. Otherwise they will be opened normally with `dir
:type 'cons
:group 'eaf)
(defcustom eaf-camera-keybinding
'(("j" . "take_photo"))
"The keybinding of camera"
:type 'cons
:group 'eaf)
(defcustom eaf-pdf-extension-list
'("pdf" "xps" "oxps" "cbz" "epub" "fb2" "fbz" "djvu")
"The extension list of pdf application."
@ -451,7 +457,7 @@ We need calcuate render allocation to make sure no black border around render co
)
;; Uncomment for debug.
;; (message (format "!!!!! %s %s %s %s" event key key-command key-desc))
;; (message (format "!!!!! %s %s %s %s %s" event key key-command key-desc buffer-app-name))
(cond
;; Fix #51 , don't handle F11 to make emacs toggle frame fullscreen status successfully.
@ -469,6 +475,8 @@ We need calcuate render allocation to make sure no black border around render co
(eaf-handle-app-key buffer-id key-desc eaf-videoplayer-keybinding))
((equal buffer-app-name "image-viewer")
(eaf-handle-app-key buffer-id key-desc eaf-imageviewer-keybinding))
((equal buffer-app-name "camera")
(eaf-handle-app-key buffer-id key-desc eaf-camera-keybinding))
(t
(eaf-call "send_key" buffer-id key-desc))))
((string-match "^[CMSs]-.*" key-desc)

Loading…
Cancel
Save