Add camera plugin.

master
Andy Stewart 8 years ago
parent 0d934ddda3
commit 2382decd9f
  1. 42
      README.md
  2. 81
      app/camera/buffer.py
  3. 6
      eaf.py

@ -40,26 +40,28 @@ sudo pip install PyMuPDF
```
M-x eaf-open
```
| App | Key | Event |
| -------- | :-----: | :---- |
| Browser | Left Button | Open link current tab |
| | Ctrl + Left Button | Open link in new tab |
| Image Viewer | j | Load next image in current directory |
| | k | Load previous image in current directory |
| Video Player | Space | Play or Pause |
| | h | Seek backward |
| | l | Seek forward |
| Pdf Viewer | j | Scroll up |
| | k | Scroll down |
| | Space | Scroll up page |
| | b | Scroll down page |
| | , | Scroll to end |
| | . | Scroll to home |
| | t | Switch scale mode |
| | - | Zoom out |
| | = | Zoom in |
| | 0 | Zoomn reset |
| | g | Goto page |
| App | Key | Event | Way to open |
| -------- | :-----: | :---- | :---- |
| Browser | Left Button | Open link current tab | URL |
| | Ctrl + Left Button | Open link in new tab | |
| Image Viewer | j | Load next image in current directory | Image file path |
| | k | Load previous image in current directory | |
| Video Player | Space | Play or Pause | Video file path |
| | h | Seek backward | |
| | l | Seek forward | |
| Pdf Viewer | j | Scroll up | Pdf file path |
| | k | Scroll down | |
| | Space | Scroll up page | |
| | b | Scroll down page | |
| | , | Scroll to end | |
| | . | Scroll to home | |
| | t | Switch scale mode | |
| | - | Zoom out | |
| | = | Zoom in | |
| | 0 | Zoomn reset | |
| | g | Goto page | |
| Camera | | | Type 'eaf-camera' |
| Demo | | | Type 'eaf-demo' |
### Why this awesome framework can't works with MacOS?
There are mainly three obstacles:

@ -0,0 +1,81 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Andy Stewart
#
# Author: Andy Stewart <lazycat.manatee@gmail.com>
# Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from PyQt5.QtCore import Qt, QSizeF
from PyQt5.QtGui import QBrush
from PyQt5.QtGui import QColor
from PyQt5.QtMultimedia import QCameraInfo, QCamera
from PyQt5.QtMultimediaWidgets import QGraphicsVideoItem
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView
from PyQt5.QtWidgets import QWidget, QVBoxLayout
from core.buffer import Buffer
class CameraBuffer(Buffer):
def __init__(self, buffer_id, url):
Buffer.__init__(self, buffer_id, url, True, QColor(0, 0, 0, 255))
self.add_widget(CameraWidget(QColor(0, 0, 0, 255)))
class CameraWidget(QWidget):
def __init__(self, background_color):
QWidget.__init__(self)
self.scene = QGraphicsScene(self)
self.scene.setBackgroundBrush(QBrush(background_color))
self.graphics_view = QGraphicsView(self.scene)
self.graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setFrameStyle(0)
self.graphics_view.setStyleSheet("QGraphicsView {background: transparent; border: 3px; outline: none;}")
self.video_item = QGraphicsVideoItem()
self.scene.addItem(self.video_item)
self.layout = QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.graphics_view)
self.available_cameras = QCameraInfo.availableCameras()
# Set the default camera.
self.select_camera(0)
def resizeEvent(self, event):
self.video_item.setSize(QSizeF(event.size().width(), event.size().height()))
QWidget.resizeEvent(self, event)
def select_camera(self, i):
self.camera = QCamera(self.available_cameras[i])
self.camera.setViewfinder(self.video_item)
self.camera.setCaptureMode(QCamera.CaptureStillImage)
self.camera.start()
if __name__ == "__main__":
from PyQt5.QtWidgets import QApplication
import sys
import signal
app = QApplication(sys.argv)
test = CameraWidget(QColor(0, 0, 0, 255))
test.show()
signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.exit(app.exec_())

@ -55,6 +55,12 @@ class EAF(dbus.service.Object):
self.create_buffer(buffer_id, DemoBuffer(buffer_id, url))
except ImportError:
return "Something wrong when import app.demo.buffer"
elif url == "eaf-camera":
try:
from app.camera.buffer import CameraBuffer
self.create_buffer(buffer_id, CameraBuffer(buffer_id, url))
except ImportError:
return "Something wrong when import app.camera.buffer"
else:
url = os.path.expanduser(url)

Loading…
Cancel
Save