#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (C) 2018 Andy Stewart # # Author: Andy Stewart # Maintainer: Andy Stewart # # 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 . from PyQt5 import QtCore from PyQt5.QtGui import QBrush from PyQt5.QtWidgets import QGraphicsScene import abc class Buffer(QGraphicsScene): __metaclass__ = abc.ABCMeta update_title = QtCore.pyqtSignal(str, str) open_url = QtCore.pyqtSignal(str) before_destroy_hook = QtCore.pyqtSignal() def __init__(self, buffer_id, url, width, height, fit_to_view, background_color): super(QGraphicsScene, self).__init__() self.buffer_id = buffer_id self.url = url self.width = width self.height = height self.fit_to_view = fit_to_view self.background_color = background_color self.setBackgroundBrush(QBrush(self.background_color)) self.buffer_widget = None def add_widget(self, widget): self.buffer_widget = widget self.addWidget(self.buffer_widget) self.buffer_widget.resize(self.width, self.height) def handle_destroy(self): self.before_destroy_hook.emit() if self.buffer_widget != None: self.buffer_widget.destroy() def change_title(self, title): self.update_title.emit(self.buffer_id, title)