update eaf package

This commit is contained in:
2021-01-30 14:52:51 +01:00
parent 84eb4929ee
commit 5207af83cb
4981 changed files with 11795 additions and 761570 deletions

View File

@@ -21,8 +21,9 @@
from PyQt5 import QtCore
from PyQt5.QtCore import Qt, QEvent, QPoint
from PyQt5.QtGui import QPainter, QWindow
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QGraphicsView
from PyQt5.QtGui import QPainter, QWindow, QBrush, QColor
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QGraphicsView, QFrame
import os
class View(QWidget):
@@ -50,14 +51,23 @@ class View(QWidget):
# Build QGraphicsView.
self.layout = QVBoxLayout(self)
self.layout.setSpacing(0)
self.layout.setContentsMargins(0, 0, 0, 0)
self.graphics_view = QGraphicsView(buffer, self)
# Set background color.
# When fit_to_view is True, QGraphicsView will fill color around app view.
# We fill color with buffer's attribute "background_color".
if hasattr(self.buffer, "background_color") and self.buffer.background_color:
self.graphics_view.setBackgroundBrush(QBrush(self.buffer.background_color))
# Remove border from QGraphicsView.
self.graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.graphics_view.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing)
# Remove damn border from QGraphicsView.
self.graphics_view.setFrameStyle(0)
self.graphics_view.setStyleSheet("QGraphicsView {background: transparent; border: 3px; outline: none;}")
self.graphics_view.setFrameStyle(QFrame.NoFrame)
# Add graphics view.
self.layout.addWidget(self.graphics_view)
# NOTE: show function must start before resize to trigger *first* resizeEvent after show.
@@ -73,7 +83,7 @@ class View(QWidget):
if self.buffer.fit_to_view:
if event.oldSize().isValid():
self.graphics_view.fitInView(self.graphics_view.scene().sceneRect(), Qt.KeepAspectRatio)
QWidget.resizeEvent(self, event)
QWidget.resizeEvent(self, event)
def adjust_aspect_ratio(self):
widget_width = self.width
@@ -96,6 +106,12 @@ class View(QWidget):
horizontal_padding, vertical_padding)
def eventFilter(self, obj, event):
# import time
# print(time.time(), event.type())
if event.type() in [QEvent.ShortcutOverride]:
self.buffer.eval_in_emacs.emit('eaf-activate-emacs-window', [])
# Focus emacs buffer when user click view.
if event.type() in [QEvent.MouseButtonPress, QEvent.MouseButtonRelease,
QEvent.MouseButtonDblClick, QEvent.Wheel]: