Merge branch 'qr_code' into 'master'

Replace QR code with generator and update tests

See merge request openlp/openlp!416
This commit is contained in:
Tim Bentley 2022-02-11 14:33:12 +00:00
commit 72fb6347bb
4 changed files with 24 additions and 12 deletions

View File

@ -30,7 +30,7 @@ install:
# Update pip # Update pip
- python -m pip install --upgrade pip - python -m pip install --upgrade pip
# Install generic dependencies from pypi # Install generic dependencies from pypi
- python -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock psycopg2-binary websockets waitress six webob requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc zeroconf flask-cors pytest-qt pyenchant pysword - python -m pip install sqlalchemy alembic appdirs chardet beautifulsoup4 lxml Mako mysql-connector-python pytest mock psycopg2-binary websockets waitress six webob requests QtAwesome PyQt5 PyQtWebEngine pymediainfo PyMuPDF QDarkStyle python-vlc zeroconf flask-cors pytest-qt pyenchant pysword qrcode pillow
# Install Windows only dependencies # Install Windows only dependencies
- cmd: python -m pip install pyodbc pypiwin32 - cmd: python -m pip install pyodbc pypiwin32
# Mac only dependencies # Mac only dependencies

View File

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

View File

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

View File

@ -21,6 +21,7 @@
""" """
This module contains tests for the lib submodule of the Remotes plugin. This module contains tests for the lib submodule of the Remotes plugin.
""" """
import hashlib
import pytest import pytest
import re import re
@ -94,6 +95,11 @@ def test_set_urls(api_tab):
assert api_tab.live_url.text() == \ assert api_tab.live_url.text() == \
"<a href=\"http://192.168.1.1:4316/main\">http://192.168.1.1:4316/main</a>", \ "<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' '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): def test_address_revert_button_clicked(api_tab, settings):