forked from openlp/openlp
Fix up the types in the signals and slots - PyQt 5.6 is stricter about them now.
This commit is contained in:
parent
8fcf42cdc3
commit
a8b72ed876
@ -46,15 +46,14 @@ __all__ = ['PJLink1']
|
|||||||
|
|
||||||
from codecs import decode
|
from codecs import decode
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot
|
from PyQt5 import QtCore, QtNetwork
|
||||||
from PyQt5.QtNetwork import QAbstractSocket, QTcpSocket
|
|
||||||
|
|
||||||
from openlp.core.common import translate, md5_hash
|
from openlp.core.common import translate, md5_hash
|
||||||
from openlp.core.lib.projector.constants import *
|
from openlp.core.lib.projector.constants import *
|
||||||
|
|
||||||
# Shortcuts
|
# Shortcuts
|
||||||
SocketError = QAbstractSocket.SocketError
|
SocketError = QtNetwork.QAbstractSocket.SocketError
|
||||||
SocketSTate = QAbstractSocket.SocketState
|
SocketSTate = QtNetwork.QAbstractSocket.SocketState
|
||||||
|
|
||||||
PJLINK_PREFIX = '%'
|
PJLINK_PREFIX = '%'
|
||||||
PJLINK_CLASS = '1'
|
PJLINK_CLASS = '1'
|
||||||
@ -62,18 +61,18 @@ PJLINK_HEADER = '{prefix}{linkclass}'.format(prefix=PJLINK_PREFIX, linkclass=PJL
|
|||||||
PJLINK_SUFFIX = CR
|
PJLINK_SUFFIX = CR
|
||||||
|
|
||||||
|
|
||||||
class PJLink1(QTcpSocket):
|
class PJLink1(QtNetwork.QTcpSocket):
|
||||||
"""
|
"""
|
||||||
Socket service for connecting to a PJLink-capable projector.
|
Socket service for connecting to a PJLink-capable projector.
|
||||||
"""
|
"""
|
||||||
# Signals sent by this module
|
# Signals sent by this module
|
||||||
changeStatus = pyqtSignal(str, int, str)
|
changeStatus = QtCore.pyqtSignal(str, int, str)
|
||||||
projectorNetwork = pyqtSignal(int) # Projector network activity
|
projectorNetwork = QtCore.pyqtSignal(int) # Projector network activity
|
||||||
projectorStatus = pyqtSignal(int) # Status update
|
projectorStatus = QtCore.pyqtSignal(int) # Status update
|
||||||
projectorAuthentication = pyqtSignal(str) # Authentication error
|
projectorAuthentication = QtCore.pyqtSignal(str) # Authentication error
|
||||||
projectorNoAuthentication = pyqtSignal(str) # PIN set and no authentication needed
|
projectorNoAuthentication = QtCore.pyqtSignal(str) # PIN set and no authentication needed
|
||||||
projectorReceivedData = pyqtSignal() # Notify when received data finished processing
|
projectorReceivedData = QtCore.pyqtSignal() # Notify when received data finished processing
|
||||||
projectorUpdateIcons = pyqtSignal() # Update the status icons on toolbar
|
projectorUpdateIcons = QtCore.pyqtSignal() # Update the status icons on toolbar
|
||||||
|
|
||||||
def __init__(self, name=None, ip=None, port=PJLINK_PORT, pin=None, *args, **kwargs):
|
def __init__(self, name=None, ip=None, port=PJLINK_PORT, pin=None, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -116,8 +115,8 @@ class PJLink1(QTcpSocket):
|
|||||||
self.error_status = S_OK
|
self.error_status = S_OK
|
||||||
# Socket information
|
# Socket information
|
||||||
# Add enough space to input buffer for extraneous \n \r
|
# Add enough space to input buffer for extraneous \n \r
|
||||||
self.maxSize = PJLINK_MAX_PACKET + 2
|
self.max_size = PJLINK_MAX_PACKET + 2
|
||||||
self.setReadBufferSize(self.maxSize)
|
self.setReadBufferSize(self.max_size)
|
||||||
# PJLink information
|
# PJLink information
|
||||||
self.pjlink_class = '1' # Default class
|
self.pjlink_class = '1' # Default class
|
||||||
self.reset_information()
|
self.reset_information()
|
||||||
@ -129,19 +128,20 @@ class PJLink1(QTcpSocket):
|
|||||||
# Socket timer for some possible brain-dead projectors or network cable pulled
|
# Socket timer for some possible brain-dead projectors or network cable pulled
|
||||||
self.socket_timer = None
|
self.socket_timer = None
|
||||||
# Map command to function
|
# Map command to function
|
||||||
self.PJLINK1_FUNC = {'AVMT': self.process_avmt,
|
self.pjlink1_functions = {
|
||||||
'CLSS': self.process_clss,
|
'AVMT': self.process_avmt,
|
||||||
'ERST': self.process_erst,
|
'CLSS': self.process_clss,
|
||||||
'INFO': self.process_info,
|
'ERST': self.process_erst,
|
||||||
'INF1': self.process_inf1,
|
'INFO': self.process_info,
|
||||||
'INF2': self.process_inf2,
|
'INF1': self.process_inf1,
|
||||||
'INPT': self.process_inpt,
|
'INF2': self.process_inf2,
|
||||||
'INST': self.process_inst,
|
'INPT': self.process_inpt,
|
||||||
'LAMP': self.process_lamp,
|
'INST': self.process_inst,
|
||||||
'NAME': self.process_name,
|
'LAMP': self.process_lamp,
|
||||||
'PJLINK': self.check_login,
|
'NAME': self.process_name,
|
||||||
'POWR': self.process_powr
|
'PJLINK': self.check_login,
|
||||||
}
|
'POWR': self.process_powr
|
||||||
|
}
|
||||||
|
|
||||||
def reset_information(self):
|
def reset_information(self):
|
||||||
"""
|
"""
|
||||||
@ -291,7 +291,7 @@ class PJLink1(QTcpSocket):
|
|||||||
message=status_message if msg is None else msg))
|
message=status_message if msg is None else msg))
|
||||||
self.changeStatus.emit(self.ip, status, message)
|
self.changeStatus.emit(self.ip, status, message)
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def check_login(self, data=None):
|
def check_login(self, data=None):
|
||||||
"""
|
"""
|
||||||
Processes the initial connection and authentication (if needed).
|
Processes the initial connection and authentication (if needed).
|
||||||
@ -309,8 +309,8 @@ class PJLink1(QTcpSocket):
|
|||||||
log.error('({ip}) Socket timeout waiting for login'.format(ip=self.ip))
|
log.error('({ip}) Socket timeout waiting for login'.format(ip=self.ip))
|
||||||
self.change_status(E_SOCKET_TIMEOUT)
|
self.change_status(E_SOCKET_TIMEOUT)
|
||||||
return
|
return
|
||||||
read = self.readLine(self.maxSize)
|
read = self.readLine(self.max_size)
|
||||||
dontcare = self.readLine(self.maxSize) # Clean out the trailing \r\n
|
dontcare = self.readLine(self.max_size) # Clean out the trailing \r\n
|
||||||
if read is None:
|
if read is None:
|
||||||
log.warn('({ip}) read is None - socket error?'.format(ip=self.ip))
|
log.warn('({ip}) read is None - socket error?'.format(ip=self.ip))
|
||||||
return
|
return
|
||||||
@ -320,7 +320,7 @@ class PJLink1(QTcpSocket):
|
|||||||
data = decode(read, 'ascii')
|
data = decode(read, 'ascii')
|
||||||
# Possibility of extraneous data on input when reading.
|
# Possibility of extraneous data on input when reading.
|
||||||
# Clean out extraneous characters in buffer.
|
# Clean out extraneous characters in buffer.
|
||||||
dontcare = self.readLine(self.maxSize)
|
dontcare = self.readLine(self.max_size)
|
||||||
log.debug('({ip}) check_login() read "{data}"'.format(ip=self.ip, data=data.strip()))
|
log.debug('({ip}) check_login() read "{data}"'.format(ip=self.ip, data=data.strip()))
|
||||||
# At this point, we should only have the initial login prompt with
|
# At this point, we should only have the initial login prompt with
|
||||||
# possible authentication
|
# possible authentication
|
||||||
@ -378,7 +378,7 @@ class PJLink1(QTcpSocket):
|
|||||||
self.timer.setInterval(2000) # Set 2 seconds for initial information
|
self.timer.setInterval(2000) # Set 2 seconds for initial information
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
"""
|
"""
|
||||||
Socket interface to retrieve data.
|
Socket interface to retrieve data.
|
||||||
@ -388,7 +388,7 @@ class PJLink1(QTcpSocket):
|
|||||||
log.debug('({ip}) get_data(): Not connected - returning'.format(ip=self.ip))
|
log.debug('({ip}) get_data(): Not connected - returning'.format(ip=self.ip))
|
||||||
self.send_busy = False
|
self.send_busy = False
|
||||||
return
|
return
|
||||||
read = self.readLine(self.maxSize)
|
read = self.readLine(self.max_size)
|
||||||
if read == -1:
|
if read == -1:
|
||||||
# No data available
|
# No data available
|
||||||
log.debug('({ip}) get_data(): No data available (-1)'.format(ip=self.ip))
|
log.debug('({ip}) get_data(): No data available (-1)'.format(ip=self.ip))
|
||||||
@ -435,7 +435,7 @@ class PJLink1(QTcpSocket):
|
|||||||
return
|
return
|
||||||
return self.process_command(cmd, data)
|
return self.process_command(cmd, data)
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def get_error(self, err):
|
def get_error(self, err):
|
||||||
"""
|
"""
|
||||||
Process error from SocketError signal.
|
Process error from SocketError signal.
|
||||||
@ -472,7 +472,7 @@ class PJLink1(QTcpSocket):
|
|||||||
:param queue: Option to force add to queue rather than sending directly
|
:param queue: Option to force add to queue rather than sending directly
|
||||||
"""
|
"""
|
||||||
if self.state() != self.ConnectedState:
|
if self.state() != self.ConnectedState:
|
||||||
log.warn('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
|
log.warning('({ip}) send_command(): Not connected - returning'.format(ip=self.ip))
|
||||||
self.send_queue = []
|
self.send_queue = []
|
||||||
return
|
return
|
||||||
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
self.projectorNetwork.emit(S_NETWORK_SENDING)
|
||||||
@ -503,7 +503,7 @@ class PJLink1(QTcpSocket):
|
|||||||
log.debug('({ip}) send_command() calling _send_string()'.format(ip=self.ip))
|
log.debug('({ip}) send_command() calling _send_string()'.format(ip=self.ip))
|
||||||
self._send_command()
|
self._send_command()
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def _send_command(self, data=None):
|
def _send_command(self, data=None):
|
||||||
"""
|
"""
|
||||||
Socket interface to send data. If data=None, then check queue.
|
Socket interface to send data. If data=None, then check queue.
|
||||||
@ -585,10 +585,10 @@ class PJLink1(QTcpSocket):
|
|||||||
self.projectorReceivedData.emit()
|
self.projectorReceivedData.emit()
|
||||||
return
|
return
|
||||||
|
|
||||||
if cmd in self.PJLINK1_FUNC:
|
if cmd in self.pjlink1_functions:
|
||||||
self.PJLINK1_FUNC[cmd](data)
|
self.pjlink1_functions[cmd](data)
|
||||||
else:
|
else:
|
||||||
log.warn('({ip}) Invalid command {data}'.format(ip=self.ip, data=cmd))
|
log.warning('({ip}) Invalid command {data}'.format(ip=self.ip, data=cmd))
|
||||||
self.send_busy = False
|
self.send_busy = False
|
||||||
self.projectorReceivedData.emit()
|
self.projectorReceivedData.emit()
|
||||||
|
|
||||||
@ -811,9 +811,9 @@ class PJLink1(QTcpSocket):
|
|||||||
log.warn('({ip}) connect_to_host(): Already connected - returning'.format(ip=self.ip))
|
log.warn('({ip}) connect_to_host(): Already connected - returning'.format(ip=self.ip))
|
||||||
return
|
return
|
||||||
self.change_status(S_CONNECTING)
|
self.change_status(S_CONNECTING)
|
||||||
self.connectToHost(self.ip, self.port if type(self.port) is int else int(self.port))
|
self.connectToHost(self.ip, self.port if isinstance(self.port, int) else int(self.port))
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def disconnect_from_host(self, abort=False):
|
def disconnect_from_host(self, abort=False):
|
||||||
"""
|
"""
|
||||||
Close socket and cleanup.
|
Close socket and cleanup.
|
||||||
|
@ -30,8 +30,6 @@ log = logging.getLogger(__name__)
|
|||||||
log.debug('editform loaded')
|
log.debug('editform loaded')
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal
|
|
||||||
from PyQt5.QtWidgets import QDialog, QPlainTextEdit, QLineEdit, QDialogButtonBox, QLabel, QGridLayout
|
|
||||||
|
|
||||||
from openlp.core.common import translate, verify_ip_address
|
from openlp.core.common import translate, verify_ip_address
|
||||||
from openlp.core.lib import build_icon
|
from openlp.core.lib import build_icon
|
||||||
@ -53,56 +51,56 @@ class Ui_ProjectorEditForm(object):
|
|||||||
edit_projector_dialog.setMinimumWidth(400)
|
edit_projector_dialog.setMinimumWidth(400)
|
||||||
edit_projector_dialog.setModal(True)
|
edit_projector_dialog.setModal(True)
|
||||||
# Define the basic layout
|
# Define the basic layout
|
||||||
self.dialog_layout = QGridLayout(edit_projector_dialog)
|
self.dialog_layout = QtWidgets.QGridLayout(edit_projector_dialog)
|
||||||
self.dialog_layout.setObjectName('dialog_layout')
|
self.dialog_layout.setObjectName('dialog_layout')
|
||||||
self.dialog_layout.setSpacing(8)
|
self.dialog_layout.setSpacing(8)
|
||||||
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
|
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
|
||||||
# IP Address
|
# IP Address
|
||||||
self.ip_label = QLabel(edit_projector_dialog)
|
self.ip_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.ip_label.setObjectName('projector_edit_ip_label')
|
self.ip_label.setObjectName('projector_edit_ip_label')
|
||||||
self.ip_text = QLineEdit(edit_projector_dialog)
|
self.ip_text = QtWidgets.QLineEdit(edit_projector_dialog)
|
||||||
self.ip_text.setObjectName('projector_edit_ip_text')
|
self.ip_text.setObjectName('projector_edit_ip_text')
|
||||||
self.dialog_layout.addWidget(self.ip_label, 0, 0)
|
self.dialog_layout.addWidget(self.ip_label, 0, 0)
|
||||||
self.dialog_layout.addWidget(self.ip_text, 0, 1)
|
self.dialog_layout.addWidget(self.ip_text, 0, 1)
|
||||||
# Port number
|
# Port number
|
||||||
self.port_label = QLabel(edit_projector_dialog)
|
self.port_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.port_label.setObjectName('projector_edit_ip_label')
|
self.port_label.setObjectName('projector_edit_ip_label')
|
||||||
self.port_text = QLineEdit(edit_projector_dialog)
|
self.port_text = QtWidgets.QLineEdit(edit_projector_dialog)
|
||||||
self.port_text.setObjectName('projector_edit_port_text')
|
self.port_text.setObjectName('projector_edit_port_text')
|
||||||
self.dialog_layout.addWidget(self.port_label, 1, 0)
|
self.dialog_layout.addWidget(self.port_label, 1, 0)
|
||||||
self.dialog_layout.addWidget(self.port_text, 1, 1)
|
self.dialog_layout.addWidget(self.port_text, 1, 1)
|
||||||
# PIN
|
# PIN
|
||||||
self.pin_label = QLabel(edit_projector_dialog)
|
self.pin_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.pin_label.setObjectName('projector_edit_pin_label')
|
self.pin_label.setObjectName('projector_edit_pin_label')
|
||||||
self.pin_text = QLineEdit(edit_projector_dialog)
|
self.pin_text = QtWidgets.QLineEdit(edit_projector_dialog)
|
||||||
self.pin_label.setObjectName('projector_edit_pin_text')
|
self.pin_label.setObjectName('projector_edit_pin_text')
|
||||||
self.dialog_layout.addWidget(self.pin_label, 2, 0)
|
self.dialog_layout.addWidget(self.pin_label, 2, 0)
|
||||||
self.dialog_layout.addWidget(self.pin_text, 2, 1)
|
self.dialog_layout.addWidget(self.pin_text, 2, 1)
|
||||||
# Name
|
# Name
|
||||||
self.name_label = QLabel(edit_projector_dialog)
|
self.name_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.name_label.setObjectName('projector_edit_name_label')
|
self.name_label.setObjectName('projector_edit_name_label')
|
||||||
self.name_text = QLineEdit(edit_projector_dialog)
|
self.name_text = QtWidgets.QLineEdit(edit_projector_dialog)
|
||||||
self.name_text.setObjectName('projector_edit_name_text')
|
self.name_text.setObjectName('projector_edit_name_text')
|
||||||
self.dialog_layout.addWidget(self.name_label, 3, 0)
|
self.dialog_layout.addWidget(self.name_label, 3, 0)
|
||||||
self.dialog_layout.addWidget(self.name_text, 3, 1)
|
self.dialog_layout.addWidget(self.name_text, 3, 1)
|
||||||
# Location
|
# Location
|
||||||
self.location_label = QLabel(edit_projector_dialog)
|
self.location_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.location_label.setObjectName('projector_edit_location_label')
|
self.location_label.setObjectName('projector_edit_location_label')
|
||||||
self.location_text = QLineEdit(edit_projector_dialog)
|
self.location_text = QtWidgets.QLineEdit(edit_projector_dialog)
|
||||||
self.location_text.setObjectName('projector_edit_location_text')
|
self.location_text.setObjectName('projector_edit_location_text')
|
||||||
self.dialog_layout.addWidget(self.location_label, 4, 0)
|
self.dialog_layout.addWidget(self.location_label, 4, 0)
|
||||||
self.dialog_layout.addWidget(self.location_text, 4, 1)
|
self.dialog_layout.addWidget(self.location_text, 4, 1)
|
||||||
# Notes
|
# Notes
|
||||||
self.notes_label = QLabel(edit_projector_dialog)
|
self.notes_label = QtWidgets.QLabel(edit_projector_dialog)
|
||||||
self.notes_label.setObjectName('projector_edit_notes_label')
|
self.notes_label.setObjectName('projector_edit_notes_label')
|
||||||
self.notes_text = QPlainTextEdit(edit_projector_dialog)
|
self.notes_text = QtWidgets.QPlainTextEdit(edit_projector_dialog)
|
||||||
self.notes_text.setObjectName('projector_edit_notes_text')
|
self.notes_text.setObjectName('projector_edit_notes_text')
|
||||||
self.dialog_layout.addWidget(self.notes_label, 5, 0, alignment=QtCore.Qt.AlignTop)
|
self.dialog_layout.addWidget(self.notes_label, 5, 0, alignment=QtCore.Qt.AlignTop)
|
||||||
self.dialog_layout.addWidget(self.notes_text, 5, 1)
|
self.dialog_layout.addWidget(self.notes_text, 5, 1)
|
||||||
# Time for the buttons
|
# Time for the buttons
|
||||||
self.button_box = QDialogButtonBox(QDialogButtonBox.Help |
|
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Help |
|
||||||
QDialogButtonBox.Save |
|
QtWidgets.QDialogButtonBox.Save |
|
||||||
QDialogButtonBox.Cancel)
|
QtWidgets.QDialogButtonBox.Cancel)
|
||||||
self.dialog_layout.addWidget(self.button_box, 8, 0, 1, 2)
|
self.dialog_layout.addWidget(self.button_box, 8, 0, 1, 2)
|
||||||
|
|
||||||
def retranslateUi(self, edit_projector_dialog):
|
def retranslateUi(self, edit_projector_dialog):
|
||||||
@ -128,7 +126,7 @@ class Ui_ProjectorEditForm(object):
|
|||||||
self.notes_text.insertPlainText(self.projector.notes)
|
self.notes_text.insertPlainText(self.projector.notes)
|
||||||
|
|
||||||
|
|
||||||
class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
|
class ProjectorEditForm(QtWidgets.QDialog, Ui_ProjectorEditForm):
|
||||||
"""
|
"""
|
||||||
Class to add or edit a projector entry in the database.
|
Class to add or edit a projector entry in the database.
|
||||||
|
|
||||||
@ -140,8 +138,8 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
|
|||||||
location = Column(String(30))
|
location = Column(String(30))
|
||||||
notes = Column(String(200))
|
notes = Column(String(200))
|
||||||
"""
|
"""
|
||||||
newProjector = pyqtSignal(str)
|
newProjector = QtCore.pyqtSignal(str)
|
||||||
editProjector = pyqtSignal(object)
|
editProjector = QtCore.pyqtSignal(object)
|
||||||
|
|
||||||
def __init__(self, parent=None, projectordb=None):
|
def __init__(self, parent=None, projectordb=None):
|
||||||
super(ProjectorEditForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
|
super(ProjectorEditForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
|
||||||
@ -159,10 +157,10 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
|
|||||||
self.projector = projector
|
self.projector = projector
|
||||||
self.new_projector = False
|
self.new_projector = False
|
||||||
self.retranslateUi(self)
|
self.retranslateUi(self)
|
||||||
reply = QDialog.exec(self)
|
reply = QtWidgets.QDialog.exec(self)
|
||||||
return reply
|
return reply
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def accept_me(self):
|
def accept_me(self):
|
||||||
"""
|
"""
|
||||||
Validate input before accepting input.
|
Validate input before accepting input.
|
||||||
@ -247,14 +245,14 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm):
|
|||||||
self.editProjector.emit(self.projector)
|
self.editProjector.emit(self.projector)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def help_me(self):
|
def help_me(self):
|
||||||
"""
|
"""
|
||||||
Show a help message about the input fields.
|
Show a help message about the input fields.
|
||||||
"""
|
"""
|
||||||
log.debug('help_me() signal received')
|
log.debug('help_me() signal received')
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def cancel_me(self):
|
def cancel_me(self):
|
||||||
"""
|
"""
|
||||||
Cancel button clicked - just close.
|
Cancel button clicked - just close.
|
||||||
|
@ -26,43 +26,46 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
log.debug('projectormanager loaded')
|
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
from PyQt5.QtCore import QObject, QThread, pyqtSlot
|
|
||||||
from PyQt5.QtWidgets import QWidget
|
|
||||||
|
|
||||||
from openlp.core.common import RegistryProperties, Settings, OpenLPMixin, \
|
from openlp.core.common import RegistryProperties, Settings, OpenLPMixin, \
|
||||||
RegistryMixin, translate
|
RegistryMixin, translate
|
||||||
from openlp.core.ui.lib import OpenLPToolbar
|
from openlp.core.ui.lib import OpenLPToolbar
|
||||||
from openlp.core.lib.ui import create_widget_action
|
from openlp.core.lib.ui import create_widget_action
|
||||||
from openlp.core.lib.projector import DialogSourceStyle
|
from openlp.core.lib.projector import DialogSourceStyle
|
||||||
from openlp.core.lib.projector.constants import *
|
from openlp.core.lib.projector.constants import S_NOT_CONNECTED, S_CONNECTING, S_CONNECTED, S_OFF, S_INITIALIZE, \
|
||||||
|
S_STANDBY, S_WARMUP, S_ON, S_COOLDOWN, E_ERROR, E_NETWORK, E_AUTHENTICATION, E_UNKNOWN_SOCKET_ERROR, \
|
||||||
|
E_NOT_CONNECTED
|
||||||
from openlp.core.lib.projector.db import ProjectorDB
|
from openlp.core.lib.projector.db import ProjectorDB
|
||||||
from openlp.core.lib.projector.pjlink1 import PJLink1
|
from openlp.core.lib.projector.pjlink1 import PJLink1
|
||||||
from openlp.core.ui.projector.editform import ProjectorEditForm
|
from openlp.core.ui.projector.editform import ProjectorEditForm
|
||||||
from openlp.core.ui.projector.sourceselectform import SourceSelectTabs, SourceSelectSingle
|
from openlp.core.ui.projector.sourceselectform import SourceSelectTabs, SourceSelectSingle
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
log.debug('projectormanager loaded')
|
||||||
|
|
||||||
|
|
||||||
# Dict for matching projector status to display icon
|
# Dict for matching projector status to display icon
|
||||||
STATUS_ICONS = {S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png',
|
STATUS_ICONS = {
|
||||||
S_CONNECTING: ':/projector/projector_item_connect.png',
|
S_NOT_CONNECTED: ':/projector/projector_item_disconnect.png',
|
||||||
S_CONNECTED: ':/projector/projector_off.png',
|
S_CONNECTING: ':/projector/projector_item_connect.png',
|
||||||
S_OFF: ':/projector/projector_off.png',
|
S_CONNECTED: ':/projector/projector_off.png',
|
||||||
S_INITIALIZE: ':/projector/projector_off.png',
|
S_OFF: ':/projector/projector_off.png',
|
||||||
S_STANDBY: ':/projector/projector_off.png',
|
S_INITIALIZE: ':/projector/projector_off.png',
|
||||||
S_WARMUP: ':/projector/projector_warmup.png',
|
S_STANDBY: ':/projector/projector_off.png',
|
||||||
S_ON: ':/projector/projector_on.png',
|
S_WARMUP: ':/projector/projector_warmup.png',
|
||||||
S_COOLDOWN: ':/projector/projector_cooldown.png',
|
S_ON: ':/projector/projector_on.png',
|
||||||
E_ERROR: ':/projector/projector_error.png',
|
S_COOLDOWN: ':/projector/projector_cooldown.png',
|
||||||
E_NETWORK: ':/projector/projector_not_connected_error.png',
|
E_ERROR: ':/projector/projector_error.png',
|
||||||
E_AUTHENTICATION: ':/projector/projector_not_connected_error.png',
|
E_NETWORK: ':/projector/projector_not_connected_error.png',
|
||||||
E_UNKNOWN_SOCKET_ERROR: ':/projector/projector_not_connected_error.png',
|
E_AUTHENTICATION: ':/projector/projector_not_connected_error.png',
|
||||||
E_NOT_CONNECTED: ':/projector/projector_not_connected_error.png'
|
E_UNKNOWN_SOCKET_ERROR: ':/projector/projector_not_connected_error.png',
|
||||||
}
|
E_NOT_CONNECTED: ':/projector/projector_not_connected_error.png'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Ui_ProjectorManager(object):
|
class UiProjectorManager(object):
|
||||||
"""
|
"""
|
||||||
UI part of the Projector Manager
|
UI part of the Projector Manager
|
||||||
"""
|
"""
|
||||||
@ -271,7 +274,7 @@ class Ui_ProjectorManager(object):
|
|||||||
self.update_icons()
|
self.update_icons()
|
||||||
|
|
||||||
|
|
||||||
class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, RegistryProperties):
|
class ProjectorManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, UiProjectorManager, RegistryProperties):
|
||||||
"""
|
"""
|
||||||
Manage the projectors.
|
Manage the projectors.
|
||||||
"""
|
"""
|
||||||
@ -720,7 +723,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
widget.setData(QtCore.Qt.UserRole, item)
|
widget.setData(QtCore.Qt.UserRole, item)
|
||||||
item.link.db_item = item.db_item
|
item.link.db_item = item.db_item
|
||||||
item.widget = widget
|
item.widget = widget
|
||||||
thread = QThread(parent=self)
|
thread = QtCore.QThread(parent=self)
|
||||||
thread.my_parent = self
|
thread.my_parent = self
|
||||||
item.moveToThread(thread)
|
item.moveToThread(thread)
|
||||||
thread.started.connect(item.link.thread_started)
|
thread.started.connect(item.link.thread_started)
|
||||||
@ -751,7 +754,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
for item in self.projector_list:
|
for item in self.projector_list:
|
||||||
log.debug('New projector list - item: ({ip}) {name}'.format(ip=item.link.ip, name=item.link.name))
|
log.debug('New projector list - item: ({ip}) {name}'.format(ip=item.link.ip, name=item.link.name))
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def add_projector_from_wizard(self, ip, opts=None):
|
def add_projector_from_wizard(self, ip, opts=None):
|
||||||
"""
|
"""
|
||||||
Add a projector from the edit dialog
|
Add a projector from the edit dialog
|
||||||
@ -763,7 +766,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
item = self.projectordb.get_projector_by_ip(ip)
|
item = self.projectordb.get_projector_by_ip(ip)
|
||||||
self.add_projector(item)
|
self.add_projector(item)
|
||||||
|
|
||||||
@pyqtSlot(object)
|
@QtCore.pyqtSlot(object)
|
||||||
def edit_projector_from_wizard(self, projector):
|
def edit_projector_from_wizard(self, projector):
|
||||||
"""
|
"""
|
||||||
Update projector from the wizard edit page
|
Update projector from the wizard edit page
|
||||||
@ -796,7 +799,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
"""
|
"""
|
||||||
return self.projector_list
|
return self.projector_list
|
||||||
|
|
||||||
@pyqtSlot(str, int, str)
|
@QtCore.pyqtSlot(str, int, str)
|
||||||
def update_status(self, ip, status=None, msg=None):
|
def update_status(self, ip, status=None, msg=None):
|
||||||
"""
|
"""
|
||||||
Update the status information/icon for selected list item
|
Update the status information/icon for selected list item
|
||||||
@ -846,7 +849,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
item.setVisible(False if hidden else True)
|
item.setVisible(False if hidden else True)
|
||||||
item.setEnabled(True if enabled else False)
|
item.setEnabled(True if enabled else False)
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def update_icons(self):
|
def update_icons(self):
|
||||||
"""
|
"""
|
||||||
Update the icons when the selected projectors change
|
Update the icons when the selected projectors change
|
||||||
@ -919,7 +922,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
self.get_toolbar_item('blank_projector_multiple', hidden=False, enabled=True)
|
self.get_toolbar_item('blank_projector_multiple', hidden=False, enabled=True)
|
||||||
self.get_toolbar_item('show_projector_multiple', hidden=False, enabled=True)
|
self.get_toolbar_item('show_projector_multiple', hidden=False, enabled=True)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def authentication_error(self, name):
|
def authentication_error(self, name):
|
||||||
"""
|
"""
|
||||||
Display warning dialog when attempting to connect with invalid pin
|
Display warning dialog when attempting to connect with invalid pin
|
||||||
@ -933,7 +936,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
'<br /><br />Please verify your PIN setting '
|
'<br /><br />Please verify your PIN setting '
|
||||||
'for projector item "{name}"'.format(name=name))
|
'for projector item "{name}"'.format(name=name))
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def no_authentication_error(self, name):
|
def no_authentication_error(self, name):
|
||||||
"""
|
"""
|
||||||
Display warning dialog when pin saved for item but projector does not
|
Display warning dialog when pin saved for item but projector does not
|
||||||
@ -949,7 +952,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager,
|
|||||||
'for projector item "{name}"'.format(name=name))
|
'for projector item "{name}"'.format(name=name))
|
||||||
|
|
||||||
|
|
||||||
class ProjectorItem(QObject):
|
class ProjectorItem(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
Class for the projector list widget item.
|
Class for the projector list widget item.
|
||||||
NOTE: Actual PJLink class instance should be saved as self.link
|
NOTE: Actual PJLink class instance should be saved as self.link
|
||||||
|
@ -25,19 +25,17 @@
|
|||||||
Provides the dialog window for selecting video source for projector.
|
Provides the dialog window for selecting video source for projector.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
log.debug('editform loaded')
|
|
||||||
|
|
||||||
from PyQt5 import QtCore, QtWidgets
|
from PyQt5 import QtCore, QtWidgets
|
||||||
from PyQt5.QtCore import pyqtSlot, QSize
|
|
||||||
from PyQt5.QtWidgets import QDialog, QButtonGroup, QDialogButtonBox, QFormLayout, QLineEdit, QRadioButton, \
|
|
||||||
QStyle, QStylePainter, QStyleOptionTab, QTabBar, QTabWidget, QVBoxLayout, QWidget
|
|
||||||
|
|
||||||
from openlp.core.common import translate, is_macosx
|
from openlp.core.common import translate, is_macosx
|
||||||
from openlp.core.lib import build_icon
|
from openlp.core.lib import build_icon
|
||||||
from openlp.core.lib.projector.db import ProjectorSource
|
from openlp.core.lib.projector.db import ProjectorSource
|
||||||
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES, PJLINK_DEFAULT_CODES
|
from openlp.core.lib.projector.constants import PJLINK_DEFAULT_SOURCES, PJLINK_DEFAULT_CODES
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
log.debug('editform loaded')
|
||||||
|
|
||||||
|
|
||||||
def source_group(inputs, source_text):
|
def source_group(inputs, source_text):
|
||||||
"""
|
"""
|
||||||
@ -78,7 +76,7 @@ def source_group(inputs, source_text):
|
|||||||
return keydict
|
return keydict
|
||||||
|
|
||||||
|
|
||||||
def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
|
def build_tab(group, source_key, default, projector, projectordb, edit=False):
|
||||||
"""
|
"""
|
||||||
Create the radio button page for a tab.
|
Create the radio button page for a tab.
|
||||||
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
|
Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
|
||||||
@ -104,8 +102,8 @@ def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
|
|||||||
:param edit: If we're editing the source text
|
:param edit: If we're editing the source text
|
||||||
"""
|
"""
|
||||||
buttonchecked = False
|
buttonchecked = False
|
||||||
widget = QWidget()
|
widget = QtWidgets.QWidget()
|
||||||
layout = QFormLayout() if edit else QVBoxLayout()
|
layout = QtWidgets.QFormLayout() if edit else QtWidgets.QVBoxLayout()
|
||||||
layout.setSpacing(10)
|
layout.setSpacing(10)
|
||||||
widget.setLayout(layout)
|
widget.setLayout(layout)
|
||||||
tempkey = list(source_key.keys())[0] # Should only be 1 key
|
tempkey = list(source_key.keys())[0] # Should only be 1 key
|
||||||
@ -114,7 +112,7 @@ def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
|
|||||||
button_count = len(sourcelist)
|
button_count = len(sourcelist)
|
||||||
if edit:
|
if edit:
|
||||||
for key in sourcelist:
|
for key in sourcelist:
|
||||||
item = QLineEdit()
|
item = QtWidgets.QLineEdit()
|
||||||
item.setObjectName('source_key_{key}'.format(key=key))
|
item.setObjectName('source_key_{key}'.format(key=key))
|
||||||
source_item = projectordb.get_source_by_code(code=key, projector_id=projector.db_item.id)
|
source_item = projectordb.get_source_by_code(code=key, projector_id=projector.db_item.id)
|
||||||
if source_item is None:
|
if source_item is None:
|
||||||
@ -130,7 +128,7 @@ def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
|
|||||||
text = source_key[tempkey][key]
|
text = source_key[tempkey][key]
|
||||||
else:
|
else:
|
||||||
text = source_item.text
|
text = source_item.text
|
||||||
itemwidget = QRadioButton(text)
|
itemwidget = QtWidgets.QRadioButton(text)
|
||||||
itemwidget.setAutoExclusive(True)
|
itemwidget.setAutoExclusive(True)
|
||||||
if default == key:
|
if default == key:
|
||||||
itemwidget.setChecked(True)
|
itemwidget.setChecked(True)
|
||||||
@ -148,23 +146,23 @@ def set_button_tooltip(bar):
|
|||||||
:param bar: QDialogButtonBar instance to update
|
:param bar: QDialogButtonBar instance to update
|
||||||
"""
|
"""
|
||||||
for button in bar.buttons():
|
for button in bar.buttons():
|
||||||
if bar.standardButton(button) == QDialogButtonBox.Cancel:
|
if bar.standardButton(button) == QtWidgets.QDialogButtonBox.Cancel:
|
||||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||||
'Ignoring current changes and return to OpenLP'))
|
'Ignoring current changes and return to OpenLP'))
|
||||||
elif bar.standardButton(button) == QDialogButtonBox.Reset:
|
elif bar.standardButton(button) == QtWidgets.QDialogButtonBox.Reset:
|
||||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||||
'Delete all user-defined text and revert to PJLink default text'))
|
'Delete all user-defined text and revert to PJLink default text'))
|
||||||
elif bar.standardButton(button) == QDialogButtonBox.Discard:
|
elif bar.standardButton(button) == QtWidgets.QDialogButtonBox.Discard:
|
||||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||||
'Discard changes and reset to previous user-defined text'))
|
'Discard changes and reset to previous user-defined text'))
|
||||||
elif bar.standardButton(button) == QDialogButtonBox.Ok:
|
elif bar.standardButton(button) == QtWidgets.QDialogButtonBox.Ok:
|
||||||
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
button.setToolTip(translate('OpenLP.SourceSelectForm',
|
||||||
'Save changes and return to OpenLP'))
|
'Save changes and return to OpenLP'))
|
||||||
else:
|
else:
|
||||||
log.debug('No tooltip for button {text}'.format(text=button.text()))
|
log.debug('No tooltip for button {text}'.format(text=button.text()))
|
||||||
|
|
||||||
|
|
||||||
class FingerTabBarWidget(QTabBar):
|
class FingerTabBarWidget(QtWidgets.QTabBar):
|
||||||
"""
|
"""
|
||||||
Realign west -orientation tabs to left-right text rather than south-north text
|
Realign west -orientation tabs to left-right text rather than south-north text
|
||||||
Borrowed from
|
Borrowed from
|
||||||
@ -177,8 +175,8 @@ class FingerTabBarWidget(QTabBar):
|
|||||||
:param width: Remove default width parameter in kwargs
|
:param width: Remove default width parameter in kwargs
|
||||||
:param height: Remove default height parameter in kwargs
|
:param height: Remove default height parameter in kwargs
|
||||||
"""
|
"""
|
||||||
self.tabSize = QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
|
self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
|
||||||
QTabBar.__init__(self, parent, *args, **kwargs)
|
QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
"""
|
"""
|
||||||
@ -186,14 +184,14 @@ class FingerTabBarWidget(QTabBar):
|
|||||||
|
|
||||||
:param event: Repaint event signal
|
:param event: Repaint event signal
|
||||||
"""
|
"""
|
||||||
painter = QStylePainter(self)
|
painter = QtWidgets.QStylePainter(self)
|
||||||
option = QStyleOptionTab()
|
option = QtWidgets.QStyleOptionTab()
|
||||||
|
|
||||||
for index in range(self.count()):
|
for index in range(self.count()):
|
||||||
self.initStyleOption(option, index)
|
self.initStyleOption(option, index)
|
||||||
tabRect = self.tabRect(index)
|
tabRect = self.tabRect(index)
|
||||||
tabRect.moveLeft(10)
|
tabRect.moveLeft(10)
|
||||||
painter.drawControl(QStyle.CE_TabBarTabShape, option)
|
painter.drawControl(QtWidgets.QStyle.CE_TabBarTabShape, option)
|
||||||
painter.drawText(tabRect, QtCore.Qt.AlignVCenter |
|
painter.drawText(tabRect, QtCore.Qt.AlignVCenter |
|
||||||
QtCore.Qt.TextDontClip,
|
QtCore.Qt.TextDontClip,
|
||||||
self.tabText(index))
|
self.tabText(index))
|
||||||
@ -209,7 +207,7 @@ class FingerTabBarWidget(QTabBar):
|
|||||||
return self.tabSize
|
return self.tabSize
|
||||||
|
|
||||||
|
|
||||||
class FingerTabWidget(QTabWidget):
|
class FingerTabWidget(QtWidgets.QTabWidget):
|
||||||
"""
|
"""
|
||||||
A QTabWidget equivalent which uses our FingerTabBarWidget
|
A QTabWidget equivalent which uses our FingerTabBarWidget
|
||||||
|
|
||||||
@ -220,11 +218,11 @@ class FingerTabWidget(QTabWidget):
|
|||||||
"""
|
"""
|
||||||
Initialize FingerTabWidget instance
|
Initialize FingerTabWidget instance
|
||||||
"""
|
"""
|
||||||
QTabWidget.__init__(self, parent, *args)
|
QtWidgets.QTabWidget.__init__(self, parent, *args)
|
||||||
self.setTabBar(FingerTabBarWidget(self))
|
self.setTabBar(FingerTabBarWidget(self))
|
||||||
|
|
||||||
|
|
||||||
class SourceSelectTabs(QDialog):
|
class SourceSelectTabs(QtWidgets.QDialog):
|
||||||
"""
|
"""
|
||||||
Class for handling selecting the source for the projector to use.
|
Class for handling selecting the source for the projector to use.
|
||||||
Uses tabbed interface.
|
Uses tabbed interface.
|
||||||
@ -248,18 +246,18 @@ class SourceSelectTabs(QDialog):
|
|||||||
self.setObjectName('source_select_tabs')
|
self.setObjectName('source_select_tabs')
|
||||||
self.setWindowIcon(build_icon(':/icon/openlp-log-32x32.png'))
|
self.setWindowIcon(build_icon(':/icon/openlp-log-32x32.png'))
|
||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
self.layout = QVBoxLayout()
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
self.layout.setObjectName('source_select_tabs_layout')
|
self.layout.setObjectName('source_select_tabs_layout')
|
||||||
if is_macosx():
|
if is_macosx():
|
||||||
self.tabwidget = QTabWidget(self)
|
self.tabwidget = QtWidgets.QTabWidget(self)
|
||||||
else:
|
else:
|
||||||
self.tabwidget = FingerTabWidget(self)
|
self.tabwidget = FingerTabWidget(self)
|
||||||
self.tabwidget.setObjectName('source_select_tabs_tabwidget')
|
self.tabwidget.setObjectName('source_select_tabs_tabwidget')
|
||||||
self.tabwidget.setUsesScrollButtons(False)
|
self.tabwidget.setUsesScrollButtons(False)
|
||||||
if is_macosx():
|
if is_macosx():
|
||||||
self.tabwidget.setTabPosition(QTabWidget.North)
|
self.tabwidget.setTabPosition(QtWidgets.QTabWidget.North)
|
||||||
else:
|
else:
|
||||||
self.tabwidget.setTabPosition(QTabWidget.West)
|
self.tabwidget.setTabPosition(QtWidgets.QTabWidget.West)
|
||||||
self.layout.addWidget(self.tabwidget)
|
self.layout.addWidget(self.tabwidget)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
@ -273,12 +271,12 @@ class SourceSelectTabs(QDialog):
|
|||||||
self.source_text = self.projectordb.get_source_list(projector=projector)
|
self.source_text = self.projectordb.get_source_list(projector=projector)
|
||||||
self.source_group = source_group(projector.source_available, self.source_text)
|
self.source_group = source_group(projector.source_available, self.source_text)
|
||||||
# self.source_group = {'4': {'41': 'Storage 1'}, '5': {"51": 'Network 1'}}
|
# self.source_group = {'4': {'41': 'Storage 1'}, '5': {"51": 'Network 1'}}
|
||||||
self.button_group = [] if self.edit else QButtonGroup()
|
self.button_group = [] if self.edit else QtWidgets.QButtonGroup()
|
||||||
keys = list(self.source_group.keys())
|
keys = list(self.source_group.keys())
|
||||||
keys.sort()
|
keys.sort()
|
||||||
if self.edit:
|
if self.edit:
|
||||||
for key in keys:
|
for key in keys:
|
||||||
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,
|
(tab, button_count, buttonchecked) = build_tab(group=self.button_group,
|
||||||
source_key={key: self.source_group[key]},
|
source_key={key: self.source_group[key]},
|
||||||
default=self.projector.source,
|
default=self.projector.source,
|
||||||
projector=self.projector,
|
projector=self.projector,
|
||||||
@ -287,13 +285,13 @@ class SourceSelectTabs(QDialog):
|
|||||||
thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
|
thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
|
||||||
if buttonchecked:
|
if buttonchecked:
|
||||||
self.tabwidget.setCurrentIndex(thistab)
|
self.tabwidget.setCurrentIndex(thistab)
|
||||||
self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset |
|
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset |
|
||||||
QtWidgets.QDialogButtonBox.Discard |
|
QtWidgets.QDialogButtonBox.Discard |
|
||||||
QtWidgets.QDialogButtonBox.Ok |
|
QtWidgets.QDialogButtonBox.Ok |
|
||||||
QtWidgets.QDialogButtonBox.Cancel)
|
QtWidgets.QDialogButtonBox.Cancel)
|
||||||
else:
|
else:
|
||||||
for key in keys:
|
for key in keys:
|
||||||
(tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,
|
(tab, button_count, buttonchecked) = build_tab(group=self.button_group,
|
||||||
source_key={key: self.source_group[key]},
|
source_key={key: self.source_group[key]},
|
||||||
default=self.projector.source,
|
default=self.projector.source,
|
||||||
projector=self.projector,
|
projector=self.projector,
|
||||||
@ -302,15 +300,15 @@ class SourceSelectTabs(QDialog):
|
|||||||
thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
|
thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key])
|
||||||
if buttonchecked:
|
if buttonchecked:
|
||||||
self.tabwidget.setCurrentIndex(thistab)
|
self.tabwidget.setCurrentIndex(thistab)
|
||||||
self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
|
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
|
||||||
QtWidgets.QDialogButtonBox.Cancel)
|
QtWidgets.QDialogButtonBox.Cancel)
|
||||||
self.button_box.clicked.connect(self.button_clicked)
|
self.button_box.clicked.connect(self.button_clicked)
|
||||||
self.layout.addWidget(self.button_box)
|
self.layout.addWidget(self.button_box)
|
||||||
set_button_tooltip(self.button_box)
|
set_button_tooltip(self.button_box)
|
||||||
selected = super(SourceSelectTabs, self).exec()
|
selected = super(SourceSelectTabs, self).exec()
|
||||||
return selected
|
return selected
|
||||||
|
|
||||||
@pyqtSlot(object)
|
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
|
||||||
def button_clicked(self, button):
|
def button_clicked(self, button):
|
||||||
"""
|
"""
|
||||||
Checks which button was clicked
|
Checks which button was clicked
|
||||||
@ -333,6 +331,9 @@ class SourceSelectTabs(QDialog):
|
|||||||
return 100
|
return 100
|
||||||
|
|
||||||
def delete_sources(self):
|
def delete_sources(self):
|
||||||
|
"""
|
||||||
|
Delete the sources for this projector
|
||||||
|
"""
|
||||||
msg = QtWidgets.QMessageBox()
|
msg = QtWidgets.QMessageBox()
|
||||||
msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
|
msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector'))
|
||||||
msg.setInformativeText(translate('OpenLP.SourceSelectForm',
|
msg.setInformativeText(translate('OpenLP.SourceSelectForm',
|
||||||
@ -376,7 +377,7 @@ class SourceSelectTabs(QDialog):
|
|||||||
self.done(selected)
|
self.done(selected)
|
||||||
|
|
||||||
|
|
||||||
class SourceSelectSingle(QDialog):
|
class SourceSelectSingle(QtWidgets.QDialog):
|
||||||
"""
|
"""
|
||||||
Class for handling selecting the source for the projector to use.
|
Class for handling selecting the source for the projector to use.
|
||||||
Uses single dialog interface.
|
Uses single dialog interface.
|
||||||
@ -407,12 +408,12 @@ class SourceSelectSingle(QDialog):
|
|||||||
:param projector: Projector instance to build source list from
|
:param projector: Projector instance to build source list from
|
||||||
"""
|
"""
|
||||||
self.projector = projector
|
self.projector = projector
|
||||||
self.layout = QFormLayout() if self.edit else QVBoxLayout()
|
self.layout = QtWidgets.QFormLayout() if self.edit else QtWidgets.QVBoxLayout()
|
||||||
self.layout.setObjectName('source_select_tabs_layout')
|
self.layout.setObjectName('source_select_tabs_layout')
|
||||||
self.layout.setSpacing(10)
|
self.layout.setSpacing(10)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.layout)
|
||||||
self.setMinimumWidth(350)
|
self.setMinimumWidth(350)
|
||||||
self.button_group = [] if self.edit else QButtonGroup()
|
self.button_group = [] if self.edit else QtWidgets.QButtonGroup()
|
||||||
self.source_text = self.projectordb.get_source_list(projector=projector)
|
self.source_text = self.projectordb.get_source_list(projector=projector)
|
||||||
keys = list(self.source_text.keys())
|
keys = list(self.source_text.keys())
|
||||||
keys.sort()
|
keys.sort()
|
||||||
@ -420,7 +421,7 @@ class SourceSelectSingle(QDialog):
|
|||||||
button_list = []
|
button_list = []
|
||||||
if self.edit:
|
if self.edit:
|
||||||
for key in keys:
|
for key in keys:
|
||||||
item = QLineEdit()
|
item = QtWidgets.QLineEdit()
|
||||||
item.setObjectName('source_key_{key}'.format(key=key))
|
item.setObjectName('source_key_{key}'.format(key=key))
|
||||||
source_item = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
|
source_item = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
|
||||||
if source_item is None:
|
if source_item is None:
|
||||||
@ -430,10 +431,10 @@ class SourceSelectSingle(QDialog):
|
|||||||
item.setText(source_item.text)
|
item.setText(source_item.text)
|
||||||
self.layout.addRow(PJLINK_DEFAULT_CODES[key], item)
|
self.layout.addRow(PJLINK_DEFAULT_CODES[key], item)
|
||||||
self.button_group.append(item)
|
self.button_group.append(item)
|
||||||
self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset |
|
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset |
|
||||||
QtWidgets.QDialogButtonBox.Discard |
|
QtWidgets.QDialogButtonBox.Discard |
|
||||||
QtWidgets.QDialogButtonBox.Ok |
|
QtWidgets.QDialogButtonBox.Ok |
|
||||||
QtWidgets.QDialogButtonBox.Cancel)
|
QtWidgets.QDialogButtonBox.Cancel)
|
||||||
else:
|
else:
|
||||||
for key in keys:
|
for key in keys:
|
||||||
source_text = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
|
source_text = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id)
|
||||||
@ -443,8 +444,8 @@ class SourceSelectSingle(QDialog):
|
|||||||
self.layout.addWidget(button)
|
self.layout.addWidget(button)
|
||||||
self.button_group.addButton(button, int(key))
|
self.button_group.addButton(button, int(key))
|
||||||
button_list.append(key)
|
button_list.append(key)
|
||||||
self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
|
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |
|
||||||
QtWidgets.QDialogButtonBox.Cancel)
|
QtWidgets.QDialogButtonBox.Cancel)
|
||||||
self.button_box.clicked.connect(self.button_clicked)
|
self.button_box.clicked.connect(self.button_clicked)
|
||||||
self.layout.addWidget(self.button_box)
|
self.layout.addWidget(self.button_box)
|
||||||
self.setMinimumHeight(key_count * 25)
|
self.setMinimumHeight(key_count * 25)
|
||||||
@ -452,7 +453,7 @@ class SourceSelectSingle(QDialog):
|
|||||||
selected = super(SourceSelectSingle, self).exec()
|
selected = super(SourceSelectSingle, self).exec()
|
||||||
return selected
|
return selected
|
||||||
|
|
||||||
@pyqtSlot(object)
|
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
|
||||||
def button_clicked(self, button):
|
def button_clicked(self, button):
|
||||||
"""
|
"""
|
||||||
Checks which button was clicked
|
Checks which button was clicked
|
||||||
@ -488,7 +489,7 @@ class SourceSelectSingle(QDialog):
|
|||||||
self.projectordb.delete_all_objects(ProjectorSource, ProjectorSource.projector_id == self.projector.db_item.id)
|
self.projectordb.delete_all_objects(ProjectorSource, ProjectorSource.projector_id == self.projector.db_item.id)
|
||||||
self.done(100)
|
self.done(100)
|
||||||
|
|
||||||
@pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def accept_me(self):
|
def accept_me(self):
|
||||||
"""
|
"""
|
||||||
Slot to accept 'OK' button
|
Slot to accept 'OK' button
|
||||||
|
@ -26,7 +26,7 @@ class and methods.
|
|||||||
import os
|
import os
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from openlp.core.common import Registry, Settings
|
from openlp.core.common import Registry
|
||||||
from openlp.core.lib.projector.db import Projector, ProjectorDB
|
from openlp.core.lib.projector.db import Projector, ProjectorDB
|
||||||
from openlp.core.ui import ProjectorEditForm
|
from openlp.core.ui import ProjectorEditForm
|
||||||
|
|
||||||
@ -63,43 +63,41 @@ class TestProjectorEditForm(TestCase, TestMixin):
|
|||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.projectordb.session.close()
|
self.projectordb.session.close()
|
||||||
del(self.projector_form)
|
del self.projector_form
|
||||||
self.destroy_settings()
|
self.destroy_settings()
|
||||||
|
|
||||||
def test_edit_form_add_projector(self):
|
@patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
|
||||||
|
def test_edit_form_add_projector(self, mocked_exec):
|
||||||
"""
|
"""
|
||||||
Test projector edit form with no parameters creates a new entry.
|
Test projector edit form with no parameters creates a new entry.
|
||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
# GIVEN: Mocked setup
|
# GIVEN: Mocked setup
|
||||||
with patch('openlp.core.ui.projector.editform.QDialog.exec'):
|
# WHEN: Calling edit form with no parameters
|
||||||
|
self.projector_form.exec()
|
||||||
|
item = self.projector_form.projector
|
||||||
|
|
||||||
# WHEN: Calling edit form with no parameters
|
# THEN: Should be creating a new instance
|
||||||
self.projector_form.exec()
|
self.assertTrue(self.projector_form.new_projector,
|
||||||
item = self.projector_form.projector
|
'Projector edit form should be marked as a new entry')
|
||||||
|
self.assertTrue((item.ip is None and item.name is None),
|
||||||
|
'Projector edit form should have a new Projector() instance to edit')
|
||||||
|
|
||||||
# THEN: Should be creating a new instance
|
@patch('openlp.core.ui.projector.editform.QtWidgets.QDialog.exec')
|
||||||
self.assertTrue(self.projector_form.new_projector,
|
def test_edit_form_edit_projector(self, mocked_exec):
|
||||||
'Projector edit form should be marked as a new entry')
|
|
||||||
self.assertTrue((item.ip is None and item.name is None),
|
|
||||||
'Projector edit form should have a new Projector() instance to edit')
|
|
||||||
|
|
||||||
def test_edit_form_edit_projector(self):
|
|
||||||
"""
|
"""
|
||||||
Test projector edit form with existing projector entry
|
Test projector edit form with existing projector entry
|
||||||
|
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
# GIVEN: Mocked setup
|
# GIVEN: Mocked setup
|
||||||
with patch('openlp.core.ui.projector.editform.QDialog.exec'):
|
# WHEN: Calling edit form with existing projector instance
|
||||||
|
self.projector_form.exec(projector=Projector(**TEST1_DATA))
|
||||||
|
item = self.projector_form.projector
|
||||||
|
|
||||||
# WHEN: Calling edit form with existing projector instance
|
# THEN: Should be editing an existing entry
|
||||||
self.projector_form.exec(projector=Projector(**TEST1_DATA))
|
self.assertFalse(self.projector_form.new_projector,
|
||||||
item = self.projector_form.projector
|
'Projector edit form should be marked as existing entry')
|
||||||
|
self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']),
|
||||||
# THEN: Should be editing an existing entry
|
'Projector edit form should have TEST1_DATA() instance to edit')
|
||||||
self.assertFalse(self.projector_form.new_projector,
|
|
||||||
'Projector edit form should be marked as existing entry')
|
|
||||||
self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']),
|
|
||||||
'Projector edit form should have TEST1_DATA() instance to edit')
|
|
||||||
|
Loading…
Reference in New Issue
Block a user