Replace QR code with generator and update tests

This commit is contained in:
Tim 2022-02-10 11:06:34 +00:00
parent d9eec25960
commit c3f00bf288
No known key found for this signature in database
GPG Key ID: E95CE08DB3F50537
3 changed files with 23 additions and 11 deletions

View File

@ -21,6 +21,11 @@
"""
The :mod:`~openlp.core.api.tab` module contains the settings tab for the API
"""
import PIL.ImageQt
import PIL.Image
import qrcode
from time import sleep
from PyQt5 import QtCore, QtGui, QtWidgets
@ -213,9 +218,7 @@ class ApiTab(SettingsTab):
'Show thumbnails of non-text slides in remote and stage view.'))
self.app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Remote App'))
self.app_qr_description_label.setText(
translate('RemotePlugin.RemoteTab',
'Scan the QR code or click <a href="{qr}">download</a> to download an app for your mobile device'
).format(qr='https://openlp.org/#mobile-app-downloads'))
translate('RemotePlugin.RemoteTab', 'Scan the QR code to open the remote view on your mobile device'))
self.user_login_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'User Authentication'))
self.web_remote_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Web Remote'))
self.check_version_button.setText(translate('RemotePlugin.RemoteTab', 'Check for Updates'))
@ -268,14 +271,15 @@ class ApiTab(SettingsTab):
Update the display based on the data input on the screen
"""
ip_address = self.get_ip_address(self.address_edit.text())
http_url = 'http://{url}:{text}/'.format(url=ip_address, text=self.port_spin_box.text())
self.remote_url.setText('<a href="{url}">{url}</a>'.format(url=http_url))
http_url_temp = http_url + 'stage'
self.stage_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
http_url_temp = http_url + 'chords'
self.chords_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
http_url_temp = http_url + 'main'
self.live_url.setText('<a href="{url}">{url}</a>'.format(url=http_url_temp))
http_url = f'http://{ip_address}:{self.port_spin_box.text()}/'
self.remote_url.setText(f'<a href="{http_url}">{http_url}</a>')
self.stage_url.setText(f'<a href="{http_url}stage">{http_url}stage</a>')
self.chords_url.setText(f'<a href="{http_url}chords">{http_url}chords</a>')
self.live_url.setText(f'<a href="{http_url}main">{http_url}main</a>')
img = qrcode.make(http_url)
img = PIL.ImageQt.ImageQt(img)
image = QtGui.QPixmap.fromImage(img)
self.app_qr_code_label.setPixmap(image)
def get_server_states(self):
"""

View File

@ -106,6 +106,7 @@ using a computer and a data projector.""",
'flask-cors',
'lxml',
'Mako',
"pillow",
'pymediainfo >= 2.2',
'pyobjc; platform_system=="Darwin"',
'pyobjc-framework-Cocoa; platform_system=="Darwin"',
@ -115,6 +116,7 @@ using a computer and a data projector.""",
'python-vlc',
'pywin32; platform_system=="Windows"',
'QtAwesome',
"qrcode",
'requests',
'SQLAlchemy >= 0.5',
'waitress',

View File

@ -21,6 +21,7 @@
"""
This module contains tests for the lib submodule of the Remotes plugin.
"""
import hashlib
import pytest
import re
@ -94,6 +95,11 @@ def test_set_urls(api_tab):
assert api_tab.live_url.text() == \
"<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>", \
'The return value should be a fully formed main link'
assert api_tab.chords_url.text() == \
"<a href=\"http://192.168.1.1:4316/chords\">http://192.168.1.1:4316/chords</a>", \
'The return value should be a fully formed chords link'
assert hashlib.sha256(api_tab.app_qr_code_label.text().encode()).hexdigest() \
== 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'Incorrect QR Code generated'
def test_address_revert_button_clicked(api_tab, settings):