From 7af1ca1d497b6f4447fc10c3936e0308469a58c6 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Fri, 6 Nov 2015 19:49:40 -0500 Subject: [PATCH] Migrate to PyQt5 --- documentation/openlp.1 | 2 +- openlp/core/__init__.py | 49 ++-- openlp/core/common/__init__.py | 15 +- openlp/core/common/historycombobox.py | 8 +- openlp/core/common/settings.py | 6 +- openlp/core/lib/__init__.py | 7 +- openlp/core/lib/colorbutton.py | 6 +- openlp/core/lib/dockwidget.py | 4 +- openlp/core/lib/filedialog.py | 10 +- openlp/core/lib/htmlbuilder.py | 2 +- openlp/core/lib/imagemanager.py | 3 +- openlp/core/lib/listwidgetwithdnd.py | 8 +- openlp/core/lib/mediamanageritem.py | 68 +++-- openlp/core/lib/plugin.py | 2 +- openlp/core/lib/projector/pjlink1.py | 4 +- openlp/core/lib/renderer.py | 6 +- openlp/core/lib/screen.py | 4 +- openlp/core/lib/searchedit.py | 24 +- openlp/core/lib/serviceitem.py | 2 +- openlp/core/lib/settingstab.py | 20 +- openlp/core/lib/spelltextedit.py | 16 +- openlp/core/lib/toolbar.py | 4 +- openlp/core/lib/treewidgetwithdnd.py | 10 +- openlp/core/lib/ui.py | 58 ++-- openlp/core/ui/__init__.py | 6 +- openlp/core/ui/aboutdialog.py | 30 +- openlp/core/ui/aboutform.py | 4 +- openlp/core/ui/advancedtab.py | 202 +++++++------- openlp/core/ui/exceptiondialog.py | 20 +- openlp/core/ui/exceptionform.py | 33 +-- openlp/core/ui/filerenamedialog.py | 8 +- openlp/core/ui/filerenameform.py | 8 +- openlp/core/ui/firsttimeform.py | 38 +-- openlp/core/ui/firsttimelanguagedialog.py | 14 +- openlp/core/ui/firsttimelanguageform.py | 12 +- openlp/core/ui/firsttimewizard.py | 120 ++++---- openlp/core/ui/formattingtagdialog.py | 48 ++-- openlp/core/ui/formattingtagform.py | 48 ++-- openlp/core/ui/generaltab.py | 82 +++--- openlp/core/ui/listpreviewwidget.py | 18 +- openlp/core/ui/maindisplay.py | 111 +++----- openlp/core/ui/mainwindow.py | 230 +++++++-------- openlp/core/ui/media/__init__.py | 2 +- openlp/core/ui/media/mediacontroller.py | 26 +- openlp/core/ui/media/playertab.py | 32 +-- .../{phononplayer.py => systemplayer.py} | 149 +++++----- openlp/core/ui/media/vlcplayer.py | 8 +- openlp/core/ui/media/webkitplayer.py | 4 +- openlp/core/ui/plugindialog.py | 24 +- openlp/core/ui/pluginform.py | 6 +- openlp/core/ui/printservicedialog.py | 42 +-- openlp/core/ui/printserviceform.py | 10 +- openlp/core/ui/projector/editform.py | 79 +++--- openlp/core/ui/projector/manager.py | 98 +++---- openlp/core/ui/projector/sourceselectform.py | 48 ++-- openlp/core/ui/projector/tab.py | 20 +- openlp/core/ui/serviceitemeditdialog.py | 8 +- openlp/core/ui/serviceitemeditform.py | 7 +- openlp/core/ui/servicemanager.py | 156 ++++++----- openlp/core/ui/servicenoteform.py | 10 +- openlp/core/ui/settingsdialog.py | 10 +- openlp/core/ui/settingsform.py | 14 +- openlp/core/ui/shortcutlistdialog.py | 28 +- openlp/core/ui/shortcutlistform.py | 27 +- openlp/core/ui/slidecontroller.py | 119 ++++---- openlp/core/ui/splashscreen.py | 4 +- openlp/core/ui/starttimedialog.py | 34 +-- openlp/core/ui/starttimeform.py | 10 +- openlp/core/ui/themeform.py | 27 +- openlp/core/ui/themelayoutdialog.py | 18 +- openlp/core/ui/themelayoutform.py | 8 +- openlp/core/ui/thememanager.py | 68 ++--- openlp/core/ui/themestab.py | 36 +-- openlp/core/ui/themewizard.py | 263 +++++++++--------- openlp/core/ui/wizard.py | 51 ++-- openlp/core/utils/__init__.py | 4 +- openlp/core/utils/actions.py | 5 +- openlp/core/utils/languagemanager.py | 11 +- openlp/plugins/alerts/alertsplugin.py | 5 +- openlp/plugins/alerts/forms/__init__.py | 8 +- openlp/plugins/alerts/forms/alertdialog.py | 22 +- openlp/plugins/alerts/forms/alertform.py | 49 ++-- openlp/plugins/alerts/lib/alertsmanager.py | 6 +- openlp/plugins/alerts/lib/alertstab.py | 30 +- openlp/plugins/bibles/bibleplugin.py | 10 +- openlp/plugins/bibles/forms/__init__.py | 8 +- .../plugins/bibles/forms/bibleimportform.py | 182 ++++++------ .../plugins/bibles/forms/bibleupgradeform.py | 46 +-- openlp/plugins/bibles/forms/booknamedialog.py | 30 +- openlp/plugins/bibles/forms/booknameform.py | 8 +- .../plugins/bibles/forms/editbibledialog.py | 50 ++-- openlp/plugins/bibles/forms/editbibleform.py | 8 +- openlp/plugins/bibles/forms/languagedialog.py | 18 +- openlp/plugins/bibles/forms/languageform.py | 6 +- openlp/plugins/bibles/lib/biblestab.py | 60 ++-- openlp/plugins/bibles/lib/db.py | 9 +- openlp/plugins/bibles/lib/mediaitem.py | 69 ++--- .../plugins/custom/forms/editcustomdialog.py | 36 +-- openlp/plugins/custom/forms/editcustomform.py | 12 +- .../custom/forms/editcustomslidedialog.py | 4 +- .../custom/forms/editcustomslideform.py | 4 +- openlp/plugins/custom/lib/customtab.py | 10 +- openlp/plugins/custom/lib/mediaitem.py | 34 ++- openlp/plugins/images/forms/__init__.py | 8 +- openlp/plugins/images/forms/addgroupdialog.py | 14 +- openlp/plugins/images/forms/addgroupform.py | 10 +- .../plugins/images/forms/choosegroupdialog.py | 34 +-- .../plugins/images/forms/choosegroupform.py | 8 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/imagetab.py | 14 +- openlp/plugins/images/lib/mediaitem.py | 39 +-- .../media/forms/mediaclipselectordialog.py | 82 +++--- .../media/forms/mediaclipselectorform.py | 22 +- openlp/plugins/media/lib/mediaitem.py | 29 +- openlp/plugins/media/lib/mediatab.py | 10 +- openlp/plugins/media/mediaplugin.py | 2 +- .../presentations/lib/impresscontroller.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 19 +- .../presentations/lib/messagelistener.py | 2 +- .../presentations/lib/pptviewlib/ppttest.py | 86 +++--- .../lib/presentationcontroller.py | 2 +- .../presentations/lib/presentationtab.py | 42 +-- .../presentations/presentationplugin.py | 2 +- openlp/plugins/remotes/lib/httprouter.py | 21 +- openlp/plugins/remotes/lib/httpserver.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 78 +++--- openlp/plugins/remotes/remoteplugin.py | 19 +- openlp/plugins/songs/forms/__init__.py | 6 +- openlp/plugins/songs/forms/authorsdialog.py | 18 +- openlp/plugins/songs/forms/authorsform.py | 14 +- .../songs/forms/duplicatesongremovalform.py | 54 ++-- openlp/plugins/songs/forms/editsongdialog.py | 156 +++++------ openlp/plugins/songs/forms/editsongform.py | 80 +++--- openlp/plugins/songs/forms/editversedialog.py | 16 +- openlp/plugins/songs/forms/editverseform.py | 4 +- .../plugins/songs/forms/mediafilesdialog.py | 12 +- openlp/plugins/songs/forms/mediafilesform.py | 6 +- openlp/plugins/songs/forms/songbookdialog.py | 14 +- openlp/plugins/songs/forms/songbookform.py | 10 +- openlp/plugins/songs/forms/songexportform.py | 42 +-- openlp/plugins/songs/forms/songimportform.py | 85 +++--- .../songs/forms/songmaintenancedialog.py | 56 ++-- .../songs/forms/songmaintenanceform.py | 36 +-- .../plugins/songs/forms/songreviewwidget.py | 82 +++--- .../plugins/songs/forms/songselectdialog.py | 117 ++++---- openlp/plugins/songs/forms/songselectform.py | 48 ++-- openlp/plugins/songs/forms/topicsdialog.py | 10 +- openlp/plugins/songs/forms/topicsform.py | 10 +- openlp/plugins/songs/lib/__init__.py | 6 +- .../plugins/songs/lib/importers/openoffice.py | 2 +- .../plugins/songs/lib/importers/songimport.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 35 +-- openlp/plugins/songs/lib/songstab.py | 16 +- openlp/plugins/songs/songsplugin.py | 10 +- .../songusage/forms/songusagedeletedialog.py | 10 +- .../songusage/forms/songusagedeleteform.py | 13 +- .../songusage/forms/songusagedetaildialog.py | 22 +- .../songusage/forms/songusagedetailform.py | 6 +- openlp/plugins/songusage/songusageplugin.py | 13 +- scripts/check_dependencies.py | 39 +-- scripts/resources.patch | 2 +- scripts/translation_utils.py | 2 +- tests/functional/__init__.py | 15 +- .../openlp_core_common/test_common.py | 6 +- .../openlp_core_lib/test_file_dialog.py | 8 +- .../openlp_core_lib/test_htmlbuilder.py | 2 +- .../openlp_core_lib/test_image_manager.py | 2 +- tests/functional/openlp_core_lib/test_lib.py | 12 +- .../openlp_core_lib/test_renderer.py | 2 +- .../functional/openlp_core_lib/test_screen.py | 4 +- tests/functional/openlp_core_lib/test_ui.py | 66 ++--- .../openlp_core_ui/test_firsttimeform.py | 2 +- .../openlp_core_ui/test_formattingtagsform.py | 4 +- .../openlp_core_ui/test_maindisplay.py | 2 +- .../openlp_core_ui/test_mainwindow.py | 4 +- tests/functional/openlp_core_ui/test_media.py | 12 +- .../openlp_core_ui/test_settingsform.py | 12 +- .../openlp_core_ui/test_slidecontroller.py | 6 +- .../openlp_core_ui/test_themeform.py | 8 +- .../openlp_core_ui/test_thememanager.py | 8 +- .../openlp_core_ui_media/test_phononplayer.py | 64 ----- .../openlp_core_ui_media/test_vlcplayer.py | 41 +-- .../openlp_core_ui_media/test_webkitplayer.py | 4 +- .../openlp_core_utils/test_actions.py | 14 +- .../functional/openlp_core_utils/test_init.py | 5 +- .../openlp_plugins/bibles/test_mediaitem.py | 2 - .../openlp_plugins/custom/test_mediaitem.py | 2 +- .../openlp_plugins/images/test_imagetab.py | 4 +- .../openlp_plugins/images/test_lib.py | 4 +- .../presentations/test_pdfcontroller.py | 2 +- .../openlp_plugins/remotes/test_remotetab.py | 5 +- .../openlp_plugins/remotes/test_router.py | 1 + .../openlp_plugins/songs/test_editsongform.py | 2 +- .../songs/test_editverseform.py | 2 +- .../openlp_plugins/songs/test_mediaitem.py | 2 +- .../openlp_plugins/songs/test_songselect.py | 22 +- tests/functional/test_init.py | 10 +- tests/helpers/testmixin.py | 4 +- tests/interfaces/__init__.py | 9 - .../test_historycombobox.py | 4 +- .../openlp_core_lib/test_pluginmanager.py | 4 +- .../openlp_core_lib/test_searchedit.py | 4 +- .../openlp_core_ui/test_filerenamedialog.py | 20 +- .../openlp_core_ui/test_listpreviewwidget.py | 4 +- .../openlp_core_ui/test_mainwindow.py | 4 +- .../openlp_core_ui/test_projectoreditform.py | 8 +- .../test_projectorsourceform.py | 11 +- .../openlp_core_ui/test_servicemanager.py | 40 +-- .../openlp_core_ui/test_servicenotedialog.py | 16 +- .../openlp_core_ui/test_settings_form.py | 8 +- .../openlp_core_ui/test_shortcutlistform.py | 8 +- .../openlp_core_ui/test_starttimedialog.py | 12 +- .../bibles/forms/test_bibleimportform.py | 4 +- .../custom/forms/test_customform.py | 8 +- .../custom/forms/test_customslideform.py | 16 +- .../media/forms/test_mediaclipselectorform.py | 22 +- .../songs/forms/test_authorsform.py | 4 +- .../songs/forms/test_editsongform.py | 4 +- .../songs/forms/test_editverseform.py | 4 +- .../songs/forms/test_topicsform.py | 4 +- 220 files changed, 2842 insertions(+), 2904 deletions(-) rename openlp/core/ui/media/{phononplayer.py => systemplayer.py} (60%) delete mode 100644 tests/functional/openlp_core_ui_media/test_phononplayer.py diff --git a/documentation/openlp.1 b/documentation/openlp.1 index 789794fb4..7272e7578 100644 --- a/documentation/openlp.1 +++ b/documentation/openlp.1 @@ -29,7 +29,7 @@ Ignore the version file and pull the version directly from Bazaar .TP \fB\-s\fR STYLE, \fB\-\-style\fR=\fISTYLE\fR -Set the Qt4 style (passed directly to Qt4). +Set the Qt5 style (passed directly to Qt5). .TP \fB\-\-testing\fR Run by testing framework diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 4734fa0c5..f4fa82839 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -34,7 +34,7 @@ import argparse from traceback import format_exception import shutil import time -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, OpenLPMixin, AppLocation, Settings, UiStrings, check_directory_exists, \ is_macosx, is_win, translate @@ -76,7 +76,7 @@ QToolBar """ -class OpenLP(OpenLPMixin, QtGui.QApplication): +class OpenLP(OpenLPMixin, QtWidgets.QApplication): """ The core application class. This class inherits from Qt's QApplication class in order to provide the core of the application. @@ -84,12 +84,12 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): args = [] - def exec_(self): + def exec(self): """ Override exec method to allow the shared memory to be released on exit """ self.is_event_loop_active = True - result = QtGui.QApplication.exec_() + result = QtWidgets.QApplication.exec() self.shared_memory.detach() return result @@ -113,7 +113,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): if not has_run_wizard: ftw = FirstTimeForm() ftw.initialize(screens) - if ftw.exec_() == QtGui.QDialog.Accepted: + if ftw.exec() == QtWidgets.QDialog.Accepted: Settings().setValue('core/has run wizard', True) elif ftw.was_cancelled: QtCore.QCoreApplication.exit() @@ -159,7 +159,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): version.start() self.main_window.is_display_blank() self.main_window.app_startup() - return self.exec_() + return self.exec() def is_already_running(self): """ @@ -167,10 +167,10 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): """ self.shared_memory = QtCore.QSharedMemory('OpenLP') if self.shared_memory.attach(): - status = QtGui.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) - if status == QtGui.QMessageBox.No: + status = QtWidgets.QMessageBox.critical(None, UiStrings().Error, UiStrings().OpenLPStart, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No)) + if status == QtWidgets.QMessageBox.No: return True return False else: @@ -192,7 +192,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): self.exception_form = ExceptionForm() self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exc_type, value, traceback))) self.set_normal_cursor() - self.exception_form.exec_() + self.exception_form.exec() def backup_on_upgrade(self, has_run_wizard): """ @@ -207,11 +207,11 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): Settings().setValue('core/application version', openlp_version) # If data_version is different from the current version ask if we should backup the data folder elif data_version != openlp_version: - if QtGui.QMessageBox.question(None, translate('OpenLP', 'Backup'), - translate('OpenLP', 'OpenLP has been upgraded, ' - 'do you want to create a backup of OpenLPs data folder?'), - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, - QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: + if QtWidgets.QMessageBox.question(None, translate('OpenLP', 'Backup'), + translate('OpenLP', 'OpenLP has been upgraded, do you want to create ' + 'a backup of OpenLPs data folder?'), + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes: # Create copy of data folder data_folder_path = AppLocation.get_data_path() timestamp = time.strftime("%Y%m%d-%H%M%S") @@ -219,12 +219,13 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): try: shutil.copytree(data_folder_path, data_folder_backup_path) except OSError: - QtGui.QMessageBox.warning(None, translate('OpenLP', 'Backup'), - translate('OpenLP', 'Backup of the data folder failed!')) + QtWidgets.QMessageBox.warning(None, translate('OpenLP', 'Backup'), + translate('OpenLP', 'Backup of the data folder failed!')) return - QtGui.QMessageBox.information(None, translate('OpenLP', 'Backup'), - translate('OpenLP', 'A backup of the data folder has been created at %s') - % data_folder_backup_path) + QtWidgets.QMessageBox.information(None, translate('OpenLP', 'Backup'), + translate('OpenLP', + 'A backup of the data folder has been created at %s') + % data_folder_backup_path) # Update the version in the settings Settings().setValue('core/application version', openlp_version) @@ -271,7 +272,7 @@ class OpenLP(OpenLPMixin, QtGui.QApplication): self.main_window.setWindowState(self.main_window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) return True - return QtGui.QApplication.event(self, event) + return QtWidgets.QApplication.event(self, event) def parse_options(args): @@ -292,7 +293,7 @@ def parse_options(args): 'off a USB flash drive (not implemented).') parser.add_argument('-d', '--dev-version', dest='dev_version', action='store_true', help='Ignore the version file and pull the version directly from Bazaar') - parser.add_argument('-s', '--style', dest='style', help='Set the Qt4 style (passed directly to Qt4).') + parser.add_argument('-s', '--style', dest='style', help='Set the Qt5 style (passed directly to Qt5).') parser.add_argument('rargs', nargs='?', default=[]) # Parse command line options and deal with them. Use args supplied pragmatically if possible. return parser.parse_args(args) if args else parser.parse_args() @@ -372,7 +373,7 @@ def main(args=None): Settings().remove_obsolete_settings() # First time checks in settings if not Settings().value('core/has run wizard'): - if not FirstTimeLanguageForm().exec_(): + if not FirstTimeLanguageForm().exec(): # if cancel then stop processing sys.exit() # i18n Set Language diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index ccb982206..ab3b79657 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -32,8 +32,8 @@ import traceback from ipaddress import IPv4Address, IPv6Address, AddressValueError from codecs import decode, encode -from PyQt4 import QtCore -from PyQt4.QtCore import QCryptographicHash as QHash +from PyQt5 import QtCore +from PyQt5.QtCore import QCryptographicHash as QHash log = logging.getLogger(__name__ + '.__init__') @@ -92,20 +92,17 @@ class ThemeLevel(object): Song = 3 -def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1, - qt_translate=QtCore.QCoreApplication.translate): +def translate(context, text, comment=None, qt_translate=QtCore.QCoreApplication.translate): """ - A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so + A special shortcut method to wrap around the Qt5 translation functions. This abstracts the translation procedure so that we can change it if at a later date if necessary, without having to redo the whole of OpenLP. :param context: The translation context, used to give each string a context or a namespace. :param text: The text to put into the translation tables for translation. :param comment: An identifying string for when the same text is used in different roles within the same context. - :param encoding: - :param n: :param qt_translate: """ - return qt_translate(context, text, comment, encoding, n) + return qt_translate(context, text, comment) class SlideLimits(object): @@ -213,7 +210,7 @@ def md5_hash(salt, data=None): def qmd5_hash(salt, data=None): """ Returns the hashed output of MD5Sum on salt, data - using PyQt4.QCryptographicHash. + using PyQt5.QCryptographicHash. :param salt: Initial salt :param data: OPTIONAL Data to hash diff --git a/openlp/core/common/historycombobox.py b/openlp/core/common/historycombobox.py index cc5e40649..2e15dc6f4 100644 --- a/openlp/core/common/historycombobox.py +++ b/openlp/core/common/historycombobox.py @@ -23,10 +23,10 @@ The :mod:`~openlp.core.common.historycombobox` module contains the HistoryComboBox widget """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets -class HistoryComboBox(QtGui.QComboBox): +class HistoryComboBox(QtWidgets.QComboBox): """ The :class:`~openlp.core.common.historycombobox.HistoryComboBox` widget emulates the QLineEdit ``returnPressed`` signal for when the :kbd:`Enter` or :kbd:`Return` keys are pressed, and saves anything that is typed into the edit @@ -43,8 +43,8 @@ class HistoryComboBox(QtGui.QComboBox): super().__init__(parent) self.setDuplicatesEnabled(False) self.setEditable(True) - self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) - self.setInsertPolicy(QtGui.QComboBox.InsertAtTop) + self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + self.setInsertPolicy(QtWidgets.QComboBox.InsertAtTop) def keyPressEvent(self, event): """ diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 41c3d4d0f..869e70993 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -26,7 +26,7 @@ import datetime import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from openlp.core.common import ThemeLevel, SlideLimits, UiStrings, is_win, is_linux @@ -425,10 +425,6 @@ class Settings(QtCore.QSettings): **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ - # On OS X (and probably on other platforms too) empty value from QSettings is represented as type - # PyQt4.QtCore.QPyNullVariant. This type has to be converted to proper 'None' Python type. - if isinstance(setting, QtCore.QPyNullVariant) and setting.isNull(): - setting = None # Handle 'None' type (empty value) properly. if setting is None: # An empty string saved to the settings results in a None type being returned. diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index 3ef0fa963..a6a3c6efe 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -28,7 +28,8 @@ from distutils.version import LooseVersion import logging import os -from PyQt4 import QtCore, QtGui, Qt +from PyQt5 import QtCore, QtGui, Qt, QtWidgets + from openlp.core.common import translate @@ -251,8 +252,8 @@ def check_item_selected(list_widget, message): :param message: The message to give the user if no item is selected """ if not list_widget.selectedIndexes(): - QtGui.QMessageBox.information(list_widget.parent(), - translate('OpenLP.MediaManagerItem', 'No Items Selected'), message) + QtWidgets.QMessageBox.information(list_widget.parent(), + translate('OpenLP.MediaManagerItem', 'No Items Selected'), message) return False return True diff --git a/openlp/core/lib/colorbutton.py b/openlp/core/lib/colorbutton.py index 20e487666..71ed5c489 100644 --- a/openlp/core/lib/colorbutton.py +++ b/openlp/core/lib/colorbutton.py @@ -23,12 +23,12 @@ """ Provide a custom widget based on QPushButton for the selection of colors """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import translate -class ColorButton(QtGui.QPushButton): +class ColorButton(QtWidgets.QPushButton): """ Subclasses QPushbutton to create a "Color Chooser" button """ @@ -76,7 +76,7 @@ class ColorButton(QtGui.QPushButton): """ Handle the PushButton clicked signal, showing the ColorDialog and validating the input """ - new_color = QtGui.QColorDialog.getColor(QtGui.QColor(self._color), self.parent) + new_color = QtWidgets.QColorDialog.getColor(QtGui.QColor(self._color), self.parent) if new_color.isValid() and self._color != new_color.name(): self.change_color(new_color.name()) self.colorChanged.emit(new_color.name()) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index ed267737a..b02e3291a 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -26,14 +26,14 @@ Provide additional functionality required by OpenLP from the inherited QDockWidg import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import ScreenList, build_icon log = logging.getLogger(__name__) -class OpenLPDockWidget(QtGui.QDockWidget): +class OpenLPDockWidget(QtWidgets.QDockWidget): """ Custom DockWidget class to handle events """ diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 7df588da9..a4e612ff6 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -26,14 +26,14 @@ import logging import os from urllib import parse -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import UiStrings log = logging.getLogger(__name__) -class FileDialog(QtGui.QFileDialog): +class FileDialog(QtWidgets.QFileDialog): """ Subclass QFileDialog to work round a bug """ @@ -43,7 +43,7 @@ class FileDialog(QtGui.QFileDialog): Reimplement getOpenFileNames to fix the way it returns some file names that url encoded when selecting multiple files """ - files = QtGui.QFileDialog.getOpenFileNames(parent, *args, **kwargs) + files, filter_used = QtWidgets.QFileDialog.getOpenFileNames(parent, *args, **kwargs) file_list = [] for file in files: if not os.path.exists(file): @@ -51,8 +51,8 @@ class FileDialog(QtGui.QFileDialog): file = parse.unquote(file) if not os.path.exists(file): log.error('File %s not found.' % file) - QtGui.QMessageBox.information(parent, UiStrings().FileNotFound, - UiStrings().FileNotFoundMessage % file) + QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound, + UiStrings().FileNotFoundMessage % file) continue file_list.append(file) return file_list diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index a87122177..942a8d93e 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -389,7 +389,7 @@ is the function which has to be called from outside. The generated and returned """ import logging -from PyQt4 import QtWebKit +from PyQt5 import QtWebKit from openlp.core.common import Settings from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, VerticalType, HorizontalType diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 75472a1bc..5ca9852ee 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 @@ -30,7 +29,7 @@ import os import time import queue -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry from openlp.core.lib import ScreenList, resize_image, image_to_byte diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 4da1cf81e..c68515d1d 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -24,12 +24,12 @@ Extend QListWidget to handle drag and drop functionality """ import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry -class ListWidgetWithDnD(QtGui.QListWidget): +class ListWidgetWithDnD(QtWidgets.QListWidget): """ Provide a list widget to store objects and handle drag and drop events """ @@ -45,7 +45,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): Activate DnD of widget """ self.setAcceptDrops(True) - self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file) def mouseMoveEvent(self, event): @@ -63,7 +63,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): mime_data = QtCore.QMimeData() drag.setMimeData(mime_data) mime_data.setText(self.mime_data_text) - drag.start(QtCore.Qt.CopyAction) + drag.exec(QtCore.Qt.CopyAction) def dragEnterEvent(self, event): """ diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 2cd30ad53..37d2705af 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -26,7 +26,7 @@ import logging import os import re -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import FileDialog, OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \ @@ -37,7 +37,7 @@ from openlp.core.lib.ui import create_widget_action, critical_error_message_box log = logging.getLogger(__name__) -class MediaManagerItem(QtGui.QWidget, RegistryProperties): +class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): """ MediaManagerItem is a helper widget for plugins. @@ -96,16 +96,13 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): self.single_service_item = True self.quick_preview_allowed = False self.has_search = False - self.page_layout = QtGui.QVBoxLayout(self) + self.page_layout = QtWidgets.QVBoxLayout(self) self.page_layout.setSpacing(0) - self.page_layout.setMargin(0) + self.page_layout.setContentsMargins(0, 0, 0, 0) self.required_icons() self.setupUi() self.retranslateUi() self.auto_select_id = -1 - # Need to use event as called across threads and UI is updated - QtCore.QObject.connect(self, QtCore.SIGNAL('%s_go_live' % self.plugin.name), self.go_live_remote) - QtCore.QObject.connect(self, QtCore.SIGNAL('%s_add_to_service' % self.plugin.name), self.add_to_service_remote) def setup_item(self): """ @@ -200,7 +197,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): # Add the List widget self.list_view = ListWidgetWithDnD(self, self.plugin.name) self.list_view.setSpacing(1) - self.list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.list_view.setAlternatingRowColors(True) self.list_view.setObjectName('%sListView' % self.plugin.name) # Add to page_layout @@ -246,7 +243,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): triggers=self.on_add_edit_click) self.add_custom_context_actions() # Create the context menu and add all actions from the list_view. - self.menu = QtGui.QMenu() + self.menu = QtWidgets.QMenu() self.menu.addActions(self.list_view.actions()) self.list_view.doubleClicked.connect(self.on_double_clicked) self.list_view.itemSelectionChanged.connect(self.on_selection_change) @@ -256,23 +253,23 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): """ Creates a search field with button and related signal handling. """ - self.search_widget = QtGui.QWidget(self) + self.search_widget = QtWidgets.QWidget(self) self.search_widget.setObjectName('search_widget') - self.search_layout = QtGui.QVBoxLayout(self.search_widget) + self.search_layout = QtWidgets.QVBoxLayout(self.search_widget) self.search_layout.setObjectName('search_layout') - self.search_text_layout = QtGui.QFormLayout() + self.search_text_layout = QtWidgets.QFormLayout() self.search_text_layout.setObjectName('search_text_layout') - self.search_text_label = QtGui.QLabel(self.search_widget) + self.search_text_label = QtWidgets.QLabel(self.search_widget) self.search_text_label.setObjectName('search_text_label') self.search_text_edit = SearchEdit(self.search_widget) self.search_text_edit.setObjectName('search_text_edit') self.search_text_label.setBuddy(self.search_text_edit) self.search_text_layout.addRow(self.search_text_label, self.search_text_edit) self.search_layout.addLayout(self.search_text_layout) - self.search_button_layout = QtGui.QHBoxLayout() + self.search_button_layout = QtWidgets.QHBoxLayout() self.search_button_layout.setObjectName('search_button_layout') self.search_button_layout.addStretch() - self.search_text_button = QtGui.QPushButton(self.search_widget) + self.search_text_button = QtWidgets.QPushButton(self.search_widget) self.search_text_button.setObjectName('search_text_button') self.search_button_layout.addWidget(self.search_text_button) self.search_layout.addLayout(self.search_button_layout) @@ -395,7 +392,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): return if not item.flags() & QtCore.Qt.ItemIsSelectable: return - self.menu.exec_(self.list_view.mapToGlobal(point)) + self.menu.exec(self.list_view.mapToGlobal(point)) def get_file_list(self): """ @@ -479,9 +476,9 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): :param keep_focus: Do we keep focus (False) """ if not self.list_view.selectedIndexes() and not self.remote_triggered: - QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to preview.')) + QtWidgets.QMessageBox.information(self, UiStrings().NISp, + translate('OpenLP.MediaManagerItem', + 'You must select one or more items to preview.')) else: log.debug('%s Preview requested' % self.plugin.name) service_item = self.build_service_item() @@ -496,9 +493,9 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): Send an item live by building a service item then adding that service item to the live slide controller. """ if not self.list_view.selectedIndexes(): - QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to send live.')) + QtWidgets.QMessageBox.information(self, UiStrings().NISp, + translate('OpenLP.MediaManagerItem', + 'You must select one or more items to send live.')) else: self.go_live() @@ -536,7 +533,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): :param item_id: Id to make live """ - item = QtGui.QListWidgetItem() + item = QtWidgets.QListWidgetItem() item.setData(QtCore.Qt.UserRole, item_id) return item @@ -545,9 +542,9 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): Add a selected item to the current service """ if not self.list_view.selectedIndexes(): - QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', - 'You must select one or more items to add.')) + QtWidgets.QMessageBox.information(self, UiStrings().NISp, + translate('OpenLP.MediaManagerItem', + 'You must select one or more items to add.')) else: # Is it possible to process multiple list items to generate # multiple service items? @@ -589,23 +586,24 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): Add a selected item to an existing item in the current service. """ if not self.list_view.selectedIndexes() and not self.remote_triggered: - QtGui.QMessageBox.information(self, UiStrings().NISp, - translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) + QtWidgets.QMessageBox.information(self, UiStrings().NISp, + translate('OpenLP.MediaManagerItem', + 'You must select one or more items.')) else: log.debug('%s Add requested', self.plugin.name) service_item = self.service_manager.get_service_item() if not service_item: - QtGui.QMessageBox.information(self, UiStrings().NISs, - translate('OpenLP.MediaManagerItem', - 'You must select an existing service item to add to.')) + QtWidgets.QMessageBox.information(self, UiStrings().NISs, + translate('OpenLP.MediaManagerItem', + 'You must select an existing service item to add to.')) elif self.plugin.name == service_item.name: self.generate_slide_data(service_item) self.service_manager.add_service_item(service_item, replace=True) else: # Turn off the remote edit update message indicator - QtGui.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), - translate('OpenLP.MediaManagerItem', - 'You must select a %s service item.') % self.title) + QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), + translate('OpenLP.MediaManagerItem', + 'You must select a %s service item.') % self.title) def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): """ @@ -638,7 +636,7 @@ class MediaManagerItem(QtGui.QWidget, RegistryProperties): if self.list_view.count(): return message = translate('OpenLP.MediaManagerItem', 'No Search Results') - item = QtGui.QListWidgetItem(message) + item = QtWidgets.QListWidgetItem(message) item.setFlags(QtCore.Qt.NoItemFlags) font = QtGui.QFont() font.setItalic(True) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 05b4164bf..24b16f7a0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -25,7 +25,7 @@ Provide the generic plugin functionality for OpenLP plugins. import logging -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings from openlp.core.utils import get_application_version diff --git a/openlp/core/lib/projector/pjlink1.py b/openlp/core/lib/projector/pjlink1.py index 208f0dd8e..6320f32bf 100644 --- a/openlp/core/lib/projector/pjlink1.py +++ b/openlp/core/lib/projector/pjlink1.py @@ -46,8 +46,8 @@ __all__ = ['PJLink1'] from codecs import decode -from PyQt4.QtCore import pyqtSignal, pyqtSlot -from PyQt4.QtNetwork import QAbstractSocket, QTcpSocket +from PyQt5.QtCore import pyqtSignal, pyqtSlot +from PyQt5.QtNetwork import QAbstractSocket, QTcpSocket from openlp.core.common import translate, qmd5_hash from openlp.core.lib.projector.constants import * diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 9f63d3475..74922b78d 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -21,7 +21,7 @@ ############################################################################### -from PyQt4 import QtGui, QtCore, QtWebKit +from PyQt5 import QtGui, QtCore, QtWebKitWidgets from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, RegistryMixin, Settings from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, ScreenList, ServiceItem, expand_tags, \ @@ -60,7 +60,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): self.force_page = False self._theme_dimensions = {} self._calculate_default() - self.web = QtWebKit.QWebView() + self.web = QtWebKitWidgets.QWebView() self.web.setVisible(False) self.web_frame = self.web.page().mainFrame() Registry().register_function('theme_update_global', self.set_global_theme) @@ -364,7 +364,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): # For the life of my I don't know why we have to completely kill the QWebView in order for the display to work # properly, but we do. See bug #1041366 for an example of what happens if we take this out. self.web = None - self.web = QtWebKit.QWebView() + self.web = QtWebKitWidgets.QWebView() self.web.setVisible(False) self.web.resize(self.page_width, self.page_height) self.web_frame = self.web.page().mainFrame() diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index c207ecf90..2b8883507 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -27,7 +27,7 @@ displays. import logging import copy -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry, Settings, translate @@ -149,7 +149,7 @@ class ScreenList(object): { 'primary': True, 'number': 0, - 'size': PyQt4.QtCore.QRect(0, 0, 1024, 768) + 'size': PyQt5.QtCore.QRect(0, 0, 1024, 768) } """ log.info('Screen %d found with resolution %s' % (screen['number'], screen['size'])) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 09616336a..c657cef1d 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import build_icon from openlp.core.lib.ui import create_widget_action @@ -30,10 +30,12 @@ from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) -class SearchEdit(QtGui.QLineEdit): +class SearchEdit(QtWidgets.QLineEdit): """ This is a specialised QLineEdit with a "clear" button inside for searches. """ + searchTypeChanged = QtCore.pyqtSignal(QtCore.QVariant) + cleared = QtCore.pyqtSignal() def __init__(self, parent): """ @@ -41,7 +43,7 @@ class SearchEdit(QtGui.QLineEdit): """ super(SearchEdit, self).__init__(parent) self._current_search_type = -1 - self.clear_button = QtGui.QToolButton(self) + self.clear_button = QtWidgets.QToolButton(self) self.clear_button.setIcon(build_icon(':/system/clear_shortcut.png')) self.clear_button.setCursor(QtCore.Qt.ArrowCursor) self.clear_button.setStyleSheet('QToolButton { border: none; padding: 0px; }') @@ -56,7 +58,7 @@ class SearchEdit(QtGui.QLineEdit): """ Internal method to update the stylesheet depending on which widgets are available and visible. """ - frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) + frame_width = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth) right_padding = self.clear_button.width() + frame_width if hasattr(self, 'menu_button'): left_padding = self.menu_button.width() @@ -75,7 +77,7 @@ class SearchEdit(QtGui.QLineEdit): :param event: The event that happened. """ size = self.clear_button.size() - frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) + frame_width = self.style().pixelMetric(QtWidgets.QStyle.PM_DefaultFrameWidth) self.clear_button.move(self.rect().right() - frame_width - size.width(), (self.rect().bottom() + 1 - size.height()) // 2) if hasattr(self, 'menu_button'): @@ -105,7 +107,7 @@ class SearchEdit(QtGui.QLineEdit): pass self.menu_button.setDefaultAction(action) self._current_search_type = identifier - self.emit(QtCore.SIGNAL('searchTypeChanged(int)'), identifier) + self.searchTypeChanged.emit(identifier) return True def set_search_types(self, items): @@ -126,7 +128,7 @@ class SearchEdit(QtGui.QLineEdit): (2, ":/songs/authors.png", "Authors", "Search Authors...") """ - menu = QtGui.QMenu(self) + menu = QtWidgets.QMenu(self) first = None for identifier, icon, title, placeholder in items: action = create_widget_action( @@ -136,10 +138,10 @@ class SearchEdit(QtGui.QLineEdit): first = action self._current_search_type = identifier if not hasattr(self, 'menu_button'): - self.menu_button = QtGui.QToolButton(self) + self.menu_button = QtWidgets.QToolButton(self) self.menu_button.setIcon(build_icon(':/system/clear_shortcut.png')) self.menu_button.setCursor(QtCore.Qt.ArrowCursor) - self.menu_button.setPopupMode(QtGui.QToolButton.InstantPopup) + self.menu_button.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.menu_button.setStyleSheet('QToolButton { border: none; padding: 0px 10px 0px 0px; }') self.menu_button.resize(QtCore.QSize(28, 18)) self.menu_button.setMenu(menu) @@ -152,7 +154,7 @@ class SearchEdit(QtGui.QLineEdit): Internally implemented slot to react to when the text in the line edit has changed so that we can show or hide the clear button. - :param text: A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit. + :param text: A :class:`~PyQt5.QtCore.QString` instance which represents the text in the line edit. """ self.clear_button.setVisible(bool(text)) @@ -163,7 +165,7 @@ class SearchEdit(QtGui.QLineEdit): line edit. """ self.clear() - self.emit(QtCore.SIGNAL('cleared()')) + self.cleared.emit() def _on_menu_action_triggered(self): """ diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 873dee902..c99229f7a 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -31,7 +31,7 @@ import os import uuid import ntpath -from PyQt4 import QtGui +from PyQt5 import QtGui from openlp.core.common import RegistryProperties, Settings, translate, AppLocation, md5_hash from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, create_thumb diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index 5b33b2f51..d5d07b26f 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -25,13 +25,13 @@ own tab to the settings dialog. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import RegistryProperties -class SettingsTab(QtGui.QWidget, RegistryProperties): +class SettingsTab(QtWidgets.QWidget, RegistryProperties): """ SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ @@ -66,18 +66,18 @@ class SettingsTab(QtGui.QWidget, RegistryProperties): """ Setup the tab's interface. """ - self.tab_layout = QtGui.QHBoxLayout(self) + self.tab_layout = QtWidgets.QHBoxLayout(self) self.tab_layout.setObjectName('tab_layout') - self.left_column = QtGui.QWidget(self) + self.left_column = QtWidgets.QWidget(self) self.left_column.setObjectName('left_column') - self.left_layout = QtGui.QVBoxLayout(self.left_column) - self.left_layout.setMargin(0) + self.left_layout = QtWidgets.QVBoxLayout(self.left_column) + self.left_layout.setContentsMargins(0, 0, 0, 0) self.left_layout.setObjectName('left_layout') self.tab_layout.addWidget(self.left_column) - self.right_column = QtGui.QWidget(self) + self.right_column = QtWidgets.QWidget(self) self.right_column.setObjectName('right_column') - self.right_layout = QtGui.QVBoxLayout(self.right_column) - self.right_layout.setMargin(0) + self.right_layout = QtWidgets.QVBoxLayout(self.right_column) + self.right_layout.setContentsMargins(0, 0, 0, 0) self.right_layout.setObjectName('right_layout') self.tab_layout.addWidget(self.right_column) @@ -86,7 +86,7 @@ class SettingsTab(QtGui.QWidget, RegistryProperties): Resize the sides in two equal halves if the layout allows this. """ if event: - QtGui.QWidget.resizeEvent(self, event) + QtWidgets.QWidget.resizeEvent(self, event) width = self.width() - self.tab_layout.spacing() - \ self.tab_layout.contentsMargins().left() - self.tab_layout.contentsMargins().right() left_width = min(width - self.right_column.minimumSizeHint().width(), width // 2) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 5a0fa63e0..5b01d6dcd 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -36,7 +36,7 @@ except ImportError: # based on code from http://john.nachtimwald.com/2009/08/22/qplaintextedit-with-in-line-spell-check -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.lib import translate, FormattingTags from openlp.core.lib.ui import create_action @@ -44,7 +44,7 @@ from openlp.core.lib.ui import create_action log = logging.getLogger(__name__) -class SpellTextEdit(QtGui.QPlainTextEdit): +class SpellTextEdit(QtWidgets.QPlainTextEdit): """ Spell checking widget based on QPlanTextEdit. """ @@ -73,7 +73,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Rewrite the mouse event to a left button event so the cursor is moved to the location of the pointer. event = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, event.pos(), QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier) - QtGui.QPlainTextEdit.mousePressEvent(self, event) + QtWidgets.QPlainTextEdit.mousePressEvent(self, event) def contextMenuEvent(self, event): """ @@ -88,7 +88,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): self.setTextCursor(cursor) # Add menu with available languages. if ENCHANT_AVAILABLE: - lang_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Language:')) + lang_menu = QtWidgets.QMenu(translate('OpenLP.SpellTextEdit', 'Language:')) for lang in enchant.list_languages(): action = create_action(lang_menu, lang, text=lang, checked=lang == self.dictionary.tag) lang_menu.addAction(action) @@ -99,7 +99,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): text = self.textCursor().selectedText() if not self.dictionary.check(text): - spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) + spell_menu = QtWidgets.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) for word in self.dictionary.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correct_word) @@ -107,7 +107,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Only add the spelling suggests to the menu if there are suggestions. if spell_menu.actions(): popup_menu.insertMenu(popup_menu.actions()[0], spell_menu) - tag_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags')) + tag_menu = QtWidgets.QMenu(translate('OpenLP.SpellTextEdit', 'Formatting Tags')) if self.formatting_tags_allowed: for html in FormattingTags.get_html_tags(): action = SpellAction(html['desc'], tag_menu) @@ -115,7 +115,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): tag_menu.addAction(action) popup_menu.insertSeparator(popup_menu.actions()[0]) popup_menu.insertMenu(popup_menu.actions()[0], tag_menu) - popup_menu.exec_(event.globalPos()) + popup_menu.exec(event.globalPos()) def set_language(self, action): """ @@ -189,7 +189,7 @@ class Highlighter(QtGui.QSyntaxHighlighter): self.setFormat(word_object.start(), word_object.end() - word_object.start(), char_format) -class SpellAction(QtGui.QAction): +class SpellAction(QtWidgets.QAction): """ A special QAction that returns the text in a signal. """ diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 8a8537af8..373e88389 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -24,14 +24,14 @@ Provide common toolbar handling for OpenLP """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.lib.ui import create_widget_action log = logging.getLogger(__name__) -class OpenLPToolbar(QtGui.QToolBar): +class OpenLPToolbar(QtWidgets.QToolBar): """ Lots of toolbars around the place, so it makes sense to have a common way to manage them. This is the base toolbar class. diff --git a/openlp/core/lib/treewidgetwithdnd.py b/openlp/core/lib/treewidgetwithdnd.py index 5dcf165f6..48055090c 100644 --- a/openlp/core/lib/treewidgetwithdnd.py +++ b/openlp/core/lib/treewidgetwithdnd.py @@ -24,12 +24,12 @@ Extend QTreeWidget to handle drag and drop functionality """ import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry -class TreeWidgetWithDnD(QtGui.QTreeWidget): +class TreeWidgetWithDnD(QtWidgets.QTreeWidget): """ Provide a tree widget to store objects and handle drag and drop events """ @@ -50,7 +50,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): Activate DnD of widget """ self.setAcceptDrops(True) - self.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file) Registry().register_function(('%s_dnd_internal' % self.mime_data_text), self.parent().dnd_move_internal) @@ -71,7 +71,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): mime_data = QtCore.QMimeData() drag.setMimeData(mime_data) mime_data.setText(self.mime_data_text) - drag.start(QtCore.Qt.CopyAction) + drag.exec(QtCore.Qt.CopyAction) def dragEnterEvent(self, event): """ @@ -92,7 +92,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): :param event: The event that occurred """ - QtGui.QTreeWidget.dragMoveEvent(self, event) + QtWidgets.QTreeWidget.dragMoveEvent(self, event) if event.mimeData().hasUrls(): event.setDropAction(QtCore.Qt.CopyAction) event.accept() diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 82b78bd09..bd37e4dfa 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -24,7 +24,7 @@ The :mod:`ui` module provides standard UI components for OpenLP. """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, UiStrings, translate, is_macosx from openlp.core.lib import build_icon @@ -41,16 +41,16 @@ def add_welcome_page(parent, image): :param parent: A ``QWizard`` object to add the welcome page to. :param image: A splash image for the wizard. """ - parent.welcome_page = QtGui.QWizardPage() - parent.welcome_page.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image)) + parent.welcome_page = QtWidgets.QWizardPage() + parent.welcome_page.setPixmap(QtWidgets.QWizard.WatermarkPixmap, QtGui.QPixmap(image)) parent.welcome_page.setObjectName('welcome_page') - parent.welcome_layout = QtGui.QVBoxLayout(parent.welcome_page) + parent.welcome_layout = QtWidgets.QVBoxLayout(parent.welcome_page) parent.welcome_layout.setObjectName('WelcomeLayout') - parent.title_label = QtGui.QLabel(parent.welcome_page) + parent.title_label = QtWidgets.QLabel(parent.welcome_page) parent.title_label.setObjectName('title_label') parent.welcome_layout.addWidget(parent.title_label) parent.welcome_layout.addSpacing(40) - parent.information_label = QtGui.QLabel(parent.welcome_page) + parent.information_label = QtWidgets.QLabel(parent.welcome_page) parent.information_label.setWordWrap(True) parent.information_label.setObjectName('information_label') parent.welcome_layout.addWidget(parent.information_label) @@ -67,30 +67,30 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None): :param name: A string which is set as object name. :param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, ``close``, and ``defaults``. - :param custom_buttons: A list of additional buttons. If an item is an instance of QtGui.QAbstractButton it is added - with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole. + :param custom_buttons: A list of additional buttons. If an item is an instance of QtWidgets.QAbstractButton it is + added with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole. """ if custom_buttons is None: custom_buttons = [] if standard_buttons is None: standard_buttons = [] - buttons = QtGui.QDialogButtonBox.NoButton + buttons = QtWidgets.QDialogButtonBox.NoButton if 'ok' in standard_buttons: - buttons |= QtGui.QDialogButtonBox.Ok + buttons |= QtWidgets.QDialogButtonBox.Ok if 'save' in standard_buttons: - buttons |= QtGui.QDialogButtonBox.Save + buttons |= QtWidgets.QDialogButtonBox.Save if 'cancel' in standard_buttons: - buttons |= QtGui.QDialogButtonBox.Cancel + buttons |= QtWidgets.QDialogButtonBox.Cancel if 'close' in standard_buttons: - buttons |= QtGui.QDialogButtonBox.Close + buttons |= QtWidgets.QDialogButtonBox.Close if 'defaults' in standard_buttons: - buttons |= QtGui.QDialogButtonBox.RestoreDefaults - button_box = QtGui.QDialogButtonBox(dialog) + buttons |= QtWidgets.QDialogButtonBox.RestoreDefaults + button_box = QtWidgets.QDialogButtonBox(dialog) button_box.setObjectName(name) button_box.setStandardButtons(buttons) for button in custom_buttons: - if isinstance(button, QtGui.QAbstractButton): - button_box.addButton(button, QtGui.QDialogButtonBox.ActionRole) + if isinstance(button, QtWidgets.QAbstractButton): + button_box.addButton(button, QtWidgets.QDialogButtonBox.ActionRole) else: button_box.addButton(*button) button_box.accepted.connect(dialog.accept) @@ -108,9 +108,9 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F :param question: Should this message box question the user. """ if question: - return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) + return QtWidgets.QMessageBox.critical(parent, UiStrings().Error, message, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No)) return Registry().get('main_window').error_message(title if title else UiStrings().Error, message) @@ -121,10 +121,10 @@ def create_horizontal_adjusting_combo_box(parent, name): :param parent: The parent widget. :param name: A string set as object name for the combo box. """ - combo = QtGui.QComboBox(parent) + combo = QtWidgets.QComboBox(parent) combo.setObjectName(name) - combo.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + combo.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToMinimumContentsLength) + combo.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) return combo @@ -167,9 +167,9 @@ def create_button(parent, name, **kwargs): else: log.warning('The role "%s" is not defined in create_push_button().', role) if kwargs.pop('btn_class', '') == 'toolbutton': - button = QtGui.QToolButton(parent) + button = QtWidgets.QToolButton(parent) else: - button = QtGui.QPushButton(parent) + button = QtWidgets.QPushButton(parent) button.setObjectName(name) if kwargs.get('text'): button.setText(kwargs.pop('text')) @@ -238,7 +238,7 @@ def create_action(parent, name, **kwargs): ``triggers`` A slot which is connected to the actions ``triggered()`` slot. """ - action = QtGui.QAction(parent) + action = QtWidgets.QAction(parent) action.setObjectName(name) if is_macosx(): action.setIconVisibleInMenu(False) @@ -292,7 +292,7 @@ def set_case_insensitive_completer(cache, widget): :param cache: The list of items to use as suggestions. :param widget: A widget to set the completer (QComboBox or QLineEdit instance) """ - completer = QtGui.QCompleter(cache) + completer = QtWidgets.QCompleter(cache) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) widget.setCompleter(completer) @@ -303,9 +303,9 @@ def create_valign_selection_widgets(parent): :param parent: The parent object. This should be a ``QWidget`` descendant. """ - label = QtGui.QLabel(parent) + label = QtWidgets.QLabel(parent) label.setText(translate('OpenLP.Ui', '&Vertical Align:')) - combo_box = QtGui.QComboBox(parent) + combo_box = QtWidgets.QComboBox(parent) combo_box.addItems([UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]) label.setBuddy(combo_box) return label, combo_box diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index bed8a7cb5..9f803e921 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -22,7 +22,7 @@ """ The :mod:`ui` module provides the core user interface for OpenLP """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets class HideMode(object): @@ -71,7 +71,7 @@ class DisplayControllerType(object): Plugin = 2 -class SingleColumnTableWidget(QtGui.QTableWidget): +class SingleColumnTableWidget(QtWidgets.QTableWidget): """ Class to for a single column table widget to use for the verse table widget. """ @@ -88,7 +88,7 @@ class SingleColumnTableWidget(QtGui.QTableWidget): """ Resize the first column together with the widget. """ - QtGui.QTableWidget.resizeEvent(self, event) + QtWidgets.QTableWidget.resizeEvent(self, event) if self.columnCount(): self.setColumnWidth(0, event.size().width()) self.resizeRowsToContents() diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 70b617108..f28e3772f 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -40,37 +40,37 @@ class UiAboutDialog(object): """ about_dialog.setObjectName('about_dialog') about_dialog.setWindowIcon(build_icon(':/icon/openlp-logo.svg')) - self.about_dialog_layout = QtGui.QVBoxLayout(about_dialog) + self.about_dialog_layout = QtWidgets.QVBoxLayout(about_dialog) self.about_dialog_layout.setObjectName('about_dialog_layout') - self.logo_label = QtGui.QLabel(about_dialog) + self.logo_label = QtWidgets.QLabel(about_dialog) self.logo_label.setPixmap(QtGui.QPixmap(':/graphics/openlp-about-logo.png')) self.logo_label.setObjectName('logo_label') self.about_dialog_layout.addWidget(self.logo_label) - self.about_notebook = QtGui.QTabWidget(about_dialog) + self.about_notebook = QtWidgets.QTabWidget(about_dialog) self.about_notebook.setObjectName('about_notebook') - self.about_tab = QtGui.QWidget() + self.about_tab = QtWidgets.QWidget() self.about_tab.setObjectName('about_tab') - self.about_tab_layout = QtGui.QVBoxLayout(self.about_tab) + self.about_tab_layout = QtWidgets.QVBoxLayout(self.about_tab) self.about_tab_layout.setObjectName('about_tab_layout') - self.about_text_edit = QtGui.QPlainTextEdit(self.about_tab) + self.about_text_edit = QtWidgets.QPlainTextEdit(self.about_tab) self.about_text_edit.setReadOnly(True) self.about_text_edit.setObjectName('about_text_edit') self.about_tab_layout.addWidget(self.about_text_edit) self.about_notebook.addTab(self.about_tab, '') - self.credits_tab = QtGui.QWidget() + self.credits_tab = QtWidgets.QWidget() self.credits_tab.setObjectName('credits_tab') - self.credits_tab_layout = QtGui.QVBoxLayout(self.credits_tab) + self.credits_tab_layout = QtWidgets.QVBoxLayout(self.credits_tab) self.credits_tab_layout.setObjectName('credits_tab_layout') - self.credits_text_edit = QtGui.QPlainTextEdit(self.credits_tab) + self.credits_text_edit = QtWidgets.QPlainTextEdit(self.credits_tab) self.credits_text_edit.setReadOnly(True) self.credits_text_edit.setObjectName('credits_text_edit') self.credits_tab_layout.addWidget(self.credits_text_edit) self.about_notebook.addTab(self.credits_tab, '') - self.license_tab = QtGui.QWidget() + self.license_tab = QtWidgets.QWidget() self.license_tab.setObjectName('license_tab') - self.license_tab_layout = QtGui.QVBoxLayout(self.license_tab) + self.license_tab_layout = QtWidgets.QVBoxLayout(self.license_tab) self.license_tab_layout.setObjectName('license_tab_layout') - self.license_text_edit = QtGui.QPlainTextEdit(self.license_tab) + self.license_text_edit = QtWidgets.QPlainTextEdit(self.license_tab) self.license_text_edit.setReadOnly(True) self.license_text_edit.setObjectName('license_text_edit') self.license_tab_layout.addWidget(self.license_text_edit) @@ -185,8 +185,8 @@ class UiAboutDialog(object): documentation = translate('OpenLP.AboutForm', 'Documentation') built_with = translate('OpenLP.AboutForm', 'Built With\n' ' Python: http://www.python.org/\n' - ' Qt4: http://qt.io\n' - ' PyQt4: http://www.riverbankcomputing.co.uk/software/pyqt/intro\n' + ' Qt5: http://qt.io\n' + ' PyQt5: http://www.riverbankcomputing.co.uk/software/pyqt/intro\n' ' Oxygen Icons: http://techbase.kde.org/Projects/Oxygen/\n' ' MuPDF: http://www.mupdf.com/\n') final_credit = translate('OpenLP.AboutForm', 'Final Credit\n' diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index b22d47328..67e0a971f 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -24,14 +24,14 @@ The About dialog. """ import webbrowser -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate from openlp.core.utils import get_application_version from .aboutdialog import UiAboutDialog -class AboutForm(QtGui.QDialog, UiAboutDialog): +class AboutForm(QtWidgets.QDialog, UiAboutDialog): """ The About dialog """ diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index d93515cd3..898a3912e 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -27,7 +27,7 @@ import logging import os import sys -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import AppLocation, Settings, SlideLimits, UiStrings, translate from openlp.core.lib import ColorButton, SettingsTab, build_icon @@ -58,108 +58,108 @@ class AdvancedTab(SettingsTab): """ self.setObjectName('AdvancedTab') super(AdvancedTab, self).setupUi() - self.ui_group_box = QtGui.QGroupBox(self.left_column) + self.ui_group_box = QtWidgets.QGroupBox(self.left_column) self.ui_group_box.setObjectName('ui_group_box') - self.ui_layout = QtGui.QFormLayout(self.ui_group_box) + self.ui_layout = QtWidgets.QFormLayout(self.ui_group_box) self.ui_layout.setObjectName('ui_layout') - self.recent_label = QtGui.QLabel(self.ui_group_box) + self.recent_label = QtWidgets.QLabel(self.ui_group_box) self.recent_label.setObjectName('recent_label') - self.recent_spin_box = QtGui.QSpinBox(self.ui_group_box) + self.recent_spin_box = QtWidgets.QSpinBox(self.ui_group_box) self.recent_spin_box.setObjectName('recent_spin_box') self.recent_spin_box.setMinimum(0) self.ui_layout.addRow(self.recent_label, self.recent_spin_box) - self.media_plugin_check_box = QtGui.QCheckBox(self.ui_group_box) + self.media_plugin_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.media_plugin_check_box.setObjectName('media_plugin_check_box') self.ui_layout.addRow(self.media_plugin_check_box) - self.double_click_live_check_box = QtGui.QCheckBox(self.ui_group_box) + self.double_click_live_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.double_click_live_check_box.setObjectName('double_click_live_check_box') self.ui_layout.addRow(self.double_click_live_check_box) - self.single_click_preview_check_box = QtGui.QCheckBox(self.ui_group_box) + self.single_click_preview_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.single_click_preview_check_box.setObjectName('single_click_preview_check_box') self.ui_layout.addRow(self.single_click_preview_check_box) - self.expand_service_item_check_box = QtGui.QCheckBox(self.ui_group_box) + self.expand_service_item_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.expand_service_item_check_box.setObjectName('expand_service_item_check_box') self.ui_layout.addRow(self.expand_service_item_check_box) - self.search_as_type_check_box = QtGui.QCheckBox(self.ui_group_box) + self.search_as_type_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.search_as_type_check_box.setObjectName('SearchAsType_check_box') self.ui_layout.addRow(self.search_as_type_check_box) - self.enable_auto_close_check_box = QtGui.QCheckBox(self.ui_group_box) + self.enable_auto_close_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.enable_auto_close_check_box.setObjectName('enable_auto_close_check_box') self.ui_layout.addRow(self.enable_auto_close_check_box) self.left_layout.addWidget(self.ui_group_box) # Default service name - self.service_name_group_box = QtGui.QGroupBox(self.left_column) + self.service_name_group_box = QtWidgets.QGroupBox(self.left_column) self.service_name_group_box.setObjectName('service_name_group_box') - self.service_name_layout = QtGui.QFormLayout(self.service_name_group_box) - self.service_name_check_box = QtGui.QCheckBox(self.service_name_group_box) + self.service_name_layout = QtWidgets.QFormLayout(self.service_name_group_box) + self.service_name_check_box = QtWidgets.QCheckBox(self.service_name_group_box) self.service_name_check_box.setObjectName('service_name_check_box') self.service_name_layout.setObjectName('service_name_layout') self.service_name_layout.addRow(self.service_name_check_box) - self.service_name_time_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_time_label = QtWidgets.QLabel(self.service_name_group_box) self.service_name_time_label.setObjectName('service_name_time_label') - self.service_name_day = QtGui.QComboBox(self.service_name_group_box) + self.service_name_day = QtWidgets.QComboBox(self.service_name_group_box) self.service_name_day.addItems(['', '', '', '', '', '', '', '']) self.service_name_day.setObjectName('service_name_day') - self.service_name_time = QtGui.QTimeEdit(self.service_name_group_box) + self.service_name_time = QtWidgets.QTimeEdit(self.service_name_group_box) self.service_name_time.setObjectName('service_name_time') - self.service_name_time_layout = QtGui.QHBoxLayout() + self.service_name_time_layout = QtWidgets.QHBoxLayout() self.service_name_time_layout.setObjectName('service_name_time_layout') self.service_name_time_layout.addWidget(self.service_name_day) self.service_name_time_layout.addWidget(self.service_name_time) self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout) - self.service_name_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_label = QtWidgets.QLabel(self.service_name_group_box) self.service_name_label.setObjectName('service_name_label') - self.service_name_edit = QtGui.QLineEdit(self.service_name_group_box) + self.service_name_edit = QtWidgets.QLineEdit(self.service_name_group_box) self.service_name_edit.setObjectName('service_name_edit') self.service_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) - self.service_name_revert_button = QtGui.QToolButton(self.service_name_group_box) + self.service_name_revert_button = QtWidgets.QToolButton(self.service_name_group_box) self.service_name_revert_button.setObjectName('service_name_revert_button') self.service_name_revert_button.setIcon(build_icon(':/general/general_revert.png')) - self.service_name_button_layout = QtGui.QHBoxLayout() + self.service_name_button_layout = QtWidgets.QHBoxLayout() self.service_name_button_layout.setObjectName('service_name_button_layout') self.service_name_button_layout.addWidget(self.service_name_edit) self.service_name_button_layout.addWidget(self.service_name_revert_button) self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) - self.service_name_example_label = QtGui.QLabel(self.service_name_group_box) + self.service_name_example_label = QtWidgets.QLabel(self.service_name_group_box) self.service_name_example_label.setObjectName('service_name_example_label') - self.service_name_example = QtGui.QLabel(self.service_name_group_box) + self.service_name_example = QtWidgets.QLabel(self.service_name_group_box) self.service_name_example.setObjectName('service_name_example') self.service_name_layout.addRow(self.service_name_example_label, self.service_name_example) self.left_layout.addWidget(self.service_name_group_box) # Data Directory - self.data_directory_group_box = QtGui.QGroupBox(self.left_column) + self.data_directory_group_box = QtWidgets.QGroupBox(self.left_column) self.data_directory_group_box.setObjectName('data_directory_group_box') - self.data_directory_layout = QtGui.QFormLayout(self.data_directory_group_box) + self.data_directory_layout = QtWidgets.QFormLayout(self.data_directory_group_box) self.data_directory_layout.setObjectName('data_directory_layout') - self.data_directory_current_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_current_label = QtWidgets.QLabel(self.data_directory_group_box) self.data_directory_current_label.setObjectName('data_directory_current_label') - self.data_directory_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_label = QtWidgets.QLabel(self.data_directory_group_box) self.data_directory_label.setObjectName('data_directory_label') - self.data_directory_new_label = QtGui.QLabel(self.data_directory_group_box) + self.data_directory_new_label = QtWidgets.QLabel(self.data_directory_group_box) self.data_directory_new_label.setObjectName('data_directory_current_label') - self.new_data_directory_edit = QtGui.QLineEdit(self.data_directory_group_box) + self.new_data_directory_edit = QtWidgets.QLineEdit(self.data_directory_group_box) self.new_data_directory_edit.setObjectName('new_data_directory_edit') self.new_data_directory_edit.setReadOnly(True) - self.new_data_directory_has_files_label = QtGui.QLabel(self.data_directory_group_box) + self.new_data_directory_has_files_label = QtWidgets.QLabel(self.data_directory_group_box) self.new_data_directory_has_files_label.setObjectName('new_data_directory_has_files_label') self.new_data_directory_has_files_label.setWordWrap(True) - self.data_directory_browse_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_browse_button = QtWidgets.QToolButton(self.data_directory_group_box) self.data_directory_browse_button.setObjectName('data_directory_browse_button') self.data_directory_browse_button.setIcon(build_icon(':/general/general_open.png')) - self.data_directory_default_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_default_button = QtWidgets.QToolButton(self.data_directory_group_box) self.data_directory_default_button.setObjectName('data_directory_default_button') self.data_directory_default_button.setIcon(build_icon(':/general/general_revert.png')) - self.data_directory_cancel_button = QtGui.QToolButton(self.data_directory_group_box) + self.data_directory_cancel_button = QtWidgets.QToolButton(self.data_directory_group_box) self.data_directory_cancel_button.setObjectName('data_directory_cancel_button') self.data_directory_cancel_button.setIcon(build_icon(':/general/general_delete.png')) - self.new_data_directory_label_layout = QtGui.QHBoxLayout() + self.new_data_directory_label_layout = QtWidgets.QHBoxLayout() self.new_data_directory_label_layout.setObjectName('new_data_directory_label_layout') self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit) self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button) self.new_data_directory_label_layout.addWidget(self.data_directory_default_button) - self.data_directory_copy_check_layout = QtGui.QHBoxLayout() + self.data_directory_copy_check_layout = QtWidgets.QHBoxLayout() self.data_directory_copy_check_layout.setObjectName('data_directory_copy_check_layout') - self.data_directory_copy_check_box = QtGui.QCheckBox(self.data_directory_group_box) + self.data_directory_copy_check_box = QtWidgets.QCheckBox(self.data_directory_group_box) self.data_directory_copy_check_box.setObjectName('data_directory_copy_check_box') self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) self.data_directory_copy_check_layout.addStretch() @@ -171,26 +171,26 @@ class AdvancedTab(SettingsTab): self.left_layout.addWidget(self.data_directory_group_box) self.left_layout.addStretch() # Default Image - self.default_image_group_box = QtGui.QGroupBox(self.right_column) + self.default_image_group_box = QtWidgets.QGroupBox(self.right_column) self.default_image_group_box.setObjectName('default_image_group_box') - self.default_image_layout = QtGui.QFormLayout(self.default_image_group_box) + self.default_image_layout = QtWidgets.QFormLayout(self.default_image_group_box) self.default_image_layout.setObjectName('default_image_layout') - self.default_color_label = QtGui.QLabel(self.default_image_group_box) + self.default_color_label = QtWidgets.QLabel(self.default_image_group_box) self.default_color_label.setObjectName('default_color_label') self.default_color_button = ColorButton(self.default_image_group_box) self.default_color_button.setObjectName('default_color_button') self.default_image_layout.addRow(self.default_color_label, self.default_color_button) - self.default_file_label = QtGui.QLabel(self.default_image_group_box) + self.default_file_label = QtWidgets.QLabel(self.default_image_group_box) self.default_file_label.setObjectName('default_file_label') - self.default_file_edit = QtGui.QLineEdit(self.default_image_group_box) + self.default_file_edit = QtWidgets.QLineEdit(self.default_image_group_box) self.default_file_edit.setObjectName('default_file_edit') - self.default_browse_button = QtGui.QToolButton(self.default_image_group_box) + self.default_browse_button = QtWidgets.QToolButton(self.default_image_group_box) self.default_browse_button.setObjectName('default_browse_button') self.default_browse_button.setIcon(build_icon(':/general/general_open.png')) - self.default_revert_button = QtGui.QToolButton(self.default_image_group_box) + self.default_revert_button = QtWidgets.QToolButton(self.default_image_group_box) self.default_revert_button.setObjectName('default_revert_button') self.default_revert_button.setIcon(build_icon(':/general/general_revert.png')) - self.default_file_layout = QtGui.QHBoxLayout() + self.default_file_layout = QtWidgets.QHBoxLayout() self.default_file_layout.setObjectName('default_file_layout') self.default_file_layout.addWidget(self.default_file_edit) self.default_file_layout.addWidget(self.default_browse_button) @@ -198,41 +198,41 @@ class AdvancedTab(SettingsTab): self.default_image_layout.addRow(self.default_file_label, self.default_file_layout) self.right_layout.addWidget(self.default_image_group_box) # Hide mouse - self.hide_mouse_group_box = QtGui.QGroupBox(self.right_column) + self.hide_mouse_group_box = QtWidgets.QGroupBox(self.right_column) self.hide_mouse_group_box.setObjectName('hide_mouse_group_box') - self.hide_mouse_layout = QtGui.QVBoxLayout(self.hide_mouse_group_box) + self.hide_mouse_layout = QtWidgets.QVBoxLayout(self.hide_mouse_group_box) self.hide_mouse_layout.setObjectName('hide_mouse_layout') - self.hide_mouse_check_box = QtGui.QCheckBox(self.hide_mouse_group_box) + self.hide_mouse_check_box = QtWidgets.QCheckBox(self.hide_mouse_group_box) self.hide_mouse_check_box.setObjectName('hide_mouse_check_box') self.hide_mouse_layout.addWidget(self.hide_mouse_check_box) self.right_layout.addWidget(self.hide_mouse_group_box) # Service Item Slide Limits - self.slide_group_box = QtGui.QGroupBox(self.right_column) + self.slide_group_box = QtWidgets.QGroupBox(self.right_column) self.slide_group_box.setObjectName('slide_group_box') - self.slide_layout = QtGui.QVBoxLayout(self.slide_group_box) + self.slide_layout = QtWidgets.QVBoxLayout(self.slide_group_box) self.slide_layout.setObjectName('slide_layout') - self.slide_label = QtGui.QLabel(self.slide_group_box) + self.slide_label = QtWidgets.QLabel(self.slide_group_box) self.slide_label.setWordWrap(True) self.slide_layout.addWidget(self.slide_label) - self.end_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.end_slide_radio_button = QtWidgets.QRadioButton(self.slide_group_box) self.end_slide_radio_button.setObjectName('end_slide_radio_button') self.slide_layout.addWidget(self.end_slide_radio_button) - self.wrap_slide_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.wrap_slide_radio_button = QtWidgets.QRadioButton(self.slide_group_box) self.wrap_slide_radio_button.setObjectName('wrap_slide_radio_button') self.slide_layout.addWidget(self.wrap_slide_radio_button) - self.next_item_radio_button = QtGui.QRadioButton(self.slide_group_box) + self.next_item_radio_button = QtWidgets.QRadioButton(self.slide_group_box) self.next_item_radio_button.setObjectName('next_item_radio_button') self.slide_layout.addWidget(self.next_item_radio_button) self.right_layout.addWidget(self.slide_group_box) # Display Workarounds - self.display_workaround_group_box = QtGui.QGroupBox(self.left_column) + self.display_workaround_group_box = QtWidgets.QGroupBox(self.left_column) self.display_workaround_group_box.setObjectName('display_workaround_group_box') - self.display_workaround_layout = QtGui.QVBoxLayout(self.display_workaround_group_box) + self.display_workaround_layout = QtWidgets.QVBoxLayout(self.display_workaround_group_box) self.display_workaround_layout.setObjectName('display_workaround_layout') - self.x11_bypass_check_box = QtGui.QCheckBox(self.display_workaround_group_box) + self.x11_bypass_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box) self.x11_bypass_check_box.setObjectName('x11_bypass_check_box') self.display_workaround_layout.addWidget(self.x11_bypass_check_box) - self.alternate_rows_check_box = QtGui.QCheckBox(self.display_workaround_group_box) + self.alternate_rows_check_box = QtWidgets.QCheckBox(self.display_workaround_group_box) self.alternate_rows_check_box.setObjectName('alternate_rows_check_box') self.display_workaround_layout.addWidget(self.alternate_rows_check_box) self.right_layout.addWidget(self.display_workaround_group_box) @@ -374,7 +374,7 @@ class AdvancedTab(SettingsTab): self.current_data_path = AppLocation.get_data_path() if not os.path.exists(self.current_data_path): log.error('Data path not found %s' % self.current_data_path) - answer = QtGui.QMessageBox.critical( + answer = QtWidgets.QMessageBox.critical( self, translate('OpenLP.AdvancedTab', 'Data Directory Error'), translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n' 'This data directory was previously changed from the OpenLP ' @@ -383,9 +383,9 @@ class AdvancedTab(SettingsTab): 'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n' 'Click "Yes" to reset the data directory to the default ' 'location.').replace('%s', self.current_data_path), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.No: log.info('User requested termination') self.main_window.clean_up() sys.exit() @@ -514,8 +514,9 @@ class AdvancedTab(SettingsTab): Select an image for the default display screen. """ file_filters = '%s;;%s (*.*)' % (get_images_filter(), UiStrings().AllFiles) - filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.AdvancedTab', 'Open File'), '', - file_filters) + filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, + translate('OpenLP.AdvancedTab', 'Open File'), '', + file_filters) if filename: self.default_file_edit.setText(filename) self.default_file_edit.setFocus() @@ -526,9 +527,10 @@ class AdvancedTab(SettingsTab): """ old_root_path = str(self.data_directory_label.text()) # Get the new directory location. - new_data_path = QtGui.QFileDialog.getExistingDirectory(self, translate('OpenLP.AdvancedTab', - 'Select Data Directory Location'), - old_root_path, options=QtGui.QFileDialog.ShowDirsOnly) + new_data_path = QtWidgets.QFileDialog.getExistingDirectory(self, translate('OpenLP.AdvancedTab', + 'Select Data Directory Location'), + old_root_path, + options=QtWidgets.QFileDialog.ShowDirsOnly) # Set the new data path. if new_data_path: new_data_path = os.path.normpath(new_data_path) @@ -538,15 +540,15 @@ class AdvancedTab(SettingsTab): else: return # Make sure they want to change the data. - answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), - translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' - 'location of the OpenLP data directory to:\n\n%s\n\nThe data ' - 'directory will be changed when OpenLP is closed.'). - replace('%s', new_data_path), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer != QtGui.QMessageBox.Yes: + answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), + translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' + 'location of the OpenLP data directory to:\n\n%s\n\nThe data ' + 'directory will be changed when OpenLP is closed.'). + replace('%s', new_data_path), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer != QtWidgets.QMessageBox.Yes: return # Check if data already exists here. self.check_data_overwrite(new_data_path) @@ -563,15 +565,16 @@ class AdvancedTab(SettingsTab): if self.current_data_path.lower() != new_data_path.lower(): # Make sure they want to change the data location back to the # default. - answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), - translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' - 'location of the OpenLP data directory to the default ' - 'location?\n\nThis location will be used after OpenLP is ' - 'closed.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer != QtGui.QMessageBox.Yes: + answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), + translate('OpenLP.AdvancedTab', 'Are you sure you want to change ' + 'the location of the OpenLP data ' + 'directory to the default location?' + '\n\nThis location will be used ' + 'after OpenLP is closed.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer != QtWidgets.QMessageBox.Yes: return self.check_data_overwrite(new_data_path) # Save the new location. @@ -602,17 +605,17 @@ class AdvancedTab(SettingsTab): if os.path.exists(test_path): self.data_exists = True # Check is they want to replace existing data. - answer = QtGui.QMessageBox.warning(self, - translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), - translate('OpenLP.AdvancedTab', - 'WARNING: \n\nThe location you have selected \n\n%s\n\n' - 'appears to contain OpenLP data files. Do you wish to ' - 'replace these files with the current data files?'). - replace('%s', os.path.abspath(data_path,)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.Yes: + answer = QtWidgets.QMessageBox.warning(self, + translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'), + translate('OpenLP.AdvancedTab', + 'WARNING: \n\nThe location you have selected \n\n%s\n\n' + 'appears to contain OpenLP data files. Do you wish to ' + 'replace these files with the current data files?'). + replace('%s', os.path.abspath(data_path,)), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.Yes: self.data_directory_copy_check_box.setChecked(True) self.new_data_directory_has_files_label.show() else: @@ -648,9 +651,10 @@ class AdvancedTab(SettingsTab): :param checked: The state of the check box (boolean). """ - QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), - translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP ' - 'has been restarted.')) + QtWidgets.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), + translate('OpenLP.AdvancedTab', + 'This change will only take effect once OpenLP ' + 'has been restarted.')) def on_end_slide_button_clicked(self): """ diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 9c72f7d56..b8d60dac4 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -23,7 +23,7 @@ The GUI widgets of the exception dialog. """ -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button, create_button_box @@ -39,32 +39,32 @@ class Ui_ExceptionDialog(object): """ exception_dialog.setObjectName('exception_dialog') exception_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) - self.exception_layout = QtGui.QVBoxLayout(exception_dialog) + self.exception_layout = QtWidgets.QVBoxLayout(exception_dialog) self.exception_layout.setObjectName('exception_layout') - self.message_layout = QtGui.QHBoxLayout() + self.message_layout = QtWidgets.QHBoxLayout() self.message_layout.setObjectName('messageLayout') self.message_layout.addSpacing(12) - self.bug_label = QtGui.QLabel(exception_dialog) + self.bug_label = QtWidgets.QLabel(exception_dialog) self.bug_label.setPixmap(QtGui.QPixmap(':/graphics/exception.png')) - self.bug_label.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.bug_label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.bug_label.setObjectName('bug_label') self.message_layout.addWidget(self.bug_label) self.message_layout.addSpacing(12) - self.message_label = QtGui.QLabel(exception_dialog) + self.message_label = QtWidgets.QLabel(exception_dialog) self.message_label.setWordWrap(True) self.message_label.setObjectName('message_label') self.message_layout.addWidget(self.message_label) self.exception_layout.addLayout(self.message_layout) - self.description_explanation = QtGui.QLabel(exception_dialog) + self.description_explanation = QtWidgets.QLabel(exception_dialog) self.description_explanation.setObjectName('description_explanation') self.exception_layout.addWidget(self.description_explanation) - self.description_text_edit = QtGui.QPlainTextEdit(exception_dialog) + self.description_text_edit = QtWidgets.QPlainTextEdit(exception_dialog) self.description_text_edit.setObjectName('description_text_edit') self.exception_layout.addWidget(self.description_text_edit) - self.description_word_count = QtGui.QLabel(exception_dialog) + self.description_word_count = QtWidgets.QLabel(exception_dialog) self.description_word_count.setObjectName('description_word_count') self.exception_layout.addWidget(self.description_word_count) - self.exception_text_edit = QtGui.QPlainTextEdit(exception_dialog) + self.exception_text_edit = QtWidgets.QPlainTextEdit(exception_dialog) self.exception_text_edit.setReadOnly(True) self.exception_text_edit.setObjectName('exception_text_edit') self.exception_layout.addWidget(self.exception_text_edit) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 60b744c05..65e00c82b 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -33,13 +33,8 @@ from lxml import etree from openlp.core.common import RegistryProperties, is_linux -from PyQt4 import Qt, QtCore, QtGui, QtWebKit +from PyQt5 import Qt, QtCore, QtGui, QtWebKit, QtWidgets -try: - from PyQt4.phonon import Phonon - PHONON_VERSION = Phonon.phononVersion() -except ImportError: - PHONON_VERSION = '-' try: import migrate MIGRATE_VERSION = getattr(migrate, '__version__', '< 0.7') @@ -86,7 +81,7 @@ from .exceptiondialog import Ui_ExceptionDialog log = logging.getLogger(__name__) -class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): +class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties): """ The exception dialog """ @@ -98,14 +93,14 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): self.setupUi(self) self.settings_section = 'crashreport' - def exec_(self): + def exec(self): """ Show the dialog. """ self.description_text_edit.setPlainText('') self.on_description_updated() self.file_attachment = None - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def _create_report(self): """ @@ -116,9 +111,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): traceback = self.exception_text_edit.toPlainText() system = translate('OpenLP.ExceptionForm', 'Platform: %s\n') % platform.platform() libraries = 'Python: %s\n' % platform.python_version() + \ - 'Qt4: %s\n' % Qt.qVersion() + \ - 'Phonon: %s\n' % PHONON_VERSION + \ - 'PyQt4: %s\n' % Qt.PYQT_VERSION_STR + \ + 'Qt5: %s\n' % Qt.qVersion() + \ + 'PyQt5: %s\n' % Qt.PYQT_VERSION_STR + \ 'QtWebkit: %s\n' % WEBKIT_VERSION + \ 'SQLAlchemy: %s\n' % sqlalchemy.__version__ + \ 'SQLAlchemy Migrate: %s\n' % MIGRATE_VERSION + \ @@ -150,11 +144,11 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n') - filename = QtGui.QFileDialog.getSaveFileName( + filename = QtWidgets.QFileDialog.getSaveFileName( self, translate('OpenLP.ExceptionForm', 'Save Crash Report'), Settings().value(self.settings_section + '/last directory'), - translate('OpenLP.ExceptionForm', 'Text files (*.txt *.log *.text)')) + translate('OpenLP.ExceptionForm', 'Text files (*.txt *.log *.text)'))[0] if filename: filename = str(filename).replace('/', os.path.sep) Settings().setValue(self.settings_section + '/last directory', os.path.dirname(filename)) @@ -195,7 +189,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): if ':' in line: exception = line.split('\n')[-1].split(':')[0] subject = 'Bug report: %s in %s' % (exception, source) - mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org') + mail_to_url = QtCore.QUrlQuery('mailto:bugs@openlp.org') mail_to_url.addQueryItem('subject', subject) mail_to_url.addQueryItem('body', body % content) if self.file_attachment: @@ -219,9 +213,12 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): """ Attache files to the bug report e-mail. """ - files = QtGui.QFileDialog.getOpenFileName(self, translate('ImagePlugin.ExceptionDialog', 'Select Attachment'), - Settings().value(self.settings_section + '/last directory'), - '%s (*)' % UiStrings().AllFiles) + files, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, + translate('ImagePlugin.ExceptionDialog', + 'Select Attachment'), + Settings().value(self.settings_section + + '/last directory'), + '%s (*)' % UiStrings().AllFiles) log.info('New files(s) %s', str(files)) if files: self.file_attachment = str(files) diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 83cfee351..19550215d 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -22,7 +22,7 @@ """ The UI widgets for the rename dialog """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box @@ -39,12 +39,12 @@ class Ui_FileRenameDialog(object): file_rename_dialog.setObjectName('file_rename_dialog') file_rename_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) file_rename_dialog.resize(300, 10) - self.dialog_layout = QtGui.QGridLayout(file_rename_dialog) + self.dialog_layout = QtWidgets.QGridLayout(file_rename_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.file_name_label = QtGui.QLabel(file_rename_dialog) + self.file_name_label = QtWidgets.QLabel(file_rename_dialog) self.file_name_label.setObjectName('file_name_label') self.dialog_layout.addWidget(self.file_name_label, 0, 0) - self.file_name_edit = QtGui.QLineEdit(file_rename_dialog) + self.file_name_edit = QtWidgets.QLineEdit(file_rename_dialog) self.file_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self)) self.file_name_edit.setObjectName('file_name_edit') self.dialog_layout.addWidget(self.file_name_edit, 0, 1) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 7446cdf9e..7d84a97d2 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -23,14 +23,14 @@ The file rename dialog. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from .filerenamedialog import Ui_FileRenameDialog from openlp.core.common import Registry, RegistryProperties, translate -class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): +class FileRenameForm(QtWidgets.QDialog, Ui_FileRenameDialog, RegistryProperties): """ The file rename dialog """ @@ -47,7 +47,7 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): """ self.setupUi(self) - def exec_(self, copy=False): + def exec(self, copy=False): """ Run the Dialog with correct heading. """ @@ -56,4 +56,4 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): else: self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) self.file_name_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 22218f983..e5ea662ee 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -33,7 +33,7 @@ import urllib.error from tempfile import gettempdir from configparser import ConfigParser, MissingSectionHeaderError, NoSectionError, NoOptionError -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, \ translate, clean_button_text, trace_error_handler @@ -91,7 +91,7 @@ class ThemeScreenshotWorker(QtCore.QObject): self.was_download_cancelled = toggle -class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): +class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties): """ This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. """ @@ -151,12 +151,12 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): else: return self.get_next_page_id() - def exec_(self): + def exec(self): """ Run the wizard. """ self.set_defaults() - return QtGui.QWizard.exec_(self) + return QtWidgets.QWizard.exec(self) def initialize(self, screens): """ @@ -182,14 +182,14 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): try: web_config = get_web_page('%s%s' % (self.web, 'download.cfg'), header=('User-Agent', user_agent)) except (urllib.error.URLError, ConnectionError) as err: - msg = QtGui.QMessageBox() + msg = QtWidgets.QMessageBox() title = translate('OpenLP.FirstTimeWizard', 'Network Error') msg.setText('{} {}'.format(title, err.code if hasattr(err, 'code') else '')) msg.setInformativeText(translate('OpenLP.FirstTimeWizard', 'There was a network error attempting to ' 'connect to retrieve initial configuration information')) msg.setStandardButtons(msg.Ok) - ans = msg.exec_() + ans = msg.exec() web_config = False if web_config: files = web_config.read() @@ -226,7 +226,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): title = self.config.get('songs_%s' % song, 'title') filename = self.config.get('songs_%s' % song, 'filename') sha256 = self.config.get('songs_%s' % song, 'sha256', fallback='') - item = QtGui.QListWidgetItem(title, self.songs_list_widget) + item = QtWidgets.QListWidgetItem(title, self.songs_list_widget) item.setData(QtCore.Qt.UserRole, (filename, sha256)) item.setCheckState(QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -235,7 +235,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): for lang in bible_languages: self.application.process_events() language = self.config.get('bibles_%s' % lang, 'title') - lang_item = QtGui.QTreeWidgetItem(self.bibles_tree_widget, [language]) + lang_item = QtWidgets.QTreeWidgetItem(self.bibles_tree_widget, [language]) bibles = self.config.get('bibles_%s' % lang, 'translations') bibles = bibles.split(',') for bible in bibles: @@ -243,7 +243,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): title = self.config.get('bible_%s' % bible, 'title') filename = self.config.get('bible_%s' % bible, 'filename') sha256 = self.config.get('bible_%s' % bible, 'sha256', fallback='') - item = QtGui.QTreeWidgetItem(lang_item, [title]) + item = QtWidgets.QTreeWidgetItem(lang_item, [title]) item.setData(0, QtCore.Qt.UserRole, (filename, sha256)) item.setCheckState(0, QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -370,7 +370,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): :param title: The title of the theme :param filename: The filename of the theme """ - item = QtGui.QListWidgetItem(title, self.themes_list_widget) + item = QtWidgets.QListWidgetItem(title, self.themes_list_widget) item.setData(QtCore.Qt.UserRole, (filename, sha256)) item.setCheckState(QtCore.Qt.Unchecked) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) @@ -510,7 +510,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): size = self._get_file_size('%s%s' % (self.songs_url, filename)) self.max_progress += size # Loop through the Bibles list and increase for each selected item - iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget) + iterator = QtWidgets.QTreeWidgetItemIterator(self.bibles_tree_widget) while iterator.value(): self.application.process_events() item = iterator.value() @@ -562,20 +562,20 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to return to OpenLP.') % - clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) + clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to start OpenLP.') % - clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) + clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to return to OpenLP.') % - clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) + clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to start OpenLP.') % - clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) + clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) self.finish_button.setVisible(True) self.finish_button.setEnabled(True) self.cancel_button.setVisible(False) @@ -631,7 +631,7 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): if not self.url_get_file('%s%s' % (self.songs_url, filename), destination, sha256): missed_files.append('Song: {}'.format(filename)) # Download Bibles - bibles_iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget) + bibles_iterator = QtWidgets.QTreeWidgetItemIterator(self.bibles_tree_widget) while bibles_iterator.value(): item = bibles_iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: @@ -656,15 +656,15 @@ class FirstTimeForm(QtGui.QWizard, UiFirstTimeWizard, RegistryProperties): file_list = '' for entry in missed_files: file_list += '{}
'.format(entry) - msg = QtGui.QMessageBox() - msg.setIcon(QtGui.QMessageBox.Warning) + msg = QtWidgets.QMessageBox() + msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'Network Error')) msg.setText(translate('OpenLP.FirstTimeWizard', 'Unable to download some files')) msg.setInformativeText(translate('OpenLP.FirstTimeWizard', 'The following files were not able to be ' 'downloaded:
{}'.format(file_list))) msg.setStandardButtons(msg.Ok) - ans = msg.exec_() + ans = msg.exec() return True def _set_plugin_status(self, field, tag): diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index 4eab093fa..8adf72b4e 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -22,7 +22,7 @@ """ The UI widgets of the language selection dialog. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -40,20 +40,20 @@ class Ui_FirstTimeLanguageDialog(object): language_dialog.setObjectName('language_dialog') language_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) language_dialog.resize(300, 50) - self.dialog_layout = QtGui.QVBoxLayout(language_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(language_dialog) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setSpacing(8) self.dialog_layout.setObjectName('dialog_layout') - self.info_label = QtGui.QLabel(language_dialog) + self.info_label = QtWidgets.QLabel(language_dialog) self.info_label.setObjectName('info_label') self.dialog_layout.addWidget(self.info_label) - self.language_layout = QtGui.QHBoxLayout() + self.language_layout = QtWidgets.QHBoxLayout() self.language_layout.setObjectName('language_layout') - self.language_label = QtGui.QLabel(language_dialog) + self.language_label = QtWidgets.QLabel(language_dialog) self.language_label.setObjectName('language_label') self.language_layout.addWidget(self.language_label) - self.language_combo_box = QtGui.QComboBox(language_dialog) - self.language_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.language_combo_box = QtWidgets.QComboBox(language_dialog) + self.language_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) self.language_combo_box.setObjectName("language_combo_box") self.language_layout.addWidget(self.language_combo_box) self.dialog_layout.addLayout(self.language_layout) diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 129c9f72d..b1bd7e7f4 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -22,14 +22,14 @@ """ The language selection dialog. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib.ui import create_action from openlp.core.utils import LanguageManager from .firsttimelanguagedialog import Ui_FirstTimeLanguageDialog -class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): +class FirstTimeLanguageForm(QtWidgets.QDialog, Ui_FirstTimeLanguageDialog): """ The language selection dialog. """ @@ -43,11 +43,11 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): self.language_combo_box.addItem('Autodetect') self.language_combo_box.addItems(sorted(self.qm_list.keys())) - def exec_(self): + def exec(self): """ Run the Dialog with correct heading. """ - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def accept(self): """ @@ -61,7 +61,7 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): LanguageManager.auto_language = False action = create_action(None, self.language_combo_box.currentText()) LanguageManager.set_language(action, False) - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) def reject(self): """ @@ -69,4 +69,4 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): """ LanguageManager.auto_language = True LanguageManager.set_language(False, False) - return QtGui.QDialog.reject(self) + return QtWidgets.QDialog.reject(self) diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 041cfc050..ec2acf881 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -22,7 +22,7 @@ """ The UI widgets for the first time wizard. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import translate, is_macosx, clean_button_text from openlp.core.lib import build_icon @@ -58,118 +58,118 @@ class UiFirstTimeWizard(object): first_time_wizard.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) first_time_wizard.resize(550, 386) first_time_wizard.setModal(True) - first_time_wizard.setOptions(QtGui.QWizard.IndependentPages | QtGui.QWizard.NoBackButtonOnStartPage | - QtGui.QWizard.NoBackButtonOnLastPage | QtGui.QWizard.HaveCustomButton1 | - QtGui.QWizard.HaveCustomButton2) + first_time_wizard.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage | + QtWidgets.QWizard.NoBackButtonOnLastPage | QtWidgets.QWizard.HaveCustomButton1 | + QtWidgets.QWizard.HaveCustomButton2) if is_macosx(): - first_time_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap, + first_time_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) first_time_wizard.resize(634, 386) else: - first_time_wizard.setWizardStyle(QtGui.QWizard.ModernStyle) - self.finish_button = self.button(QtGui.QWizard.FinishButton) - self.no_internet_finish_button = self.button(QtGui.QWizard.CustomButton1) - self.cancel_button = self.button(QtGui.QWizard.CancelButton) - self.no_internet_cancel_button = self.button(QtGui.QWizard.CustomButton2) - self.next_button = self.button(QtGui.QWizard.NextButton) - self.back_button = self.button(QtGui.QWizard.BackButton) + first_time_wizard.setWizardStyle(QtWidgets.QWizard.ModernStyle) + self.finish_button = self.button(QtWidgets.QWizard.FinishButton) + self.no_internet_finish_button = self.button(QtWidgets.QWizard.CustomButton1) + self.cancel_button = self.button(QtWidgets.QWizard.CancelButton) + self.no_internet_cancel_button = self.button(QtWidgets.QWizard.CustomButton2) + self.next_button = self.button(QtWidgets.QWizard.NextButton) + self.back_button = self.button(QtWidgets.QWizard.BackButton) add_welcome_page(first_time_wizard, ':/wizards/wizard_firsttime.bmp') # The download page - self.download_page = QtGui.QWizardPage() + self.download_page = QtWidgets.QWizardPage() self.download_page.setObjectName('download_page') - self.download_layout = QtGui.QVBoxLayout(self.download_page) - self.download_layout.setMargin(48) + self.download_layout = QtWidgets.QVBoxLayout(self.download_page) + self.download_layout.setContentsMargins(48, 48, 48, 48) self.download_layout.setObjectName('download_layout') - self.download_label = QtGui.QLabel(self.download_page) + self.download_label = QtWidgets.QLabel(self.download_page) self.download_label.setObjectName('download_label') self.download_layout.addWidget(self.download_label) first_time_wizard.setPage(FirstTimePage.Download, self.download_page) # The "you don't have an internet connection" page. - self.no_internet_page = QtGui.QWizardPage() + self.no_internet_page = QtWidgets.QWizardPage() self.no_internet_page.setObjectName('no_internet_page') - self.no_internet_layout = QtGui.QVBoxLayout(self.no_internet_page) + self.no_internet_layout = QtWidgets.QVBoxLayout(self.no_internet_page) self.no_internet_layout.setContentsMargins(50, 30, 50, 40) self.no_internet_layout.setObjectName('no_internet_layout') - self.no_internet_label = QtGui.QLabel(self.no_internet_page) + self.no_internet_label = QtWidgets.QLabel(self.no_internet_page) self.no_internet_label.setWordWrap(True) self.no_internet_label.setObjectName('no_internet_label') self.no_internet_layout.addWidget(self.no_internet_label) first_time_wizard.setPage(FirstTimePage.NoInternet, self.no_internet_page) # The plugins page - self.plugin_page = QtGui.QWizardPage() + self.plugin_page = QtWidgets.QWizardPage() self.plugin_page.setObjectName('plugin_page') - self.plugin_layout = QtGui.QVBoxLayout(self.plugin_page) + self.plugin_layout = QtWidgets.QVBoxLayout(self.plugin_page) self.plugin_layout.setContentsMargins(40, 15, 40, 0) self.plugin_layout.setObjectName('plugin_layout') - self.songs_check_box = QtGui.QCheckBox(self.plugin_page) + self.songs_check_box = QtWidgets.QCheckBox(self.plugin_page) self.songs_check_box.setChecked(True) self.songs_check_box.setObjectName('songs_check_box') self.plugin_layout.addWidget(self.songs_check_box) - self.custom_check_box = QtGui.QCheckBox(self.plugin_page) + self.custom_check_box = QtWidgets.QCheckBox(self.plugin_page) self.custom_check_box.setChecked(True) self.custom_check_box.setObjectName('custom_check_box') self.plugin_layout.addWidget(self.custom_check_box) - self.bible_check_box = QtGui.QCheckBox(self.plugin_page) + self.bible_check_box = QtWidgets.QCheckBox(self.plugin_page) self.bible_check_box.setChecked(True) self.bible_check_box.setObjectName('bible_check_box') self.plugin_layout.addWidget(self.bible_check_box) - self.image_check_box = QtGui.QCheckBox(self.plugin_page) + self.image_check_box = QtWidgets.QCheckBox(self.plugin_page) self.image_check_box.setChecked(True) self.image_check_box.setObjectName('image_check_box') self.plugin_layout.addWidget(self.image_check_box) - self.presentation_check_box = QtGui.QCheckBox(self.plugin_page) + self.presentation_check_box = QtWidgets.QCheckBox(self.plugin_page) self.presentation_check_box.setChecked(True) self.presentation_check_box.setObjectName('presentation_check_box') self.plugin_layout.addWidget(self.presentation_check_box) - self.media_check_box = QtGui.QCheckBox(self.plugin_page) + self.media_check_box = QtWidgets.QCheckBox(self.plugin_page) self.media_check_box.setChecked(True) self.media_check_box.setObjectName('media_check_box') self.plugin_layout.addWidget(self.media_check_box) - self.remote_check_box = QtGui.QCheckBox(self.plugin_page) + self.remote_check_box = QtWidgets.QCheckBox(self.plugin_page) self.remote_check_box.setObjectName('remote_check_box') self.plugin_layout.addWidget(self.remote_check_box) - self.song_usage_check_box = QtGui.QCheckBox(self.plugin_page) + self.song_usage_check_box = QtWidgets.QCheckBox(self.plugin_page) self.song_usage_check_box.setChecked(True) self.song_usage_check_box.setObjectName('song_usage_check_box') self.plugin_layout.addWidget(self.song_usage_check_box) - self.alert_check_box = QtGui.QCheckBox(self.plugin_page) + self.alert_check_box = QtWidgets.QCheckBox(self.plugin_page) self.alert_check_box.setChecked(True) self.alert_check_box.setObjectName('alert_check_box') self.plugin_layout.addWidget(self.alert_check_box) first_time_wizard.setPage(FirstTimePage.Plugins, self.plugin_page) # The song samples page - self.songs_page = QtGui.QWizardPage() + self.songs_page = QtWidgets.QWizardPage() self.songs_page.setObjectName('songs_page') - self.songs_layout = QtGui.QVBoxLayout(self.songs_page) + self.songs_layout = QtWidgets.QVBoxLayout(self.songs_page) self.songs_layout.setContentsMargins(50, 20, 50, 20) self.songs_layout.setObjectName('songs_layout') - self.songs_list_widget = QtGui.QListWidget(self.songs_page) + self.songs_list_widget = QtWidgets.QListWidget(self.songs_page) self.songs_list_widget.setAlternatingRowColors(True) self.songs_list_widget.setObjectName('songs_list_widget') self.songs_layout.addWidget(self.songs_list_widget) first_time_wizard.setPage(FirstTimePage.Songs, self.songs_page) # The Bible samples page - self.bibles_page = QtGui.QWizardPage() + self.bibles_page = QtWidgets.QWizardPage() self.bibles_page.setObjectName('bibles_page') - self.bibles_layout = QtGui.QVBoxLayout(self.bibles_page) + self.bibles_layout = QtWidgets.QVBoxLayout(self.bibles_page) self.bibles_layout.setContentsMargins(50, 20, 50, 20) self.bibles_layout.setObjectName('bibles_layout') - self.bibles_tree_widget = QtGui.QTreeWidget(self.bibles_page) + self.bibles_tree_widget = QtWidgets.QTreeWidget(self.bibles_page) self.bibles_tree_widget.setAlternatingRowColors(True) self.bibles_tree_widget.header().setVisible(False) self.bibles_tree_widget.setObjectName('bibles_tree_widget') self.bibles_layout.addWidget(self.bibles_tree_widget) first_time_wizard.setPage(FirstTimePage.Bibles, self.bibles_page) # The theme samples page - self.themes_page = QtGui.QWizardPage() + self.themes_page = QtWidgets.QWizardPage() self.themes_page.setObjectName('themes_page') - self.themes_layout = QtGui.QVBoxLayout(self.themes_page) + self.themes_layout = QtWidgets.QVBoxLayout(self.themes_page) self.themes_layout.setContentsMargins(20, 50, 20, 60) self.themes_layout.setObjectName('themes_layout') - self.themes_list_widget = QtGui.QListWidget(self.themes_page) - self.themes_list_widget.setViewMode(QtGui.QListView.IconMode) - self.themes_list_widget.setMovement(QtGui.QListView.Static) - self.themes_list_widget.setFlow(QtGui.QListView.LeftToRight) + self.themes_list_widget = QtWidgets.QListWidget(self.themes_page) + self.themes_list_widget.setViewMode(QtWidgets.QListView.IconMode) + self.themes_list_widget.setMovement(QtWidgets.QListView.Static) + self.themes_list_widget.setFlow(QtWidgets.QListView.LeftToRight) self.themes_list_widget.setSpacing(4) self.themes_list_widget.setUniformItemSizes(True) self.themes_list_widget.setIconSize(QtCore.QSize(133, 100)) @@ -178,37 +178,37 @@ class UiFirstTimeWizard(object): self.themes_layout.addWidget(self.themes_list_widget) first_time_wizard.setPage(FirstTimePage.Themes, self.themes_page) # the default settings page - self.defaults_page = QtGui.QWizardPage() + self.defaults_page = QtWidgets.QWizardPage() self.defaults_page.setObjectName('defaults_page') - self.defaults_layout = QtGui.QFormLayout(self.defaults_page) + self.defaults_layout = QtWidgets.QFormLayout(self.defaults_page) self.defaults_layout.setContentsMargins(50, 20, 50, 20) self.defaults_layout.setObjectName('defaults_layout') - self.display_label = QtGui.QLabel(self.defaults_page) + self.display_label = QtWidgets.QLabel(self.defaults_page) self.display_label.setObjectName('display_label') - self.display_combo_box = QtGui.QComboBox(self.defaults_page) + self.display_combo_box = QtWidgets.QComboBox(self.defaults_page) self.display_combo_box.setEditable(False) - self.display_combo_box.setInsertPolicy(QtGui.QComboBox.NoInsert) + self.display_combo_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) self.display_combo_box.setObjectName('display_combo_box') self.defaults_layout.addRow(self.display_label, self.display_combo_box) - self.theme_label = QtGui.QLabel(self.defaults_page) + self.theme_label = QtWidgets.QLabel(self.defaults_page) self.theme_label.setObjectName('theme_label') - self.theme_combo_box = QtGui.QComboBox(self.defaults_page) + self.theme_combo_box = QtWidgets.QComboBox(self.defaults_page) self.theme_combo_box.setEditable(False) - self.theme_combo_box.setInsertPolicy(QtGui.QComboBox.NoInsert) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.theme_combo_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) + self.theme_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) self.theme_combo_box.setObjectName('theme_combo_box') self.defaults_layout.addRow(self.theme_label, self.theme_combo_box) first_time_wizard.setPage(FirstTimePage.Defaults, self.defaults_page) # Progress page - self.progress_page = QtGui.QWizardPage() + self.progress_page = QtWidgets.QWizardPage() self.progress_page.setObjectName('progress_page') - self.progress_layout = QtGui.QVBoxLayout(self.progress_page) - self.progress_layout.setMargin(48) + self.progress_layout = QtWidgets.QVBoxLayout(self.progress_page) + self.progress_layout.setContentsMargins(48, 48, 48, 48) self.progress_layout.setObjectName('progress_layout') - self.progress_label = QtGui.QLabel(self.progress_page) + self.progress_label = QtWidgets.QLabel(self.progress_page) self.progress_label.setObjectName('progress_label') self.progress_layout.addWidget(self.progress_label) - self.progress_bar = QtGui.QProgressBar(self.progress_page) + self.progress_bar = QtWidgets.QProgressBar(self.progress_page) self.progress_bar.setObjectName('progress_bar') self.progress_layout.addWidget(self.progress_bar) first_time_wizard.setPage(FirstTimePage.Progress, self.progress_page) @@ -226,7 +226,7 @@ class UiFirstTimeWizard(object): first_time_wizard.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the %s button below to start.') % - clean_button_text(first_time_wizard.buttonText(QtGui.QWizard.NextButton))) + clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.NextButton))) self.download_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading Resource Index')) self.download_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while the resource index is ' 'downloaded.')) @@ -256,7 +256,7 @@ class UiFirstTimeWizard(object): self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard', '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' 'click the %s button now.') % \ - clean_button_text(first_time_wizard.buttonText(QtGui.QWizard.CancelButton)) + clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) @@ -272,5 +272,5 @@ class UiFirstTimeWizard(object): self.progress_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded ' 'and OpenLP is configured.')) self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...')) - first_time_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish')) - first_time_wizard.setButtonText(QtGui.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel')) + first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish')) + first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel')) diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index 5dff428ed..3e14d4b57 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -22,7 +22,7 @@ """ The UI widgets for the formatting tags window. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -40,66 +40,66 @@ class Ui_FormattingTagDialog(object): formatting_tag_dialog.setObjectName('formatting_tag_dialog') formatting_tag_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) formatting_tag_dialog.resize(725, 548) - self.list_data_grid_layout = QtGui.QVBoxLayout(formatting_tag_dialog) - self.list_data_grid_layout.setMargin(8) + self.list_data_grid_layout = QtWidgets.QVBoxLayout(formatting_tag_dialog) + self.list_data_grid_layout.setContentsMargins(8, 8, 8, 8) self.list_data_grid_layout.setObjectName('list_data_grid_layout') - self.tag_table_widget_read_label = QtGui.QLabel() + self.tag_table_widget_read_label = QtWidgets.QLabel() self.list_data_grid_layout.addWidget(self.tag_table_widget_read_label) - self.tag_table_widget_read = QtGui.QTableWidget(formatting_tag_dialog) + self.tag_table_widget_read = QtWidgets.QTableWidget(formatting_tag_dialog) self.tag_table_widget_read.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.tag_table_widget_read.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.tag_table_widget_read.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.tag_table_widget_read.setAlternatingRowColors(True) self.tag_table_widget_read.setCornerButtonEnabled(False) self.tag_table_widget_read.setObjectName('tag_table_widget_read') self.tag_table_widget_read.setColumnCount(4) self.tag_table_widget_read.setRowCount(0) self.tag_table_widget_read.horizontalHeader().setStretchLastSection(True) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget_read.setHorizontalHeaderItem(0, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget_read.setHorizontalHeaderItem(1, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget_read.setHorizontalHeaderItem(2, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget_read.setHorizontalHeaderItem(3, item) self.list_data_grid_layout.addWidget(self.tag_table_widget_read) - self.tag_table_widget_label = QtGui.QLabel() + self.tag_table_widget_label = QtWidgets.QLabel() self.list_data_grid_layout.addWidget(self.tag_table_widget_label) - self.tag_table_widget = QtGui.QTableWidget(formatting_tag_dialog) + self.tag_table_widget = QtWidgets.QTableWidget(formatting_tag_dialog) self.tag_table_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.tag_table_widget.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers) + self.tag_table_widget.setEditTriggers(QtWidgets.QAbstractItemView.AllEditTriggers) self.tag_table_widget.setAlternatingRowColors(True) - self.tag_table_widget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) - self.tag_table_widget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) + self.tag_table_widget.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) + self.tag_table_widget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.tag_table_widget.setCornerButtonEnabled(False) self.tag_table_widget.setObjectName('tag_table_widget') self.tag_table_widget.setColumnCount(4) self.tag_table_widget.setRowCount(0) self.tag_table_widget.horizontalHeader().setStretchLastSection(True) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget.setHorizontalHeaderItem(0, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget.setHorizontalHeaderItem(1, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget.setHorizontalHeaderItem(2, item) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() self.tag_table_widget.setHorizontalHeaderItem(3, item) self.list_data_grid_layout.addWidget(self.tag_table_widget) - self.edit_button_layout = QtGui.QHBoxLayout() - self.new_button = QtGui.QPushButton(formatting_tag_dialog) + self.edit_button_layout = QtWidgets.QHBoxLayout() + self.new_button = QtWidgets.QPushButton(formatting_tag_dialog) self.new_button.setIcon(build_icon(':/general/general_new.png')) self.new_button.setObjectName('new_button') self.edit_button_layout.addWidget(self.new_button) - self.delete_button = QtGui.QPushButton(formatting_tag_dialog) + self.delete_button = QtWidgets.QPushButton(formatting_tag_dialog) self.delete_button.setIcon(build_icon(':/general/general_delete.png')) self.delete_button.setObjectName('delete_button') self.edit_button_layout.addWidget(self.delete_button) self.edit_button_layout.addStretch() self.list_data_grid_layout.addLayout(self.edit_button_layout) self.button_box = create_button_box(formatting_tag_dialog, 'button_box', ['cancel', 'save', 'defaults']) - self.save_button = self.button_box.button(QtGui.QDialogButtonBox.Save) + self.save_button = self.button_box.button(QtWidgets.QDialogButtonBox.Save) self.save_button.setObjectName('save_button') - self.restore_button = self.button_box.button(QtGui.QDialogButtonBox.RestoreDefaults) + self.restore_button = self.button_box.button(QtWidgets.QDialogButtonBox.RestoreDefaults) self.restore_button.setIcon(build_icon(':/general/general_revert.png')) self.restore_button.setObjectName('restore_button') self.list_data_grid_layout.addWidget(self.button_box) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index a2fa48c2a..bd2a32978 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -25,7 +25,7 @@ Custom tags can be defined and saved. The Custom Tag arrays are saved in a json Base Tags cannot be changed. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import FormattingTags @@ -43,7 +43,7 @@ class EditColumn(object): EndHtml = 3 -class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagController): +class FormattingTagForm(QtWidgets.QDialog, Ui_FormattingTagDialog, FormattingTagController): """ The :class:`FormattingTagForm` manages the settings tab . """ @@ -70,13 +70,13 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont self.is_deleting = False self.reloading = False - def exec_(self): + def exec(self): """ Load Display and set field state. """ # Create initial copy from master self._reloadTable() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def on_row_selected(self): """ @@ -90,12 +90,12 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont """ new_row = self.tag_table_widget.rowCount() self.tag_table_widget.insertRow(new_row) - self.tag_table_widget.setItem(new_row, 0, QtGui.QTableWidgetItem(translate('OpenLP.FormattingTagForm', - 'New Tag %d' % new_row))) - self.tag_table_widget.setItem(new_row, 1, QtGui.QTableWidgetItem('n%d' % new_row)) + self.tag_table_widget.setItem(new_row, 0, QtWidgets.QTableWidgetItem(translate('OpenLP.FormattingTagForm', + 'New Tag %d' % new_row))) + self.tag_table_widget.setItem(new_row, 1, QtWidgets.QTableWidgetItem('n%d' % new_row)) self.tag_table_widget.setItem(new_row, 2, - QtGui.QTableWidgetItem(translate('OpenLP.FormattingTagForm', ''))) - self.tag_table_widget.setItem(new_row, 3, QtGui.QTableWidgetItem('')) + QtWidgets.QTableWidgetItem(translate('OpenLP.FormattingTagForm', ''))) + self.tag_table_widget.setItem(new_row, 3, QtWidgets.QTableWidgetItem('')) self.tag_table_widget.resizeRowsToContents() self.tag_table_widget.scrollToBottom() self.tag_table_widget.selectRow(new_row) @@ -121,13 +121,13 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont self.tag_table_widget.item(count, 2).text(), self.tag_table_widget.item(count, 3).text()) if error: - QtGui.QMessageBox.warning(self, translate('OpenLP.FormattingTagForm', 'Validation Error'), error, - QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.warning(self, translate('OpenLP.FormattingTagForm', 'Validation Error'), error, + QtWidgets.QMessageBox.Ok) self.tag_table_widget.selectRow(count) return count += 1 self.services.save_tags() - QtGui.QDialog.accept(self) + QtWidgets.QDialog.accept(self) def _reloadTable(self): """ @@ -144,18 +144,18 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont if html['protected']: line = self.tag_table_widget_read.rowCount() self.tag_table_widget_read.setRowCount(line + 1) - self.tag_table_widget_read.setItem(line, 0, QtGui.QTableWidgetItem(html['desc'])) - self.tag_table_widget_read.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html['start tag']))) - self.tag_table_widget_read.setItem(line, 2, QtGui.QTableWidgetItem(html['start html'])) - self.tag_table_widget_read.setItem(line, 3, QtGui.QTableWidgetItem(html['end html'])) + self.tag_table_widget_read.setItem(line, 0, QtWidgets.QTableWidgetItem(html['desc'])) + self.tag_table_widget_read.setItem(line, 1, QtWidgets.QTableWidgetItem(self._strip(html['start tag']))) + self.tag_table_widget_read.setItem(line, 2, QtWidgets.QTableWidgetItem(html['start html'])) + self.tag_table_widget_read.setItem(line, 3, QtWidgets.QTableWidgetItem(html['end html'])) self.tag_table_widget_read.resizeRowsToContents() else: line = self.tag_table_widget.rowCount() self.tag_table_widget.setRowCount(line + 1) - self.tag_table_widget.setItem(line, 0, QtGui.QTableWidgetItem(html['desc'])) - self.tag_table_widget.setItem(line, 1, QtGui.QTableWidgetItem(self._strip(html['start tag']))) - self.tag_table_widget.setItem(line, 2, QtGui.QTableWidgetItem(html['start html'])) - self.tag_table_widget.setItem(line, 3, QtGui.QTableWidgetItem(html['end html'])) + self.tag_table_widget.setItem(line, 0, QtWidgets.QTableWidgetItem(html['desc'])) + self.tag_table_widget.setItem(line, 1, QtWidgets.QTableWidgetItem(self._strip(html['start tag']))) + self.tag_table_widget.setItem(line, 2, QtWidgets.QTableWidgetItem(html['start html'])) + self.tag_table_widget.setItem(line, 3, QtWidgets.QTableWidgetItem(html['end html'])) self.tag_table_widget.resizeRowsToContents() # Permanent (persistent) tags do not have this key html['temporary'] = False @@ -187,7 +187,7 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont end_html = item.text() errors, tag = self.services.start_tag_changed(text, end_html) if tag: - self.tag_table_widget.setItem(pre_row, 3, QtGui.QTableWidgetItem(tag)) + self.tag_table_widget.setItem(pre_row, 3, QtWidgets.QTableWidgetItem(tag)) self.tag_table_widget.resizeRowsToContents() elif pre_col is EditColumn.EndHtml: # HTML edited @@ -195,8 +195,8 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont start_html = item.text() errors, tag = self.services.end_tag_changed(start_html, text) if tag: - self.tag_table_widget.setItem(pre_row, 3, QtGui.QTableWidgetItem(tag)) + self.tag_table_widget.setItem(pre_row, 3, QtWidgets.QTableWidgetItem(tag)) if errors: - QtGui.QMessageBox.warning(self, translate('OpenLP.FormattingTagForm', 'Validation Error'), errors, - QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.warning(self, translate('OpenLP.FormattingTagForm', 'Validation Error'), errors, + QtWidgets.QMessageBox.Ok) self.tag_table_widget.resizeRowsToContents() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index f54659bb2..47a6a9594 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -24,7 +24,7 @@ The general tab of the configuration dialog. """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.lib import SettingsTab, ScreenList @@ -53,50 +53,50 @@ class GeneralTab(SettingsTab): super(GeneralTab, self).setupUi() self.tab_layout.setStretch(1, 1) # Monitors - self.monitor_group_box = QtGui.QGroupBox(self.left_column) + self.monitor_group_box = QtWidgets.QGroupBox(self.left_column) self.monitor_group_box.setObjectName('monitor_group_box') - self.monitor_layout = QtGui.QGridLayout(self.monitor_group_box) + self.monitor_layout = QtWidgets.QGridLayout(self.monitor_group_box) self.monitor_layout.setObjectName('monitor_layout') - self.monitor_radio_button = QtGui.QRadioButton(self.monitor_group_box) + self.monitor_radio_button = QtWidgets.QRadioButton(self.monitor_group_box) self.monitor_radio_button.setObjectName('monitor_radio_button') self.monitor_layout.addWidget(self.monitor_radio_button, 0, 0, 1, 5) - self.monitor_combo_box = QtGui.QComboBox(self.monitor_group_box) + self.monitor_combo_box = QtWidgets.QComboBox(self.monitor_group_box) self.monitor_combo_box.setObjectName('monitor_combo_box') self.monitor_layout.addWidget(self.monitor_combo_box, 1, 1, 1, 4) # Display Position - self.override_radio_button = QtGui.QRadioButton(self.monitor_group_box) + self.override_radio_button = QtWidgets.QRadioButton(self.monitor_group_box) self.override_radio_button.setObjectName('override_radio_button') self.monitor_layout.addWidget(self.override_radio_button, 2, 0, 1, 5) # Custom position - self.custom_x_label = QtGui.QLabel(self.monitor_group_box) + self.custom_x_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_x_label.setObjectName('custom_x_label') self.monitor_layout.addWidget(self.custom_x_label, 3, 1) - self.custom_X_value_edit = QtGui.QSpinBox(self.monitor_group_box) + self.custom_X_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_X_value_edit.setObjectName('custom_X_value_edit') self.custom_X_value_edit.setRange(-9999, 9999) self.monitor_layout.addWidget(self.custom_X_value_edit, 4, 1) - self.custom_y_label = QtGui.QLabel(self.monitor_group_box) + self.custom_y_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_y_label.setObjectName('custom_y_label') self.monitor_layout.addWidget(self.custom_y_label, 3, 2) - self.custom_Y_value_edit = QtGui.QSpinBox(self.monitor_group_box) + self.custom_Y_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_Y_value_edit.setObjectName('custom_Y_value_edit') self.custom_Y_value_edit.setRange(-9999, 9999) self.monitor_layout.addWidget(self.custom_Y_value_edit, 4, 2) - self.custom_width_label = QtGui.QLabel(self.monitor_group_box) + self.custom_width_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_width_label.setObjectName('custom_width_label') self.monitor_layout.addWidget(self.custom_width_label, 3, 3) - self.custom_width_value_edit = QtGui.QSpinBox(self.monitor_group_box) + self.custom_width_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_width_value_edit.setObjectName('custom_width_value_edit') self.custom_width_value_edit.setRange(1, 9999) self.monitor_layout.addWidget(self.custom_width_value_edit, 4, 3) - self.custom_height_label = QtGui.QLabel(self.monitor_group_box) + self.custom_height_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_height_label.setObjectName('custom_height_label') self.monitor_layout.addWidget(self.custom_height_label, 3, 4) - self.custom_height_value_edit = QtGui.QSpinBox(self.monitor_group_box) + self.custom_height_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_height_value_edit.setObjectName('custom_height_value_edit') self.custom_height_value_edit.setRange(1, 9999) self.monitor_layout.addWidget(self.custom_height_value_edit, 4, 4) - self.display_on_monitor_check = QtGui.QCheckBox(self.monitor_group_box) + self.display_on_monitor_check = QtWidgets.QCheckBox(self.monitor_group_box) self.display_on_monitor_check.setObjectName('monitor_combo_box') self.monitor_layout.addWidget(self.display_on_monitor_check, 5, 0, 1, 5) # Set up the stretchiness of each column, so that the first column @@ -108,77 +108,77 @@ class GeneralTab(SettingsTab): self.monitor_layout.setColumnStretch(4, 3) self.left_layout.addWidget(self.monitor_group_box) # CCLI Details - self.ccli_group_box = QtGui.QGroupBox(self.left_column) + self.ccli_group_box = QtWidgets.QGroupBox(self.left_column) self.ccli_group_box.setObjectName('ccli_group_box') - self.ccli_layout = QtGui.QFormLayout(self.ccli_group_box) + self.ccli_layout = QtWidgets.QFormLayout(self.ccli_group_box) self.ccli_layout.setObjectName('ccli_layout') - self.number_label = QtGui.QLabel(self.ccli_group_box) + self.number_label = QtWidgets.QLabel(self.ccli_group_box) self.number_label.setObjectName('number_label') - self.number_edit = QtGui.QLineEdit(self.ccli_group_box) + self.number_edit = QtWidgets.QLineEdit(self.ccli_group_box) self.number_edit.setValidator(QtGui.QIntValidator()) self.number_edit.setObjectName('number_edit') self.ccli_layout.addRow(self.number_label, self.number_edit) - self.username_label = QtGui.QLabel(self.ccli_group_box) + self.username_label = QtWidgets.QLabel(self.ccli_group_box) self.username_label.setObjectName('username_label') - self.username_edit = QtGui.QLineEdit(self.ccli_group_box) + self.username_edit = QtWidgets.QLineEdit(self.ccli_group_box) self.username_edit.setObjectName('username_edit') self.ccli_layout.addRow(self.username_label, self.username_edit) - self.password_label = QtGui.QLabel(self.ccli_group_box) + self.password_label = QtWidgets.QLabel(self.ccli_group_box) self.password_label.setObjectName('password_label') - self.password_edit = QtGui.QLineEdit(self.ccli_group_box) - self.password_edit.setEchoMode(QtGui.QLineEdit.Password) + self.password_edit = QtWidgets.QLineEdit(self.ccli_group_box) + self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password) self.password_edit.setObjectName('password_edit') self.ccli_layout.addRow(self.password_label, self.password_edit) self.left_layout.addWidget(self.ccli_group_box) # Background audio - self.audio_group_box = QtGui.QGroupBox(self.left_column) + self.audio_group_box = QtWidgets.QGroupBox(self.left_column) self.audio_group_box.setObjectName('audio_group_box') - self.audio_layout = QtGui.QVBoxLayout(self.audio_group_box) + self.audio_layout = QtWidgets.QVBoxLayout(self.audio_group_box) self.audio_layout.setObjectName('audio_layout') - self.start_paused_check_box = QtGui.QCheckBox(self.audio_group_box) + self.start_paused_check_box = QtWidgets.QCheckBox(self.audio_group_box) self.start_paused_check_box.setObjectName('start_paused_check_box') self.audio_layout.addWidget(self.start_paused_check_box) - self.repeat_list_check_box = QtGui.QCheckBox(self.audio_group_box) + self.repeat_list_check_box = QtWidgets.QCheckBox(self.audio_group_box) self.repeat_list_check_box.setObjectName('repeat_list_check_box') self.audio_layout.addWidget(self.repeat_list_check_box) self.left_layout.addWidget(self.audio_group_box) self.left_layout.addStretch() # Application Startup - self.startup_group_box = QtGui.QGroupBox(self.right_column) + self.startup_group_box = QtWidgets.QGroupBox(self.right_column) self.startup_group_box.setObjectName('startup_group_box') - self.startup_layout = QtGui.QVBoxLayout(self.startup_group_box) + self.startup_layout = QtWidgets.QVBoxLayout(self.startup_group_box) self.startup_layout.setObjectName('startup_layout') - self.warning_check_box = QtGui.QCheckBox(self.startup_group_box) + self.warning_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.warning_check_box.setObjectName('warning_check_box') self.startup_layout.addWidget(self.warning_check_box) - self.auto_open_check_box = QtGui.QCheckBox(self.startup_group_box) + self.auto_open_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.auto_open_check_box.setObjectName('auto_open_check_box') self.startup_layout.addWidget(self.auto_open_check_box) - self.show_splash_check_box = QtGui.QCheckBox(self.startup_group_box) + self.show_splash_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.show_splash_check_box.setObjectName('show_splash_check_box') self.startup_layout.addWidget(self.show_splash_check_box) - self.check_for_updates_check_box = QtGui.QCheckBox(self.startup_group_box) + self.check_for_updates_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.check_for_updates_check_box.setObjectName('check_for_updates_check_box') self.startup_layout.addWidget(self.check_for_updates_check_box) self.right_layout.addWidget(self.startup_group_box) # Application Settings - self.settings_group_box = QtGui.QGroupBox(self.right_column) + self.settings_group_box = QtWidgets.QGroupBox(self.right_column) self.settings_group_box.setObjectName('settings_group_box') - self.settings_layout = QtGui.QFormLayout(self.settings_group_box) + self.settings_layout = QtWidgets.QFormLayout(self.settings_group_box) self.settings_layout.setObjectName('settings_layout') - self.save_check_service_check_box = QtGui.QCheckBox(self.settings_group_box) + self.save_check_service_check_box = QtWidgets.QCheckBox(self.settings_group_box) self.save_check_service_check_box.setObjectName('save_check_service_check_box') self.settings_layout.addRow(self.save_check_service_check_box) - self.auto_unblank_check_box = QtGui.QCheckBox(self.settings_group_box) + self.auto_unblank_check_box = QtWidgets.QCheckBox(self.settings_group_box) self.auto_unblank_check_box.setObjectName('auto_unblank_check_box') self.settings_layout.addRow(self.auto_unblank_check_box) - self.auto_preview_check_box = QtGui.QCheckBox(self.settings_group_box) + self.auto_preview_check_box = QtWidgets.QCheckBox(self.settings_group_box) self.auto_preview_check_box.setObjectName('auto_preview_check_box') self.settings_layout.addRow(self.auto_preview_check_box) # Moved here from image tab - self.timeout_label = QtGui.QLabel(self.settings_group_box) + self.timeout_label = QtWidgets.QLabel(self.settings_group_box) self.timeout_label.setObjectName('timeout_label') - self.timeout_spin_box = QtGui.QSpinBox(self.settings_group_box) + self.timeout_spin_box = QtWidgets.QSpinBox(self.settings_group_box) self.timeout_spin_box.setObjectName('timeout_spin_box') self.timeout_spin_box.setRange(1, 180) self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box) diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index e8cfbdf80..e64f02520 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -24,13 +24,13 @@ The :mod:`listpreviewwidget` is a widget that lists the slides in the slide cont It is based on a QTableWidget but represents its contents in list form. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import RegistryProperties from openlp.core.lib import ImageSource, ServiceItem -class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): +class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): """ A special type of QTableWidget which lists the slides in the slide controller @@ -45,7 +45,7 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): An empty ``ServiceItem`` is used by default. replace_service_manager_item() needs to be called to make this widget display something. """ - super(QtGui.QTableWidget, self).__init__(parent) + super(QtWidgets.QTableWidget, self).__init__(parent) self._setup(screen_ratio) def _setup(self, screen_ratio): @@ -55,9 +55,9 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): self.setColumnCount(1) self.horizontalHeader().setVisible(False) self.setColumnWidth(0, self.parent().width()) - self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) - self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) - self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) + self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setAlternatingRowColors(True) # Initialize variables. @@ -111,7 +111,7 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): text = [] for frame_number, frame in enumerate(self.service_item.get_frames()): self.setRowCount(self.slide_count() + 1) - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() slide_height = 0 if self.service_item.is_text(): if frame['verseTag']: @@ -124,8 +124,8 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): row += 1 item.setText(frame['text']) else: - label = QtGui.QLabel() - label.setMargin(4) + label = QtWidgets.QLabel() + label.setContentsMargins(4, 4, 4, 4) if self.service_item.is_media(): label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) else: diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index d59090d40..05ab222b9 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -32,13 +32,7 @@ Some of the code for this form is based on the examples at: import html import logging -from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL - -PHONON_AVAILABLE = True -try: - from PyQt4.phonon import Phonon -except ImportError: - PHONON_AVAILABLE = False +from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte @@ -68,7 +62,7 @@ QGraphicsView { """ -class Display(QtGui.QGraphicsView): +class Display(QtWidgets.QGraphicsView): """ This is a general display screen class. Here the general display settings will done. It will be used as specialized classes by Main Display and Preview display. @@ -97,7 +91,7 @@ class Display(QtGui.QGraphicsView): Set up and build the screen base """ self.setGeometry(self.screen['size']) - self.web_view = QtWebKit.QWebView(self) + self.web_view = QtWebKitWidgets.QWebView(self) self.web_view.setGeometry(0, 0, self.screen['size'].width(), self.screen['size'].height()) self.web_view.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled, True) palette = self.web_view.palette() @@ -144,7 +138,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.override = {} self.retranslateUi() self.media_object = None - if self.is_live and PHONON_AVAILABLE: + if self.is_live: self.audio_player = AudioPlayer(self) else: self.audio_player = None @@ -397,7 +391,7 @@ class MainDisplay(OpenLPMixin, Display, RegistryProperties): self.setVisible(True) else: self.setVisible(True) - return QtGui.QPixmap.grabWidget(self) + return self.grab() def build_html(self, service_item, image_path=''): """ @@ -511,6 +505,7 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): """ This Class will play audio only allowing components to work with a soundtrack independent of the user interface. """ + position_changed = QtCore.pyqtSignal(int) def __init__(self, parent): """ @@ -519,78 +514,66 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): :param parent: The parent widget. """ super(AudioPlayer, self).__init__(parent) - self.current_index = -1 - self.playlist = [] - self.repeat = False - self.media_object = Phonon.MediaObject() - self.media_object.setTickInterval(100) - self.audio_object = Phonon.AudioOutput(Phonon.VideoCategory) - Phonon.createPath(self.media_object, self.audio_object) - self.media_object.aboutToFinish.connect(self.on_about_to_finish) - self.media_object.finished.connect(self.on_finished) + self.player = QtMultimedia.QMediaPlayer() + self.playlist = QtMultimedia.QMediaPlaylist(self.player) + self.volume_slider = None + self.player.positionChanged.connect(self._on_position_changed) def __del__(self): """ Shutting down so clean up connections """ self.stop() - for path in self.media_object.outputPaths(): - path.disconnect() - def on_about_to_finish(self): + def _on_position_changed(self, position): """ - Just before the audio player finishes the current track, queue the next - item in the playlist, if there is one. + Emit a signal when the position of the media player updates """ - self.current_index += 1 - if len(self.playlist) > self.current_index: - self.media_object.enqueue(self.playlist[self.current_index]) + self.position_changed.emit(position) - def on_finished(self): + def set_volume_slider(self, slider): """ - When the audio track finishes. + Connect the volume slider to the media player + :param slider: """ - if self.repeat: - self.log_debug('Repeat is enabled... here we go again!') - self.media_object.clearQueue() - self.media_object.clear() - self.current_index = -1 - self.play() + self.volume_slider = slider + self.volume_slider.setMinimum(0) + self.volume_slider.setMaximum(100) + self.volume_slider.setValue(self.player.volume()) + self.volume_slider.valueChanged.connect(self.set_volume) - def connectVolumeSlider(self, slider): + def set_volume(self, volume): """ - Connect the volume slider to the output channel. + Set the volume of the media player + + :param volume: """ - slider.setAudioOutput(self.audio_object) + self.player.setVolume(volume) def reset(self): """ Reset the audio player, clearing the playlist and the queue. """ - self.current_index = -1 - self.playlist = [] self.stop() - self.media_object.clear() + self.playlist.clear() def play(self): """ We want to play the file so start it """ - if self.current_index == -1: - self.on_about_to_finish() - self.media_object.play() + self.player.play() def pause(self): """ Pause the Audio """ - self.media_object.pause() + self.player.pause() def stop(self): """ Stop the Audio and clean up """ - self.media_object.stop() + self.player.stop() def add_to_playlist(self, file_names): """ @@ -600,23 +583,14 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): """ if not isinstance(file_names, list): file_names = [file_names] - self.playlist.extend(list(map(Phonon.MediaSource, file_names))) + for file_name in file_names: + self.playlist.addMedia(QtCore.QUrl(file_name)) def next(self): """ Skip forward to the next track in the list """ - if not self.repeat and self.current_index + 1 >= len(self.playlist): - return - is_playing = self.media_object.state() == Phonon.PlayingState - self.current_index += 1 - if self.repeat and self.current_index == len(self.playlist): - self.current_index = 0 - self.media_object.clearQueue() - self.media_object.clear() - self.media_object.enqueue(self.playlist[self.current_index]) - if is_playing: - self.media_object.play() + self.player.next() def go_to(self, index): """ @@ -624,19 +598,6 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): :param index: The track to go to """ - is_playing = self.media_object.state() == Phonon.PlayingState - self.media_object.clearQueue() - self.media_object.clear() - self.current_index = index - self.media_object.enqueue(self.playlist[self.current_index]) - if is_playing: - self.media_object.play() - - def connectSlot(self, signal, slot): - """ - Connect a slot to a signal on the media object. Used by slidecontroller to connect to audio object. - - :param slot: The slot the signal is attached to. - :param signal: The signal to be fired - """ - QtCore.QObject.connect(self.media_object, signal, slot) + self.playlist.setCurrentIndex(index) + if self.player.state() == QtMultimedia.QMediaPlayer.PlayingState: + self.player.play() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 10c67e79a..dc6ee3eb0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -32,7 +32,7 @@ from tempfile import gettempdir import time from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, translate, \ is_win, is_macosx @@ -89,14 +89,14 @@ class Ui_MainWindow(object): if is_macosx(): main_window.setDocumentMode(True) # Set up the main container, which contains all the other form widgets. - self.main_content = QtGui.QWidget(main_window) + self.main_content = QtWidgets.QWidget(main_window) self.main_content.setObjectName('main_content') - self.main_content_layout = QtGui.QHBoxLayout(self.main_content) + self.main_content_layout = QtWidgets.QHBoxLayout(self.main_content) self.main_content_layout.setSpacing(0) - self.main_content_layout.setMargin(0) + self.main_content_layout.setContentsMargins(0, 0, 0, 0) self.main_content_layout.setObjectName('main_content_layout') main_window.setCentralWidget(self.main_content) - self.control_splitter = QtGui.QSplitter(self.main_content) + self.control_splitter = QtWidgets.QSplitter(self.main_content) self.control_splitter.setOrientation(QtCore.Qt.Horizontal) self.control_splitter.setObjectName('control_splitter') self.main_content_layout.addWidget(self.control_splitter) @@ -107,47 +107,47 @@ class Ui_MainWindow(object): live_visible = Settings().value('user interface/live panel') panel_locked = Settings().value('user interface/lock panel') # Create menu - self.menu_bar = QtGui.QMenuBar(main_window) + self.menu_bar = QtWidgets.QMenuBar(main_window) self.menu_bar.setObjectName('menu_bar') - self.file_menu = QtGui.QMenu(self.menu_bar) + self.file_menu = QtWidgets.QMenu(self.menu_bar) self.file_menu.setObjectName('fileMenu') - self.recent_files_menu = QtGui.QMenu(self.file_menu) + self.recent_files_menu = QtWidgets.QMenu(self.file_menu) self.recent_files_menu.setObjectName('recentFilesMenu') - self.file_import_menu = QtGui.QMenu(self.file_menu) + self.file_import_menu = QtWidgets.QMenu(self.file_menu) if not is_macosx(): self.file_import_menu.setIcon(build_icon(u':/general/general_import.png')) self.file_import_menu.setObjectName('file_import_menu') - self.file_export_menu = QtGui.QMenu(self.file_menu) + self.file_export_menu = QtWidgets.QMenu(self.file_menu) if not is_macosx(): self.file_export_menu.setIcon(build_icon(u':/general/general_export.png')) self.file_export_menu.setObjectName('file_export_menu') # View Menu - self.view_menu = QtGui.QMenu(self.menu_bar) + self.view_menu = QtWidgets.QMenu(self.menu_bar) self.view_menu.setObjectName('viewMenu') - self.view_mode_menu = QtGui.QMenu(self.view_menu) + self.view_mode_menu = QtWidgets.QMenu(self.view_menu) self.view_mode_menu.setObjectName('viewModeMenu') # Tools Menu - self.tools_menu = QtGui.QMenu(self.menu_bar) + self.tools_menu = QtWidgets.QMenu(self.menu_bar) self.tools_menu.setObjectName('tools_menu') # Settings Menu - self.settings_menu = QtGui.QMenu(self.menu_bar) + self.settings_menu = QtWidgets.QMenu(self.menu_bar) self.settings_menu.setObjectName('settingsMenu') - self.settings_language_menu = QtGui.QMenu(self.settings_menu) + self.settings_language_menu = QtWidgets.QMenu(self.settings_menu) self.settings_language_menu.setObjectName('settingsLanguageMenu') # Help Menu - self.help_menu = QtGui.QMenu(self.menu_bar) + self.help_menu = QtWidgets.QMenu(self.menu_bar) self.help_menu.setObjectName('helpMenu') main_window.setMenuBar(self.menu_bar) - self.status_bar = QtGui.QStatusBar(main_window) + self.status_bar = QtWidgets.QStatusBar(main_window) self.status_bar.setObjectName('status_bar') main_window.setStatusBar(self.status_bar) - self.load_progress_bar = QtGui.QProgressBar(self.status_bar) + self.load_progress_bar = QtWidgets.QProgressBar(self.status_bar) self.load_progress_bar.setObjectName('load_progress_bar') self.status_bar.addPermanentWidget(self.load_progress_bar) self.load_progress_bar.hide() self.load_progress_bar.setValue(0) self.load_progress_bar.setStyleSheet(PROGRESSBAR_STYLE) - self.default_theme_label = QtGui.QLabel(self.status_bar) + self.default_theme_label = QtWidgets.QLabel(self.status_bar) self.default_theme_label.setObjectName('default_theme_label') self.status_bar.addPermanentWidget(self.default_theme_label) # Create the MediaManager @@ -155,7 +155,7 @@ class Ui_MainWindow(object): ':/system/system_mediamanager.png') self.media_manager_dock.setStyleSheet(MEDIA_MANAGER_STYLE) # Create the media toolbox - self.media_tool_box = QtGui.QToolBox(self.media_manager_dock) + self.media_tool_box = QtWidgets.QToolBox(self.media_manager_dock) self.media_tool_box.setObjectName('media_tool_box') self.media_manager_dock.setWidget(self.media_tool_box) main_window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.media_manager_dock) @@ -202,7 +202,7 @@ class Ui_MainWindow(object): can_shortcuts=True, category=UiStrings().File, triggers=main_window.close) # Give QT Extra Hint that this is the Exit Menu Item - self.file_exit_item.setMenuRole(QtGui.QAction.QuitRole) + self.file_exit_item.setMenuRole(QtWidgets.QAction.QuitRole) action_list.add_category(UiStrings().Import, CategoryOrder.standard_menu) self.import_theme_item = create_action(main_window, 'importThemeItem', category=UiStrings().Import, can_shortcuts=True) @@ -249,7 +249,7 @@ class Ui_MainWindow(object): can_shortcuts=True) self.mode_live_item = create_action(main_window, 'modeLiveItem', checked=True, category=UiStrings().ViewMode, can_shortcuts=True) - self.mode_group = QtGui.QActionGroup(main_window) + self.mode_group = QtWidgets.QActionGroup(main_window) self.mode_group.addAction(self.mode_default_item) self.mode_group.addAction(self.mode_setup_item) self.mode_group.addAction(self.mode_live_item) @@ -275,7 +275,7 @@ class Ui_MainWindow(object): triggers=self.on_plugin_item_clicked) # i18n Language Items self.auto_language_item = create_action(main_window, 'autoLanguageItem', checked=LanguageManager.auto_language) - self.language_group = QtGui.QActionGroup(main_window) + self.language_group = QtWidgets.QActionGroup(main_window) self.language_group.setExclusive(True) self.language_group.setObjectName('languageGroup') add_actions(self.language_group, [self.auto_language_item]) @@ -295,7 +295,7 @@ class Ui_MainWindow(object): icon=':/system/system_settings.png', can_shortcuts=True, category=UiStrings().Settings) # Give QT Extra Hint that this is the Preferences Menu Item - self.settings_configure_item.setMenuRole(QtGui.QAction.PreferencesRole) + self.settings_configure_item.setMenuRole(QtWidgets.QAction.PreferencesRole) self.settings_import_item = create_action(main_window, 'settingsImportItem', category=UiStrings().Import, can_shortcuts=True) self.settings_export_item = create_action(main_window, 'settingsExportItem', @@ -305,7 +305,7 @@ class Ui_MainWindow(object): can_shortcuts=True, category=UiStrings().Help, triggers=self.on_about_item_clicked) # Give QT Extra Hint that this is an About Menu Item - self.about_item.setMenuRole(QtGui.QAction.AboutRole) + self.about_item.setMenuRole(QtWidgets.QAction.AboutRole) if is_win(): self.local_help_file = os.path.join(AppLocation.get_directory(AppLocation.AppDir), 'OpenLP.chm') self.offline_help_item = create_action(main_window, 'offlineHelpItem', @@ -353,8 +353,8 @@ class Ui_MainWindow(object): # menu. If we are running on Mac OS X the menu items whose title contains those keywords but don't belong in the # main menu need to be marked as such with QAction.NoRole. if is_macosx(): - self.settings_shortcuts_item.setMenuRole(QtGui.QAction.NoRole) - self.formatting_tag_item.setMenuRole(QtGui.QAction.NoRole) + self.settings_shortcuts_item.setMenuRole(QtWidgets.QAction.NoRole) + self.formatting_tag_item.setMenuRole(QtWidgets.QAction.NoRole) add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) add_actions(self.tools_menu, (self.tools_add_tool_item, None)) @@ -492,10 +492,11 @@ class Ui_MainWindow(object): self.mode_live_item.setStatusTip(translate('OpenLP.MainWindow', 'Set the view mode to Live.')) -class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): +class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties): """ The main window. """ + openlp_version_check = QtCore.pyqtSignal(QtCore.QVariant) log.info('MainWindow loaded') def __init__(self): @@ -566,7 +567,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.application.set_busy_cursor() # Simple message boxes Registry().register_function('theme_update_global', self.default_theme_changed) - QtCore.QObject.connect(self, QtCore.SIGNAL('openlp_version_check'), self.version_notice) + self.openlp_version_check.connect(self.version_notice) Registry().register_function('config_screen_changed', self.screen_changed) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) # Reset the cursor @@ -622,14 +623,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): version_text = translate('OpenLP.MainWindow', 'Version %s of OpenLP is now available for download (you are ' 'currently running version %s). \n\nYou can download the latest version from ' 'http://openlp.org/.') - QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), - version_text % (version, get_application_version()[u'full'])) + QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Version Updated'), + version_text % (version, get_application_version()[u'full'])) def show(self): """ Show the main form, as well as the display form """ - QtGui.QWidget.show(self) + QtWidgets.QWidget.show(self) if self.live_controller.display.isVisible(): self.live_controller.display.setFocus() self.activateWindow() @@ -676,20 +677,21 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): themes are imported. The default theme is changed (if necessary). The plugins in pluginmanager are set active/in-active to match the selection in the wizard. """ - answer = QtGui.QMessageBox.warning(self, - translate('OpenLP.MainWindow', 'Re-run First Time Wizard?'), - translate('OpenLP.MainWindow', 'Are you sure you want to re-run the First ' - 'Time Wizard?\n\nRe-running this wizard may make changes to your ' - 'current OpenLP configuration and possibly add songs to your ' - 'existing songs list and change your default theme.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: + answer = QtWidgets.QMessageBox.warning(self, + translate('OpenLP.MainWindow', 'Re-run First Time Wizard?'), + translate('OpenLP.MainWindow', + 'Are you sure you want to re-run the First ' + 'Time Wizard?\n\nRe-running this wizard may make changes to ' + 'your current OpenLP configuration and possibly add songs to ' + 'your existing songs list and change your default theme.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.No: return first_run_wizard = FirstTimeForm(self) first_run_wizard.initialize(ScreenList()) - first_run_wizard.exec_() + first_run_wizard.exec() if first_run_wizard.was_cancelled: return self.application.set_busy_cursor() @@ -722,8 +724,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.live_controller.main_display_set_background() if settings.value('%s/screen blank' % self.general_settings_section): if settings.value('%s/blank warning' % self.general_settings_section): - QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), - translate('OpenLP.MainWindow', 'The Main Display has been blanked out')) + QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), + translate('OpenLP.MainWindow', 'The Main Display has been blanked out')) def error_message(self, title, message): """ @@ -734,7 +736,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ if hasattr(self.application, 'splash'): self.application.splash.close() - QtGui.QMessageBox.critical(self, title, message) + QtWidgets.QMessageBox.critical(self, title, message) def warning_message(self, title, message): """ @@ -745,7 +747,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ if hasattr(self.application, 'splash'): self.application.splash.close() - QtGui.QMessageBox.warning(self, title, message) + QtWidgets.QMessageBox.warning(self, title, message) def information_message(self, title, message): """ @@ -756,7 +758,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ if hasattr(self.application, 'splash'): self.application.splash.close() - QtGui.QMessageBox.information(self, title, message) + QtWidgets.QMessageBox.information(self, title, message) def on_help_web_site_clicked(self): """ @@ -782,14 +784,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Show the About form """ - self.about_form.exec_() + self.about_form.exec() def on_plugin_item_clicked(self): """ Show the Plugin form """ self.plugin_form.load() - self.plugin_form.exec_() + self.plugin_form.exec() def on_tools_open_data_folder_clicked(self): """ @@ -808,13 +810,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Show the Settings dialog """ - self.formatting_tag_form.exec_() + self.formatting_tag_form.exec() def on_settings_configure_iem_clicked(self): """ Show the Settings dialog """ - self.settings_form.exec_() + self.settings_form.exec() def paintEvent(self, event): """ @@ -827,29 +829,31 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Show the shortcuts dialog """ - if self.shortcut_form.exec_(): + if self.shortcut_form.exec(): self.shortcut_form.save() def on_settings_import_item_clicked(self): """ Import settings from an export INI file """ - answer = QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings?'), - translate('OpenLP.MainWindow', 'Are you sure you want to import ' - 'settings?\n\n Importing settings will ' - 'make permanent changes to your current ' - 'OpenLP configuration.\n\n Importing ' - 'incorrect settings may cause erratic ' - 'behaviour or OpenLP to terminate ' - 'abnormally.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: + answer = QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings?'), + translate('OpenLP.MainWindow', 'Are you sure you want to import ' + 'settings?\n\n Importing settings will ' + 'make permanent changes to your current ' + 'OpenLP configuration.\n\n Importing ' + 'incorrect settings may cause erratic ' + 'behaviour or OpenLP to terminate ' + 'abnormally.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.No: return - import_file_name = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.MainWindow', 'Open File'), '', - translate('OpenLP.MainWindow', 'OpenLP Export Settings ' - 'Files (*.conf)')) + import_file_name, filter_used = QtWidgets.QFileDialog.getOpenFileName( + self, + translate('OpenLP.MainWindow', 'Open File'), + '', + translate('OpenLP.MainWindow', 'OpenLP Export Settings Files (*.conf)')) if not import_file_name: return setting_sections = [] @@ -882,11 +886,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): # Lets do a basic sanity check. If it contains this string we can assume it was created by OpenLP and so we'll # load what we can from it, and just silently ignore anything we don't recognise. if import_settings.value('SettingsImport/type') != 'OpenLP_settings_export': - QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'), - translate('OpenLP.MainWindow', 'The file you have selected does not appear to ' - 'be a valid OpenLP settings file.\n\nProcessing has terminated and ' - 'no changes have been made.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Import settings'), + translate('OpenLP.MainWindow', 'The file you have selected does not appear ' + 'to be a valid OpenLP settings file.\n\n' + 'Processing has terminated and ' + 'no changes have been made.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) return import_keys = import_settings.allKeys() for section_key in import_keys: @@ -921,10 +926,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): settings.sync() # We must do an immediate restart or current configuration will overwrite what was just imported when # application terminates normally. We need to exit without saving configuration. - QtGui.QMessageBox.information(self, translate('OpenLP.MainWindow', 'Import settings'), - translate('OpenLP.MainWindow', 'OpenLP will now close. Imported settings will ' - 'be applied the next time you start OpenLP.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.information(self, translate('OpenLP.MainWindow', 'Import settings'), + translate('OpenLP.MainWindow', + 'OpenLP will now close. Imported settings will ' + 'be applied the next time you start OpenLP.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) self.settings_imported = True self.clean_up() QtCore.QCoreApplication.exit() @@ -933,11 +939,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Export settings to a .conf file in INI format """ - export_file_name = QtGui.QFileDialog.getSaveFileName(self, - translate('OpenLP.MainWindow', 'Export Settings File'), - '', - translate('OpenLP.MainWindow', 'OpenLP Export Settings ' - 'File (*.conf)')) + export_file_name, filter_used = QtWidgets.QFileDialog.getSaveFileName( + self, + translate('OpenLP.MainWindow', 'Export Settings File'), + '', + translate('OpenLP.MainWindow', 'OpenLP Export Settings File (*.conf)')) if not export_file_name: return # Make sure it's a .conf file. @@ -987,10 +993,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): try: key_value = settings.value(section_key) except KeyError: - QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'), - translate('OpenLP.MainWindow', 'The key "%s" does not have a default value ' - 'so it will be skipped in this export.') % section_key, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'), + translate('OpenLP.MainWindow', 'The key "%s" does not have a default ' + 'value so it will be skipped in this ' + 'export.') % section_key, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) key_value = None if key_value is not None: export_settings.setValue(section_key, key_value) @@ -1010,10 +1017,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): export_conf.close() os.remove(temp_file) except OSError as ose: - QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'), - translate('OpenLP.MainWindow', 'An error occurred while exporting the ' - 'settings: %s') % ose.strerror, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'Export setting error'), + translate('OpenLP.MainWindow', 'An error occurred while exporting the ' + 'settings: %s') % ose.strerror, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) def on_mode_default_item_clicked(self): """ @@ -1076,26 +1083,26 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): event.accept() if self.service_manager_contents.is_modified(): ret = self.service_manager_contents.save_modified_service() - if ret == QtGui.QMessageBox.Save: + if ret == QtWidgets.QMessageBox.Save: if self.service_manager_contents.decide_save_method(): self.clean_up() event.accept() else: event.ignore() - elif ret == QtGui.QMessageBox.Discard: + elif ret == QtWidgets.QMessageBox.Discard: self.clean_up() event.accept() else: event.ignore() else: if Settings().value('advanced/enable exit confirmation'): - ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), - translate('OpenLP.MainWindow', 'Are you sure you want to close ' - 'OpenLP?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.Yes) - if ret == QtGui.QMessageBox.Yes: + ret = QtWidgets.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), + translate('OpenLP.MainWindow', 'Are you sure you want to close ' + 'OpenLP?'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.Yes) + if ret == QtWidgets.QMessageBox.Yes: self.clean_up() event.accept() else: @@ -1203,10 +1210,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): Sets the ability to stop the toolbars being changed. """ if lock: - self.theme_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) - self.service_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) - self.media_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) - self.projector_manager_dock.setFeatures(QtGui.QDockWidget.NoDockWidgetFeatures) + self.theme_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) + self.service_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) + self.media_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) + self.projector_manager_dock.setFeatures(QtWidgets.QDockWidget.NoDockWidgetFeatures) self.view_media_manager_item.setEnabled(False) self.view_service_manager_item.setEnabled(False) self.view_theme_manager_item.setEnabled(False) @@ -1214,10 +1221,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.view_preview_panel.setEnabled(False) self.view_live_panel.setEnabled(False) else: - self.theme_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) - self.service_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) - self.media_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) - self.projector_manager_dock.setFeatures(QtGui.QDockWidget.AllDockWidgetFeatures) + self.theme_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) + self.service_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) + self.media_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) + self.projector_manager_dock.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) self.view_media_manager_item.setEnabled(True) self.view_service_manager_item.setEnabled(True) self.view_theme_manager_item.setEnabled(True) @@ -1401,10 +1408,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): except (IOError, os.error, DistutilsFileError) as why: self.application.set_normal_cursor() log.exception('Data copy failed %s' % str(why)) - QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), - translate('OpenLP.MainWindow', 'OpenLP Data directory copy failed\n\n%s'). - replace('%s', str(why)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), + translate('OpenLP.MainWindow', + 'OpenLP Data directory copy failed\n\n%s'). + replace('%s', str(why)), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) return False else: log.info('No data copy requested') diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index a98541fe3..a6cb8aae6 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -26,7 +26,7 @@ import logging from openlp.core.common import Settings -from PyQt4 import QtCore +from PyQt5 import QtCore log = logging.getLogger(__name__ + '.__init__') diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 5209a8253..5bbb72b4b 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -26,7 +26,7 @@ related to playing media, such as sliders. import logging import os import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import OpenLPMixin, Registry, RegistryMixin, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import OpenLPToolbar, ItemCapabilities @@ -40,7 +40,7 @@ from openlp.core.ui import DisplayControllerType log = logging.getLogger(__name__) -class MediaSlider(QtGui.QSlider): +class MediaSlider(QtWidgets.QSlider): """ Allows the mouse events of a slider to be overridden and extra functionality added """ @@ -56,22 +56,22 @@ class MediaSlider(QtGui.QSlider): """ Override event to allow hover time to be displayed. """ - time_value = QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()) + time_value = QtWidgets.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()) self.setToolTip('%s' % datetime.timedelta(seconds=int(time_value / 1000))) - QtGui.QSlider.mouseMoveEvent(self, event) + QtWidgets.QSlider.mouseMoveEvent(self, event) def mousePressEvent(self, event): """ Mouse Press event no new functionality """ - QtGui.QSlider.mousePressEvent(self, event) + QtWidgets.QSlider.mousePressEvent(self, event) def mouseReleaseEvent(self, event): """ Set the slider position when the mouse is clicked and released on the slider. """ - self.setValue(QtGui.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width())) - QtGui.QSlider.mouseReleaseEvent(self, event) + self.setValue(QtWidgets.QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width())) + QtWidgets.QSlider.mouseReleaseEvent(self, event) class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): @@ -284,9 +284,9 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): controller.seek_slider.setObjectName('seek_slider') controller.mediabar.add_toolbar_widget(controller.seek_slider) # Build the volume_slider. - controller.volume_slider = QtGui.QSlider(QtCore.Qt.Horizontal) + controller.volume_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) controller.volume_slider.setTickInterval(10) - controller.volume_slider.setTickPosition(QtGui.QSlider.TicksAbove) + controller.volume_slider.setTickPosition(QtWidgets.QSlider.TicksAbove) controller.volume_slider.setMinimum(0) controller.volume_slider.setMaximum(100) controller.volume_slider.setTracking(True) @@ -419,7 +419,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): translate('MediaPlugin.MediaItem', 'Unsupported File')) return False self.set_controls_visible(controller, True) - log.debug('use %s controller' % self.current_media_players[controller.controller_type]) + log.debug('use %s controller' % self.current_media_players[controller.controller_type].display_name) return True def media_length(self, service_item): @@ -526,6 +526,12 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): if not title: continue player = self.media_players[title] + if title == 'system': + self.resize(display, player) + if player.load(display): + self.current_media_players[controller.controller_type] = player + controller.media_info.media_type = MediaType.Video + return True if suffix in player.video_extensions_list: if not controller.media_info.is_background or controller.media_info.is_background and \ player.can_background: diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index dc3053f40..a47852510 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -22,7 +22,7 @@ """ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab for the media stuff. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.lib import ColorButton, SettingsTab @@ -30,7 +30,7 @@ from openlp.core.lib.ui import create_button from openlp.core.ui.media import get_media_players, set_media_players -class MediaQCheckBox(QtGui.QCheckBox): +class MediaQCheckBox(QtWidgets.QCheckBox): """ MediaQCheckBox adds an extra property, player_name to the QCheckBox class. """ @@ -61,46 +61,46 @@ class PlayerTab(SettingsTab): """ self.setObjectName('MediaTab') super(PlayerTab, self).setupUi() - self.background_color_group_box = QtGui.QGroupBox(self.left_column) + self.background_color_group_box = QtWidgets.QGroupBox(self.left_column) self.background_color_group_box.setObjectName('background_color_group_box') - self.form_layout = QtGui.QFormLayout(self.background_color_group_box) + self.form_layout = QtWidgets.QFormLayout(self.background_color_group_box) self.form_layout.setObjectName('form_layout') - self.color_layout = QtGui.QHBoxLayout() - self.background_color_label = QtGui.QLabel(self.background_color_group_box) + self.color_layout = QtWidgets.QHBoxLayout() + self.background_color_label = QtWidgets.QLabel(self.background_color_group_box) self.background_color_label.setObjectName('background_color_label') self.color_layout.addWidget(self.background_color_label) self.background_color_button = ColorButton(self.background_color_group_box) self.background_color_button.setObjectName('background_color_button') self.color_layout.addWidget(self.background_color_button) self.form_layout.addRow(self.color_layout) - self.information_label = QtGui.QLabel(self.background_color_group_box) + self.information_label = QtWidgets.QLabel(self.background_color_group_box) self.information_label.setObjectName('information_label') self.information_label.setWordWrap(True) self.form_layout.addRow(self.information_label) self.left_layout.addWidget(self.background_color_group_box) - self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) - self.media_player_group_box = QtGui.QGroupBox(self.left_column) + self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + self.media_player_group_box = QtWidgets.QGroupBox(self.left_column) self.media_player_group_box.setObjectName('media_player_group_box') - self.media_player_layout = QtGui.QVBoxLayout(self.media_player_group_box) + self.media_player_layout = QtWidgets.QVBoxLayout(self.media_player_group_box) self.media_player_layout.setObjectName('media_player_layout') self.player_check_boxes = {} self.left_layout.addWidget(self.media_player_group_box) - self.player_order_group_box = QtGui.QGroupBox(self.left_column) + self.player_order_group_box = QtWidgets.QGroupBox(self.left_column) self.player_order_group_box.setObjectName('player_order_group_box') - self.player_order_layout = QtGui.QHBoxLayout(self.player_order_group_box) + self.player_order_layout = QtWidgets.QHBoxLayout(self.player_order_group_box) self.player_order_layout.setObjectName('player_order_layout') - self.player_order_list_widget = QtGui.QListWidget(self.player_order_group_box) - size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.player_order_list_widget = QtWidgets.QListWidget(self.player_order_group_box) + size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth()) self.player_order_list_widget.setSizePolicy(size_policy) self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.player_order_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.player_order_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.player_order_list_widget.setObjectName('player_order_list_widget') self.player_order_layout.addWidget(self.player_order_list_widget) - self.ordering_button_layout = QtGui.QVBoxLayout() + self.ordering_button_layout = QtWidgets.QVBoxLayout() self.ordering_button_layout.setObjectName('ordering_button_layout') self.ordering_button_layout.addStretch(1) self.ordering_up_button = create_button(self, 'ordering_up_button', role='up', diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/systemplayer.py similarity index 60% rename from openlp/core/ui/media/phononplayer.py rename to openlp/core/ui/media/systemplayer.py index 8e6851bca..46974c803 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/systemplayer.py @@ -4,7 +4,14 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # # --------------------------------------------------------------------------- # # 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 # @@ -20,19 +27,16 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`~openlp.core.ui.media.phononplayer` contains the Phonon player component. +The :mod:`~openlp.core.ui.media.systemplayer` contains the system (aka QtMultimedia) player component. """ import logging import mimetypes -from datetime import datetime -from PyQt4.phonon import Phonon +from PyQt5 import QtCore, QtMultimedia, QtMultimediaWidgets from openlp.core.lib import translate - from openlp.core.ui.media import MediaState from openlp.core.ui.media.mediaplayer import MediaPlayer -from openlp.core.common import is_macosx log = logging.getLogger(__name__) @@ -56,26 +60,39 @@ ADDITIONAL_EXT = { } -class PhononPlayer(MediaPlayer): +class SystemPlayer(MediaPlayer): """ - A specialised version of the MediaPlayer class, which provides a Phonon display. + A specialised version of the MediaPlayer class, which provides a QtMultimedia display. """ + def __init__(self, parent): """ Constructor """ - super(PhononPlayer, self).__init__(parent, 'phonon') - self.original_name = 'Phonon' - self.display_name = '&Phonon' + super(SystemPlayer, self).__init__(parent, 'system') + self.original_name = 'System' + self.display_name = '&System' self.parent = parent self.additional_extensions = ADDITIONAL_EXT + self.media_player = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface) mimetypes.init() - for mime_type in Phonon.BackendCapabilities.availableMimeTypes(): - mime_type = str(mime_type) - if mime_type.startswith('audio/'): - self._add_to_list(self.audio_extensions_list, mime_type) - elif mime_type.startswith('video/'): - self._add_to_list(self.video_extensions_list, mime_type) + media_service = self.media_player.service() + log.info(media_service.__class__.__name__) + container_control = media_service.requestControl('org.qt-project.qt.mediacontainercontrol/5.0') + if container_control is not None: + supported_codecs = container_control.supportedContainers() + self.media_player.service().releaseControl(container_control) + for mime_type in supported_codecs: + # mime_type = str(mime_type) + # if mime_type.startswith('audio/'): + log.info(mime_type) + # self._add_to_list(self.audio_extensions_list, mime_type) + # video_device_info = QtMultimedia.QVideoDeviceInfo(QtMultimedia.QAudioDeviceInfo.defaultOutputDevice()) + # log.info('Supported audio codecs: %s', device_info.supportedCodecs()) + # for mime_type in device_info.supportedCodecs(): + # elif mime_type.startswith('video/'): + # self._add_to_list(self.video_extensions_list, mime_type) + self._add_to_list(self.audio_extensions_list, 'audio/pcm') def _add_to_list(self, mime_type_list, mimetype): """ @@ -102,97 +119,76 @@ class PhononPlayer(MediaPlayer): def setup(self, display): """ Set up the player widgets + :param display: """ - display.phonon_widget = Phonon.VideoWidget(display) - display.phonon_widget.resize(display.size()) - display.media_object = Phonon.MediaObject(display) - Phonon.createPath(display.media_object, display.phonon_widget) - if display.has_audio: - display.audio = Phonon.AudioOutput(Phonon.VideoCategory, display.media_object) - Phonon.createPath(display.media_object, display.audio) - display.phonon_widget.raise_() - display.phonon_widget.hide() + display.video_widget = QtMultimediaWidgets.QVideoWidget(display) + display.video_widget.resize(display.size()) + display.media_player = QtMultimedia.QMediaPlayer(display) + display.media_player.setVideoOutput(display.video_widget) + display.video_widget.raise_() + display.video_widget.hide() self.has_own_widget = True def check_available(self): """ Check if the player is available """ - # At the moment we don't have support for phononplayer on Mac OS X - if is_macosx(): - return False - else: - return True + return True def load(self, display): """ Load a video into the display + :param display: """ log.debug('load vid in Phonon Controller') controller = display.controller volume = controller.media_info.volume path = controller.media_info.file_info.absoluteFilePath() - display.media_object.setCurrentSource(Phonon.MediaSource(path)) - if not self.media_state_wait(display, Phonon.StoppedState): - return False + display.media_player.setMedia(QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile(path))) self.volume(display, volume) return True - def media_state_wait(self, display, media_state): - """ - Wait for the video to change its state - Wait no longer than 5 seconds. - """ - start = datetime.now() - current_state = display.media_object.state() - while current_state != media_state: - current_state = display.media_object.state() - if current_state == Phonon.ErrorState: - return False - self.application.process_events() - if (datetime.now() - start).seconds > 5: - return False - return True - def resize(self, display): """ Resize the display + :param display: """ - display.phonon_widget.resize(display.size()) + display.video_widget.resize(display.size()) def play(self, display): """ Play the current media item + :param display: """ + log.info('Play the current item') controller = display.controller start_time = 0 - if display.media_object.state() != Phonon.PausedState and controller.media_info.start_time > 0: + if display.media_player.state() != QtMultimedia.QMediaPlayer.PausedState and \ + controller.media_info.start_time > 0: start_time = controller.media_info.start_time - display.media_object.play() - if not self.media_state_wait(display, Phonon.PlayingState): - return False + display.media_player.play() if start_time > 0: self.seek(display, controller.media_info.start_time * 1000) self.volume(display, controller.media_info.volume) - controller.media_info.length = int(display.media_object.totalTime() / 1000) + controller.media_info.length = int(display.media_player.duration() / 1000) controller.seek_slider.setMaximum(controller.media_info.length * 1000) self.state = MediaState.Playing - display.phonon_widget.raise_() + display.video_widget.raise_() return True def pause(self, display): """ Pause the current media item """ - display.media_object.pause() - if self.media_state_wait(display, Phonon.PausedState): + display.media_player.pause() + if display.media_player.state() == QtMultimedia.QMediaPlayer.PausedState: self.state = MediaState.Paused def stop(self, display): """ Stop the current media item """ - display.media_object.stop() + display.media_player.stop() self.set_visible(display, False) self.state = MediaState.Stopped @@ -203,22 +199,22 @@ class PhononPlayer(MediaPlayer): # 1.0 is the highest value if display.has_audio: vol = float(vol) / float(100) - display.audio.setVolume(vol) + display.media_player.setVolume(vol) def seek(self, display, seek_value): """ Go to a particular point in the current media item """ - display.media_object.seek(seek_value) + display.media_player.setPosition(seek_value) def reset(self, display): """ Reset the media player """ - display.media_object.stop() - display.media_object.clearQueue() + display.media_player.stop() + display.media_player.setMedia(QtMultimedia.QMediaContent()) self.set_visible(display, False) - display.phonon_widget.setVisible(False) + display.video_widget.setVisible(False) self.state = MediaState.Off def set_visible(self, display, status): @@ -226,22 +222,22 @@ class PhononPlayer(MediaPlayer): Set the visibility of the widget """ if self.has_own_widget: - display.phonon_widget.setVisible(status) + display.video_widget.setVisible(status) def update_ui(self, display): """ Update the UI """ - if display.media_object.state() == Phonon.PausedState and self.state != MediaState.Paused: + if display.media_player.state() == QtMultimedia.QMediaPlayer.PausedState and self.state != MediaState.Paused: self.stop(display) controller = display.controller if controller.media_info.end_time > 0: - if display.media_object.currentTime() > controller.media_info.end_time * 1000: + if display.media_player.position() > controller.media_info.end_time * 1000: self.stop(display) self.set_visible(display, False) if not controller.seek_slider.isSliderDown(): controller.seek_slider.blockSignals(True) - controller.seek_slider.setSliderPosition(display.media_object.currentTime()) + controller.seek_slider.setSliderPosition(display.media_player.position()) controller.seek_slider.blockSignals(False) def get_media_display_css(self): @@ -254,9 +250,12 @@ class PhononPlayer(MediaPlayer): """ Return some info about this player """ - return(translate('Media.player', 'Phonon is a media player which ' - 'interacts with the operating system to provide media capabilities.') + - '
' + translate('Media.player', 'Audio') + - '
' + str(self.audio_extensions_list) + - '
' + translate('Media.player', 'Video') + - '
' + str(self.video_extensions_list) + '
') + return (translate('Media.player', 'This media player uses your operating system ' + 'to provide media capabilities.') + + '
' + translate('Media.player', 'Audio') + + '
' + str(self.audio_extensions_list) + + '
' + translate('Media.player', 'Video') + + '
' + str(self.video_extensions_list) + '
') + + + diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index b560b20f8..e8bc1f281 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -29,7 +29,7 @@ import os import threading import sys -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Settings, is_win, is_macosx, is_linux from openlp.core.lib import translate @@ -136,8 +136,8 @@ class VlcPlayer(MediaPlayer): Set up the media player """ vlc = get_vlc() - display.vlc_widget = QtGui.QFrame(display) - display.vlc_widget.setFrameStyle(QtGui.QFrame.NoFrame) + display.vlc_widget = QtWidgets.QFrame(display) + display.vlc_widget.setFrameStyle(QtWidgets.QFrame.NoFrame) # creating a basic vlc instance command_line_options = '--no-video-title-show' if not display.has_audio: @@ -159,7 +159,7 @@ class VlcPlayer(MediaPlayer): if is_win(): display.vlc_media_player.set_hwnd(win_id) elif is_macosx(): - # We have to use 'set_nsobject' since Qt4 on OSX uses Cocoa + # We have to use 'set_nsobject' since Qt5 on OSX uses Cocoa # framework and not the old Carbon. display.vlc_media_player.set_nsobject(win_id) else: diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index bff9cf940..519d43604 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -22,7 +22,7 @@ """ The :mod:`~openlp.core.ui.media.webkit` module contains our WebKit video player """ -from PyQt4 import QtGui, QtWebKit +from PyQt5 import QtGui, QtWebKitWidgets import logging @@ -226,7 +226,7 @@ class WebkitPlayer(MediaPlayer): :return: boolean. True if available """ - web = QtWebKit.QWebPage() + web = QtWebKitWidgets.QWebPage() # This script should return '[object HTMLVideoElement]' if the html5 video is available in webkit. Otherwise it # should return '[object HTMLUnknownElement]' return web.mainFrame().evaluateJavaScript( diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index aa7284981..2c6a7f2c2 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -22,7 +22,7 @@ """ The UI widgets of the plugin view dialog #""" -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -40,31 +40,31 @@ class Ui_PluginViewDialog(object): plugin_view_dialog.setObjectName('plugin_view_dialog') plugin_view_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) plugin_view_dialog.setWindowModality(QtCore.Qt.ApplicationModal) - self.plugin_layout = QtGui.QVBoxLayout(plugin_view_dialog) + self.plugin_layout = QtWidgets.QVBoxLayout(plugin_view_dialog) self.plugin_layout.setObjectName('plugin_layout') - self.list_layout = QtGui.QHBoxLayout() + self.list_layout = QtWidgets.QHBoxLayout() self.list_layout.setObjectName('list_layout') - self.plugin_list_widget = QtGui.QListWidget(plugin_view_dialog) + self.plugin_list_widget = QtWidgets.QListWidget(plugin_view_dialog) self.plugin_list_widget.setObjectName('plugin_list_widget') self.list_layout.addWidget(self.plugin_list_widget) - self.plugin_info_group_box = QtGui.QGroupBox(plugin_view_dialog) + self.plugin_info_group_box = QtWidgets.QGroupBox(plugin_view_dialog) self.plugin_info_group_box.setObjectName('plugin_info_group_box') - self.plugin_info_layout = QtGui.QFormLayout(self.plugin_info_group_box) + self.plugin_info_layout = QtWidgets.QFormLayout(self.plugin_info_group_box) self.plugin_info_layout.setObjectName('plugin_info_layout') - self.status_label = QtGui.QLabel(self.plugin_info_group_box) + self.status_label = QtWidgets.QLabel(self.plugin_info_group_box) self.status_label.setObjectName('status_label') - self.status_combo_box = QtGui.QComboBox(self.plugin_info_group_box) + self.status_combo_box = QtWidgets.QComboBox(self.plugin_info_group_box) self.status_combo_box.addItems(('', '')) self.status_combo_box.setObjectName('status_combo_box') self.plugin_info_layout.addRow(self.status_label, self.status_combo_box) - self.version_label = QtGui.QLabel(self.plugin_info_group_box) + self.version_label = QtWidgets.QLabel(self.plugin_info_group_box) self.version_label.setObjectName('version_label') - self.version_number_label = QtGui.QLabel(self.plugin_info_group_box) + self.version_number_label = QtWidgets.QLabel(self.plugin_info_group_box) self.version_number_label.setObjectName('version_number_label') self.plugin_info_layout.addRow(self.version_label, self.version_number_label) - self.about_label = QtGui.QLabel(self.plugin_info_group_box) + self.about_label = QtWidgets.QLabel(self.plugin_info_group_box) self.about_label.setObjectName('about_label') - self.about_text_browser = QtGui.QTextBrowser(self.plugin_info_group_box) + self.about_text_browser = QtWidgets.QTextBrowser(self.plugin_info_group_box) self.about_text_browser.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse) self.about_text_browser.setObjectName('aboutTextBrowser') self.plugin_info_layout.addRow(self.about_label, self.about_text_browser) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 63b18bc48..4eacebdab 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -24,7 +24,7 @@ The actual plugin view form """ import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import RegistryProperties, translate from openlp.core.lib import PluginStatus @@ -33,7 +33,7 @@ from .plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) -class PluginForm(QtGui.QDialog, Ui_PluginViewDialog, RegistryProperties): +class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ The plugin form provides user control over the plugins OpenLP uses. """ @@ -61,7 +61,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog, RegistryProperties): self.programatic_change = True plugin_list_width = 0 for plugin in self.plugin_manager.plugins: - item = QtGui.QListWidgetItem(self.plugin_list_widget) + item = QtWidgets.QListWidgetItem(self.plugin_list_widget) # We do this just to make 100% sure the status is an integer as # sometimes when it's loaded from the config, it isn't cast to int. plugin.status = int(plugin.status) diff --git a/openlp/core/ui/printservicedialog.py b/openlp/core/ui/printservicedialog.py index 47433268d..8f22306cf 100644 --- a/openlp/core/ui/printservicedialog.py +++ b/openlp/core/ui/printservicedialog.py @@ -22,7 +22,7 @@ """ The UI widgets of the print service dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets, QtPrintSupport from openlp.core.common import UiStrings, translate from openlp.core.lib import SpellTextEdit, build_icon @@ -51,16 +51,16 @@ class Ui_PrintServiceDialog(object): print_service_dialog.setObjectName('print_service_dialog') print_service_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) print_service_dialog.resize(664, 594) - self.main_layout = QtGui.QVBoxLayout(print_service_dialog) + self.main_layout = QtWidgets.QVBoxLayout(print_service_dialog) self.main_layout.setSpacing(0) - self.main_layout.setMargin(0) + self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setObjectName('main_layout') - self.toolbar = QtGui.QToolBar(print_service_dialog) + self.toolbar = QtWidgets.QToolBar(print_service_dialog) self.toolbar.setIconSize(QtCore.QSize(22, 22)) self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.print_button = self.toolbar.addAction(build_icon(':/general/general_print.png'), translate('OpenLP.PrintServiceForm', 'Print')) - self.options_button = QtGui.QToolButton(self.toolbar) + self.options_button = QtWidgets.QToolButton(self.toolbar) self.options_button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self.options_button.setIcon(build_icon(':/system/system_configure.png')) self.options_button.setCheckable(True) @@ -71,54 +71,54 @@ class Ui_PrintServiceDialog(object): self.html_copy = self.toolbar.addAction(build_icon(':/system/system_edit_copy.png'), translate('OpenLP.PrintServiceForm', 'Copy as HTML')) self.toolbar.addSeparator() - self.zoom_in_button = QtGui.QToolButton(self.toolbar) + self.zoom_in_button = QtWidgets.QToolButton(self.toolbar) self.zoom_in_button.setIcon(build_icon(':/general/general_zoom_in.png')) self.zoom_in_button.setObjectName('zoom_in_button') self.zoom_in_button.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoom_in_button) - self.zoom_out_button = QtGui.QToolButton(self.toolbar) + self.zoom_out_button = QtWidgets.QToolButton(self.toolbar) self.zoom_out_button.setIcon(build_icon(':/general/general_zoom_out.png')) self.zoom_out_button.setObjectName('zoom_out_button') self.zoom_out_button.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoom_out_button) - self.zoom_original_button = QtGui.QToolButton(self.toolbar) + self.zoom_original_button = QtWidgets.QToolButton(self.toolbar) self.zoom_original_button.setIcon(build_icon(':/general/general_zoom_original.png')) self.zoom_original_button.setObjectName('zoom_original_button') self.zoom_original_button.setIconSize(QtCore.QSize(22, 22)) self.toolbar.addWidget(self.zoom_original_button) - self.zoom_combo_box = QtGui.QComboBox(print_service_dialog) + self.zoom_combo_box = QtWidgets.QComboBox(print_service_dialog) self.zoom_combo_box.setObjectName('zoom_combo_box') self.toolbar.addWidget(self.zoom_combo_box) self.main_layout.addWidget(self.toolbar) - self.preview_widget = QtGui.QPrintPreviewWidget(print_service_dialog) + self.preview_widget = QtPrintSupport.QPrintPreviewWidget(print_service_dialog) self.main_layout.addWidget(self.preview_widget) - self.options_widget = QtGui.QWidget(print_service_dialog) + self.options_widget = QtWidgets.QWidget(print_service_dialog) self.options_widget.hide() self.options_widget.resize(400, 300) self.options_widget.setAutoFillBackground(True) - self.options_layout = QtGui.QVBoxLayout(self.options_widget) + self.options_layout = QtWidgets.QVBoxLayout(self.options_widget) self.options_layout.setContentsMargins(8, 8, 8, 8) - self.title_label = QtGui.QLabel(self.options_widget) + self.title_label = QtWidgets.QLabel(self.options_widget) self.title_label.setObjectName('title_label') self.options_layout.addWidget(self.title_label) - self.title_line_edit = QtGui.QLineEdit(self.options_widget) + self.title_line_edit = QtWidgets.QLineEdit(self.options_widget) self.title_line_edit.setObjectName('title_line_edit') self.options_layout.addWidget(self.title_line_edit) - self.footer_label = QtGui.QLabel(self.options_widget) + self.footer_label = QtWidgets.QLabel(self.options_widget) self.footer_label.setObjectName('footer_label') self.options_layout.addWidget(self.footer_label) self.footer_text_edit = SpellTextEdit(self.options_widget, False) self.footer_text_edit.setObjectName('footer_text_edit') self.options_layout.addWidget(self.footer_text_edit) - self.options_group_box = QtGui.QGroupBox() - self.group_layout = QtGui.QVBoxLayout() - self.slide_text_check_box = QtGui.QCheckBox() + self.options_group_box = QtWidgets.QGroupBox() + self.group_layout = QtWidgets.QVBoxLayout() + self.slide_text_check_box = QtWidgets.QCheckBox() self.group_layout.addWidget(self.slide_text_check_box) - self.page_break_after_text = QtGui.QCheckBox() + self.page_break_after_text = QtWidgets.QCheckBox() self.group_layout.addWidget(self.page_break_after_text) - self.notes_check_box = QtGui.QCheckBox() + self.notes_check_box = QtWidgets.QCheckBox() self.group_layout.addWidget(self.notes_check_box) - self.meta_data_check_box = QtGui.QCheckBox() + self.meta_data_check_box = QtWidgets.QCheckBox() self.group_layout.addWidget(self.meta_data_check_box) self.group_layout.addStretch(1) self.options_group_box.setLayout(self.group_layout) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index d1c47fbef..cfe0d883a 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -27,7 +27,7 @@ import os import html import lxml.html -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import get_text_file_string @@ -104,7 +104,7 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties """ -class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties): +class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryProperties): """ The :class:`~openlp.core.ui.printserviceform.PrintServiceForm` class displays a dialog for printing the service. """ @@ -113,8 +113,8 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties) Constructor """ super(PrintServiceForm, self).__init__(Registry().get('main_window')) - self.printer = QtGui.QPrinter() - self.print_dialog = QtGui.QPrintDialog(self.printer, self) + self.printer = QtPrintSupport.QPrinter() + self.print_dialog = QtPrintSupport.QPrintDialog(self.printer, self) self.document = QtGui.QTextDocument() self.zoom = 0 self.setupUi(self) @@ -324,7 +324,7 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties) """ Called, when the *print_button* is clicked. Opens the *print_dialog*. """ - if not self.print_dialog.exec_(): + if not self.print_dialog.exec(): return self.update_song_usage() # Print the document. diff --git a/openlp/core/ui/projector/editform.py b/openlp/core/ui/projector/editform.py index 2eb72b72d..df0c57b4c 100644 --- a/openlp/core/ui/projector/editform.py +++ b/openlp/core/ui/projector/editform.py @@ -29,9 +29,9 @@ import logging log = logging.getLogger(__name__) log.debug('editform loaded') -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import pyqtSlot, pyqtSignal -from PyQt4.QtGui import QDialog, QPlainTextEdit, QLineEdit, QDialogButtonBox, QLabel, QGridLayout +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.lib import build_icon @@ -151,7 +151,7 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): self.button_box.helpRequested.connect(self.help_me) self.button_box.rejected.connect(self.cancel_me) - def exec_(self, projector=None): + def exec(self, projector=None): if projector is None: self.projector = Projector() self.new_projector = True @@ -159,7 +159,7 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): self.projector = projector self.new_projector = False self.retranslateUi(self) - reply = QDialog.exec_(self) + reply = QDialog.exec(self) return reply @pyqtSlot() @@ -169,22 +169,22 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): """ log.debug('accept_me() signal received') if len(self.name_text.text().strip()) < 1: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorEdit', 'Name Not Set'), - translate('OpenLP.ProjectorEdit', - 'You must enter a name for this entry.
' - 'Please enter a new name for this entry.')) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorEdit', 'Name Not Set'), + translate('OpenLP.ProjectorEdit', + 'You must enter a name for this entry.
' + 'Please enter a new name for this entry.')) valid = False return name = self.name_text.text().strip() record = self.projectordb.get_projector_by_name(name) if record is not None and record.id != self.projector.id: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorEdit', 'Duplicate Name'), - translate('OpenLP.ProjectorEdit', - 'There is already an entry with name "%s" in ' - 'the database as ID "%s".
' - 'Please enter a different name.' % (name, record.id))) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorEdit', 'Duplicate Name'), + translate('OpenLP.ProjectorEdit', + 'There is already an entry with name "%s" in ' + 'the database as ID "%s".
' + 'Please enter a different name.' % (name, record.id))) valid = False return adx = self.ip_text.text() @@ -195,31 +195,32 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): valid = True self.new_projector = True elif ip.id != self.projector.id: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorWizard', 'Duplicate IP Address'), - translate('OpenLP.ProjectorWizard', - 'IP address "%s"
is already in the database as ID %s.' - '

Please Enter a different IP address.' % (adx, ip.id))) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorWizard', 'Duplicate IP Address'), + translate('OpenLP.ProjectorWizard', + 'IP address "%s"
is already in the database as ID %s.' + '

Please Enter a different IP address.' % + (adx, ip.id))) valid = False return else: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorWizard', 'Invalid IP Address'), - translate('OpenLP.ProjectorWizard', - 'IP address "%s"
is not a valid IP address.' - '

Please enter a valid IP address.' % adx)) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorWizard', 'Invalid IP Address'), + translate('OpenLP.ProjectorWizard', + 'IP address "%s"
is not a valid IP address.' + '

Please enter a valid IP address.' % adx)) valid = False return port = int(self.port_text.text()) if port < 1000 or port > 32767: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorWizard', 'Invalid Port Number'), - translate('OpenLP.ProjectorWizard', - 'Port numbers below 1000 are reserved for admin use only, ' - '
and port numbers above 32767 are not currently usable.' - '

Please enter a valid port number between ' - ' 1000 and 32767.' - '

Default PJLink port is %s' % PJLINK_PORT)) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorWizard', 'Invalid Port Number'), + translate('OpenLP.ProjectorWizard', + 'Port numbers below 1000 are reserved for admin use only, ' + '
and port numbers above 32767 are not currently usable.' + '

Please enter a valid port number between ' + ' 1000 and 32767.' + '

Default PJLink port is %s' % PJLINK_PORT)) valid = False if valid: self.projector.ip = self.ip_text.text() @@ -233,11 +234,11 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): else: saved = self.projectordb.update_projector(self.projector) if not saved: - QtGui.QMessageBox.warning(self, - translate('OpenLP.ProjectorEditForm', 'Database Error'), - translate('OpenLP.ProjectorEditForm', - 'There was an error saving projector ' - 'information. See the log for the error')) + QtWidgets.QMessageBox.warning(self, + translate('OpenLP.ProjectorEditForm', 'Database Error'), + translate('OpenLP.ProjectorEditForm', + 'There was an error saving projector ' + 'information. See the log for the error')) return saved if self.new_projector: self.newProjector.emit(adx) diff --git a/openlp/core/ui/projector/manager.py b/openlp/core/ui/projector/manager.py index f9485f364..f7badc7e6 100644 --- a/openlp/core/ui/projector/manager.py +++ b/openlp/core/ui/projector/manager.py @@ -29,9 +29,9 @@ import logging log = logging.getLogger(__name__) log.debug('projectormanager loaded') -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import QObject, QThread, pyqtSlot -from PyQt4.QtGui import QWidget +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, \ RegistryMixin, translate @@ -74,9 +74,9 @@ class Ui_ProjectorManager(object): """ log.debug('setup_ui()') # Create ProjectorManager box - self.layout = QtGui.QVBoxLayout(widget) + self.layout = QtWidgets.QVBoxLayout(widget) self.layout.setSpacing(0) - self.layout.setMargin(0) + self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setObjectName('layout') # Add one selection toolbar self.one_toolbar = OpenLPToolbar(widget) @@ -195,11 +195,11 @@ class Ui_ProjectorManager(object): 'Show selected projector screen'), triggers=self.on_show_projector) self.layout.addWidget(self.one_toolbar) - self.projector_one_widget = QtGui.QWidgetAction(self.one_toolbar) + self.projector_one_widget = QtWidgets.QWidgetAction(self.one_toolbar) self.projector_one_widget.setObjectName('projector_one_toolbar_widget') # Create projector manager list - self.projector_list_widget = QtGui.QListWidget(widget) - self.projector_list_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.projector_list_widget = QtWidgets.QListWidget(widget) + self.projector_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.projector_list_widget.setAlternatingRowColors(True) self.projector_list_widget.setIconSize(QtCore.QSize(90, 50)) self.projector_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) @@ -208,7 +208,7 @@ class Ui_ProjectorManager(object): self.projector_list_widget.customContextMenuRequested.connect(self.context_menu) self.projector_list_widget.itemDoubleClicked.connect(self.on_doubleclick_item) # Build the context menu - self.menu = QtGui.QMenu() + self.menu = QtWidgets.QMenu() self.status_action = create_widget_action(self.menu, text=translate('OpenLP.ProjectorManager', '&View Projector Information'), @@ -367,7 +367,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, self.blank_action.setVisible(False) self.show_action.setVisible(False) self.menu.projector = real_projector - self.menu.exec_(self.projector_list_widget.mapToGlobal(point)) + self.menu.exec(self.projector_list_widget.mapToGlobal(point)) def on_edit_input(self, opt=None): self.on_select_input(opt=opt, edit=True) @@ -377,7 +377,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, Builds menu for 'Select Input' option, then calls the selected projector item to change input source. - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ self.get_settings() # In case the dialog interface setting was changed list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) @@ -393,7 +393,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, source_select_form = SourceSelectSingle(parent=self, projectordb=self.projectordb, edit=edit) - source = source_select_form.exec_(projector.link) + source = source_select_form.exec(projector.link) log.debug('(%s) source_select_form() returned %s' % (projector.link.ip, source)) if source is not None and source > 0: projector.link.set_input_source(str(source)) @@ -403,15 +403,15 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls edit dialog to add a new projector to the database - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ - self.projector_form.exec_() + self.projector_form.exec() def on_blank_projector(self, opt=None): """ Calls projector thread to send blank screen command - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -432,7 +432,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, When item is doubleclicked, will connect to projector. :param item: List widget item for connection. - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ projector = item.data(QtCore.Qt.UserRole) if projector.link.state() != projector.link.ConnectedState: @@ -446,7 +446,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls projector thread to connect to projector - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -466,19 +466,19 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Deletes a projector from the list and the database - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) if list_item is None: return projector = list_item.data(QtCore.Qt.UserRole) - msg = QtGui.QMessageBox() + msg = QtWidgets.QMessageBox() msg.setText(translate('OpenLP.ProjectorManager', 'Delete projector (%s) %s?') % (projector.link.ip, projector.link.name)) msg.setInformativeText(translate('OpenLP.ProjectorManager', 'Are you sure you want to delete this projector?')) msg.setStandardButtons(msg.Cancel | msg.Ok) msg.setDefaultButton(msg.Cancel) - ans = msg.exec_() + ans = msg.exec() if ans == msg.Cancel: return try: @@ -528,7 +528,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls projector thread to disconnect from projector - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -548,7 +548,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls edit dialog with selected projector to edit information - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ list_item = self.projector_list_widget.item(self.projector_list_widget.currentRow()) projector = list_item.data(QtCore.Qt.UserRole) @@ -556,14 +556,14 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, return self.old_projector = projector projector.link.disconnect_from_host() - self.projector_form.exec_(projector.db_item) + self.projector_form.exec(projector.db_item) projector.db_item = self.projectordb.get_projector_by_id(self.old_projector.db_item.id) def on_poweroff_projector(self, opt=None): """ Calls projector link to send Power Off command - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -583,7 +583,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls projector link to send Power On command - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -603,7 +603,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Calls projector thread to send open shutter command - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ try: ip = opt.link.ip @@ -623,7 +623,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, """ Builds message box with projector status information - :param opt: Needed by PyQt4 + :param opt: Needed by PyQt5 """ lwi = self.projector_list_widget.item(self.projector_list_widget.currentRow()) projector = lwi.data(QtCore.Qt.UserRole) @@ -674,7 +674,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, message = '%s%s' % (message, translate('OpenLP.ProjectorManager', 'Current errors/warnings')) for (key, val) in projector.link.projector_errors.items(): message = '%s%s: %s
' % (message, key, ERROR_MSG[val]) - QtGui.QMessageBox.information(self, translate('OpenLP.ProjectorManager', 'Projector Information'), message) + QtWidgets.QMessageBox.information(self, translate('OpenLP.ProjectorManager', 'Projector Information'), message) def _add_projector(self, projector): """ @@ -707,10 +707,10 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, item.db_item = projector icon = QtGui.QIcon(QtGui.QPixmap(STATUS_ICONS[S_NOT_CONNECTED])) item.icon = icon - widget = QtGui.QListWidgetItem(icon, - item.link.name, - self.projector_list_widget - ) + widget = QtWidgets.QListWidgetItem(icon, + item.link.name, + self.projector_list_widget + ) widget.setData(QtCore.Qt.UserRole, item) item.link.db_item = item.db_item item.widget = widget @@ -751,7 +751,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, Add a projector from the edit dialog :param ip: IP address of new record item to find - :param opts: Needed by PyQt4 + :param opts: Needed by PyQt5 """ log.debug('add_projector_from_wizard(ip=%s)' % ip) item = self.projectordb.get_projector_by_ip(ip) @@ -831,7 +831,7 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, self.update_icons() def get_toolbar_item(self, name, enabled=False, hidden=False): - item = self.one_toolbar.findChild(QtGui.QAction, name) + item = self.one_toolbar.findChild(QtWidgets.QAction, name) if item == 0: log.debug('No item found with name "%s"' % name) return @@ -918,11 +918,11 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, :param name: Name from QListWidgetItem """ - QtGui.QMessageBox.warning(self, translate('OpenLP.ProjectorManager', - '"%s" Authentication Error' % name), - '
There was an authentication error while trying to connect.' - '

Please verify your PIN setting ' - 'for projector item "%s"' % name) + QtWidgets.QMessageBox.warning(self, translate('OpenLP.ProjectorManager', + '"%s" Authentication Error' % name), + '
There was an authentication error while trying to connect.' + '

Please verify your PIN setting ' + 'for projector item "%s"' % name) @pyqtSlot(str) def no_authentication_error(self, name): @@ -932,11 +932,11 @@ class ProjectorManager(OpenLPMixin, RegistryMixin, QWidget, Ui_ProjectorManager, :param name: Name from QListWidgetItem """ - QtGui.QMessageBox.warning(self, translate('OpenLP.ProjectorManager', - '"%s" No Authentication Error' % name), - '
PIN is set and projector does not require authentication.' - '

Please verify your PIN setting ' - 'for projector item "%s"' % name) + QtWidgets.QMessageBox.warning(self, translate('OpenLP.ProjectorManager', + '"%s" No Authentication Error' % name), + '
PIN is set and projector does not require authentication.' + '

Please verify your PIN setting ' + 'for projector item "%s"' % name) class ProjectorItem(QObject): @@ -969,8 +969,8 @@ def not_implemented(function): :param func: Function name """ - QtGui.QMessageBox.information(None, - translate('OpenLP.ProjectorManager', 'Not Implemented Yet'), - translate('OpenLP.ProjectorManager', - 'Function "%s"
has not been implemented yet.' - '
Please check back again later.' % function)) + QtWidgets.QMessageBox.information(None, + translate('OpenLP.ProjectorManager', 'Not Implemented Yet'), + translate('OpenLP.ProjectorManager', + 'Function "%s"
has not been implemented yet.' + '
Please check back again later.' % function)) diff --git a/openlp/core/ui/projector/sourceselectform.py b/openlp/core/ui/projector/sourceselectform.py index d539f2312..4722e1dcf 100644 --- a/openlp/core/ui/projector/sourceselectform.py +++ b/openlp/core/ui/projector/sourceselectform.py @@ -28,9 +28,9 @@ import logging log = logging.getLogger(__name__) log.debug('editform loaded') -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import pyqtSlot, QSize -from PyQt4.QtGui import QDialog, QButtonGroup, QDialogButtonBox, QFormLayout, QLineEdit, QRadioButton, \ +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 @@ -263,7 +263,7 @@ class SourceSelectTabs(QDialog): self.layout.addWidget(self.tabwidget) self.setLayout(self.layout) - def exec_(self, projector): + def exec(self, projector): """ Override initial method so we can build the tabs. @@ -287,10 +287,10 @@ class SourceSelectTabs(QDialog): thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key]) if buttonchecked: self.tabwidget.setCurrentIndex(thistab) - self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset | - QtGui.QDialogButtonBox.Discard | - QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) + self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset | + QtWidgets.QDialogButtonBox.Discard | + QtWidgets.QDialogButtonBox.Ok | + QtWidgets.QDialogButtonBox.Cancel) else: for key in keys: (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group, @@ -302,12 +302,12 @@ class SourceSelectTabs(QDialog): thistab = self.tabwidget.addTab(tab, PJLINK_DEFAULT_SOURCES[key]) if buttonchecked: self.tabwidget.setCurrentIndex(thistab) - self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) + self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | + QtWidgets.QDialogButtonBox.Cancel) self.button_box.clicked.connect(self.button_clicked) self.layout.addWidget(self.button_box) set_button_tooltip(self.button_box) - selected = super(SourceSelectTabs, self).exec_() + selected = super(SourceSelectTabs, self).exec() return selected @pyqtSlot(object) @@ -333,14 +333,14 @@ class SourceSelectTabs(QDialog): return 100 def delete_sources(self): - msg = QtGui.QMessageBox() + msg = QtWidgets.QMessageBox() msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector')) msg.setInformativeText(translate('OpenLP.SourceSelectForm', 'Are you sure you want to delete ALL user-defined ' 'source input text for this projector?')) msg.setStandardButtons(msg.Cancel | msg.Ok) msg.setDefaultButton(msg.Cancel) - ans = msg.exec_() + ans = msg.exec() if ans == msg.Cancel: return self.projectordb.delete_all_objects(ProjectorSource, ProjectorSource.projector_id == self.projector.db_item.id) @@ -396,7 +396,7 @@ class SourceSelectSingle(QDialog): self.setModal(True) self.edit = edit - def exec_(self, projector, edit=False): + def exec(self, projector, edit=False): """ Override initial method so we can build the tabs. @@ -426,26 +426,26 @@ class SourceSelectSingle(QDialog): item.setText(source_item.text) self.layout.addRow(PJLINK_DEFAULT_CODES[key], item) self.button_group.append(item) - self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Reset | - QtGui.QDialogButtonBox.Discard | - QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) + self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Reset | + QtWidgets.QDialogButtonBox.Discard | + QtWidgets.QDialogButtonBox.Ok | + QtWidgets.QDialogButtonBox.Cancel) else: for key in keys: source_text = self.projectordb.get_source_by_code(code=key, projector_id=self.projector.db_item.id) text = self.source_text[key] if source_text is None else source_text.text - button = QtGui.QRadioButton(text) + button = QtWidgets.QRadioButton(text) button.setChecked(True if key == projector.source else False) self.layout.addWidget(button) self.button_group.addButton(button, int(key)) button_list.append(key) - self.button_box = QDialogButtonBox(QtGui.QDialogButtonBox.Ok | - QtGui.QDialogButtonBox.Cancel) + self.button_box = QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | + QtWidgets.QDialogButtonBox.Cancel) self.button_box.clicked.connect(self.button_clicked) self.layout.addWidget(self.button_box) self.setMinimumHeight(key_count*25) set_button_tooltip(self.button_box) - selected = super(SourceSelectSingle, self).exec_() + selected = super(SourceSelectSingle, self).exec() return selected @pyqtSlot(object) @@ -471,14 +471,14 @@ class SourceSelectSingle(QDialog): return 100 def delete_sources(self): - msg = QtGui.QMessageBox() + msg = QtWidgets.QMessageBox() msg.setText(translate('OpenLP.SourceSelectForm', 'Delete entries for this projector')) msg.setInformativeText(translate('OpenLP.SourceSelectForm', 'Are you sure you want to delete ALL user-defined ' 'source input text for this projector?')) msg.setStandardButtons(msg.Cancel | msg.Ok) msg.setDefaultButton(msg.Cancel) - ans = msg.exec_() + ans = msg.exec() if ans == msg.Cancel: return self.projectordb.delete_all_objects(ProjectorSource, ProjectorSource.projector_id == self.projector.db_item.id) diff --git a/openlp/core/ui/projector/tab.py b/openlp/core/ui/projector/tab.py index a5c68e2ad..2479e8e63 100644 --- a/openlp/core/ui/projector/tab.py +++ b/openlp/core/ui/projector/tab.py @@ -29,7 +29,7 @@ import logging log = logging.getLogger(__name__) log.debug('projectortab module loaded') -from PyQt4 import QtCore, QtGui +from PyQt5 import QtWidgets from openlp.core.common import Settings, UiStrings, translate from openlp.core.lib import SettingsTab @@ -56,35 +56,35 @@ class ProjectorTab(SettingsTab): """ self.setObjectName('ProjectorTab') super(ProjectorTab, self).setupUi() - self.connect_box = QtGui.QGroupBox(self.left_column) + self.connect_box = QtWidgets.QGroupBox(self.left_column) self.connect_box.setObjectName('connect_box') - self.connect_box_layout = QtGui.QFormLayout(self.connect_box) + self.connect_box_layout = QtWidgets.QFormLayout(self.connect_box) self.connect_box_layout.setObjectName('connect_box_layout') # Start comms with projectors on startup - self.connect_on_startup = QtGui.QCheckBox(self.connect_box) + self.connect_on_startup = QtWidgets.QCheckBox(self.connect_box) self.connect_on_startup.setObjectName('connect_on_startup') self.connect_box_layout.addRow(self.connect_on_startup) # Socket timeout - self.socket_timeout_label = QtGui.QLabel(self.connect_box) + self.socket_timeout_label = QtWidgets.QLabel(self.connect_box) self.socket_timeout_label.setObjectName('socket_timeout_label') - self.socket_timeout_spin_box = QtGui.QSpinBox(self.connect_box) + self.socket_timeout_spin_box = QtWidgets.QSpinBox(self.connect_box) self.socket_timeout_spin_box.setObjectName('socket_timeout_spin_box') self.socket_timeout_spin_box.setMinimum(2) self.socket_timeout_spin_box.setMaximum(10) self.connect_box_layout.addRow(self.socket_timeout_label, self.socket_timeout_spin_box) # Poll interval - self.socket_poll_label = QtGui.QLabel(self.connect_box) + self.socket_poll_label = QtWidgets.QLabel(self.connect_box) self.socket_poll_label.setObjectName('socket_poll_label') - self.socket_poll_spin_box = QtGui.QSpinBox(self.connect_box) + self.socket_poll_spin_box = QtWidgets.QSpinBox(self.connect_box) self.socket_poll_spin_box.setObjectName('socket_timeout_spin_box') self.socket_poll_spin_box.setMinimum(5) self.socket_poll_spin_box.setMaximum(60) self.connect_box_layout.addRow(self.socket_poll_label, self.socket_poll_spin_box) self.left_layout.addWidget(self.connect_box) # Source input select dialog box type - self.dialog_type_label = QtGui.QLabel(self.connect_box) + self.dialog_type_label = QtWidgets.QLabel(self.connect_box) self.dialog_type_label.setObjectName('dialog_type_label') - self.dialog_type_combo_box = QtGui.QComboBox(self.connect_box) + self.dialog_type_combo_box = QtWidgets.QComboBox(self.connect_box) self.dialog_type_combo_box.setObjectName('dialog_type_combo_box') self.dialog_type_combo_box.addItems(['', '']) self.connect_box_layout.addRow(self.dialog_type_label, self.dialog_type_combo_box) diff --git a/openlp/core/ui/serviceitemeditdialog.py b/openlp/core/ui/serviceitemeditdialog.py index 186a170cd..0cfd25446 100644 --- a/openlp/core/ui/serviceitemeditdialog.py +++ b/openlp/core/ui/serviceitemeditdialog.py @@ -22,7 +22,7 @@ """ The UI widgets for the service item edit dialog """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -39,15 +39,15 @@ class Ui_ServiceItemEditDialog(object): """ serviceItemEditDialog.setObjectName('serviceItemEditDialog') serviceItemEditDialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) - self.dialog_layout = QtGui.QGridLayout(serviceItemEditDialog) + self.dialog_layout = QtWidgets.QGridLayout(serviceItemEditDialog) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setSpacing(8) self.dialog_layout.setObjectName('dialog_layout') - self.list_widget = QtGui.QListWidget(serviceItemEditDialog) + self.list_widget = QtWidgets.QListWidget(serviceItemEditDialog) self.list_widget.setAlternatingRowColors(True) self.list_widget.setObjectName('list_widget') self.dialog_layout.addWidget(self.list_widget, 0, 0) - self.button_layout = QtGui.QVBoxLayout() + self.button_layout = QtWidgets.QVBoxLayout() self.button_layout.setObjectName('button_layout') self.delete_button = create_button(serviceItemEditDialog, 'deleteButton', role='delete', click=serviceItemEditDialog.on_delete_button_clicked) diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 856da3cd8..3e8b140c1 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -22,13 +22,14 @@ """ The service item edit dialog """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets + from openlp.core.common import Registry, RegistryProperties from .serviceitemeditdialog import Ui_ServiceItemEditDialog -class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog, RegistryProperties): +class ServiceItemEditForm(QtWidgets.QDialog, Ui_ServiceItemEditDialog, RegistryProperties): """ This is the form that is used to edit the verses of the song. """ @@ -71,7 +72,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog, RegistryPrope """ self.list_widget.clear() for frame in self.item_list: - item_name = QtGui.QListWidgetItem(frame['title']) + item_name = QtWidgets.QListWidgetItem(frame['title']) self.list_widget.addItem(item_name) def on_delete_button_clicked(self): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c3db9a071..acfde8964 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -30,7 +30,7 @@ import json from tempfile import mkstemp from datetime import datetime, timedelta -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, ThemeLevel, OpenLPMixin, \ RegistryMixin, check_directory_exists, UiStrings, translate @@ -42,7 +42,7 @@ from openlp.core.utils import delete_file, split_filename, format_time from openlp.core.utils.actions import ActionList, CategoryOrder -class ServiceManagerList(QtGui.QTreeWidget): +class ServiceManagerList(QtWidgets.QTreeWidget): """ Set up key bindings and mouse behaviour for the service list """ @@ -89,7 +89,7 @@ class ServiceManagerList(QtGui.QTreeWidget): mime_data = QtCore.QMimeData() drag.setMimeData(mime_data) mime_data.setText('ServiceManager') - drag.start(QtCore.Qt.CopyAction) + drag.exec(QtCore.Qt.CopyAction) class Ui_ServiceManager(object): @@ -102,9 +102,9 @@ class Ui_ServiceManager(object): :param widget: """ # start with the layout - self.layout = QtGui.QVBoxLayout(widget) + self.layout = QtWidgets.QVBoxLayout(widget) self.layout.setSpacing(0) - self.layout.setMargin(0) + self.layout.setContentsMargins(0, 0, 0, 0) # Create the top toolbar self.toolbar = OpenLPToolbar(widget) self.toolbar.add_toolbar_action('newService', text=UiStrings().NewService, icon=':/general/general_new.png', @@ -118,14 +118,14 @@ class Ui_ServiceManager(object): tooltip=translate('OpenLP.ServiceManager', 'Save this service.'), triggers=self.decide_save_method) self.toolbar.addSeparator() - self.theme_label = QtGui.QLabel('%s:' % UiStrings().Theme, widget) - self.theme_label.setMargin(3) + self.theme_label = QtWidgets.QLabel('%s:' % UiStrings().Theme, widget) + self.theme_label.setContentsMargins(3, 3, 3, 3) self.theme_label.setObjectName('theme_label') self.toolbar.add_toolbar_widget(self.theme_label) - self.theme_combo_box = QtGui.QComboBox(self.toolbar) + self.theme_combo_box = QtWidgets.QComboBox(self.toolbar) self.theme_combo_box.setToolTip(translate('OpenLP.ServiceManager', 'Select a theme for the service.')) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.theme_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToMinimumContentsLength) + self.theme_combo_box.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.theme_combo_box.setObjectName('theme_combo_box') self.toolbar.add_toolbar_widget(self.theme_combo_box) self.toolbar.setObjectName('toolbar') @@ -133,10 +133,10 @@ class Ui_ServiceManager(object): # Create the service manager list self.service_manager_list = ServiceManagerList(widget) self.service_manager_list.setEditTriggers( - QtGui.QAbstractItemView.CurrentChanged | - QtGui.QAbstractItemView.DoubleClicked | - QtGui.QAbstractItemView.EditKeyPressed) - self.service_manager_list.setDragDropMode(QtGui.QAbstractItemView.DragDrop) + QtWidgets.QAbstractItemView.CurrentChanged | + QtWidgets.QAbstractItemView.DoubleClicked | + QtWidgets.QAbstractItemView.EditKeyPressed) + self.service_manager_list.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) self.service_manager_list.setAlternatingRowColors(True) self.service_manager_list.setHeaderHidden(True) self.service_manager_list.setExpandsOnDoubleClick(False) @@ -218,13 +218,13 @@ class Ui_ServiceManager(object): self.service_theme = Settings().value(self.main_window.service_manager_settings_section + '/service theme') self.service_path = AppLocation.get_section_data_path('servicemanager') # build the drag and drop context menu - self.dnd_menu = QtGui.QMenu() + self.dnd_menu = QtWidgets.QMenu() self.new_action = self.dnd_menu.addAction(translate('OpenLP.ServiceManager', '&Add New Item')) self.new_action.setIcon(build_icon(':/general/general_edit.png')) self.add_to_action = self.dnd_menu.addAction(translate('OpenLP.ServiceManager', '&Add to Selected Item')) self.add_to_action.setIcon(build_icon(':/general/general_edit.png')) # build the context menu - self.menu = QtGui.QMenu() + self.menu = QtWidgets.QMenu() self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Edit Item'), icon=':/general/general_edit.png', triggers=self.remote_edit) self.rename_action = create_widget_action(self.menu, text=translate('OpenLP.ServiceManager', '&Rename...'), @@ -250,9 +250,9 @@ class Ui_ServiceManager(object): triggers=self.create_custom) self.menu.addSeparator() # Add AutoPlay menu actions - self.auto_play_slides_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) + self.auto_play_slides_menu = QtWidgets.QMenu(translate('OpenLP.ServiceManager', '&Auto play slides')) self.menu.addMenu(self.auto_play_slides_menu) - auto_play_slides_group = QtGui.QActionGroup(self.auto_play_slides_menu) + auto_play_slides_group = QtWidgets.QActionGroup(self.auto_play_slides_menu) auto_play_slides_group.setExclusive(True) self.auto_play_slides_loop = create_widget_action(self.auto_play_slides_menu, text=translate('OpenLP.ServiceManager', 'Auto play slides ' @@ -275,7 +275,7 @@ class Ui_ServiceManager(object): # Add already existing make live action to the menu. self.menu.addAction(self.service_manager_list.make_live) self.menu.addSeparator() - self.theme_menu = QtGui.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) + self.theme_menu = QtWidgets.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme')) self.menu.addMenu(self.theme_menu) self.service_manager_list.addActions( [self.service_manager_list.move_down, @@ -302,12 +302,16 @@ class Ui_ServiceManager(object): event.accept() -class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManager, RegistryProperties): +class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceManager, RegistryProperties): """ Manages the services. This involves taking text strings from plugins and adding them to the service. This service can then be zipped up with all the resources used into one OSZ or oszl file for use on any OpenLP v2 installation. Also handles the UI tasks of moving things up and down etc. """ + servicemanager_set_item = QtCore.pyqtSignal(int) + servicemanager_next_item = QtCore.pyqtSignal() + servicemanager_previous_item = QtCore.pyqtSignal() + def __init__(self, parent=None): """ Sets up the service manager, toolbars, list view, et al. @@ -330,9 +334,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ self.setup_ui(self) # Need to use event as called across threads and UI is updated - QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_set_item'), self.on_set_item) - QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_next_item'), self.next_item) - QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_previous_item'), self.previous_item) + self.servicemanager_set_item.connect(self.on_set_item) + self.servicemanager_next_item.connect(self.next_item) + self.servicemanager_previous_item.connect(self.previous_item) def bootstrap_post_set_up(self): """ @@ -410,9 +414,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ if self.is_modified(): result = self.save_modified_service() - if result == QtGui.QMessageBox.Cancel: + if result == QtWidgets.QMessageBox.Cancel: return False - elif result == QtGui.QMessageBox.Save: + elif result == QtWidgets.QMessageBox.Save: if not self.decide_save_method(): return False self.new_file() @@ -425,17 +429,16 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ if self.is_modified(): result = self.save_modified_service() - if result == QtGui.QMessageBox.Cancel: + if result == QtWidgets.QMessageBox.Cancel: return False - elif result == QtGui.QMessageBox.Save: + elif result == QtWidgets.QMessageBox.Save: self.decide_save_method() if not load_file: - file_name = QtGui.QFileDialog.getOpenFileName( + file_name, filter_used = QtWidgets.QFileDialog.getOpenFileName( self.main_window, translate('OpenLP.ServiceManager', 'Open File'), Settings().value(self.main_window.service_manager_settings_section + '/last directory'), - translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)') - ) + translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')) if not file_name: return False else: @@ -448,13 +451,13 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ Check to see if a service needs to be saved. """ - return QtGui.QMessageBox.question(self.main_window, - translate('OpenLP.ServiceManager', 'Modified Service'), - translate('OpenLP.ServiceManager', - 'The current service has been modified. Would you like to save ' - 'this service?'), - QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) + return QtWidgets.QMessageBox.question(self.main_window, + translate('OpenLP.ServiceManager', 'Modified Service'), + translate('OpenLP.ServiceManager', + 'The current service has been modified. Would you like to save ' + 'this service?'), + QtWidgets.QMessageBox.Save | QtWidgets.QMessageBox.Discard | + QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.Save) def on_recent_service_clicked(self, field=None): """ @@ -535,10 +538,10 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage message = translate('OpenLP.ServiceManager', 'The following file(s) in the service are missing: %s\n\n' 'These files will be removed if you continue to save.') % "\n\t".join(missing_list) - answer = QtGui.QMessageBox.critical(self, title, message, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok | - QtGui.QMessageBox.Cancel)) - if answer == QtGui.QMessageBox.Cancel: + answer = QtWidgets.QMessageBox.critical(self, title, message, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok | + QtWidgets.QMessageBox.Cancel)) + if answer == QtWidgets.QMessageBox.Cancel: self.main_window.finished_progress_bar() return False # Check if item contains a missing file. @@ -602,10 +605,10 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage except shutil.Error: return self.save_file_as() except OSError as ose: - QtGui.QMessageBox.critical(self, translate('OpenLP.ServiceManager', 'Error Saving File'), - translate('OpenLP.ServiceManager', 'An error occurred while writing the ' - 'service file: %s') % ose.strerror, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.ServiceManager', 'Error Saving File'), + translate('OpenLP.ServiceManager', 'An error occurred while writing the ' + 'service file: %s') % ose.strerror, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) success = False self.main_window.add_recent_file(path_file_name) self.set_modified(False) @@ -694,14 +697,14 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage # SaveAs from osz to oszl is not valid as the files will be deleted on exit which is not sensible or usable in # the long term. if self._file_name.endswith('oszl') or self.service_has_all_original_files: - file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, - translate('OpenLP.ServiceManager', - 'OpenLP Service Files (*.osz);; OpenLP Service ' - 'Files - lite (*.oszl)')) + file_name, filter_used = QtWidgets.QFileDialog.getSaveFileName( + self.main_window, UiStrings().SaveService, path, + translate('OpenLP.ServiceManager', + 'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)')) else: - file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, - translate('OpenLP.ServiceManager', - 'OpenLP Service Files (*.osz);;')) + file_name, filter_uesd = QtWidgets.QFileDialog.getSaveFileName( + self.main_window, UiStrings().SaveService, path, + translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;')) if not file_name: return False if os.path.splitext(file_name)[1] == '': @@ -783,15 +786,16 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage except zipfile.BadZipfile: if os.path.getsize(file_name) == 0: self.log_exception('Service file is zero sized: %s' % file_name) - QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Empty File'), - translate('OpenLP.ServiceManager', 'This service file does not contain ' - 'any data.')) + QtWidgets.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Empty File'), + translate('OpenLP.ServiceManager', + 'This service file does not contain ' + 'any data.')) else: self.log_exception('Service file is cannot be extracted as zip: %s' % file_name) - QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'), - translate('OpenLP.ServiceManager', - 'This file is either corrupt or it is not an OpenLP 2 service ' - 'file.')) + QtWidgets.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'), + translate('OpenLP.ServiceManager', + 'This file is either corrupt or it is not an OpenLP 2 ' + 'service file.')) self.application.set_normal_cursor() return finally: @@ -907,10 +911,10 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if service_item['service_item'].theme is None: theme_action = self.theme_menu.defaultAction() else: - theme_action = self.theme_menu.findChild(QtGui.QAction, service_item['service_item'].theme) + theme_action = self.theme_menu.findChild(QtWidgets.QAction, service_item['service_item'].theme) if theme_action is not None: theme_action.setChecked(True) - self.menu.exec_(self.service_manager_list.mapToGlobal(point)) + self.menu.exec(self.service_manager_list.mapToGlobal(point)) def on_service_item_note_form(self, field=None): """ @@ -919,7 +923,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ item = self.find_service_item()[0] self.service_note_form.text_edit.setPlainText(self.service_items[item]['service_item'].notes) - if self.service_note_form.exec_(): + if self.service_note_form.exec(): self.service_items[item]['service_item'].notes = self.service_note_form.text_edit.toPlainText() self.repaint_service_list(item, -1) self.set_modified() @@ -931,7 +935,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ item = self.find_service_item()[0] self.start_time_form.item = self.service_items[item] - if self.start_time_form.exec_(): + if self.start_time_form.exec(): self.repaint_service_list(item, -1) def toggle_auto_play_slides_once(self, field=None): @@ -979,7 +983,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage timed_slide_interval = Settings().value(self.main_window.general_settings_section + '/loop delay') else: timed_slide_interval = service_item.timed_slide_interval - timed_slide_interval, ok = QtGui.QInputDialog.getInteger(self, translate('OpenLP.ServiceManager', + timed_slide_interval, ok = QtWidgets.QInputDialog.getInt(self, translate('OpenLP.ServiceManager', 'Input delay'), translate('OpenLP.ServiceManager', 'Delay between slides in seconds.'), @@ -1009,7 +1013,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage """ item = self.find_service_item()[0] self.service_item_edit_form.set_service_item(self.service_items[item]['service_item']) - if self.service_item_edit_form.exec_(): + if self.service_item_edit_form.exec(): self.add_service_item(self.service_item_edit_form.get_service_item(), replace=True, expand=self.service_items[item]['expanded']) @@ -1036,7 +1040,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage return selected = self.service_manager_list.selectedItems()[0] look_for = 0 - service_iterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list) + service_iterator = QtWidgets.QTreeWidgetItemIterator(self.service_manager_list) while service_iterator.value(): if look_for == 1 and service_iterator.value().parent() is None: self.service_manager_list.setCurrentItem(service_iterator.value()) @@ -1057,7 +1061,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage selected = self.service_manager_list.selectedItems()[0] prev_item = None prev_item_last_slide = None - service_iterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list) + service_iterator = QtWidgets.QTreeWidgetItemIterator(self.service_manager_list) while service_iterator.value(): if service_iterator.value() == selected: if last_slide and prev_item_last_slide: @@ -1239,7 +1243,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.service_manager_list.clearSelection() for item_count, item in enumerate(self.service_items): service_item_from_item = item['service_item'] - tree_widget_item = QtGui.QTreeWidgetItem(self.service_manager_list) + tree_widget_item = QtWidgets.QTreeWidgetItem(self.service_manager_list) if service_item_from_item.is_valid: if service_item_from_item.notes: icon = QtGui.QImage(service_item_from_item.icon) @@ -1281,7 +1285,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage tree_widget_item.setSelected(item['selected']) # Add the children to their parent tree_widget_item. for count, frame in enumerate(service_item_from_item.get_frames()): - child = QtGui.QTreeWidgetItem(tree_widget_item) + child = QtWidgets.QTreeWidgetItem(tree_widget_item) # prefer to use a display_title if service_item_from_item.is_capable(ItemCapabilities.HasDisplayTitle): text = frame['display_title'].replace('\n', ' ') @@ -1337,7 +1341,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if self.service_items: for item in self.service_items: item['selected'] = False - service_iterator = QtGui.QTreeWidgetItemIterator(self.service_manager_list) + service_iterator = QtWidgets.QTreeWidgetItemIterator(self.service_manager_list) selected_item = None while service_iterator.value(): if service_iterator.value().isSelected(): @@ -1511,9 +1515,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if not self.service_items[item]['service_item'].is_capable(ItemCapabilities.CanEditTitle): return title = self.service_items[item]['service_item'].title - title, ok = QtGui.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), - translate('OpenLP.ServiceManager', 'Title:'), - QtGui.QLineEdit.Normal, self.trUtf8(title)) + title, ok = QtWidgets.QInputDialog.getText(self, translate('OpenLP.ServiceManager', 'Rename item title'), + translate('OpenLP.ServiceManager', 'Title:'), + QtWidgets.QLineEdit.Normal, self.tr(title)) if ok: self.service_items[item]['service_item'].title = title self.repaint_service_list(item, -1) @@ -1598,7 +1602,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage service_item = self.service_items[pos] if (plugin == service_item['service_item'].name and service_item['service_item'].is_capable(ItemCapabilities.CanAppend)): - action = self.dnd_menu.exec_(QtGui.QCursor.pos()) + action = self.dnd_menu.exec(QtGui.QCursor.pos()) # New action required if action == self.new_action: self.drop_position = self._get_parent_item_data(item) @@ -1620,7 +1624,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.theme_combo_box.clear() self.theme_menu.clear() self.theme_combo_box.addItem('') - theme_group = QtGui.QActionGroup(self.theme_menu) + theme_group = QtWidgets.QActionGroup(self.theme_menu) theme_group.setExclusive(True) theme_group.setObjectName('theme_group') # Create a "Default" theme, which allows the user to reset the item's theme to the service theme or global @@ -1669,7 +1673,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage Print a Service Order Sheet. """ setting_dialog = PrintServiceForm() - setting_dialog.exec_() + setting_dialog.exec() def get_drop_position(self): """ diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index e812208ba..54a09ee25 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -22,14 +22,14 @@ """ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` class. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.lib import SpellTextEdit from openlp.core.lib.ui import create_button_box -class ServiceNoteForm(QtGui.QDialog, RegistryProperties): +class ServiceNoteForm(QtWidgets.QDialog, RegistryProperties): """ This is the form that is used to edit the verses of the song. """ @@ -41,19 +41,19 @@ class ServiceNoteForm(QtGui.QDialog, RegistryProperties): self.setupUi() self.retranslateUi() - def exec_(self): + def exec(self): """ Execute the form and return the result. """ self.text_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def setupUi(self): """ Set up the UI of the dialog """ self.setObjectName('serviceNoteEdit') - self.dialog_layout = QtGui.QVBoxLayout(self) + self.dialog_layout = QtWidgets.QVBoxLayout(self) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setSpacing(8) self.dialog_layout.setObjectName('vertical_layout') diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 0fa049bb3..566dc70ea 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -22,7 +22,7 @@ """ The UI widgets of the settings dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -40,16 +40,16 @@ class Ui_SettingsDialog(object): settings_dialog.setObjectName('settings_dialog') settings_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) settings_dialog.resize(800, 700) - self.dialog_layout = QtGui.QGridLayout(settings_dialog) + self.dialog_layout = QtWidgets.QGridLayout(settings_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.dialog_layout.setMargin(8) - self.setting_list_widget = QtGui.QListWidget(settings_dialog) + self.dialog_layout.setContentsMargins(8, 8, 8, 8) + self.setting_list_widget = QtWidgets.QListWidget(settings_dialog) self.setting_list_widget.setUniformItemSizes(True) self.setting_list_widget.setMinimumSize(QtCore.QSize(150, 0)) self.setting_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setting_list_widget.setObjectName('setting_list_widget') self.dialog_layout.addWidget(self.setting_list_widget, 0, 0, 1, 1) - self.stacked_layout = QtGui.QStackedLayout() + self.stacked_layout = QtWidgets.QStackedLayout() self.stacked_layout.setObjectName('stacked_layout') self.dialog_layout.addLayout(self.stacked_layout, 0, 1, 1, 1) self.button_box = create_button_box(settings_dialog, 'button_box', ['cancel', 'ok']) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 8f5572e6d..628cd68a8 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -24,7 +24,7 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties from openlp.core.lib import build_icon @@ -36,7 +36,7 @@ from openlp.core.ui.projector.tab import ProjectorTab log = logging.getLogger(__name__) -class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): +class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): """ Provide the form to manipulate the settings for OpenLP """ @@ -56,7 +56,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): self.advanced_tab = None self.player_tab = None - def exec_(self): + def exec(self): """ Execute the form """ @@ -74,7 +74,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): if plugin.settings_tab: self.insert_tab(plugin.settings_tab, plugin.is_active()) self.setting_list_widget.setCurrentRow(0) - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def insert_tab(self, tab_widget, is_visible=True): """ @@ -87,7 +87,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): # add the tab to get it to display in the correct part of the screen self.stacked_layout.addWidget(tab_widget) if is_visible: - list_item = QtGui.QListWidgetItem(build_icon(tab_widget.icon_path), tab_widget.tab_title_visible) + list_item = QtWidgets.QListWidgetItem(build_icon(tab_widget.icon_path), tab_widget.tab_title_visible) list_item.setData(QtCore.Qt.UserRole, tab_widget.tab_title) self.setting_list_widget.addItem(list_item) @@ -116,7 +116,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): # Now lets process all the post save handlers while self.processes: Registry().execute(self.processes.pop(0)) - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) def reject(self): """ @@ -135,7 +135,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): tab_widget = self.stacked_layout.widget(tab_index) if tab_widget.tab_title == plugin_name: tab_widget.cancel() - return QtGui.QDialog.reject(self) + return QtWidgets.QDialog.reject(self) def bootstrap_post_set_up(self): """ diff --git a/openlp/core/ui/shortcutlistdialog.py b/openlp/core/ui/shortcutlistdialog.py index a38980c03..6d9726597 100644 --- a/openlp/core/ui/shortcutlistdialog.py +++ b/openlp/core/ui/shortcutlistdialog.py @@ -22,14 +22,14 @@ """ The list of shortcuts within a dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon from openlp.core.lib.ui import create_button_box -class CaptureShortcutButton(QtGui.QPushButton): +class CaptureShortcutButton(QtWidgets.QPushButton): """ A class to encapsulate a ``QPushButton``. """ @@ -61,56 +61,56 @@ class Ui_ShortcutListDialog(object): shortcutListDialog.setObjectName('shortcutListDialog') shortcutListDialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) shortcutListDialog.resize(500, 438) - self.shortcut_list_layout = QtGui.QVBoxLayout(shortcutListDialog) + self.shortcut_list_layout = QtWidgets.QVBoxLayout(shortcutListDialog) self.shortcut_list_layout.setObjectName('shortcut_list_layout') - self.description_label = QtGui.QLabel(shortcutListDialog) + self.description_label = QtWidgets.QLabel(shortcutListDialog) self.description_label.setObjectName('description_label') self.description_label.setWordWrap(True) self.shortcut_list_layout.addWidget(self.description_label) - self.tree_widget = QtGui.QTreeWidget(shortcutListDialog) + self.tree_widget = QtWidgets.QTreeWidget(shortcutListDialog) self.tree_widget.setObjectName('tree_widget') self.tree_widget.setAlternatingRowColors(True) self.tree_widget.setColumnCount(3) self.tree_widget.setColumnWidth(0, 250) self.shortcut_list_layout.addWidget(self.tree_widget) - self.details_layout = QtGui.QGridLayout() + self.details_layout = QtWidgets.QGridLayout() self.details_layout.setObjectName('details_layout') self.details_layout.setContentsMargins(-1, 0, -1, -1) - self.default_radio_button = QtGui.QRadioButton(shortcutListDialog) + self.default_radio_button = QtWidgets.QRadioButton(shortcutListDialog) self.default_radio_button.setObjectName('default_radio_button') self.default_radio_button.setChecked(True) self.details_layout.addWidget(self.default_radio_button, 0, 0, 1, 1) - self.custom_radio_button = QtGui.QRadioButton(shortcutListDialog) + self.custom_radio_button = QtWidgets.QRadioButton(shortcutListDialog) self.custom_radio_button.setObjectName('custom_radio_button') self.details_layout.addWidget(self.custom_radio_button, 1, 0, 1, 1) - self.primary_layout = QtGui.QHBoxLayout() + self.primary_layout = QtWidgets.QHBoxLayout() self.primary_layout.setObjectName('primary_layout') self.primary_push_button = CaptureShortcutButton(shortcutListDialog) self.primary_push_button.setObjectName('primary_push_button') self.primary_push_button.setMinimumSize(QtCore.QSize(84, 0)) self.primary_push_button.setIcon(build_icon(':/system/system_configure_shortcuts.png')) self.primary_layout.addWidget(self.primary_push_button) - self.clear_primary_button = QtGui.QToolButton(shortcutListDialog) + self.clear_primary_button = QtWidgets.QToolButton(shortcutListDialog) self.clear_primary_button.setObjectName('clear_primary_button') self.clear_primary_button.setMinimumSize(QtCore.QSize(0, 16)) self.clear_primary_button.setIcon(build_icon(':/system/clear_shortcut.png')) self.primary_layout.addWidget(self.clear_primary_button) self.details_layout.addLayout(self.primary_layout, 1, 1, 1, 1) - self.alternate_layout = QtGui.QHBoxLayout() + self.alternate_layout = QtWidgets.QHBoxLayout() self.alternate_layout.setObjectName('alternate_layout') self.alternate_push_button = CaptureShortcutButton(shortcutListDialog) self.alternate_push_button.setObjectName('alternate_push_button') self.alternate_push_button.setIcon(build_icon(':/system/system_configure_shortcuts.png')) self.alternate_layout.addWidget(self.alternate_push_button) - self.clear_alternate_button = QtGui.QToolButton(shortcutListDialog) + self.clear_alternate_button = QtWidgets.QToolButton(shortcutListDialog) self.clear_alternate_button.setObjectName('clear_alternate_button') self.clear_alternate_button.setIcon(build_icon(':/system/clear_shortcut.png')) self.alternate_layout.addWidget(self.clear_alternate_button) self.details_layout.addLayout(self.alternate_layout, 1, 2, 1, 1) - self.primary_label = QtGui.QLabel(shortcutListDialog) + self.primary_label = QtWidgets.QLabel(shortcutListDialog) self.primary_label.setObjectName('primary_label') self.details_layout.addWidget(self.primary_label, 0, 1, 1, 1) - self.alternate_label = QtGui.QLabel(shortcutListDialog) + self.alternate_label = QtWidgets.QLabel(shortcutListDialog) self.alternate_label.setObjectName('alternate_label') self.details_layout.addWidget(self.alternate_label, 0, 2, 1, 1) self.shortcut_list_layout.addLayout(self.details_layout) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 96f5be9ac..9780c66f8 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -24,7 +24,7 @@ The :mod:`~openlp.core.ui.shortcutlistform` module contains the form class""" import logging import re -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import RegistryProperties, Settings, translate from openlp.core.utils.actions import ActionList @@ -35,7 +35,7 @@ REMOVE_AMPERSAND = re.compile(r'&{1}') log = logging.getLogger(__name__) -class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties): +class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryProperties): """ The shortcut list dialog """ @@ -100,7 +100,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) elif self.alternate_push_button.isChecked(): self._adjust_button(self.alternate_push_button, False, text=key_sequence.toString()) - def exec_(self): + def exec(self): """ Execute the dialog """ @@ -108,7 +108,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) self.reload_shortcut_list() self._adjust_button(self.primary_push_button, False, False, '') self._adjust_button(self.alternate_push_button, False, False, '') - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def reload_shortcut_list(self): """ @@ -119,10 +119,10 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) # Check if the category is for internal use only. if category.name is None: continue - item = QtGui.QTreeWidgetItem([category.name]) + item = QtWidgets.QTreeWidgetItem([category.name]) for action in category.actions: action_text = REMOVE_AMPERSAND.sub('', action.text()) - action_item = QtGui.QTreeWidgetItem([action_text]) + action_item = QtWidgets.QTreeWidgetItem([action_text]) action_item.setIcon(0, action.icon()) action_item.setData(0, QtCore.Qt.UserRole, action) tool_tip_text = action.toolTip() @@ -142,7 +142,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) This refreshes the item's shortcuts shown in the list. Note, this neither adds new actions nor removes old actions. """ - iterator = QtGui.QTreeWidgetItemIterator(self.tree_widget) + iterator = QtWidgets.QTreeWidgetItemIterator(self.tree_widget) while iterator.value(): item = iterator.value() iterator += 1 @@ -273,13 +273,14 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) """ Restores all default shortcuts. """ - if self.button_box.buttonRole(button) != QtGui.QDialogButtonBox.ResetRole: + if self.button_box.buttonRole(button) != QtWidgets.QDialogButtonBox.ResetRole: return - if QtGui.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), - translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' - 'shortcuts to their defaults?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: + if QtWidgets.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), + translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' + 'shortcuts to their defaults?'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No) + ) == QtWidgets.QMessageBox.No: return self._adjust_button(self.primary_push_button, False, text='') self._adjust_button(self.alternate_push_button, False, text='') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 59ca286a7..d82732fe1 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -28,7 +28,7 @@ import copy from collections import deque from threading import Lock -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, Settings, SlideLimits, UiStrings, translate, \ RegistryMixin, OpenLPMixin @@ -73,7 +73,7 @@ NON_TEXT_MENU = [ ] -class DisplayController(QtGui.QWidget): +class DisplayController(QtWidgets.QWidget): """ Controller is a general display controller widget. """ @@ -98,7 +98,7 @@ class DisplayController(QtGui.QWidget): Registry().execute('%s' % sender, [controller, args]) -class InfoLabel(QtGui.QLabel): +class InfoLabel(QtWidgets.QLabel): """ InfoLabel is a subclassed QLabel. Created to provide the ablilty to add a ellipsis if the text is cut off. Original source: https://stackoverflow.com/questions/11446478/pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize @@ -161,17 +161,17 @@ class SlideController(DisplayController, RegistryProperties): self.service_item = None self.slide_limits = None self.update_slide_limits() - self.panel = QtGui.QWidget(self.main_window.control_splitter) + self.panel = QtWidgets.QWidget(self.main_window.control_splitter) self.slide_list = {} self.slide_count = 0 self.slide_image = None self.controller_width = -1 # Layout for holding panel - self.panel_layout = QtGui.QVBoxLayout(self.panel) + self.panel_layout = QtWidgets.QVBoxLayout(self.panel) self.panel_layout.setSpacing(0) - self.panel_layout.setMargin(0) + self.panel_layout.setContentsMargins(0, 0, 0, 0) # Type label at the top of the slide controller - self.type_label = QtGui.QLabel(self.panel) + self.type_label = QtWidgets.QLabel(self.panel) self.type_label.setStyleSheet('font-weight: bold; font-size: 12pt;') self.type_label.setAlignment(QtCore.Qt.AlignCenter) if self.is_live: @@ -181,25 +181,26 @@ class SlideController(DisplayController, RegistryProperties): self.panel_layout.addWidget(self.type_label) # Info label for the title of the current item, at the top of the slide controller self.info_label = InfoLabel(self.panel) - self.info_label.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred) + self.info_label.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred) self.panel_layout.addWidget(self.info_label) # Splitter - self.splitter = QtGui.QSplitter(self.panel) + self.splitter = QtWidgets.QSplitter(self.panel) self.splitter.setOrientation(QtCore.Qt.Vertical) self.panel_layout.addWidget(self.splitter) # Actual controller section - self.controller = QtGui.QWidget(self.splitter) + self.controller = QtWidgets.QWidget(self.splitter) self.controller.setGeometry(QtCore.QRect(0, 0, 100, 536)) - self.controller.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum)) - self.controller_layout = QtGui.QVBoxLayout(self.controller) + self.controller.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, + QtWidgets.QSizePolicy.Maximum)) + self.controller_layout = QtWidgets.QVBoxLayout(self.controller) self.controller_layout.setSpacing(0) - self.controller_layout.setMargin(0) + self.controller_layout.setContentsMargins(0, 0, 0, 0) # Controller list view self.preview_widget = ListPreviewWidget(self, self.ratio) self.controller_layout.addWidget(self.preview_widget) # Build the full toolbar self.toolbar = OpenLPToolbar(self) - size_toolbar_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + size_toolbar_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) size_toolbar_policy.setHorizontalStretch(0) size_toolbar_policy.setVerticalStretch(0) size_toolbar_policy.setHeightForWidth(self.toolbar.sizePolicy().hasHeightForWidth()) @@ -223,11 +224,11 @@ class SlideController(DisplayController, RegistryProperties): if self.is_live: self.controller_type = DisplayControllerType.Live # Hide Menu - self.hide_menu = QtGui.QToolButton(self.toolbar) + self.hide_menu = QtWidgets.QToolButton(self.toolbar) self.hide_menu.setObjectName('hide_menu') self.hide_menu.setText(translate('OpenLP.SlideController', 'Hide')) - self.hide_menu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) - self.hide_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar)) + self.hide_menu.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) + self.hide_menu.setMenu(QtWidgets.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar)) self.toolbar.add_toolbar_widget(self.hide_menu) self.blank_screen = create_action(self, 'blankScreen', text=translate('OpenLP.SlideController', 'Blank Screen'), @@ -249,25 +250,26 @@ class SlideController(DisplayController, RegistryProperties): self.hide_menu.menu().addAction(self.theme_screen) self.hide_menu.menu().addAction(self.desktop_screen) # Wide menu of display control buttons. - self.blank_screen_button = QtGui.QToolButton(self.toolbar) + self.blank_screen_button = QtWidgets.QToolButton(self.toolbar) self.blank_screen_button.setObjectName('blank_screen_button') self.toolbar.add_toolbar_widget(self.blank_screen_button) self.blank_screen_button.setDefaultAction(self.blank_screen) - self.theme_screen_button = QtGui.QToolButton(self.toolbar) + self.theme_screen_button = QtWidgets.QToolButton(self.toolbar) self.theme_screen_button.setObjectName('theme_screen_button') self.toolbar.add_toolbar_widget(self.theme_screen_button) self.theme_screen_button.setDefaultAction(self.theme_screen) - self.desktop_screen_button = QtGui.QToolButton(self.toolbar) + self.desktop_screen_button = QtWidgets.QToolButton(self.toolbar) self.desktop_screen_button.setObjectName('desktop_screen_button') self.toolbar.add_toolbar_widget(self.desktop_screen_button) self.desktop_screen_button.setDefaultAction(self.desktop_screen) self.toolbar.add_toolbar_action('loop_separator', separator=True) # Play Slides Menu - self.play_slides_menu = QtGui.QToolButton(self.toolbar) + self.play_slides_menu = QtWidgets.QToolButton(self.toolbar) self.play_slides_menu.setObjectName('play_slides_menu') self.play_slides_menu.setText(translate('OpenLP.SlideController', 'Play Slides')) - self.play_slides_menu.setPopupMode(QtGui.QToolButton.MenuButtonPopup) - self.play_slides_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Play Slides'), self.toolbar)) + self.play_slides_menu.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) + self.play_slides_menu.setMenu(QtWidgets.QMenu(translate('OpenLP.SlideController', 'Play Slides'), + self.toolbar)) self.toolbar.add_toolbar_widget(self.play_slides_menu) self.play_slides_loop = create_action(self, 'playSlidesLoop', text=UiStrings().PlaySlidesInLoop, icon=':/media/media_time.png', checked=False, can_shortcuts=True, @@ -282,7 +284,7 @@ class SlideController(DisplayController, RegistryProperties): self.play_slides_menu.menu().addAction(self.play_slides_loop) self.play_slides_menu.menu().addAction(self.play_slides_once) # Loop Delay Spinbox - self.delay_spin_box = QtGui.QSpinBox() + self.delay_spin_box = QtWidgets.QSpinBox() self.delay_spin_box.setObjectName('delay_spin_box') self.delay_spin_box.setRange(1, 180) self.delay_spin_box.setSuffix(UiStrings().Seconds) @@ -306,11 +308,11 @@ class SlideController(DisplayController, RegistryProperties): self.media_controller.register_controller(self) if self.is_live: # Build the Song Toolbar - self.song_menu = QtGui.QToolButton(self.toolbar) + self.song_menu = QtWidgets.QToolButton(self.toolbar) self.song_menu.setObjectName('song_menu') self.song_menu.setText(translate('OpenLP.SlideController', 'Go To')) - self.song_menu.setPopupMode(QtGui.QToolButton.InstantPopup) - self.song_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Go To'), self.toolbar)) + self.song_menu.setPopupMode(QtWidgets.QToolButton.InstantPopup) + self.song_menu.setMenu(QtWidgets.QMenu(translate('OpenLP.SlideController', 'Go To'), self.toolbar)) self.toolbar.add_toolbar_widget(self.song_menu) # Stuff for items with background audio. # FIXME: object name should be changed. But this requires that we migrate the shortcut. @@ -320,10 +322,10 @@ class SlideController(DisplayController, RegistryProperties): tooltip=translate('OpenLP.SlideController', 'Pause audio.'), checked=False, visible=False, category=self.category, context=QtCore.Qt.WindowShortcut, can_shortcuts=True, triggers=self.set_audio_pause_clicked) - self.audio_menu = QtGui.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) + self.audio_menu = QtWidgets.QMenu(translate('OpenLP.SlideController', 'Background Audio'), self.toolbar) self.audio_pause_item.setMenu(self.audio_menu) self.audio_pause_item.setParent(self.toolbar) - self.toolbar.widgetForAction(self.audio_pause_item).setPopupMode(QtGui.QToolButton.MenuButtonPopup) + self.toolbar.widgetForAction(self.audio_pause_item).setPopupMode(QtWidgets.QToolButton.MenuButtonPopup) self.next_track_item = create_action(self, 'nextTrackItem', text=UiStrings().NextTrack, icon=':/slides/media_playback_next.png', tooltip=translate('OpenLP.SlideController', @@ -333,7 +335,7 @@ class SlideController(DisplayController, RegistryProperties): triggers=self.on_next_track_clicked) self.audio_menu.addAction(self.next_track_item) self.track_menu = self.audio_menu.addMenu(translate('OpenLP.SlideController', 'Tracks')) - self.audio_time_label = QtGui.QLabel(' 00:00 ', self.toolbar) + self.audio_time_label = QtWidgets.QLabel(' 00:00 ', self.toolbar) self.audio_time_label.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignHCenter) self.audio_time_label.setStyleSheet(AUDIO_TIME_LABEL_STYLESHEET) self.audio_time_label.setObjectName('audio_time_label') @@ -341,33 +343,34 @@ class SlideController(DisplayController, RegistryProperties): self.toolbar.set_widget_visible(AUDIO_LIST, False) self.toolbar.set_widget_visible(['song_menu'], False) # Screen preview area - self.preview_frame = QtGui.QFrame(self.splitter) + self.preview_frame = QtWidgets.QFrame(self.splitter) self.preview_frame.setGeometry(QtCore.QRect(0, 0, 300, 300 * self.ratio)) self.preview_frame.setMinimumHeight(100) - self.preview_frame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored, - QtGui.QSizePolicy.Label)) - self.preview_frame.setFrameShape(QtGui.QFrame.StyledPanel) - self.preview_frame.setFrameShadow(QtGui.QFrame.Sunken) + self.preview_frame.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, + QtWidgets.QSizePolicy.Ignored, + QtWidgets.QSizePolicy.Label)) + self.preview_frame.setFrameShape(QtWidgets.QFrame.StyledPanel) + self.preview_frame.setFrameShadow(QtWidgets.QFrame.Sunken) self.preview_frame.setObjectName('preview_frame') - self.grid = QtGui.QGridLayout(self.preview_frame) - self.grid.setMargin(8) + self.grid = QtWidgets.QGridLayout(self.preview_frame) + self.grid.setContentsMargins(8, 8, 8, 8) self.grid.setObjectName('grid') - self.slide_layout = QtGui.QVBoxLayout() + self.slide_layout = QtWidgets.QVBoxLayout() self.slide_layout.setSpacing(0) - self.slide_layout.setMargin(0) + self.slide_layout.setContentsMargins(0, 0, 0, 0) self.slide_layout.setObjectName('SlideLayout') self.preview_display = Display(self) self.slide_layout.insertWidget(0, self.preview_display) self.preview_display.hide() # Actual preview screen - self.slide_preview = QtGui.QLabel(self) - size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.slide_preview = QtWidgets.QLabel(self) + size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.slide_preview.sizePolicy().hasHeightForWidth()) self.slide_preview.setSizePolicy(size_policy) - self.slide_preview.setFrameShape(QtGui.QFrame.Box) - self.slide_preview.setFrameShadow(QtGui.QFrame.Plain) + self.slide_preview.setFrameShape(QtWidgets.QFrame.Box) + self.slide_preview.setFrameShadow(QtWidgets.QFrame.Plain) self.slide_preview.setLineWidth(1) self.slide_preview.setScaledContents(True) self.slide_preview.setObjectName('slide_preview') @@ -401,7 +404,7 @@ class SlideController(DisplayController, RegistryProperties): self.preview_widget.verticalHeader().sectionClicked.connect(self.on_slide_selected) if self.is_live: # Need to use event as called across threads and UI is updated - QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_toggle_display'), self.toggle_display) + self.slidecontroller_toggle_display.connect(self.toggle_display) Registry().register_function('slidecontroller_live_spin_delay', self.receive_spin_delay) self.toolbar.set_widget_visible(LOOP_LIST, False) self.toolbar.set_widget_visible(WIDE_MENU, False) @@ -416,12 +419,9 @@ class SlideController(DisplayController, RegistryProperties): Registry().register_function('slidecontroller_%s_blank' % self.type_prefix, self.on_slide_blank) Registry().register_function('slidecontroller_%s_unblank' % self.type_prefix, self.on_slide_unblank) Registry().register_function('slidecontroller_update_slide_limits', self.update_slide_limits) - QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_%s_set' % self.type_prefix), - self.on_slide_selected_index) - QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_%s_next' % self.type_prefix), - self.on_slide_selected_next) - QtCore.QObject.connect(self, QtCore.SIGNAL('slidecontroller_%s_previous' % self.type_prefix), - self.on_slide_selected_previous) + getattr(self, 'slidecontroller_%s_set' % self.type_prefix).connect(self.on_slide_selected_index) + getattr(self, 'slidecontroller_%s_next' % self.type_prefix).connect(self.on_slide_selected_next) + getattr(self, 'slidecontroller_%s_previous' % self.type_prefix).connect(self.on_slide_selected_previous) def _slide_shortcut_activated(self): """ @@ -581,7 +581,7 @@ class SlideController(DisplayController, RegistryProperties): if self.is_live: self.__add_actions_to_widget(self.display) if self.display.audio_player: - self.display.audio_player.connectSlot(QtCore.SIGNAL('tick(qint64)'), self.on_audio_time_remaining) + self.display.audio_player.position_changed.connect(self.on_audio_time_remaining) # The SlidePreview's ratio. try: self.ratio = self.screens.current['size'].width() / self.screens.current['size'].height() @@ -616,13 +616,13 @@ class SlideController(DisplayController, RegistryProperties): """ if self.ratio < self.preview_frame.width() / self.preview_frame.height(): # We have to take the height as limit. - max_height = self.preview_frame.height() - self.grid.margin() * 2 + max_height = self.preview_frame.height() - self.grid.contentsMargins().top() * 2 self.slide_preview.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height)) self.preview_display.setFixedSize(QtCore.QSize(max_height * self.ratio, max_height)) self.preview_display.screen = {'size': self.preview_display.geometry()} else: # We have to take the width as limit. - max_width = self.preview_frame.width() - self.grid.margin() * 2 + max_width = self.preview_frame.width() - self.grid.contentsMargins().top() * 2 self.slide_preview.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) self.preview_display.setFixedSize(QtCore.QSize(max_width, max_width / self.ratio)) self.preview_display.screen = {'size': self.preview_display.geometry()} @@ -1136,9 +1136,9 @@ class SlideController(DisplayController, RegistryProperties): """ Creates an image of the current screen and updates the preview frame. """ - win_id = QtGui.QApplication.desktop().winId() + win_id = QtWidgets.QApplication.desktop().winId() rect = self.screens.current['size'] - win_image = QtGui.QPixmap.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height()) + win_image = QtGui.QScreen.grabWindow(win_id, rect.x(), rect.y(), rect.width(), rect.height()) self.slide_preview.setPixmap(win_image) self.slide_image = win_image @@ -1435,6 +1435,10 @@ class PreviewController(RegistryMixin, OpenLPMixin, SlideController): """ Set up the Preview Controller. """ + slidecontroller_preview_set = QtCore.pyqtSignal(list) + slidecontroller_preview_next = QtCore.pyqtSignal() + slidecontroller_preview_previous = QtCore.pyqtSignal() + def __init__(self, parent): """ Set up the base Controller as a preview. @@ -1455,6 +1459,11 @@ class LiveController(RegistryMixin, OpenLPMixin, SlideController): """ Set up the Live Controller. """ + slidecontroller_live_set = QtCore.pyqtSignal(list) + slidecontroller_live_next = QtCore.pyqtSignal() + slidecontroller_live_previous = QtCore.pyqtSignal() + slidecontroller_toggle_display = QtCore.pyqtSignal(str) + def __init__(self, parent): """ Set up the base Controller as a live. diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index 5137ce1f0..f67a8150d 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -23,10 +23,10 @@ The splash screen """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets -class SplashScreen(QtGui.QSplashScreen): +class SplashScreen(QtWidgets.QSplashScreen): """ The splash screen """ diff --git a/openlp/core/ui/starttimedialog.py b/openlp/core/ui/starttimedialog.py index 055737021..9313b953c 100644 --- a/openlp/core/ui/starttimedialog.py +++ b/openlp/core/ui/starttimedialog.py @@ -22,7 +22,7 @@ """ The UI widgets for the time dialog """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -40,67 +40,67 @@ class Ui_StartTimeDialog(object): StartTimeDialog.setObjectName('StartTimeDialog') StartTimeDialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) StartTimeDialog.resize(350, 10) - self.dialog_layout = QtGui.QGridLayout(StartTimeDialog) + self.dialog_layout = QtWidgets.QGridLayout(StartTimeDialog) self.dialog_layout.setObjectName('dialog_layout') - self.start_label = QtGui.QLabel(StartTimeDialog) + self.start_label = QtWidgets.QLabel(StartTimeDialog) self.start_label.setObjectName('start_label') self.start_label.setAlignment(QtCore.Qt.AlignHCenter) self.dialog_layout.addWidget(self.start_label, 0, 1, 1, 1) - self.finish_label = QtGui.QLabel(StartTimeDialog) + self.finish_label = QtWidgets.QLabel(StartTimeDialog) self.finish_label.setObjectName('finish_label') self.finish_label.setAlignment(QtCore.Qt.AlignHCenter) self.dialog_layout.addWidget(self.finish_label, 0, 2, 1, 1) - self.length_label = QtGui.QLabel(StartTimeDialog) + self.length_label = QtWidgets.QLabel(StartTimeDialog) self.length_label.setObjectName('start_label') self.length_label.setAlignment(QtCore.Qt.AlignHCenter) self.dialog_layout.addWidget(self.length_label, 0, 3, 1, 1) - self.hour_label = QtGui.QLabel(StartTimeDialog) + self.hour_label = QtWidgets.QLabel(StartTimeDialog) self.hour_label.setObjectName('hour_label') self.dialog_layout.addWidget(self.hour_label, 1, 0, 1, 1) - self.hour_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.hour_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.hour_spin_box.setObjectName('hour_spin_box') self.hour_spin_box.setMinimum(0) self.hour_spin_box.setMaximum(4) self.dialog_layout.addWidget(self.hour_spin_box, 1, 1, 1, 1) - self.hour_finish_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.hour_finish_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.hour_finish_spin_box.setObjectName('hour_finish_spin_box') self.hour_finish_spin_box.setMinimum(0) self.hour_finish_spin_box.setMaximum(4) self.dialog_layout.addWidget(self.hour_finish_spin_box, 1, 2, 1, 1) - self.hour_finish_label = QtGui.QLabel(StartTimeDialog) + self.hour_finish_label = QtWidgets.QLabel(StartTimeDialog) self.hour_finish_label.setObjectName('hour_label') self.hour_finish_label.setAlignment(QtCore.Qt.AlignRight) self.dialog_layout.addWidget(self.hour_finish_label, 1, 3, 1, 1) - self.minute_label = QtGui.QLabel(StartTimeDialog) + self.minute_label = QtWidgets.QLabel(StartTimeDialog) self.minute_label.setObjectName('minute_label') self.dialog_layout.addWidget(self.minute_label, 2, 0, 1, 1) - self.minute_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.minute_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.minute_spin_box.setObjectName('minute_spin_box') self.minute_spin_box.setMinimum(0) self.minute_spin_box.setMaximum(59) self.dialog_layout.addWidget(self.minute_spin_box, 2, 1, 1, 1) - self.minute_finish_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.minute_finish_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.minute_finish_spin_box.setObjectName('minute_finish_spin_box') self.minute_finish_spin_box.setMinimum(0) self.minute_finish_spin_box.setMaximum(59) self.dialog_layout.addWidget(self.minute_finish_spin_box, 2, 2, 1, 1) - self.minute_finish_label = QtGui.QLabel(StartTimeDialog) + self.minute_finish_label = QtWidgets.QLabel(StartTimeDialog) self.minute_finish_label.setObjectName('minute_label') self.minute_finish_label.setAlignment(QtCore.Qt.AlignRight) self.dialog_layout.addWidget(self.minute_finish_label, 2, 3, 1, 1) - self.second_label = QtGui.QLabel(StartTimeDialog) + self.second_label = QtWidgets.QLabel(StartTimeDialog) self.second_label.setObjectName('second_label') self.dialog_layout.addWidget(self.second_label, 3, 0, 1, 1) - self.second_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.second_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.second_spin_box.setObjectName('second_spin_box') self.second_spin_box.setMinimum(0) self.second_spin_box.setMaximum(59) - self.second_finish_spin_box = QtGui.QSpinBox(StartTimeDialog) + self.second_finish_spin_box = QtWidgets.QSpinBox(StartTimeDialog) self.second_finish_spin_box.setObjectName('second_finish_spin_box') self.second_finish_spin_box.setMinimum(0) self.second_finish_spin_box.setMaximum(59) self.dialog_layout.addWidget(self.second_finish_spin_box, 3, 2, 1, 1) - self.second_finish_label = QtGui.QLabel(StartTimeDialog) + self.second_finish_label = QtWidgets.QLabel(StartTimeDialog) self.second_finish_label.setObjectName('second_label') self.second_finish_label.setAlignment(QtCore.Qt.AlignRight) self.dialog_layout.addWidget(self.second_finish_label, 3, 3, 1, 1) diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index b9ba8bf03..c37c4dacf 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -22,7 +22,7 @@ """ The actual start time form. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from .starttimedialog import Ui_StartTimeDialog @@ -30,7 +30,7 @@ from openlp.core.common import Registry, RegistryProperties, UiStrings, translat from openlp.core.lib.ui import critical_error_message_box -class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): +class StartTimeForm(QtWidgets.QDialog, Ui_StartTimeDialog, RegistryProperties): """ The start time dialog """ @@ -41,7 +41,7 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): super(StartTimeForm, self).__init__(Registry().get('main_window')) self.setupUi(self) - def exec_(self): + def exec(self): """ Run the Dialog with correct heading. """ @@ -58,7 +58,7 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): self.hour_finish_label.setText('%s%s' % (str(hour), UiStrings().Hours)) self.minute_finish_label.setText('%s%s' % (str(minutes), UiStrings().Minutes)) self.second_finish_label.setText('%s%s' % (str(seconds), UiStrings().Seconds)) - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def accept(self): """ @@ -79,7 +79,7 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): return self.item['service_item'].start_time = start self.item['service_item'].end_time = end - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) def _time_split(self, seconds): """ diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 7629b899e..593336dfb 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -25,7 +25,7 @@ The Theme wizard import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, UiStrings, translate from openlp.core.lib.theme import BackgroundType, BackgroundGradientType @@ -37,7 +37,7 @@ from .themewizard import Ui_ThemeWizard log = logging.getLogger(__name__) -class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): +class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties): """ This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. @@ -158,7 +158,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): """ if not event: event = QtGui.QResizeEvent(self.size(), self.size()) - QtGui.QWizard.resizeEvent(self, event) + QtWidgets.QWizard.resizeEvent(self, event) if self.currentPage() == self.preview_page: frame_width = self.preview_box_label.lineWidth() pixmap_width = self.preview_area.width() - 2 * frame_width @@ -177,9 +177,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.background_page and \ self.theme.background_type == background_image and is_not_image_file(self.theme.background_filename): - QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), - translate('OpenLP.ThemeWizard', 'You have not selected a ' - 'background image. Please select one before continuing.')) + QtWidgets.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), + translate('OpenLP.ThemeWizard', 'You have not selected a ' + 'background image. Please select one before continuing.')) return False else: return True @@ -189,7 +189,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): Detects Page changes and updates as appropriate. """ enabled = self.page(page_id) == self.area_position_page - self.setOption(QtGui.QWizard.HaveCustomButton1, enabled) + self.setOption(QtWidgets.QWizard.HaveCustomButton1, enabled) if self.page(page_id) == self.preview_page: self.update_theme() frame = self.theme_manager.generate_image(self.theme) @@ -212,7 +212,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): paint.setPen(QtGui.QPen(QtCore.Qt.red, 2)) paint.drawRect(self.renderer.get_footer_rectangle(self.theme)) paint.end() - self.theme_layout_form.exec_(pixmap) + self.theme_layout_form.exec(pixmap) def on_outline_check_check_box_state_changed(self, state): """ @@ -253,7 +253,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): if self.update_theme_allowed: self.theme.font_footer_override = not (value == QtCore.Qt.Checked) - def exec_(self, edit=False): + def exec(self, edit=False): """ Run the wizard. """ @@ -270,7 +270,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): self.next() else: self.setWindowTitle(UiStrings().NewTheme) - return QtGui.QWizard.exec_(self) + return QtWidgets.QWizard.exec(self) def initializePage(self, page_id): """ @@ -428,8 +428,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): """ images_filter = get_images_filter() images_filter = '%s;;%s (*.*)' % (images_filter, UiStrings().AllFiles) - filename = QtGui.QFileDialog.getOpenFileName(self, translate('OpenLP.ThemeWizard', 'Select Image'), - self.image_file_edit.text(), images_filter) + filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( + self, translate('OpenLP.ThemeWizard', 'Select Image'), + self.image_file_edit.text(), images_filter) if filename: self.theme.background_filename = filename self.set_background_page_values() @@ -522,4 +523,4 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): if not self.edit_mode and not self.theme_manager.check_if_theme_exists(self.theme.theme_name): return self.theme_manager.save_theme(self.theme, save_from, save_to) - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) diff --git a/openlp/core/ui/themelayoutdialog.py b/openlp/core/ui/themelayoutdialog.py index cba32cb34..f6acf462e 100644 --- a/openlp/core/ui/themelayoutdialog.py +++ b/openlp/core/ui/themelayoutdialog.py @@ -22,7 +22,7 @@ """ The layout of the theme """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -39,25 +39,25 @@ class Ui_ThemeLayoutDialog(object): """ themeLayoutDialog.setObjectName('themeLayoutDialogDialog') themeLayoutDialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) - self.preview_layout = QtGui.QVBoxLayout(themeLayoutDialog) + self.preview_layout = QtWidgets.QVBoxLayout(themeLayoutDialog) self.preview_layout.setObjectName('preview_layout') - self.preview_area = QtGui.QWidget(themeLayoutDialog) + self.preview_area = QtWidgets.QWidget(themeLayoutDialog) self.preview_area.setObjectName('preview_area') - self.preview_area_layout = QtGui.QGridLayout(self.preview_area) - self.preview_area_layout.setMargin(0) + self.preview_area_layout = QtWidgets.QGridLayout(self.preview_area) + self.preview_area_layout.setContentsMargins(0, 0, 0, 0) self.preview_area_layout.setColumnStretch(0, 1) self.preview_area_layout.setRowStretch(0, 1) self.preview_area_layout.setObjectName('preview_area_layout') - self.theme_display_label = QtGui.QLabel(self.preview_area) - self.theme_display_label.setFrameShape(QtGui.QFrame.Box) + self.theme_display_label = QtWidgets.QLabel(self.preview_area) + self.theme_display_label.setFrameShape(QtWidgets.QFrame.Box) self.theme_display_label.setScaledContents(True) self.theme_display_label.setObjectName('theme_display_label') self.preview_area_layout.addWidget(self.theme_display_label) self.preview_layout.addWidget(self.preview_area) - self.main_colour_label = QtGui.QLabel(self.preview_area) + self.main_colour_label = QtWidgets.QLabel(self.preview_area) self.main_colour_label.setObjectName('main_colour_label') self.preview_layout.addWidget(self.main_colour_label) - self.footer_colour_label = QtGui.QLabel(self.preview_area) + self.footer_colour_label = QtWidgets.QLabel(self.preview_area) self.footer_colour_label.setObjectName('footer_colour_label') self.preview_layout.addWidget(self.footer_colour_label) self.button_box = create_button_box(themeLayoutDialog, 'button_box', ['ok']) diff --git a/openlp/core/ui/themelayoutform.py b/openlp/core/ui/themelayoutform.py index d4fa6242a..9977665bc 100644 --- a/openlp/core/ui/themelayoutform.py +++ b/openlp/core/ui/themelayoutform.py @@ -22,12 +22,12 @@ """ The form layout """ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets from .themelayoutdialog import Ui_ThemeLayoutDialog -class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): +class ThemeLayoutForm(QtWidgets.QDialog, Ui_ThemeLayoutDialog): """ The exception dialog """ @@ -38,7 +38,7 @@ class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): super(ThemeLayoutForm, self).__init__(parent) self.setupUi(self) - def exec_(self, image): + def exec(self, image): """ Run the Dialog with correct heading. """ @@ -46,4 +46,4 @@ class ThemeLayoutForm(QtGui.QDialog, Ui_ThemeLayoutDialog): self.theme_display_label.setPixmap(pixmap) display_aspect_ratio = float(image.width()) / image.height() self.theme_display_label.setFixedSize(400, 400 / display_aspect_ratio) - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 33fc614b0..1115b95fc 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -27,7 +27,7 @@ import zipfile import shutil from xml.etree.ElementTree import ElementTree, XML -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, OpenLPMixin, RegistryMixin, \ check_directory_exists, UiStrings, translate, is_win @@ -49,9 +49,9 @@ class Ui_ThemeManager(object): :param widget: The screen object the the dialog is to be attached to. """ # start with the layout - self.layout = QtGui.QVBoxLayout(widget) + self.layout = QtWidgets.QVBoxLayout(widget) self.layout.setSpacing(0) - self.layout.setMargin(0) + self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setObjectName('layout') self.toolbar = OpenLPToolbar(widget) self.toolbar.setObjectName('toolbar') @@ -83,10 +83,10 @@ class Ui_ThemeManager(object): tooltip=translate('OpenLP.ThemeManager', 'Export a theme.'), triggers=self.on_export_theme) self.layout.addWidget(self.toolbar) - self.theme_widget = QtGui.QWidgetAction(self.toolbar) + self.theme_widget = QtWidgets.QWidgetAction(self.toolbar) self.theme_widget.setObjectName('theme_widget') # create theme manager list - self.theme_list_widget = QtGui.QListWidget(widget) + self.theme_list_widget = QtWidgets.QListWidget(widget) self.theme_list_widget.setAlternatingRowColors(True) self.theme_list_widget.setIconSize(QtCore.QSize(88, 50)) self.theme_list_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) @@ -94,7 +94,7 @@ class Ui_ThemeManager(object): self.layout.addWidget(self.theme_list_widget) self.theme_list_widget.customContextMenuRequested.connect(self.context_menu) # build the context menu - self.menu = QtGui.QMenu() + self.menu = QtWidgets.QMenu() self.edit_action = create_widget_action(self.menu, text=translate('OpenLP.ThemeManager', '&Edit Theme'), icon=':/themes/theme_edit.png', triggers=self.on_edit_theme) @@ -120,7 +120,7 @@ class Ui_ThemeManager(object): self.theme_list_widget.currentItemChanged.connect(self.check_list_state) -class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, RegistryProperties): +class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManager, RegistryProperties): """ Manages the orders of Theme. """ @@ -195,7 +195,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R self.delete_action.setVisible(visible) self.rename_action.setVisible(visible) self.global_action.setVisible(visible) - self.menu.exec_(self.theme_list_widget.mapToGlobal(point)) + self.menu.exec(self.theme_list_widget.mapToGlobal(point)) def change_global_from_tab(self): """ @@ -247,7 +247,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R theme = ThemeXML() theme.set_default_header_footer() self.theme_form.theme = theme - self.theme_form.exec_() + self.theme_form.exec() self.load_themes() def on_rename_theme(self, field=None): @@ -261,7 +261,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R item = self.theme_list_widget.currentItem() old_theme_name = item.data(QtCore.Qt.UserRole) self.file_rename_form.file_name_edit.setText(old_theme_name) - if self.file_rename_form.exec_(): + if self.file_rename_form.exec(): new_theme_name = self.file_rename_form.file_name_edit.text() if old_theme_name == new_theme_name: return @@ -284,7 +284,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R old_theme_name = item.data(QtCore.Qt.UserRole) self.file_rename_form.file_name_edit.setText(translate('OpenLP.ThemeManager', 'Copy of %s', 'Copy of ') % old_theme_name) - if self.file_rename_form.exec_(True): + if self.file_rename_form.exec(True): new_theme_name = self.file_rename_form.file_name_edit.text() if self.check_if_theme_exists(new_theme_name): theme_data = self.get_theme_data(old_theme_name) @@ -320,7 +320,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R if theme.background_type == 'image': self.old_background_image = theme.background_filename self.theme_form.theme = theme - self.theme_form.exec_(True) + self.theme_form.exec(True) self.old_background_image = None self.renderer.update_theme(theme.theme_name) self.load_themes() @@ -374,18 +374,18 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) return theme = item.data(QtCore.Qt.UserRole) - path = QtGui.QFileDialog.getExistingDirectory(self, - translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, - Settings().value(self.settings_section + - '/last directory export')) + path = QtWidgets.QFileDialog.getExistingDirectory(self, + translate('OpenLP.ThemeManager', 'Save Theme - (%s)') % theme, + Settings().value(self.settings_section + + '/last directory export')) self.application.set_busy_cursor() if path: Settings().setValue(self.settings_section + '/last directory export', path) if self._export_theme(path, theme): - QtGui.QMessageBox.information(self, - translate('OpenLP.ThemeManager', 'Theme Exported'), - translate('OpenLP.ThemeManager', - 'Your theme has been successfully exported.')) + QtWidgets.QMessageBox.information(self, + translate('OpenLP.ThemeManager', 'Theme Exported'), + translate('OpenLP.ThemeManager', + 'Your theme has been successfully exported.')) self.application.set_normal_cursor() def _export_theme(self, path, theme): @@ -475,7 +475,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R else: name = text_name thumb = os.path.join(self.thumb_path, '%s.png' % text_name) - item_name = QtGui.QListWidgetItem(name) + item_name = QtWidgets.QListWidgetItem(name) if validate_thumb(theme, thumb): icon = build_icon(thumb) else: @@ -521,14 +521,14 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R :param theme_name: Name of the theme. :return: Confirm if the theme is to be overwritten. """ - ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), - translate('OpenLP.ThemeManager', - 'Theme %s already exists. Do you want to replace it?') - .replace('%s', theme_name), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - return ret == QtGui.QMessageBox.Yes + ret = QtWidgets.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), + translate('OpenLP.ThemeManager', + 'Theme %s already exists. Do you want to replace it?') + .replace('%s', theme_name), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + return ret == QtWidgets.QMessageBox.Yes def unzip_theme(self, file_name, directory): """ @@ -742,11 +742,11 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R theme = item.text() # confirm deletion if confirm: - answer = QtGui.QMessageBox.question(self, confirm_title, confirm_text % theme, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No), - QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: + answer = QtWidgets.QMessageBox.question( + self, confirm_title, confirm_text % theme, + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.No: return False # should be the same unless default if theme != item.data(QtCore.Qt.UserRole): diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 1e77ffcf0..7c3a45f23 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -24,7 +24,7 @@ The Themes configuration tab """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, Settings, ThemeLevel, UiStrings, translate from openlp.core.lib import SettingsTab @@ -49,47 +49,47 @@ class ThemesTab(SettingsTab): """ self.setObjectName('ThemesTab') super(ThemesTab, self).setupUi() - self.global_group_box = QtGui.QGroupBox(self.left_column) + self.global_group_box = QtWidgets.QGroupBox(self.left_column) self.global_group_box.setObjectName('global_group_box') - self.global_group_box_layout = QtGui.QVBoxLayout(self.global_group_box) + self.global_group_box_layout = QtWidgets.QVBoxLayout(self.global_group_box) self.global_group_box_layout.setObjectName('global_group_box_layout') - self.default_combo_box = QtGui.QComboBox(self.global_group_box) - self.default_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.default_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.default_combo_box = QtWidgets.QComboBox(self.global_group_box) + self.default_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToMinimumContentsLength) + self.default_combo_box.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.default_combo_box.setObjectName('default_combo_box') self.global_group_box_layout.addWidget(self.default_combo_box) - self.default_list_view = QtGui.QLabel(self.global_group_box) + self.default_list_view = QtWidgets.QLabel(self.global_group_box) self.default_list_view.setObjectName('default_list_view') self.global_group_box_layout.addWidget(self.default_list_view) self.left_layout.addWidget(self.global_group_box) - self.universal_group_box = QtGui.QGroupBox(self.left_column) + self.universal_group_box = QtWidgets.QGroupBox(self.left_column) self.universal_group_box.setObjectName('universal_group_box') - self.universal_group_box_layout = QtGui.QVBoxLayout(self.universal_group_box) + self.universal_group_box_layout = QtWidgets.QVBoxLayout(self.universal_group_box) self.universal_group_box_layout.setObjectName('universal_group_box_layout') - self.wrap_footer_check_box = QtGui.QCheckBox(self.universal_group_box) + self.wrap_footer_check_box = QtWidgets.QCheckBox(self.universal_group_box) self.wrap_footer_check_box.setObjectName('wrap_footer_check_box') self.universal_group_box_layout.addWidget(self.wrap_footer_check_box) self.left_layout.addWidget(self.universal_group_box) self.left_layout.addStretch() - self.level_group_box = QtGui.QGroupBox(self.right_column) + self.level_group_box = QtWidgets.QGroupBox(self.right_column) self.level_group_box.setObjectName('level_group_box') - self.level_layout = QtGui.QFormLayout(self.level_group_box) + self.level_layout = QtWidgets.QFormLayout(self.level_group_box) self.level_layout.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.level_layout.setFormAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.level_layout.setObjectName('level_layout') - self.song_level_radio_button = QtGui.QRadioButton(self.level_group_box) + self.song_level_radio_button = QtWidgets.QRadioButton(self.level_group_box) self.song_level_radio_button.setObjectName('song_level_radio_button') - self.song_level_label = QtGui.QLabel(self.level_group_box) + self.song_level_label = QtWidgets.QLabel(self.level_group_box) self.song_level_label.setObjectName('song_level_label') self.level_layout.addRow(self.song_level_radio_button, self.song_level_label) - self.service_level_radio_button = QtGui.QRadioButton(self.level_group_box) + self.service_level_radio_button = QtWidgets.QRadioButton(self.level_group_box) self.service_level_radio_button.setObjectName('service_level_radio_button') - self.service_level_label = QtGui.QLabel(self.level_group_box) + self.service_level_label = QtWidgets.QLabel(self.level_group_box) self.service_level_label.setObjectName('service_level_label') self.level_layout.addRow(self.service_level_radio_button, self.service_level_label) - self.global_level_radio_button = QtGui.QRadioButton(self.level_group_box) + self.global_level_radio_button = QtWidgets.QRadioButton(self.level_group_box) self.global_level_radio_button.setObjectName('global_level_radio_button') - self.global_level_label = QtGui.QLabel(self.level_group_box) + self.global_level_label = QtWidgets.QLabel(self.level_group_box) self.global_level_label.setObjectName('global_level_label') self.level_layout.addRow(self.global_level_radio_button, self.global_level_label) label_top_margin = (self.song_level_radio_button.sizeHint().height() - diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 4d44dcbce..5b60a6567 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -22,7 +22,7 @@ """ The Create/Edit theme wizard """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import UiStrings, translate, is_macosx from openlp.core.lib import build_icon, ColorButton @@ -41,213 +41,213 @@ class Ui_ThemeWizard(object): theme_wizard.setObjectName('OpenLP.ThemeWizard') theme_wizard.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) theme_wizard.setModal(True) - theme_wizard.setOptions(QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.HaveCustomButton1) + theme_wizard.setOptions(QtWidgets.QWizard.IndependentPages | + QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.HaveCustomButton1) if is_macosx(): - theme_wizard.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) + theme_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) theme_wizard.resize(646, 400) else: - theme_wizard.setWizardStyle(QtGui.QWizard.ModernStyle) - self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) + theme_wizard.setWizardStyle(QtWidgets.QWizard.ModernStyle) + self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) # Welcome Page add_welcome_page(theme_wizard, ':/wizards/wizard_createtheme.bmp') # Background Page - self.background_page = QtGui.QWizardPage() + self.background_page = QtWidgets.QWizardPage() self.background_page.setObjectName('background_page') - self.background_layout = QtGui.QVBoxLayout(self.background_page) + self.background_layout = QtWidgets.QVBoxLayout(self.background_page) self.background_layout.setObjectName('background_layout') - self.background_type_layout = QtGui.QFormLayout() + self.background_type_layout = QtWidgets.QFormLayout() self.background_type_layout.setObjectName('background_type_layout') - self.background_label = QtGui.QLabel(self.background_page) + self.background_label = QtWidgets.QLabel(self.background_page) self.background_label.setObjectName('background_label') - self.background_combo_box = QtGui.QComboBox(self.background_page) + self.background_combo_box = QtWidgets.QComboBox(self.background_page) self.background_combo_box.addItems(['', '', '', '']) self.background_combo_box.setObjectName('background_combo_box') self.background_type_layout.addRow(self.background_label, self.background_combo_box) - self.background_type_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.background_type_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) self.background_layout.addLayout(self.background_type_layout) - self.background_stack = QtGui.QStackedLayout() + self.background_stack = QtWidgets.QStackedLayout() self.background_stack.setObjectName('background_stack') - self.color_widget = QtGui.QWidget(self.background_page) + self.color_widget = QtWidgets.QWidget(self.background_page) self.color_widget.setObjectName('color_widget') - self.color_layout = QtGui.QFormLayout(self.color_widget) - self.color_layout.setMargin(0) + self.color_layout = QtWidgets.QFormLayout(self.color_widget) + self.color_layout.setContentsMargins(0, 0, 0, 0) self.color_layout.setObjectName('color_layout') - self.color_label = QtGui.QLabel(self.color_widget) + self.color_label = QtWidgets.QLabel(self.color_widget) self.color_label.setObjectName('color_label') self.color_button = ColorButton(self.color_widget) self.color_button.setObjectName('color_button') self.color_layout.addRow(self.color_label, self.color_button) - self.color_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.color_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) self.background_stack.addWidget(self.color_widget) - self.gradient_widget = QtGui.QWidget(self.background_page) + self.gradient_widget = QtWidgets.QWidget(self.background_page) self.gradient_widget.setObjectName('Gradient_widget') - self.gradient_layout = QtGui.QFormLayout(self.gradient_widget) - self.gradient_layout.setMargin(0) + self.gradient_layout = QtWidgets.QFormLayout(self.gradient_widget) + self.gradient_layout.setContentsMargins(0, 0, 0, 0) self.gradient_layout.setObjectName('gradient_layout') - self.gradient_start_label = QtGui.QLabel(self.gradient_widget) + self.gradient_start_label = QtWidgets.QLabel(self.gradient_widget) self.gradient_start_label.setObjectName('gradient_start_label') self.gradient_start_button = ColorButton(self.gradient_widget) self.gradient_start_button.setObjectName('gradient_start_button') self.gradient_layout.addRow(self.gradient_start_label, self.gradient_start_button) - self.gradient_end_label = QtGui.QLabel(self.gradient_widget) + self.gradient_end_label = QtWidgets.QLabel(self.gradient_widget) self.gradient_end_label.setObjectName('gradient_end_label') self.gradient_end_button = ColorButton(self.gradient_widget) self.gradient_end_button.setObjectName('gradient_end_button') self.gradient_layout.addRow(self.gradient_end_label, self.gradient_end_button) - self.gradient_type_label = QtGui.QLabel(self.gradient_widget) + self.gradient_type_label = QtWidgets.QLabel(self.gradient_widget) self.gradient_type_label.setObjectName('Gradient_type_label') - self.gradient_combo_box = QtGui.QComboBox(self.gradient_widget) + self.gradient_combo_box = QtWidgets.QComboBox(self.gradient_widget) self.gradient_combo_box.setObjectName('gradient_combo_box') self.gradient_combo_box.addItems(['', '', '', '', '']) self.gradient_layout.addRow(self.gradient_type_label, self.gradient_combo_box) - self.gradient_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.gradient_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) self.background_stack.addWidget(self.gradient_widget) - self.image_widget = QtGui.QWidget(self.background_page) + self.image_widget = QtWidgets.QWidget(self.background_page) self.image_widget.setObjectName('image_widget') - self.image_layout = QtGui.QFormLayout(self.image_widget) - self.image_layout.setMargin(0) + self.image_layout = QtWidgets.QFormLayout(self.image_widget) + self.image_layout.setContentsMargins(0, 0, 0, 0) self.image_layout.setObjectName('image_layout') - self.image_color_label = QtGui.QLabel(self.color_widget) + self.image_color_label = QtWidgets.QLabel(self.color_widget) self.image_color_label.setObjectName('image_color_label') self.image_color_button = ColorButton(self.color_widget) self.image_color_button.setObjectName('image_color_button') self.image_layout.addRow(self.image_color_label, self.image_color_button) - self.image_label = QtGui.QLabel(self.image_widget) + self.image_label = QtWidgets.QLabel(self.image_widget) self.image_label.setObjectName('image_label') - self.image_file_layout = QtGui.QHBoxLayout() + self.image_file_layout = QtWidgets.QHBoxLayout() self.image_file_layout.setObjectName('image_file_layout') - self.image_file_edit = QtGui.QLineEdit(self.image_widget) + self.image_file_edit = QtWidgets.QLineEdit(self.image_widget) self.image_file_edit.setObjectName('image_file_edit') self.image_file_layout.addWidget(self.image_file_edit) - self.image_browse_button = QtGui.QToolButton(self.image_widget) + self.image_browse_button = QtWidgets.QToolButton(self.image_widget) self.image_browse_button.setObjectName('image_browse_button') self.image_browse_button.setIcon(build_icon(':/general/general_open.png')) self.image_file_layout.addWidget(self.image_browse_button) self.image_layout.addRow(self.image_label, self.image_file_layout) - self.image_layout.setItem(2, QtGui.QFormLayout.LabelRole, self.spacer) + self.image_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) self.background_stack.addWidget(self.image_widget) - self.transparent_widget = QtGui.QWidget(self.background_page) + self.transparent_widget = QtWidgets.QWidget(self.background_page) self.transparent_widget.setObjectName('TransparentWidget') - self.transparent_layout = QtGui.QFormLayout(self.transparent_widget) - self.transparent_layout.setMargin(0) + self.transparent_layout = QtWidgets.QFormLayout(self.transparent_widget) + self.transparent_layout.setContentsMargins(0, 0, 0, 0) self.transparent_layout.setObjectName('Transparent_layout') self.background_stack.addWidget(self.transparent_widget) self.background_layout.addLayout(self.background_stack) theme_wizard.addPage(self.background_page) # Main Area Page - self.main_area_page = QtGui.QWizardPage() + self.main_area_page = QtWidgets.QWizardPage() self.main_area_page.setObjectName('main_area_page') - self.main_area_layout = QtGui.QFormLayout(self.main_area_page) + self.main_area_layout = QtWidgets.QFormLayout(self.main_area_page) self.main_area_layout.setObjectName('main_area_layout') - self.main_font_label = QtGui.QLabel(self.main_area_page) + self.main_font_label = QtWidgets.QLabel(self.main_area_page) self.main_font_label.setObjectName('main_font_label') - self.main_font_combo_box = QtGui.QFontComboBox(self.main_area_page) + self.main_font_combo_box = QtWidgets.QFontComboBox(self.main_area_page) self.main_font_combo_box.setObjectName('main_font_combo_box') self.main_area_layout.addRow(self.main_font_label, self.main_font_combo_box) - self.main_color_label = QtGui.QLabel(self.main_area_page) + self.main_color_label = QtWidgets.QLabel(self.main_area_page) self.main_color_label.setObjectName('main_color_label') - self.main_properties_layout = QtGui.QHBoxLayout() + self.main_properties_layout = QtWidgets.QHBoxLayout() self.main_properties_layout.setObjectName('main_properties_layout') self.main_color_button = ColorButton(self.main_area_page) self.main_color_button.setObjectName('main_color_button') self.main_properties_layout.addWidget(self.main_color_button) self.main_properties_layout.addSpacing(20) - self.main_bold_check_box = QtGui.QCheckBox(self.main_area_page) + self.main_bold_check_box = QtWidgets.QCheckBox(self.main_area_page) self.main_bold_check_box.setObjectName('main_bold_check_box') self.main_properties_layout.addWidget(self.main_bold_check_box) self.main_properties_layout.addSpacing(20) - self.main_italics_check_box = QtGui.QCheckBox(self.main_area_page) + self.main_italics_check_box = QtWidgets.QCheckBox(self.main_area_page) self.main_italics_check_box.setObjectName('MainItalicsCheckBox') self.main_properties_layout.addWidget(self.main_italics_check_box) self.main_area_layout.addRow(self.main_color_label, self.main_properties_layout) - self.main_size_label = QtGui.QLabel(self.main_area_page) + self.main_size_label = QtWidgets.QLabel(self.main_area_page) self.main_size_label.setObjectName('main_size_label') - self.main_size_layout = QtGui.QHBoxLayout() + self.main_size_layout = QtWidgets.QHBoxLayout() self.main_size_layout.setObjectName('main_size_layout') - self.main_size_spin_box = QtGui.QSpinBox(self.main_area_page) + self.main_size_spin_box = QtWidgets.QSpinBox(self.main_area_page) self.main_size_spin_box.setMaximum(999) self.main_size_spin_box.setValue(16) self.main_size_spin_box.setObjectName('main_size_spin_box') self.main_size_layout.addWidget(self.main_size_spin_box) - self.main_line_count_label = QtGui.QLabel(self.main_area_page) + self.main_line_count_label = QtWidgets.QLabel(self.main_area_page) self.main_line_count_label.setObjectName('main_line_count_label') self.main_size_layout.addWidget(self.main_line_count_label) self.main_area_layout.addRow(self.main_size_label, self.main_size_layout) - self.line_spacing_label = QtGui.QLabel(self.main_area_page) + self.line_spacing_label = QtWidgets.QLabel(self.main_area_page) self.line_spacing_label.setObjectName('line_spacing_label') - self.line_spacing_spin_box = QtGui.QSpinBox(self.main_area_page) + self.line_spacing_spin_box = QtWidgets.QSpinBox(self.main_area_page) self.line_spacing_spin_box.setMinimum(-250) self.line_spacing_spin_box.setMaximum(250) self.line_spacing_spin_box.setObjectName('line_spacing_spin_box') self.main_area_layout.addRow(self.line_spacing_label, self.line_spacing_spin_box) - self.outline_check_box = QtGui.QCheckBox(self.main_area_page) + self.outline_check_box = QtWidgets.QCheckBox(self.main_area_page) self.outline_check_box.setObjectName('outline_check_box') - self.outline_layout = QtGui.QHBoxLayout() + self.outline_layout = QtWidgets.QHBoxLayout() self.outline_layout.setObjectName('outline_layout') self.outline_color_button = ColorButton(self.main_area_page) self.outline_color_button.setEnabled(False) self.outline_color_button.setObjectName('Outline_color_button') self.outline_layout.addWidget(self.outline_color_button) self.outline_layout.addSpacing(20) - self.outline_size_label = QtGui.QLabel(self.main_area_page) + self.outline_size_label = QtWidgets.QLabel(self.main_area_page) self.outline_size_label.setObjectName('outline_size_label') self.outline_layout.addWidget(self.outline_size_label) - self.outline_size_spin_box = QtGui.QSpinBox(self.main_area_page) + self.outline_size_spin_box = QtWidgets.QSpinBox(self.main_area_page) self.outline_size_spin_box.setEnabled(False) self.outline_size_spin_box.setObjectName('outline_size_spin_box') self.outline_layout.addWidget(self.outline_size_spin_box) self.main_area_layout.addRow(self.outline_check_box, self.outline_layout) - self.shadow_check_box = QtGui.QCheckBox(self.main_area_page) + self.shadow_check_box = QtWidgets.QCheckBox(self.main_area_page) self.shadow_check_box.setObjectName('shadow_check_box') - self.shadow_layout = QtGui.QHBoxLayout() + self.shadow_layout = QtWidgets.QHBoxLayout() self.shadow_layout.setObjectName('shadow_layout') self.shadow_color_button = ColorButton(self.main_area_page) self.shadow_color_button.setEnabled(False) self.shadow_color_button.setObjectName('shadow_color_button') self.shadow_layout.addWidget(self.shadow_color_button) self.shadow_layout.addSpacing(20) - self.shadow_size_label = QtGui.QLabel(self.main_area_page) + self.shadow_size_label = QtWidgets.QLabel(self.main_area_page) self.shadow_size_label.setObjectName('shadow_size_label') self.shadow_layout.addWidget(self.shadow_size_label) - self.shadow_size_spin_box = QtGui.QSpinBox(self.main_area_page) + self.shadow_size_spin_box = QtWidgets.QSpinBox(self.main_area_page) self.shadow_size_spin_box.setEnabled(False) self.shadow_size_spin_box.setObjectName('shadow_size_spin_box') self.shadow_layout.addWidget(self.shadow_size_spin_box) self.main_area_layout.addRow(self.shadow_check_box, self.shadow_layout) theme_wizard.addPage(self.main_area_page) # Footer Area Page - self.footer_area_page = QtGui.QWizardPage() + self.footer_area_page = QtWidgets.QWizardPage() self.footer_area_page.setObjectName('footer_area_page') - self.footer_area_layout = QtGui.QFormLayout(self.footer_area_page) + self.footer_area_layout = QtWidgets.QFormLayout(self.footer_area_page) self.footer_area_layout.setObjectName('footer_area_layout') - self.footer_font_label = QtGui.QLabel(self.footer_area_page) + self.footer_font_label = QtWidgets.QLabel(self.footer_area_page) self.footer_font_label.setObjectName('FooterFontLabel') - self.footer_font_combo_box = QtGui.QFontComboBox(self.footer_area_page) + self.footer_font_combo_box = QtWidgets.QFontComboBox(self.footer_area_page) self.footer_font_combo_box.setObjectName('footer_font_combo_box') self.footer_area_layout.addRow(self.footer_font_label, self.footer_font_combo_box) - self.footer_color_label = QtGui.QLabel(self.footer_area_page) + self.footer_color_label = QtWidgets.QLabel(self.footer_area_page) self.footer_color_label.setObjectName('footer_color_label') self.footer_color_button = ColorButton(self.footer_area_page) self.footer_color_button.setObjectName('footer_color_button') self.footer_area_layout.addRow(self.footer_color_label, self.footer_color_button) - self.footer_size_label = QtGui.QLabel(self.footer_area_page) + self.footer_size_label = QtWidgets.QLabel(self.footer_area_page) self.footer_size_label.setObjectName('footer_size_label') - self.footer_size_spin_box = QtGui.QSpinBox(self.footer_area_page) + self.footer_size_spin_box = QtWidgets.QSpinBox(self.footer_area_page) self.footer_size_spin_box.setMaximum(999) self.footer_size_spin_box.setValue(10) self.footer_size_spin_box.setObjectName('FooterSizeSpinBox') self.footer_area_layout.addRow(self.footer_size_label, self.footer_size_spin_box) - self.footer_area_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.footer_area_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) theme_wizard.addPage(self.footer_area_page) # Alignment Page - self.alignment_page = QtGui.QWizardPage() + self.alignment_page = QtWidgets.QWizardPage() self.alignment_page.setObjectName('alignment_page') - self.alignment_layout = QtGui.QFormLayout(self.alignment_page) + self.alignment_layout = QtWidgets.QFormLayout(self.alignment_page) self.alignment_layout.setObjectName('alignment_layout') - self.horizontal_label = QtGui.QLabel(self.alignment_page) + self.horizontal_label = QtWidgets.QLabel(self.alignment_page) self.horizontal_label.setObjectName('horizontal_label') - self.horizontal_combo_box = QtGui.QComboBox(self.alignment_page) + self.horizontal_combo_box = QtWidgets.QComboBox(self.alignment_page) self.horizontal_combo_box.addItems(['', '', '', '']) self.horizontal_combo_box.setObjectName('horizontal_combo_box') self.alignment_layout.addRow(self.horizontal_label, self.horizontal_combo_box) @@ -255,138 +255,125 @@ class Ui_ThemeWizard(object): self.vertical_label.setObjectName('vertical_label') self.vertical_combo_box.setObjectName('vertical_combo_box') self.alignment_layout.addRow(self.vertical_label, self.vertical_combo_box) - self.transitions_label = QtGui.QLabel(self.alignment_page) + self.transitions_label = QtWidgets.QLabel(self.alignment_page) self.transitions_label.setObjectName('transitions_label') - self.transitions_check_box = QtGui.QCheckBox(self.alignment_page) + self.transitions_check_box = QtWidgets.QCheckBox(self.alignment_page) self.transitions_check_box.setObjectName('transitions_check_box') self.alignment_layout.addRow(self.transitions_label, self.transitions_check_box) - self.alignment_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.alignment_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) theme_wizard.addPage(self.alignment_page) # Area Position Page - self.area_position_page = QtGui.QWizardPage() + self.area_position_page = QtWidgets.QWizardPage() self.area_position_page.setObjectName('area_position_page') - self.area_position_layout = QtGui.QHBoxLayout(self.area_position_page) + self.area_position_layout = QtWidgets.QHBoxLayout(self.area_position_page) self.area_position_layout.setObjectName('area_position_layout') - self.main_position_group_box = QtGui.QGroupBox(self.area_position_page) + self.main_position_group_box = QtWidgets.QGroupBox(self.area_position_page) self.main_position_group_box.setObjectName('main_position_group_box') - self.main_position_layout = QtGui.QFormLayout(self.main_position_group_box) + self.main_position_layout = QtWidgets.QFormLayout(self.main_position_group_box) self.main_position_layout.setObjectName('main_position_layout') - self.main_position_check_box = QtGui.QCheckBox(self.main_position_group_box) + self.main_position_check_box = QtWidgets.QCheckBox(self.main_position_group_box) self.main_position_check_box.setObjectName('main_position_check_box') self.main_position_layout.addRow(self.main_position_check_box) - self.main_x_label = QtGui.QLabel(self.main_position_group_box) + self.main_x_label = QtWidgets.QLabel(self.main_position_group_box) self.main_x_label.setObjectName('main_x_label') - self.main_x_spin_box = QtGui.QSpinBox(self.main_position_group_box) + self.main_x_spin_box = QtWidgets.QSpinBox(self.main_position_group_box) self.main_x_spin_box.setMaximum(9999) self.main_x_spin_box.setObjectName('main_x_spin_box') self.main_position_layout.addRow(self.main_x_label, self.main_x_spin_box) - self.main_y_label = QtGui.QLabel(self.main_position_group_box) + self.main_y_label = QtWidgets.QLabel(self.main_position_group_box) self.main_y_label.setObjectName('main_y_label') - self.main_y_spin_box = QtGui.QSpinBox(self.main_position_group_box) + self.main_y_spin_box = QtWidgets.QSpinBox(self.main_position_group_box) self.main_y_spin_box.setMaximum(9999) self.main_y_spin_box.setObjectName('main_y_spin_box') self.main_position_layout.addRow(self.main_y_label, self.main_y_spin_box) - self.main_width_label = QtGui.QLabel(self.main_position_group_box) + self.main_width_label = QtWidgets.QLabel(self.main_position_group_box) self.main_width_label.setObjectName('main_width_label') - self.main_width_spin_box = QtGui.QSpinBox(self.main_position_group_box) + self.main_width_spin_box = QtWidgets.QSpinBox(self.main_position_group_box) self.main_width_spin_box.setMaximum(9999) self.main_width_spin_box.setObjectName('main_width_spin_box') self.main_position_layout.addRow(self.main_width_label, self.main_width_spin_box) - self.main_height_label = QtGui.QLabel(self.main_position_group_box) + self.main_height_label = QtWidgets.QLabel(self.main_position_group_box) self.main_height_label.setObjectName('main_height_label') - self.main_height_spin_box = QtGui.QSpinBox(self.main_position_group_box) + self.main_height_spin_box = QtWidgets.QSpinBox(self.main_position_group_box) self.main_height_spin_box.setMaximum(9999) self.main_height_spin_box.setObjectName('main_height_spin_box') self.main_position_layout.addRow(self.main_height_label, self.main_height_spin_box) self.area_position_layout.addWidget(self.main_position_group_box) - self.footer_position_group_box = QtGui.QGroupBox(self.area_position_page) + self.footer_position_group_box = QtWidgets.QGroupBox(self.area_position_page) self.footer_position_group_box.setObjectName('footer_position_group_box') - self.footer_position_layout = QtGui.QFormLayout(self.footer_position_group_box) + self.footer_position_layout = QtWidgets.QFormLayout(self.footer_position_group_box) self.footer_position_layout.setObjectName('footer_position_layout') - self.footer_position_check_box = QtGui.QCheckBox(self.footer_position_group_box) + self.footer_position_check_box = QtWidgets.QCheckBox(self.footer_position_group_box) self.footer_position_check_box.setObjectName('footer_position_check_box') self.footer_position_layout.addRow(self.footer_position_check_box) - self.footer_x_label = QtGui.QLabel(self.footer_position_group_box) + self.footer_x_label = QtWidgets.QLabel(self.footer_position_group_box) self.footer_x_label.setObjectName('footer_x_label') - self.footer_x_spin_box = QtGui.QSpinBox(self.footer_position_group_box) + self.footer_x_spin_box = QtWidgets.QSpinBox(self.footer_position_group_box) self.footer_x_spin_box.setMaximum(9999) self.footer_x_spin_box.setObjectName('footer_x_spin_box') self.footer_position_layout.addRow(self.footer_x_label, self.footer_x_spin_box) - self.footer_y_label = QtGui.QLabel(self.footer_position_group_box) + self.footer_y_label = QtWidgets.QLabel(self.footer_position_group_box) self.footer_y_label.setObjectName('footer_y_label') - self.footer_y_spin_box = QtGui.QSpinBox(self.footer_position_group_box) + self.footer_y_spin_box = QtWidgets.QSpinBox(self.footer_position_group_box) self.footer_y_spin_box.setMaximum(9999) self.footer_y_spin_box.setObjectName('footer_y_spin_box') self.footer_position_layout.addRow(self.footer_y_label, self.footer_y_spin_box) - self.footer_width_label = QtGui.QLabel(self.footer_position_group_box) + self.footer_width_label = QtWidgets.QLabel(self.footer_position_group_box) self.footer_width_label.setObjectName('footer_width_label') - self.footer_width_spin_box = QtGui.QSpinBox(self.footer_position_group_box) + self.footer_width_spin_box = QtWidgets.QSpinBox(self.footer_position_group_box) self.footer_width_spin_box.setMaximum(9999) self.footer_width_spin_box.setObjectName('footer_width_spin_box') self.footer_position_layout.addRow(self.footer_width_label, self.footer_width_spin_box) - self.footer_height_label = QtGui.QLabel(self.footer_position_group_box) + self.footer_height_label = QtWidgets.QLabel(self.footer_position_group_box) self.footer_height_label.setObjectName('footer_height_label') - self.footer_height_spin_box = QtGui.QSpinBox(self.footer_position_group_box) + self.footer_height_spin_box = QtWidgets.QSpinBox(self.footer_position_group_box) self.footer_height_spin_box.setMaximum(9999) self.footer_height_spin_box.setObjectName('footer_height_spin_box') self.footer_position_layout.addRow(self.footer_height_label, self.footer_height_spin_box) self.area_position_layout.addWidget(self.footer_position_group_box) theme_wizard.addPage(self.area_position_page) # Preview Page - self.preview_page = QtGui.QWizardPage() + self.preview_page = QtWidgets.QWizardPage() self.preview_page.setObjectName('preview_page') - self.preview_layout = QtGui.QVBoxLayout(self.preview_page) + self.preview_layout = QtWidgets.QVBoxLayout(self.preview_page) self.preview_layout.setObjectName('preview_layout') - self.theme_name_layout = QtGui.QFormLayout() + self.theme_name_layout = QtWidgets.QFormLayout() self.theme_name_layout.setObjectName('theme_name_layout') - self.theme_name_label = QtGui.QLabel(self.preview_page) + self.theme_name_label = QtWidgets.QLabel(self.preview_page) self.theme_name_label.setObjectName('theme_name_label') - self.theme_name_edit = QtGui.QLineEdit(self.preview_page) + self.theme_name_edit = QtWidgets.QLineEdit(self.preview_page) self.theme_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'), self)) self.theme_name_edit.setObjectName('ThemeNameEdit') self.theme_name_layout.addRow(self.theme_name_label, self.theme_name_edit) self.preview_layout.addLayout(self.theme_name_layout) - self.preview_area = QtGui.QWidget(self.preview_page) + self.preview_area = QtWidgets.QWidget(self.preview_page) self.preview_area.setObjectName('PreviewArea') - self.preview_area_layout = QtGui.QGridLayout(self.preview_area) - self.preview_area_layout.setMargin(0) + self.preview_area_layout = QtWidgets.QGridLayout(self.preview_area) + self.preview_area_layout.setContentsMargins(0, 0, 0, 0) self.preview_area_layout.setColumnStretch(0, 1) self.preview_area_layout.setRowStretch(0, 1) self.preview_area_layout.setObjectName('preview_area_layout') - self.preview_box_label = QtGui.QLabel(self.preview_area) - self.preview_box_label.setFrameShape(QtGui.QFrame.Box) + self.preview_box_label = QtWidgets.QLabel(self.preview_area) + self.preview_box_label.setFrameShape(QtWidgets.QFrame.Box) self.preview_box_label.setScaledContents(True) self.preview_box_label.setObjectName('preview_box_label') self.preview_area_layout.addWidget(self.preview_box_label) self.preview_layout.addWidget(self.preview_area) theme_wizard.addPage(self.preview_page) self.retranslateUi(theme_wizard) - QtCore.QObject.connect(self.background_combo_box, QtCore.SIGNAL('currentIndexChanged(int)'), - self.background_stack, QtCore.SLOT('setCurrentIndex(int)')) - QtCore.QObject.connect(self.outline_check_box, QtCore.SIGNAL('toggled(bool)'), self.outline_color_button, - QtCore.SLOT('setEnabled(bool)')) - QtCore.QObject.connect(self.outline_check_box, QtCore.SIGNAL('toggled(bool)'), self.outline_size_spin_box, - QtCore.SLOT('setEnabled(bool)')) - QtCore.QObject.connect(self.shadow_check_box, QtCore.SIGNAL('toggled(bool)'), self.shadow_color_button, - QtCore.SLOT('setEnabled(bool)')) - QtCore.QObject.connect(self.shadow_check_box, QtCore.SIGNAL('toggled(bool)'), self.shadow_size_spin_box, - QtCore.SLOT('setEnabled(bool)')) - QtCore.QObject.connect(self.main_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.main_x_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.main_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.main_y_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.main_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.main_width_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.main_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.main_height_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.footer_x_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.footer_y_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), - self.footer_width_spin_box, QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), - self.footer_height_spin_box, QtCore.SLOT('setDisabled(bool)')) + self.background_combo_box.currentIndexChanged.connect(self.background_stack.setCurrentIndex) + self.outline_check_box.toggled.connect(self.outline_color_button.setEnabled) + self.outline_check_box.toggled.connect(self.outline_size_spin_box.setEnabled) + self.shadow_check_box.toggled.connect(self.shadow_color_button.setEnabled) + self.shadow_check_box.toggled.connect(self.shadow_size_spin_box.setEnabled) + self.main_position_check_box.toggled.connect(self.main_x_spin_box.setDisabled) + self.main_position_check_box.toggled.connect(self.main_y_spin_box.setDisabled) + self.main_position_check_box.toggled.connect(self.main_width_spin_box.setDisabled) + self.main_position_check_box.toggled.connect(self.main_height_spin_box.setDisabled) + self.footer_position_check_box.toggled.connect(self.footer_x_spin_box.setDisabled) + self.footer_position_check_box.toggled.connect(self.footer_y_spin_box.setDisabled) + self.footer_position_check_box.toggled.connect(self.footer_width_spin_box.setDisabled) + self.footer_position_check_box.toggled.connect(self.footer_height_spin_box.setDisabled) def retranslateUi(self, theme_wizard): """ @@ -481,12 +468,12 @@ class Ui_ThemeWizard(object): self.footer_height_label.setText(translate('OpenLP.ThemeWizard', 'Height:')) self.footer_height_spin_box.setSuffix(translate('OpenLP.ThemeWizard', 'px')) self.footer_position_check_box.setText(translate('OpenLP.ThemeWizard', 'Use default location')) - theme_wizard.setOption(QtGui.QWizard.HaveCustomButton1, False) - theme_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.ThemeWizard', 'Layout Preview')) + theme_wizard.setOption(QtWidgets.QWizard.HaveCustomButton1, False) + theme_wizard.setButtonText(QtWidgets.QWizard.CustomButton1, translate('OpenLP.ThemeWizard', 'Layout Preview')) self.preview_page.setTitle(translate('OpenLP.ThemeWizard', 'Preview and Save')) self.preview_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Preview the theme and save it.')) self.theme_name_label.setText(translate('OpenLP.ThemeWizard', 'Theme name:')) # Align all QFormLayouts towards each other. label_width = max(self.background_label.minimumSizeHint().width(), self.horizontal_label.minimumSizeHint().width()) - self.spacer.changeSize(label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index c2de33cc5..4bccf2240 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -25,7 +25,7 @@ The :mod:``wizard`` module provides generic wizard tools for OpenLP. import logging import os -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate, is_macosx from openlp.core.lib import build_icon @@ -66,7 +66,7 @@ class WizardStrings(object): 'A song format e.g. PowerSong') -class OpenLPWizard(QtGui.QWizard, RegistryProperties): +class OpenLPWizard(QtWidgets.QWizard, RegistryProperties): """ Generic OpenLP wizard to provide generic functionality and a unified look and feel. @@ -97,8 +97,8 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): self.setObjectName(name) self.open_icon = build_icon(':/general/general_open.png') self.delete_icon = build_icon(':/general/general_delete.png') - self.finish_button = self.button(QtGui.QWizard.FinishButton) - self.cancel_button = self.button(QtGui.QWizard.CancelButton) + self.finish_button = self.button(QtWidgets.QWizard.FinishButton) + self.cancel_button = self.button(QtWidgets.QWizard.CancelButton) self.setupUi(image) self.register_fields() self.custom_init() @@ -114,12 +114,12 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): """ self.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) self.setModal(True) - self.setOptions(QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) + self.setOptions(QtWidgets.QWizard.IndependentPages | + QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.NoBackButtonOnLastPage) if is_macosx(): - self.setPixmap(QtGui.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) + self.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) else: - self.setWizardStyle(QtGui.QWizard.ModernStyle) + self.setWizardStyle(QtWidgets.QWizard.ModernStyle) add_welcome_page(self, image) self.add_custom_pages() if self.with_progress_page: @@ -155,35 +155,35 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): Add the progress page for the wizard. This page informs the user how the wizard is progressing with its task. """ - self.progress_page = QtGui.QWizardPage() + self.progress_page = QtWidgets.QWizardPage() self.progress_page.setObjectName('progress_page') - self.progress_layout = QtGui.QVBoxLayout(self.progress_page) - self.progress_layout.setMargin(48) + self.progress_layout = QtWidgets.QVBoxLayout(self.progress_page) + self.progress_layout.setContentsMargins(48, 48, 48, 48) self.progress_layout.setObjectName('progress_layout') - self.progress_label = QtGui.QLabel(self.progress_page) + self.progress_label = QtWidgets.QLabel(self.progress_page) self.progress_label.setObjectName('progress_label') self.progress_label.setWordWrap(True) self.progress_layout.addWidget(self.progress_label) - self.progress_bar = QtGui.QProgressBar(self.progress_page) + self.progress_bar = QtWidgets.QProgressBar(self.progress_page) self.progress_bar.setObjectName('progress_bar') self.progress_layout.addWidget(self.progress_bar) # Add a QTextEdit and a copy to file and copy to clipboard button to be # able to provide feedback to the user. Hidden by default. - self.error_report_text_edit = QtGui.QTextEdit(self.progress_page) + self.error_report_text_edit = QtWidgets.QTextEdit(self.progress_page) self.error_report_text_edit.setObjectName('error_report_text_edit') self.error_report_text_edit.setHidden(True) self.error_report_text_edit.setReadOnly(True) self.progress_layout.addWidget(self.error_report_text_edit) - self.error_button_layout = QtGui.QHBoxLayout() + self.error_button_layout = QtWidgets.QHBoxLayout() self.error_button_layout.setObjectName('error_button_layout') - spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.error_button_layout.addItem(spacer) - self.error_copy_to_button = QtGui.QPushButton(self.progress_page) + self.error_copy_to_button = QtWidgets.QPushButton(self.progress_page) self.error_copy_to_button.setObjectName('error_copy_to_button') self.error_copy_to_button.setHidden(True) self.error_copy_to_button.setIcon(build_icon(':/system/system_edit_copy.png')) self.error_button_layout.addWidget(self.error_copy_to_button) - self.error_save_to_button = QtGui.QPushButton(self.progress_page) + self.error_save_to_button = QtWidgets.QPushButton(self.progress_page) self.error_save_to_button.setObjectName('error_save_to_button') self.error_save_to_button.setHidden(True) self.error_save_to_button.setIcon(build_icon(':/general/general_save.png')) @@ -191,12 +191,12 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): self.progress_layout.addLayout(self.error_button_layout) self.addPage(self.progress_page) - def exec_(self): + def exec(self): """ Run the wizard. """ self.set_defaults() - return QtGui.QWizard.exec_(self) + return QtWidgets.QWizard.exec(self) def reject(self): """ @@ -205,7 +205,7 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): log.debug('Wizard cancelled by user.') if self.with_progress_page and self.currentPage() == self.progress_page: Registry().execute('openlp_stop_wizard') - self.done(QtGui.QDialog.Rejected) + self.done(QtWidgets.QDialog.Rejected) def on_current_id_changed(self, page_id): """ @@ -282,8 +282,9 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): if filters: filters += ';;' filters += '%s (*)' % UiStrings().AllFiles - filename = QtGui.QFileDialog.getOpenFileName( - self, title, os.path.dirname(Settings().value(self.plugin.settings_section + '/' + setting_name)), filters) + filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( + self, title, os.path.dirname(Settings().value(self.plugin.settings_section + '/' + setting_name)), + filters) if filename: editbox.setText(filename) Settings().setValue(self.plugin.settings_section + '/' + setting_name, filename) @@ -296,9 +297,9 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): :param editbox: An editbox (QLineEdit). :param setting_name: The place where to save the last opened directory. """ - folder = QtGui.QFileDialog.getExistingDirectory( + folder = QtWidgets.QFileDialog.getExistingDirectory( self, title, Settings().value(self.plugin.settings_section + '/' + setting_name), - QtGui.QFileDialog.ShowDirsOnly) + QtWidgets.QFileDialog.ShowDirsOnly) if folder: editbox.setText(folder) Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 38dd1fa0c..75f84b8f8 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -40,7 +40,7 @@ import urllib.error import urllib.parse from random import randint -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore from openlp.core.common import Registry, AppLocation, Settings, is_win, is_macosx @@ -117,7 +117,7 @@ class VersionThread(QtCore.QThread): version = check_latest_version(app_version) log.debug("Versions %s and %s " % (LooseVersion(str(version)), LooseVersion(str(app_version['full'])))) if LooseVersion(str(version)) > LooseVersion(str(app_version['full'])): - self.main_window.emit(QtCore.SIGNAL('openlp_version_check'), '%s' % version) + self.main_window.openlp_version_check.emit('%s' % version) class HTTPRedirectHandlerFixed(urllib.request.HTTPRedirectHandler): diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 2683d1538..3d0afa2be 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -25,7 +25,7 @@ by the shortcuts system. """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Settings @@ -357,7 +357,8 @@ class ActionList(object): global_context = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] affected_actions = [] if global_context: - affected_actions = [a for a in self.get_all_child_objects(action.parent()) if isinstance(a, QtGui.QAction)] + affected_actions = [a for a in self.get_all_child_objects(action.parent()) if isinstance(a, + QtWidgets.QAction)] for existing_action in existing_actions: if action is existing_action: continue diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 2b14991f6..f2937a9fa 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -26,7 +26,8 @@ import logging import re import sys -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets + from openlp.core.common import AppLocation, Settings, translate, is_win, is_macosx @@ -117,10 +118,10 @@ class LanguageManager(object): Settings().setValue('core/language', language) log.info('Language file: \'%s\' written to conf file' % language) if message: - QtGui.QMessageBox.information(None, - translate('OpenLP.LanguageManager', 'Language'), - translate('OpenLP.LanguageManager', 'Please restart OpenLP to use your new ' - 'language setting.')) + QtWidgets.QMessageBox.information(None, + translate('OpenLP.LanguageManager', 'Language'), + translate('OpenLP.LanguageManager', + 'Please restart OpenLP to use your new language setting.')) @staticmethod def init_qm_list(): diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 9517f1aa0..e41b34d4d 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -22,7 +22,8 @@ import logging -from PyQt4 import QtGui +from PyQt5 import QtGui + from openlp.core.common import Settings, translate from openlp.core.lib import Plugin, StringContent, build_icon @@ -188,7 +189,7 @@ class AlertsPlugin(Plugin): Start of the Alerts dialog triggered from the main menu. """ self.alert_form.load_list() - self.alert_form.exec_() + self.alert_form.exec() def about(self): """ diff --git a/openlp/plugins/alerts/forms/__init__.py b/openlp/plugins/alerts/forms/__init__.py index 83aa6a4f0..ad44a5389 100644 --- a/openlp/plugins/alerts/forms/__init__.py +++ b/openlp/plugins/alerts/forms/__init__.py @@ -24,14 +24,14 @@ Forms in OpenLP are made up of two classes. One class holds all the graphical el other class holds all the functional code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly -modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be +modified version of the class that the ``pyuic5`` command produces from Qt5's .ui file. Typical modifications will be converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which -is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned -above, like so:: +is instantiated and used. It uses dual inheritance to inherit from (usually) QtWidgets.QDialog and the Ui class +mentioned above, like so:: - class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): + class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): def __init__(self, parent=None): super(AuthorsForm, self).__init__(parent) diff --git a/openlp/plugins/alerts/forms/alertdialog.py b/openlp/plugins/alerts/forms/alertdialog.py index 88a08b52a..f9827eb6e 100644 --- a/openlp/plugins/alerts/forms/alertdialog.py +++ b/openlp/plugins/alerts/forms/alertdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -40,34 +40,34 @@ class Ui_AlertDialog(object): alert_dialog.setObjectName('alert_dialog') alert_dialog.resize(400, 300) alert_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) - self.alert_dialog_layout = QtGui.QGridLayout(alert_dialog) + self.alert_dialog_layout = QtWidgets.QGridLayout(alert_dialog) self.alert_dialog_layout.setObjectName('alert_dialog_layout') - self.alert_text_layout = QtGui.QFormLayout() + self.alert_text_layout = QtWidgets.QFormLayout() self.alert_text_layout.setObjectName('alert_text_layout') - self.alert_entry_label = QtGui.QLabel(alert_dialog) + self.alert_entry_label = QtWidgets.QLabel(alert_dialog) self.alert_entry_label.setObjectName('alert_entry_label') - self.alert_text_edit = QtGui.QLineEdit(alert_dialog) + self.alert_text_edit = QtWidgets.QLineEdit(alert_dialog) self.alert_text_edit.setObjectName('alert_text_edit') self.alert_entry_label.setBuddy(self.alert_text_edit) self.alert_text_layout.addRow(self.alert_entry_label, self.alert_text_edit) - self.alert_parameter = QtGui.QLabel(alert_dialog) + self.alert_parameter = QtWidgets.QLabel(alert_dialog) self.alert_parameter.setObjectName('alert_parameter') - self.parameter_edit = QtGui.QLineEdit(alert_dialog) + self.parameter_edit = QtWidgets.QLineEdit(alert_dialog) self.parameter_edit.setObjectName('parameter_edit') self.alert_parameter.setBuddy(self.parameter_edit) self.alert_text_layout.addRow(self.alert_parameter, self.parameter_edit) self.alert_dialog_layout.addLayout(self.alert_text_layout, 0, 0, 1, 2) - self.alert_list_widget = QtGui.QListWidget(alert_dialog) + self.alert_list_widget = QtWidgets.QListWidget(alert_dialog) self.alert_list_widget.setAlternatingRowColors(True) self.alert_list_widget.setObjectName('alert_list_widget') self.alert_dialog_layout.addWidget(self.alert_list_widget, 1, 0) - self.manage_button_layout = QtGui.QVBoxLayout() + self.manage_button_layout = QtWidgets.QVBoxLayout() self.manage_button_layout.setObjectName('manage_button_layout') - self.new_button = QtGui.QPushButton(alert_dialog) + self.new_button = QtWidgets.QPushButton(alert_dialog) self.new_button.setIcon(build_icon(':/general/general_new.png')) self.new_button.setObjectName('new_button') self.manage_button_layout.addWidget(self.new_button) - self.save_button = QtGui.QPushButton(alert_dialog) + self.save_button = QtWidgets.QPushButton(alert_dialog) self.save_button.setEnabled(False) self.save_button.setIcon(build_icon(':/general/general_save.png')) self.save_button.setObjectName('save_button') diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 39b84cad7..c6fb31bb6 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, translate from openlp.plugins.alerts.lib.db import AlertItem @@ -28,7 +28,7 @@ from openlp.plugins.alerts.lib.db import AlertItem from .alertdialog import Ui_AlertDialog -class AlertForm(QtGui.QDialog, Ui_AlertDialog): +class AlertForm(QtWidgets.QDialog, Ui_AlertDialog): """ Provide UI for the alert system """ @@ -50,14 +50,14 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alert_list_widget.clicked.connect(self.on_single_click) self.alert_list_widget.currentRowChanged.connect(self.on_current_row_changed) - def exec_(self): + def exec(self): """ Execute the dialog and return the exit code. """ self.display_button.setEnabled(False) self.display_close_button.setEnabled(False) self.alert_text_edit.setText('') - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def load_list(self): """ @@ -66,7 +66,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.alert_list_widget.clear() alerts = self.manager.get_all_objects(AlertItem, order_by_ref=AlertItem.text) for alert in alerts: - item_name = QtGui.QListWidgetItem(alert.text) + item_name = QtWidgets.QListWidgetItem(alert.text) item_name.setData(QtCore.Qt.UserRole, alert.id) self.alert_list_widget.addItem(item_name) if alert.text == str(self.alert_text_edit.text()): @@ -104,11 +104,11 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): Create a new alert. """ if not self.alert_text_edit.text(): - QtGui.QMessageBox.information(self, - translate('AlertsPlugin.AlertForm', 'New Alert'), - translate('AlertsPlugin.AlertForm', - 'You haven\'t specified any text for your alert. \n' - 'Please type in some text before clicking New.')) + QtWidgets.QMessageBox.information(self, + translate('AlertsPlugin.AlertForm', 'New Alert'), + translate('AlertsPlugin.AlertForm', + 'You haven\'t specified any text for your alert. \n' + 'Please type in some text before clicking New.')) else: alert = AlertItem() alert.text = self.alert_text_edit.text() @@ -175,24 +175,27 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): return False # We found '<>' in the alert text, but the ParameterEdit field is empty. if text.find('<>') != -1 and not self.parameter_edit.text() and \ - QtGui.QMessageBox.question(self, - translate('AlertsPlugin.AlertForm', 'No Parameter Found'), - translate('AlertsPlugin.AlertForm', - 'You have not entered a parameter to be replaced.\n' - 'Do you want to continue anyway?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.question(self, + translate('AlertsPlugin.AlertForm', 'No Parameter Found'), + translate('AlertsPlugin.AlertForm', + 'You have not entered a parameter to be replaced.\n' + 'Do you want to continue anyway?'), + QtWidgets.QMessageBox.StandardButtons( + QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes) + ) == QtWidgets.QMessageBox.No: self.parameter_edit.setFocus() return False # The ParameterEdit field is not empty, but we have not found '<>' # in the alert text. elif text.find('<>') == -1 and self.parameter_edit.text() and \ - QtGui.QMessageBox.question(self, - translate('AlertsPlugin.AlertForm', 'No Placeholder Found'), - translate('AlertsPlugin.AlertForm', 'The alert text does not contain \'<>\'.\n' - 'Do you want to continue anyway?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.question(self, + translate('AlertsPlugin.AlertForm', 'No Placeholder Found'), + translate('AlertsPlugin.AlertForm', + 'The alert text does not contain \'<>\'.\n' + 'Do you want to continue anyway?'), + QtWidgets.QMessageBox.StandardButtons( + QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes) + ) == QtWidgets.QMessageBox.No: self.parameter_edit.setFocus() return False text = text.replace('<>', self.parameter_edit.text()) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 8d691c2bb..998da76bc 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -24,7 +24,7 @@ The :mod:`~openlp.plugins.alerts.lib.alertsmanager` module contains the part of displaying of alerts. """ -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, Settings, translate @@ -33,13 +33,15 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperti """ AlertsManager manages the settings of Alerts. """ + alerts_text = QtCore.pyqtSignal(list) + def __init__(self, parent): super(AlertsManager, self).__init__(parent) self.timer_id = 0 self.alert_list = [] Registry().register_function('live_display_active', self.generate_alert) Registry().register_function('alerts_text', self.alert_text) - QtCore.QObject.connect(self, QtCore.SIGNAL('alerts_text'), self.alert_text) + self.alerts_text.connect(self.alert_text) def alert_text(self, message): """ diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 9c3b44398..bae2e8c89 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.common import Settings, UiStrings, translate from openlp.core.lib import ColorButton, SettingsTab @@ -37,38 +37,38 @@ class AlertsTab(SettingsTab): def setupUi(self): self.setObjectName('AlertsTab') super(AlertsTab, self).setupUi() - self.font_group_box = QtGui.QGroupBox(self.left_column) + self.font_group_box = QtWidgets.QGroupBox(self.left_column) self.font_group_box.setObjectName('font_group_box') - self.font_layout = QtGui.QFormLayout(self.font_group_box) + self.font_layout = QtWidgets.QFormLayout(self.font_group_box) self.font_layout.setObjectName('font_layout') - self.font_label = QtGui.QLabel(self.font_group_box) + self.font_label = QtWidgets.QLabel(self.font_group_box) self.font_label.setObjectName('font_label') - self.font_combo_box = QtGui.QFontComboBox(self.font_group_box) + self.font_combo_box = QtWidgets.QFontComboBox(self.font_group_box) self.font_combo_box.setObjectName('font_combo_box') self.font_layout.addRow(self.font_label, self.font_combo_box) - self.font_color_label = QtGui.QLabel(self.font_group_box) + self.font_color_label = QtWidgets.QLabel(self.font_group_box) self.font_color_label.setObjectName('font_color_label') - self.color_layout = QtGui.QHBoxLayout() + self.color_layout = QtWidgets.QHBoxLayout() self.color_layout.setObjectName('color_layout') self.font_color_button = ColorButton(self.font_group_box) self.font_color_button.setObjectName('font_color_button') self.color_layout.addWidget(self.font_color_button) self.color_layout.addSpacing(20) - self.background_color_label = QtGui.QLabel(self.font_group_box) + self.background_color_label = QtWidgets.QLabel(self.font_group_box) self.background_color_label.setObjectName('background_color_label') self.color_layout.addWidget(self.background_color_label) self.background_color_button = ColorButton(self.font_group_box) self.background_color_button.setObjectName('background_color_button') self.color_layout.addWidget(self.background_color_button) self.font_layout.addRow(self.font_color_label, self.color_layout) - self.font_size_label = QtGui.QLabel(self.font_group_box) + self.font_size_label = QtWidgets.QLabel(self.font_group_box) self.font_size_label.setObjectName('font_size_label') - self.font_size_spin_box = QtGui.QSpinBox(self.font_group_box) + self.font_size_spin_box = QtWidgets.QSpinBox(self.font_group_box) self.font_size_spin_box.setObjectName('font_size_spin_box') self.font_layout.addRow(self.font_size_label, self.font_size_spin_box) - self.timeout_label = QtGui.QLabel(self.font_group_box) + self.timeout_label = QtWidgets.QLabel(self.font_group_box) self.timeout_label.setObjectName('timeout_label') - self.timeout_spin_box = QtGui.QSpinBox(self.font_group_box) + self.timeout_spin_box = QtWidgets.QSpinBox(self.font_group_box) self.timeout_spin_box.setMaximum(180) self.timeout_spin_box.setObjectName('timeout_spin_box') self.font_layout.addRow(self.timeout_label, self.timeout_spin_box) @@ -78,11 +78,11 @@ class AlertsTab(SettingsTab): self.font_layout.addRow(self.vertical_label, self.vertical_combo_box) self.left_layout.addWidget(self.font_group_box) self.left_layout.addStretch() - self.preview_group_box = QtGui.QGroupBox(self.right_column) + self.preview_group_box = QtWidgets.QGroupBox(self.right_column) self.preview_group_box.setObjectName('preview_group_box') - self.preview_layout = QtGui.QVBoxLayout(self.preview_group_box) + self.preview_layout = QtWidgets.QVBoxLayout(self.preview_group_box) self.preview_layout.setObjectName('preview_layout') - self.font_preview = QtGui.QLineEdit(self.preview_group_box) + self.font_preview = QtWidgets.QLineEdit(self.preview_group_box) self.font_preview.setObjectName('font_preview') self.preview_layout.addWidget(self.font_preview) self.right_layout.addWidget(self.preview_group_box) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index e95cc0875..cd4fada7a 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.ui import UiStrings, create_action @@ -107,12 +107,12 @@ class BiblePlugin(Plugin): """ super(BiblePlugin, self).app_startup() if self.manager.old_bible_databases: - if QtGui.QMessageBox.information( + if QtWidgets.QMessageBox.information( self.main_window, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' 'existing Bibles.\nShould OpenLP upgrade now?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ - QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)) == \ + QtWidgets.QMessageBox.Yes: self.on_tools_upgrade_item_triggered() def add_import_menu_item(self, import_menu): @@ -157,7 +157,7 @@ class BiblePlugin(Plugin): if not hasattr(self, 'upgrade_wizard'): self.upgrade_wizard = BibleUpgradeForm(self.main_window, self.manager, self) # If the import was not cancelled then reload. - if self.upgrade_wizard.exec_(): + if self.upgrade_wizard.exec(): self.media_item.reload_bibles() def on_bible_import_click(self): diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 1a199fbf5..f5e770815 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -25,14 +25,14 @@ Forms in OpenLP are made up of two classes. One class holds all the graphical el other class holds all the functional code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly -modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be +modified version of the class that the ``pyuic5`` command produces from Qt5's .ui file. Typical modifications will be converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which -is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned -above, like so:: +is instantiated and used. It uses dual inheritance to inherit from (usually) QtWidgets.QDialog and the Ui class +mentioned above, like so:: - class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): + class BibleImportForm(QtWidgets.QWizard, Ui_BibleImportWizard): def __init__(self, parent, manager, bible_plugin): super(BibleImportForm, self).__init__(parent) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index b563ab3bf..10d7b15a7 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -26,7 +26,7 @@ import logging import os import urllib.error -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import AppLocation, Settings, UiStrings, translate from openlp.core.lib.db import delete_database @@ -112,194 +112,194 @@ class BibleImportForm(OpenLPWizard): Add the bible import specific wizard pages. """ # Select Page - self.select_page = QtGui.QWizardPage() + self.select_page = QtWidgets.QWizardPage() self.select_page.setObjectName('SelectPage') - self.select_page_layout = QtGui.QVBoxLayout(self.select_page) + self.select_page_layout = QtWidgets.QVBoxLayout(self.select_page) self.select_page_layout.setObjectName('SelectPageLayout') - self.format_layout = QtGui.QFormLayout() + self.format_layout = QtWidgets.QFormLayout() self.format_layout.setObjectName('FormatLayout') - self.format_label = QtGui.QLabel(self.select_page) + self.format_label = QtWidgets.QLabel(self.select_page) self.format_label.setObjectName('FormatLabel') - self.format_combo_box = QtGui.QComboBox(self.select_page) + self.format_combo_box = QtWidgets.QComboBox(self.select_page) self.format_combo_box.addItems(['', '', '', '', '']) self.format_combo_box.setObjectName('FormatComboBox') self.format_layout.addRow(self.format_label, self.format_combo_box) - self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.format_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) + self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) self.select_page_layout.addLayout(self.format_layout) - self.select_stack = QtGui.QStackedLayout() + self.select_stack = QtWidgets.QStackedLayout() self.select_stack.setObjectName('SelectStack') - self.osis_widget = QtGui.QWidget(self.select_page) + self.osis_widget = QtWidgets.QWidget(self.select_page) self.osis_widget.setObjectName('OsisWidget') - self.osis_layout = QtGui.QFormLayout(self.osis_widget) - self.osis_layout.setMargin(0) + self.osis_layout = QtWidgets.QFormLayout(self.osis_widget) + self.osis_layout.setContentsMargins(0, 0, 0, 0) self.osis_layout.setObjectName('OsisLayout') - self.osis_file_label = QtGui.QLabel(self.osis_widget) + self.osis_file_label = QtWidgets.QLabel(self.osis_widget) self.osis_file_label.setObjectName('OsisFileLabel') - self.osis_file_layout = QtGui.QHBoxLayout() + self.osis_file_layout = QtWidgets.QHBoxLayout() self.osis_file_layout.setObjectName('OsisFileLayout') - self.osis_file_edit = QtGui.QLineEdit(self.osis_widget) + self.osis_file_edit = QtWidgets.QLineEdit(self.osis_widget) self.osis_file_edit.setObjectName('OsisFileEdit') self.osis_file_layout.addWidget(self.osis_file_edit) - self.osis_browse_button = QtGui.QToolButton(self.osis_widget) + self.osis_browse_button = QtWidgets.QToolButton(self.osis_widget) self.osis_browse_button.setIcon(self.open_icon) self.osis_browse_button.setObjectName('OsisBrowseButton') self.osis_file_layout.addWidget(self.osis_browse_button) self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) - self.osis_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.osis_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) self.select_stack.addWidget(self.osis_widget) - self.csv_widget = QtGui.QWidget(self.select_page) + self.csv_widget = QtWidgets.QWidget(self.select_page) self.csv_widget.setObjectName('CsvWidget') - self.csv_layout = QtGui.QFormLayout(self.csv_widget) - self.csv_layout.setMargin(0) + self.csv_layout = QtWidgets.QFormLayout(self.csv_widget) + self.csv_layout.setContentsMargins(0, 0, 0, 0) self.csv_layout.setObjectName('CsvLayout') - self.csv_books_label = QtGui.QLabel(self.csv_widget) + self.csv_books_label = QtWidgets.QLabel(self.csv_widget) self.csv_books_label.setObjectName('CsvBooksLabel') - self.csv_books_layout = QtGui.QHBoxLayout() + self.csv_books_layout = QtWidgets.QHBoxLayout() self.csv_books_layout.setObjectName('CsvBooksLayout') - self.csv_books_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_books_edit = QtWidgets.QLineEdit(self.csv_widget) self.csv_books_edit.setObjectName('CsvBooksEdit') self.csv_books_layout.addWidget(self.csv_books_edit) - self.csv_books_button = QtGui.QToolButton(self.csv_widget) + self.csv_books_button = QtWidgets.QToolButton(self.csv_widget) self.csv_books_button.setIcon(self.open_icon) self.csv_books_button.setObjectName('CsvBooksButton') self.csv_books_layout.addWidget(self.csv_books_button) self.csv_layout.addRow(self.csv_books_label, self.csv_books_layout) - self.csv_verses_label = QtGui.QLabel(self.csv_widget) + self.csv_verses_label = QtWidgets.QLabel(self.csv_widget) self.csv_verses_label.setObjectName('CsvVersesLabel') - self.csv_verses_layout = QtGui.QHBoxLayout() + self.csv_verses_layout = QtWidgets.QHBoxLayout() self.csv_verses_layout.setObjectName('CsvVersesLayout') - self.csv_verses_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_verses_edit = QtWidgets.QLineEdit(self.csv_widget) self.csv_verses_edit.setObjectName('CsvVersesEdit') self.csv_verses_layout.addWidget(self.csv_verses_edit) - self.csv_verses_button = QtGui.QToolButton(self.csv_widget) + self.csv_verses_button = QtWidgets.QToolButton(self.csv_widget) self.csv_verses_button.setIcon(self.open_icon) self.csv_verses_button.setObjectName('CsvVersesButton') self.csv_verses_layout.addWidget(self.csv_verses_button) self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) - self.csv_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.csv_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) self.select_stack.addWidget(self.csv_widget) - self.open_song_widget = QtGui.QWidget(self.select_page) + self.open_song_widget = QtWidgets.QWidget(self.select_page) self.open_song_widget.setObjectName('OpenSongWidget') - self.open_song_layout = QtGui.QFormLayout(self.open_song_widget) - self.open_song_layout.setMargin(0) + self.open_song_layout = QtWidgets.QFormLayout(self.open_song_widget) + self.open_song_layout.setContentsMargins(0, 0, 0, 0) self.open_song_layout.setObjectName('OpenSongLayout') - self.open_song_file_label = QtGui.QLabel(self.open_song_widget) + self.open_song_file_label = QtWidgets.QLabel(self.open_song_widget) self.open_song_file_label.setObjectName('OpenSongFileLabel') - self.open_song_file_layout = QtGui.QHBoxLayout() + self.open_song_file_layout = QtWidgets.QHBoxLayout() self.open_song_file_layout.setObjectName('OpenSongFileLayout') - self.open_song_file_edit = QtGui.QLineEdit(self.open_song_widget) + self.open_song_file_edit = QtWidgets.QLineEdit(self.open_song_widget) self.open_song_file_edit.setObjectName('OpenSongFileEdit') self.open_song_file_layout.addWidget(self.open_song_file_edit) - self.open_song_browse_button = QtGui.QToolButton(self.open_song_widget) + self.open_song_browse_button = QtWidgets.QToolButton(self.open_song_widget) self.open_song_browse_button.setIcon(self.open_icon) self.open_song_browse_button.setObjectName('OpenSongBrowseButton') self.open_song_file_layout.addWidget(self.open_song_browse_button) self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) - self.open_song_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.open_song_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) self.select_stack.addWidget(self.open_song_widget) - self.web_tab_widget = QtGui.QTabWidget(self.select_page) + self.web_tab_widget = QtWidgets.QTabWidget(self.select_page) self.web_tab_widget.setObjectName('WebTabWidget') - self.web_bible_tab = QtGui.QWidget() + self.web_bible_tab = QtWidgets.QWidget() self.web_bible_tab.setObjectName('WebBibleTab') - self.web_bible_layout = QtGui.QFormLayout(self.web_bible_tab) + self.web_bible_layout = QtWidgets.QFormLayout(self.web_bible_tab) self.web_bible_layout.setObjectName('WebBibleLayout') - self.web_update_label = QtGui.QLabel(self.web_bible_tab) + self.web_source_label = QtWidgets.QLabel(self.web_bible_tab) self.web_update_label.setObjectName('WebUpdateLabel') - self.web_bible_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_update_label) - self.web_update_button = QtGui.QPushButton(self.web_bible_tab) + self.web_bible_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.web_update_label) + self.web_update_button = QtWidgets.QPushButton(self.web_bible_tab) self.web_update_button.setObjectName('WebUpdateButton') - self.web_bible_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_update_button) - self.web_source_label = QtGui.QLabel(self.web_bible_tab) + self.web_bible_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.web_update_button) + self.web_source_label = QtWidgets.QLabel(self.web_bible_tab) self.web_source_label.setObjectName('WebSourceLabel') - self.web_bible_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_source_label) - self.web_source_combo_box = QtGui.QComboBox(self.web_bible_tab) + self.web_bible_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.web_source_label) + self.web_source_combo_box = QtWidgets.QComboBox(self.web_bible_tab) self.web_source_combo_box.setObjectName('WebSourceComboBox') self.web_source_combo_box.addItems(['', '', '']) self.web_source_combo_box.setEnabled(False) - self.web_bible_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_source_combo_box) - self.web_translation_label = QtGui.QLabel(self.web_bible_tab) + self.web_bible_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.web_source_combo_box) + self.web_translation_label = QtWidgets.QLabel(self.web_bible_tab) self.web_translation_label.setObjectName('web_translation_label') - self.web_bible_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.web_translation_label) - self.web_translation_combo_box = QtGui.QComboBox(self.web_bible_tab) - self.web_translation_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.web_bible_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.web_translation_label) + self.web_translation_combo_box = QtWidgets.QComboBox(self.web_bible_tab) + self.web_translation_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) self.web_translation_combo_box.setObjectName('WebTranslationComboBox') self.web_translation_combo_box.setEnabled(False) - self.web_bible_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.web_translation_combo_box) - self.web_progress_bar = QtGui.QProgressBar(self) + self.web_bible_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.web_translation_combo_box) + self.web_progress_bar = QtWidgets.QProgressBar(self) self.web_progress_bar.setRange(0, 3) self.web_progress_bar.setObjectName('WebTranslationProgressBar') self.web_progress_bar.setVisible(False) - self.web_bible_layout.setWidget(3, QtGui.QFormLayout.SpanningRole, self.web_progress_bar) + self.web_bible_layout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.web_progress_bar) self.web_tab_widget.addTab(self.web_bible_tab, '') - self.web_proxy_tab = QtGui.QWidget() + self.web_proxy_tab = QtWidgets.QWidget() self.web_proxy_tab.setObjectName('WebProxyTab') - self.web_proxy_layout = QtGui.QFormLayout(self.web_proxy_tab) + self.web_proxy_layout = QtWidgets.QFormLayout(self.web_proxy_tab) self.web_proxy_layout.setObjectName('WebProxyLayout') - self.web_server_label = QtGui.QLabel(self.web_proxy_tab) + self.web_server_label = QtWidgets.QLabel(self.web_proxy_tab) self.web_server_label.setObjectName('WebServerLabel') - self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_server_label) - self.web_server_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_proxy_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.web_server_label) + self.web_server_edit = QtWidgets.QLineEdit(self.web_proxy_tab) self.web_server_edit.setObjectName('WebServerEdit') - self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_server_edit) - self.web_user_label = QtGui.QLabel(self.web_proxy_tab) + self.web_proxy_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.web_server_edit) + self.web_user_label = QtWidgets.QLabel(self.web_proxy_tab) self.web_user_label.setObjectName('WebUserLabel') - self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_user_label) - self.web_user_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_proxy_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.web_user_label) + self.web_user_edit = QtWidgets.QLineEdit(self.web_proxy_tab) self.web_user_edit.setObjectName('WebUserEdit') - self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_user_edit) - self.web_password_label = QtGui.QLabel(self.web_proxy_tab) + self.web_proxy_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.web_user_edit) + self.web_password_label = QtWidgets.QLabel(self.web_proxy_tab) self.web_password_label.setObjectName('WebPasswordLabel') - self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.web_password_label) - self.web_password_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_proxy_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.web_password_label) + self.web_password_edit = QtWidgets.QLineEdit(self.web_proxy_tab) self.web_password_edit.setObjectName('WebPasswordEdit') - self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.web_password_edit) + self.web_proxy_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.web_password_edit) self.web_tab_widget.addTab(self.web_proxy_tab, '') self.select_stack.addWidget(self.web_tab_widget) - self.zefania_widget = QtGui.QWidget(self.select_page) + self.zefania_widget = QtWidgets.QWidget(self.select_page) self.zefania_widget.setObjectName('ZefaniaWidget') - self.zefania_layout = QtGui.QFormLayout(self.zefania_widget) + self.zefania_layout = QtWidgets.QFormLayout(self.zefania_widget) self.zefania_layout.setMargin(0) self.zefania_layout.setObjectName('ZefaniaLayout') - self.zefania_file_label = QtGui.QLabel(self.zefania_widget) + self.zefania_file_label = QtWidgets.QLabel(self.zefania_widget) self.zefania_file_label.setObjectName('ZefaniaFileLabel') - self.zefania_file_layout = QtGui.QHBoxLayout() + self.zefania_file_layout = QtWidgets.QHBoxLayout() self.zefania_file_layout.setObjectName('ZefaniaFileLayout') - self.zefania_file_edit = QtGui.QLineEdit(self.zefania_widget) + self.zefania_file_edit = QtWidgets.QLineEdit(self.zefania_widget) self.zefania_file_edit.setObjectName('ZefaniaFileEdit') self.zefania_file_layout.addWidget(self.zefania_file_edit) - self.zefania_browse_button = QtGui.QToolButton(self.zefania_widget) + self.zefania_browse_button = QtWidgets.QToolButton(self.zefania_widget) self.zefania_browse_button.setIcon(self.open_icon) self.zefania_browse_button.setObjectName('ZefaniaBrowseButton') self.zefania_file_layout.addWidget(self.zefania_browse_button) self.zefania_layout.addRow(self.zefania_file_label, self.zefania_file_layout) - self.zefania_layout.setItem(5, QtGui.QFormLayout.LabelRole, self.spacer) + self.zefania_layout.setItem(5, QtWidgets.QFormLayout.LabelRole, self.spacer) self.select_stack.addWidget(self.zefania_widget) self.select_page_layout.addLayout(self.select_stack) self.addPage(self.select_page) # License Page - self.license_details_page = QtGui.QWizardPage() + self.license_details_page = QtWidgets.QWizardPage() self.license_details_page.setObjectName('LicenseDetailsPage') - self.license_details_layout = QtGui.QFormLayout(self.license_details_page) + self.license_details_layout = QtWidgets.QFormLayout(self.license_details_page) self.license_details_layout.setObjectName('LicenseDetailsLayout') - self.version_name_label = QtGui.QLabel(self.license_details_page) + self.version_name_label = QtWidgets.QLabel(self.license_details_page) self.version_name_label.setObjectName('VersionNameLabel') - self.license_details_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.version_name_label) - self.version_name_edit = QtGui.QLineEdit(self.license_details_page) + self.license_details_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.version_name_label) + self.version_name_edit = QtWidgets.QLineEdit(self.license_details_page) self.version_name_edit.setObjectName('VersionNameEdit') - self.license_details_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.version_name_edit) - self.copyright_label = QtGui.QLabel(self.license_details_page) + self.license_details_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.version_name_edit) + self.copyright_label = QtWidgets.QLabel(self.license_details_page) self.copyright_label.setObjectName('CopyrightLabel') - self.license_details_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyright_label) - self.copyright_edit = QtGui.QLineEdit(self.license_details_page) + self.license_details_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.copyright_label) + self.copyright_edit = QtWidgets.QLineEdit(self.license_details_page) self.copyright_edit.setObjectName('CopyrightEdit') - self.license_details_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyright_edit) - self.permissions_label = QtGui.QLabel(self.license_details_page) + self.license_details_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.copyright_edit) + self.permissions_label = QtWidgets.QLabel(self.license_details_page) self.permissions_label.setObjectName('PermissionsLabel') - self.license_details_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.permissions_label) - self.permissions_edit = QtGui.QLineEdit(self.license_details_page) + self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.permissions_label) + self.permissions_edit = QtWidgets.QLineEdit(self.license_details_page) self.permissions_edit.setObjectName('PermissionsEdit') - self.license_details_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissions_edit) + self.license_details_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.permissions_edit) self.addPage(self.license_details_page) def retranslateUi(self): @@ -365,7 +365,7 @@ class BibleImportForm(OpenLPWizard): self.csv_verses_label.minimumSizeHint().width(), self.open_song_file_label.minimumSizeHint().width(), self.zefania_file_label.minimumSizeHint().width()) - self.spacer.changeSize(label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) def validateCurrentPage(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index c97479e4a..00f81b558 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -27,7 +27,7 @@ import os import shutil from tempfile import gettempdir -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, AppLocation, UiStrings, Settings, check_directory_exists, translate from openlp.core.lib.ui import critical_error_message_box @@ -87,7 +87,7 @@ class BibleUpgradeForm(OpenLPWizard): log.debug('Wizard cancelled by user') self.stop_import_flag = True if not self.currentPage() == self.progress_page: - self.done(QtGui.QDialog.Rejected) + self.done(QtWidgets.QDialog.Rejected) def onCurrentIdChanged(self, page_id): """ @@ -104,8 +104,8 @@ class BibleUpgradeForm(OpenLPWizard): """ Show the file open dialog for the OSIS file. """ - filename = QtGui.QFileDialog.getExistingDirectory(self, translate('BiblesPlugin.UpgradeWizardForm', - 'Select a Backup Directory'), '') + filename = QtWidgets.QFileDialog.getExistingDirectory(self, translate('BiblesPlugin.UpgradeWizardForm', + 'Select a Backup Directory'), '') if filename: self.backupDirectoryEdit.setText(filename) @@ -148,53 +148,53 @@ class BibleUpgradeForm(OpenLPWizard): Add the bible import specific wizard pages. """ # Backup Page - self.backup_page = QtGui.QWizardPage() + self.backup_page = QtWidgets.QWizardPage() self.backup_page.setObjectName('BackupPage') - self.backupLayout = QtGui.QVBoxLayout(self.backup_page) + self.backupLayout = QtWidgets.QVBoxLayout(self.backup_page) self.backupLayout.setObjectName('BackupLayout') - self.backupInfoLabel = QtGui.QLabel(self.backup_page) + self.backupInfoLabel = QtWidgets.QLabel(self.backup_page) self.backupInfoLabel.setOpenExternalLinks(True) self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText) self.backupInfoLabel.setWordWrap(True) self.backupInfoLabel.setObjectName('backupInfoLabel') self.backupLayout.addWidget(self.backupInfoLabel) - self.selectLabel = QtGui.QLabel(self.backup_page) + self.selectLabel = QtWidgets.QLabel(self.backup_page) self.selectLabel.setObjectName('select_label') self.backupLayout.addWidget(self.selectLabel) - self.formLayout = QtGui.QFormLayout() - self.formLayout.setMargin(0) + self.formLayout = QtWidgets.QFormLayout() + self.formLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setObjectName('FormLayout') - self.backupDirectoryLabel = QtGui.QLabel(self.backup_page) + self.backupDirectoryLabel = QtWidgets.QLabel(self.backup_page) self.backupDirectoryLabel.setObjectName('backupDirectoryLabel') - self.backupDirectoryLayout = QtGui.QHBoxLayout() + self.backupDirectoryLayout = QtWidgets.QHBoxLayout() self.backupDirectoryLayout.setObjectName('BackupDirectoryLayout') - self.backupDirectoryEdit = QtGui.QLineEdit(self.backup_page) + self.backupDirectoryEdit = QtWidgets.QLineEdit(self.backup_page) self.backupDirectoryEdit.setObjectName('BackupFolderEdit') self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit) - self.backupBrowseButton = QtGui.QToolButton(self.backup_page) + self.backupBrowseButton = QtWidgets.QToolButton(self.backup_page) self.backupBrowseButton.setIcon(self.open_icon) self.backupBrowseButton.setObjectName('BackupBrowseButton') self.backupDirectoryLayout.addWidget(self.backupBrowseButton) self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout) self.backupLayout.addLayout(self.formLayout) - self.noBackupCheckBox = QtGui.QCheckBox(self.backup_page) + self.noBackupCheckBox = QtWidgets.QCheckBox(self.backup_page) self.noBackupCheckBox.setObjectName('NoBackupCheckBox') self.backupLayout.addWidget(self.noBackupCheckBox) - self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) + self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) self.backupLayout.addItem(self.spacer) self.addPage(self.backup_page) # Select Page - self.selectPage = QtGui.QWizardPage() + self.selectPage = QtWidgets.QWizardPage() self.selectPage.setObjectName('SelectPage') - self.pageLayout = QtGui.QVBoxLayout(self.selectPage) + self.pageLayout = QtWidgets.QVBoxLayout(self.selectPage) self.pageLayout.setObjectName('pageLayout') - self.scrollArea = QtGui.QScrollArea(self.selectPage) + self.scrollArea = QtWidgets.QScrollArea(self.selectPage) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName('scrollArea') self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.scrollAreaContents = QtGui.QWidget(self.scrollArea) + self.scrollAreaContents = QtWidgets.QWidget(self.scrollArea) self.scrollAreaContents.setObjectName('scrollAreaContents') - self.formLayout = QtGui.QVBoxLayout(self.scrollAreaContents) + self.formLayout = QtWidgets.QVBoxLayout(self.scrollAreaContents) self.formLayout.setSpacing(2) self.formLayout.setObjectName('formLayout') self.addScrollArea() @@ -208,12 +208,12 @@ class BibleUpgradeForm(OpenLPWizard): self.checkBox = {} for number, filename in enumerate(self.files): bible = OldBibleDB(self.media_item, path=self.path, file=filename[0]) - self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) + self.checkBox[number] = QtWidgets.QCheckBox(self.scrollAreaContents) self.checkBox[number].setObjectName('checkBox[%d]' % number) self.checkBox[number].setText(bible.get_name()) self.checkBox[number].setCheckState(QtCore.Qt.Checked) self.formLayout.addWidget(self.checkBox[number]) - self.spacer_item = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.spacer_item = QtWidgets.QSpacerItem(20, 5, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.formLayout.addItem(self.spacer_item) self.scrollArea.setWidget(self.scrollAreaContents) diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 904b1d15a..b83e6b9c2 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -32,46 +32,46 @@ class Ui_BookNameDialog(object): book_name_dialog.setObjectName('book_name_dialog') book_name_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) book_name_dialog.resize(400, 271) - self.book_name_layout = QtGui.QVBoxLayout(book_name_dialog) + self.book_name_layout = QtWidgets.QVBoxLayout(book_name_dialog) self.book_name_layout.setSpacing(8) - self.book_name_layout.setMargin(8) + self.book_name_layout.setContentsMargins(8, 8, 8, 8) self.book_name_layout.setObjectName('book_name_layout') - self.info_label = QtGui.QLabel(book_name_dialog) + self.info_label = QtWidgets.QLabel(book_name_dialog) self.info_label.setWordWrap(True) self.info_label.setObjectName('info_label') self.book_name_layout.addWidget(self.info_label) - self.corresponding_layout = QtGui.QGridLayout() + self.corresponding_layout = QtWidgets.QGridLayout() self.corresponding_layout.setColumnStretch(1, 1) self.corresponding_layout.setSpacing(8) self.corresponding_layout.setObjectName('corresponding_layout') - self.current_label = QtGui.QLabel(book_name_dialog) + self.current_label = QtWidgets.QLabel(book_name_dialog) self.current_label.setObjectName('current_label') self.corresponding_layout.addWidget(self.current_label, 0, 0, 1, 1) - self.current_book_label = QtGui.QLabel(book_name_dialog) + self.current_book_label = QtWidgets.QLabel(book_name_dialog) self.current_book_label.setObjectName('current_book_label') self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1) - self.corresponding_label = QtGui.QLabel(book_name_dialog) + self.corresponding_label = QtWidgets.QLabel(book_name_dialog) self.corresponding_label.setObjectName('corresponding_label') self.corresponding_layout.addWidget(self.corresponding_label, 1, 0, 1, 1) - self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog) + self.corresponding_combo_box = QtWidgets.QComboBox(book_name_dialog) self.corresponding_combo_box.setObjectName('corresponding_combo_box') self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1) self.book_name_layout.addLayout(self.corresponding_layout) - self.options_group_box = QtGui.QGroupBox(book_name_dialog) + self.options_group_box = QtWidgets.QGroupBox(book_name_dialog) self.options_group_box.setObjectName('options_group_box') - self.options_layout = QtGui.QVBoxLayout(self.options_group_box) + self.options_layout = QtWidgets.QVBoxLayout(self.options_group_box) self.options_layout.setSpacing(8) - self.options_layout.setMargin(8) + self.options_layout.setContentsMargins(8, 8, 8, 8) self.options_layout.setObjectName('options_layout') - self.old_testament_check_box = QtGui.QCheckBox(self.options_group_box) + self.old_testament_check_box = QtWidgets.QCheckBox(self.options_group_box) self.old_testament_check_box.setObjectName('old_testament_check_box') self.old_testament_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.old_testament_check_box) - self.new_testament_check_box = QtGui.QCheckBox(self.options_group_box) + self.new_testament_check_box = QtWidgets.QCheckBox(self.options_group_box) self.new_testament_check_box.setObjectName('new_testament_check_box') self.new_testament_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.new_testament_check_box) - self.apocrypha_check_box = QtGui.QCheckBox(self.options_group_box) + self.apocrypha_check_box = QtWidgets.QCheckBox(self.options_group_box) self.apocrypha_check_box.setObjectName('apocrypha_check_box') self.apocrypha_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.apocrypha_check_box) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 136fc8642..2fe79510b 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -26,8 +26,8 @@ Module implementing BookNameForm. import logging import re -from PyQt4.QtGui import QDialog -from PyQt4 import QtCore +from PyQt5.QtWidgets import QDialog +from PyQt5 import QtCore from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box @@ -90,7 +90,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): if add_book: self.corresponding_combo_box.addItem(self.book_names[item['abbreviation']]) - def exec_(self, name, books, max_books): + def exec(self, name, books, max_books): self.books = books log.debug(max_books) if max_books <= 27: @@ -101,7 +101,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): self.reload_combo_box() self.current_book_label.setText(str(name)) self.corresponding_combo_box.setFocus() - return QDialog.exec_(self) + return QDialog.exec(self) def accept(self): if not self.corresponding_combo_box.currentText(): diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index d80f17eab..894eddb84 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -35,46 +35,46 @@ class Ui_EditBibleDialog(object): edit_bible_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) edit_bible_dialog.resize(520, 400) edit_bible_dialog.setModal(True) - self.dialog_layout = QtGui.QVBoxLayout(edit_bible_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(edit_bible_dialog) self.dialog_layout.setSpacing(8) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setObjectName('dialog_layout') - self.bible_tab_widget = QtGui.QTabWidget(edit_bible_dialog) + self.bible_tab_widget = QtWidgets.QTabWidget(edit_bible_dialog) self.bible_tab_widget.setObjectName('BibleTabWidget') # Meta tab - self.meta_tab = QtGui.QWidget() + self.meta_tab = QtWidgets.QWidget() self.meta_tab.setObjectName('meta_tab') - self.meta_tab_layout = QtGui.QVBoxLayout(self.meta_tab) + self.meta_tab_layout = QtWidgets.QVBoxLayout(self.meta_tab) self.meta_tab_layout.setObjectName('meta_tab_layout') - self.license_details_group_box = QtGui.QGroupBox(self.meta_tab) + self.license_details_group_box = QtWidgets.QGroupBox(self.meta_tab) self.license_details_group_box.setObjectName('license_details_group_box') - self.license_details_layout = QtGui.QFormLayout(self.license_details_group_box) + self.license_details_layout = QtWidgets.QFormLayout(self.license_details_group_box) self.license_details_layout.setObjectName('license_details_layout') - self.version_name_label = QtGui.QLabel(self.license_details_group_box) + self.version_name_label = QtWidgets.QLabel(self.license_details_group_box) self.version_name_label.setObjectName('version_name_label') - self.version_name_edit = QtGui.QLineEdit(self.license_details_group_box) + self.version_name_edit = QtWidgets.QLineEdit(self.license_details_group_box) self.version_name_edit.setObjectName('version_name_edit') self.version_name_label.setBuddy(self.version_name_edit) self.license_details_layout.addRow(self.version_name_label, self.version_name_edit) - self.copyright_label = QtGui.QLabel(self.license_details_group_box) + self.copyright_label = QtWidgets.QLabel(self.license_details_group_box) self.copyright_label.setObjectName('copyright_label') - self.copyright_edit = QtGui.QLineEdit(self.license_details_group_box) + self.copyright_edit = QtWidgets.QLineEdit(self.license_details_group_box) self.copyright_edit.setObjectName('copyright_edit') self.copyright_label.setBuddy(self.copyright_edit) self.license_details_layout.addRow(self.copyright_label, self.copyright_edit) - self.permissions_label = QtGui.QLabel(self.license_details_group_box) + self.permissions_label = QtWidgets.QLabel(self.license_details_group_box) self.permissions_label.setObjectName('permissions_label') - self.permissions_edit = QtGui.QLineEdit(self.license_details_group_box) + self.permissions_edit = QtWidgets.QLineEdit(self.license_details_group_box) self.permissions_edit.setObjectName('permissions_edit') self.permissions_label.setBuddy(self.permissions_edit) self.license_details_layout.addRow(self.permissions_label, self.permissions_edit) self.meta_tab_layout.addWidget(self.license_details_group_box) - self.language_selection_group_box = QtGui.QGroupBox(self.meta_tab) + self.language_selection_group_box = QtWidgets.QGroupBox(self.meta_tab) self.language_selection_group_box.setObjectName('language_selection_group_box') - self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box) - self.language_selection_label = QtGui.QLabel(self.language_selection_group_box) + self.language_selection_layout = QtWidgets.QVBoxLayout(self.language_selection_group_box) + self.language_selection_label = QtWidgets.QLabel(self.language_selection_group_box) self.language_selection_label.setObjectName('language_selection_label') - self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box) + self.language_selection_combo_box = QtWidgets.QComboBox(self.language_selection_group_box) self.language_selection_combo_box.setObjectName('language_selection_combo_box') self.language_selection_combo_box.addItems(['', '', '', '']) self.language_selection_layout.addWidget(self.language_selection_label) @@ -83,28 +83,28 @@ class Ui_EditBibleDialog(object): self.meta_tab_layout.addStretch() self.bible_tab_widget.addTab(self.meta_tab, '') # Book name tab - self.book_name_tab = QtGui.QWidget() + self.book_name_tab = QtWidgets.QWidget() self.book_name_tab.setObjectName('book_name_tab') - self.book_name_tab_layout = QtGui.QVBoxLayout(self.book_name_tab) + self.book_name_tab_layout = QtWidgets.QVBoxLayout(self.book_name_tab) self.book_name_tab_layout.setObjectName('book_name_tab_layout') - self.book_name_notice = QtGui.QLabel(self.book_name_tab) + self.book_name_notice = QtWidgets.QLabel(self.book_name_tab) self.book_name_notice.setObjectName('book_name_notice') self.book_name_notice.setWordWrap(True) self.book_name_tab_layout.addWidget(self.book_name_notice) - self.scroll_area = QtGui.QScrollArea(self.book_name_tab) + self.scroll_area = QtWidgets.QScrollArea(self.book_name_tab) self.scroll_area.setWidgetResizable(True) self.scroll_area.setObjectName('scroll_area') self.scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.book_name_widget = QtGui.QWidget(self.scroll_area) + self.book_name_widget = QtWidgets.QWidget(self.scroll_area) self.book_name_widget.setObjectName('book_name_widget') - self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget) + self.book_name_widget_layout = QtWidgets.QFormLayout(self.book_name_widget) self.book_name_widget_layout.setObjectName('book_name_widget_layout') self.book_name_label = {} self.book_name_edit = {} for book in BiblesResourcesDB.get_books(): - self.book_name_label[book['abbreviation']] = QtGui.QLabel(self.book_name_widget) + self.book_name_label[book['abbreviation']] = QtWidgets.QLabel(self.book_name_widget) self.book_name_label[book['abbreviation']].setObjectName('book_name_label[%s]' % book['abbreviation']) - self.book_name_edit[book['abbreviation']] = QtGui.QLineEdit(self.book_name_widget) + self.book_name_edit[book['abbreviation']] = QtWidgets.QLineEdit(self.book_name_widget) self.book_name_edit[book['abbreviation']].setObjectName('book_name_edit[%s]' % book['abbreviation']) self.book_name_widget_layout.addRow( self.book_name_label[book['abbreviation']], diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 548608b7c..64399dc2d 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -24,7 +24,7 @@ import logging import os import re -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import RegistryProperties, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box @@ -35,7 +35,7 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) -class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): +class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Class to manage the editing of a bible """ @@ -97,7 +97,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): """ log.debug('BibleEditForm.reject') self.bible = None - QtGui.QDialog.reject(self) + QtWidgets.QDialog.reject(self) def accept(self): """ @@ -130,7 +130,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): self.manager.update_book(self.bible, book) self.bible = None self.application.set_normal_cursor() - QtGui.QDialog.accept(self) + QtWidgets.QDialog.accept(self) def validate_meta(self, name, copyright): """ diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 1f2246488..2dc0566f7 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -32,25 +32,25 @@ class Ui_LanguageDialog(object): language_dialog.setObjectName('language_dialog') language_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) language_dialog.resize(400, 165) - self.language_layout = QtGui.QVBoxLayout(language_dialog) + self.language_layout = QtWidgets.QVBoxLayout(language_dialog) self.language_layout.setSpacing(8) - self.language_layout.setMargin(8) + self.language_layout.setContentsMargins(8, 8, 8, 8) self.language_layout.setObjectName('language_layout') - self.bible_label = QtGui.QLabel(language_dialog) + self.bible_label = QtWidgets.QLabel(language_dialog) self.bible_label.setObjectName('bible_label') self.language_layout.addWidget(self.bible_label) - self.info_label = QtGui.QLabel(language_dialog) + self.info_label = QtWidgets.QLabel(language_dialog) self.info_label.setWordWrap(True) self.info_label.setObjectName('info_label') self.language_layout.addWidget(self.info_label) - self.language_h_box_layout = QtGui.QHBoxLayout() + self.language_h_box_layout = QtWidgets.QHBoxLayout() self.language_h_box_layout.setSpacing(8) self.language_h_box_layout.setObjectName('language_h_box_layout') - self.language_label = QtGui.QLabel(language_dialog) + self.language_label = QtWidgets.QLabel(language_dialog) self.language_label.setObjectName('language_label') self.language_h_box_layout.addWidget(self.language_label) - self.language_combo_box = QtGui.QComboBox(language_dialog) - size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + self.language_combo_box = QtWidgets.QComboBox(language_dialog) + size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth()) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 37d6e68fb..f0e270a4a 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -25,7 +25,7 @@ Module implementing LanguageForm. """ import logging -from PyQt4.QtGui import QDialog +from PyQt5.QtWidgets import QDialog from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box @@ -49,13 +49,13 @@ class LanguageForm(QDialog, Ui_LanguageDialog): super(LanguageForm, self).__init__(parent) self.setupUi(self) - def exec_(self, bible_name): + def exec(self, bible_name): self.language_combo_box.addItem('') if bible_name: self.bible_label.setText(str(bible_name)) items = BiblesResourcesDB.get_languages() self.language_combo_box.addItems([item['name'] for item in items]) - return QDialog.exec_(self) + return QDialog.exec(self) def accept(self): if not self.language_combo_box.currentText(): diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 969f87363..f32bf6146 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.lib import SettingsTab @@ -48,81 +48,81 @@ class BiblesTab(SettingsTab): def setupUi(self): self.setObjectName('BiblesTab') super(BiblesTab, self).setupUi() - self.verse_display_group_box = QtGui.QGroupBox(self.left_column) + self.verse_display_group_box = QtWidgets.QGroupBox(self.left_column) self.verse_display_group_box.setObjectName('verse_display_group_box') - self.verse_display_layout = QtGui.QFormLayout(self.verse_display_group_box) + self.verse_display_layout = QtWidgets.QFormLayout(self.verse_display_group_box) self.verse_display_layout.setObjectName('verse_display_layout') - self.is_verse_number_visible_check_box = QtGui.QCheckBox(self.verse_display_group_box) + self.is_verse_number_visible_check_box = QtWidgets.QCheckBox(self.verse_display_group_box) self.is_verse_number_visible_check_box.setObjectName('is_verse_number_visible_check_box') self.verse_display_layout.addRow(self.is_verse_number_visible_check_box) - self.new_chapters_check_box = QtGui.QCheckBox(self.verse_display_group_box) + self.new_chapters_check_box = QtWidgets.QCheckBox(self.verse_display_group_box) self.new_chapters_check_box.setObjectName('new_chapters_check_box') self.verse_display_layout.addRow(self.new_chapters_check_box) - self.display_style_label = QtGui.QLabel(self.verse_display_group_box) + self.display_style_label = QtWidgets.QLabel(self.verse_display_group_box) self.display_style_label.setObjectName('display_style_label') - self.display_style_combo_box = QtGui.QComboBox(self.verse_display_group_box) + self.display_style_combo_box = QtWidgets.QComboBox(self.verse_display_group_box) self.display_style_combo_box.addItems(['', '', '', '']) self.display_style_combo_box.setObjectName('display_style_combo_box') self.verse_display_layout.addRow(self.display_style_label, self.display_style_combo_box) - self.layout_style_label = QtGui.QLabel(self.verse_display_group_box) + self.layout_style_label = QtWidgets.QLabel(self.verse_display_group_box) self.layout_style_label.setObjectName('layout_style_label') - self.layout_style_combo_box = QtGui.QComboBox(self.verse_display_group_box) + self.layout_style_combo_box = QtWidgets.QComboBox(self.verse_display_group_box) self.layout_style_combo_box.setObjectName('layout_style_combo_box') self.layout_style_combo_box.addItems(['', '', '']) self.verse_display_layout.addRow(self.layout_style_label, self.layout_style_combo_box) - self.bible_second_check_box = QtGui.QCheckBox(self.verse_display_group_box) + self.bible_second_check_box = QtWidgets.QCheckBox(self.verse_display_group_box) self.bible_second_check_box.setObjectName('bible_second_check_box') self.verse_display_layout.addRow(self.bible_second_check_box) - self.bible_theme_label = QtGui.QLabel(self.verse_display_group_box) + self.bible_theme_label = QtWidgets.QLabel(self.verse_display_group_box) self.bible_theme_label.setObjectName('BibleTheme_label') - self.bible_theme_combo_box = QtGui.QComboBox(self.verse_display_group_box) - self.bible_theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - self.bible_theme_combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + self.bible_theme_combo_box = QtWidgets.QComboBox(self.verse_display_group_box) + self.bible_theme_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToMinimumContentsLength) + self.bible_theme_combo_box.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.bible_theme_combo_box.addItem('') self.bible_theme_combo_box.setObjectName('BibleThemecombo_box') self.verse_display_layout.addRow(self.bible_theme_label, self.bible_theme_combo_box) - self.change_note_label = QtGui.QLabel(self.verse_display_group_box) + self.change_note_label = QtWidgets.QLabel(self.verse_display_group_box) self.change_note_label.setWordWrap(True) self.change_note_label.setObjectName('change_note_label') self.verse_display_layout.addRow(self.change_note_label) self.left_layout.addWidget(self.verse_display_group_box) - self.scripture_reference_group_box = QtGui.QGroupBox(self.left_column) + self.scripture_reference_group_box = QtWidgets.QGroupBox(self.left_column) self.scripture_reference_group_box.setObjectName('scripture_reference_group_box') - self.scripture_reference_layout = QtGui.QGridLayout(self.scripture_reference_group_box) - self.verse_separator_check_box = QtGui.QCheckBox(self.scripture_reference_group_box) + self.scripture_reference_layout = QtWidgets.QGridLayout(self.scripture_reference_group_box) + self.verse_separator_check_box = QtWidgets.QCheckBox(self.scripture_reference_group_box) self.verse_separator_check_box.setObjectName('verse_separator_check_box') self.scripture_reference_layout.addWidget(self.verse_separator_check_box, 0, 0) - self.verse_separator_line_edit = QtGui.QLineEdit(self.scripture_reference_group_box) + self.verse_separator_line_edit = QtWidgets.QLineEdit(self.scripture_reference_group_box) self.verse_separator_line_edit.setObjectName('verse_separator_line_edit') self.scripture_reference_layout.addWidget(self.verse_separator_line_edit, 0, 1) - self.range_separator_check_box = QtGui.QCheckBox(self.scripture_reference_group_box) + self.range_separator_check_box = QtWidgets.QCheckBox(self.scripture_reference_group_box) self.range_separator_check_box.setObjectName('range_separator_check_box') self.scripture_reference_layout.addWidget(self.range_separator_check_box, 1, 0) - self.range_separator_line_edit = QtGui.QLineEdit(self.scripture_reference_group_box) + self.range_separator_line_edit = QtWidgets.QLineEdit(self.scripture_reference_group_box) self.range_separator_line_edit.setObjectName('range_separator_line_edit') self.scripture_reference_layout.addWidget(self.range_separator_line_edit, 1, 1) - self.list_separator_check_box = QtGui.QCheckBox(self.scripture_reference_group_box) + self.list_separator_check_box = QtWidgets.QCheckBox(self.scripture_reference_group_box) self.list_separator_check_box.setObjectName('list_separator_check_box') self.scripture_reference_layout.addWidget(self.list_separator_check_box, 2, 0) - self.list_separator_line_edit = QtGui.QLineEdit(self.scripture_reference_group_box) + self.list_separator_line_edit = QtWidgets.QLineEdit(self.scripture_reference_group_box) self.list_separator_line_edit.setObjectName('list_separator_line_edit') self.scripture_reference_layout.addWidget(self.list_separator_line_edit, 2, 1) - self.end_separator_check_box = QtGui.QCheckBox(self.scripture_reference_group_box) + self.end_separator_check_box = QtWidgets.QCheckBox(self.scripture_reference_group_box) self.end_separator_check_box.setObjectName('end_separator_check_box') self.scripture_reference_layout.addWidget(self.end_separator_check_box, 3, 0) - self.end_separator_line_edit = QtGui.QLineEdit(self.scripture_reference_group_box) + self.end_separator_line_edit = QtWidgets.QLineEdit(self.scripture_reference_group_box) self.end_separator_line_edit.setObjectName('end_separator_line_edit') self.end_separator_line_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^0-9]*'), self.end_separator_line_edit)) self.scripture_reference_layout.addWidget(self.end_separator_line_edit, 3, 1) self.left_layout.addWidget(self.scripture_reference_group_box) - self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) - self.language_selection_group_box = QtGui.QGroupBox(self.right_column) + self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + self.language_selection_group_box = QtWidgets.QGroupBox(self.right_column) self.language_selection_group_box.setObjectName('language_selection_group_box') - self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box) - self.language_selection_label = QtGui.QLabel(self.language_selection_group_box) + self.language_selection_layout = QtWidgets.QVBoxLayout(self.language_selection_group_box) + self.language_selection_label = QtWidgets.QLabel(self.language_selection_group_box) self.language_selection_label.setObjectName('language_selection_label') - self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box) + self.language_selection_combo_box = QtWidgets.QComboBox(self.language_selection_group_box) self.language_selection_combo_box.setObjectName('language_selection_combo_box') self.language_selection_combo_box.addItems(['', '', '']) self.language_selection_layout.addWidget(self.language_selection_label) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index e6ca14027..a749ca2c3 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -27,7 +27,7 @@ import re import sqlite3 import time -from PyQt4 import QtCore +from PyQt5 import QtCore from sqlalchemy import Column, ForeignKey, Table, or_, types, func from sqlalchemy.exc import OperationalError from sqlalchemy.orm import class_mapper, mapper, relation @@ -107,7 +107,7 @@ def init_schema(url): return session -class BibleDB(QtCore.QObject, Manager, RegistryProperties): +class BibleDB(Manager, RegistryProperties): """ This class represents a database-bound Bible. It is used as a base class for all the custom importers, so that the can implement their own import methods, but benefit from the database methods in here via inheritance, @@ -129,7 +129,6 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): The name of the database. This is also used as the file name for SQLite databases. """ log.info('BibleDB loaded') - QtCore.QObject.__init__(self) self.bible_plugin = parent self.session = None if 'path' not in kwargs: @@ -315,7 +314,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): else: from openlp.plugins.bibles.forms import BookNameForm book_name = BookNameForm(self.wizard) - if book_name.exec_(book, self.get_books(), maxbooks): + if book_name.exec(book, self.get_books(), maxbooks): book_id = book_name.book_id if book_id: AlternativeBookNamesDB.create_alternative_book_name( @@ -467,7 +466,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): from openlp.plugins.bibles.forms import LanguageForm language = None language_form = LanguageForm(self.wizard) - if language_form.exec_(bible_name): + if language_form.exec(bible_name): language = str(language_form.language_combo_box.currentText()) if not language: return False diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c838c3b9c..98a0175f2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, create_separated_list @@ -51,6 +51,8 @@ class BibleMediaItem(MediaManagerItem): """ This is the custom media manager item for Bibles. """ + bibles_go_live = QtCore.pyqtSignal(list) + bibles_add_to_service = QtCore.pyqtSignal(list) log.info('Bible Media Item loaded') def __init__(self, parent, plugin): @@ -62,6 +64,8 @@ class BibleMediaItem(MediaManagerItem): """ Do some additional setup. """ + self.bibles_go_live.connect(self.go_live_remote) + self.bibles_add_to_service.connect(self.add_to_service_remote) # Place to store the search results for both bibles. self.settings = self.plugin.settings_tab self.quick_preview_allowed = True @@ -89,7 +93,7 @@ class BibleMediaItem(MediaManagerItem): message=translate('BiblesPlugin.MediaItem', 'You cannot combine single and dual Bible verse search results. ' 'Do you want to delete your search results and start a new search?'), - parent=self, question=True) == QtGui.QMessageBox.Yes: + parent=self, question=True) == QtWidgets.QMessageBox.Yes: self.list_view.clear() self.display_results(bible, second_bible) @@ -111,10 +115,10 @@ class BibleMediaItem(MediaManagerItem): def add_search_tab(self, prefix, name): self.search_tab_bar.addTab(name) - tab = QtGui.QWidget() + tab = QtWidgets.QWidget() tab.setObjectName(prefix + 'Tab') - tab.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) - layout = QtGui.QGridLayout(tab) + tab.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) + layout = QtWidgets.QGridLayout(tab) layout.setObjectName(prefix + 'Layout') setattr(self, prefix + 'Tab', tab) setattr(self, prefix + 'Layout', layout) @@ -132,33 +136,33 @@ class BibleMediaItem(MediaManagerItem): idx = 5 tab = getattr(self, prefix + 'Tab') layout = getattr(self, prefix + 'Layout') - version_label = QtGui.QLabel(tab) + version_label = QtWidgets.QLabel(tab) version_label.setObjectName(prefix + 'VersionLabel') layout.addWidget(version_label, idx, 0, QtCore.Qt.AlignRight) version_combo_box = create_horizontal_adjusting_combo_box(tab, prefix + 'VersionComboBox') version_label.setBuddy(version_combo_box) layout.addWidget(version_combo_box, idx, 1, 1, 2) - second_label = QtGui.QLabel(tab) + second_label = QtWidgets.QLabel(tab) second_label.setObjectName(prefix + 'SecondLabel') layout.addWidget(second_label, idx + 1, 0, QtCore.Qt.AlignRight) second_combo_box = create_horizontal_adjusting_combo_box(tab, prefix + 'SecondComboBox') version_label.setBuddy(second_combo_box) layout.addWidget(second_combo_box, idx + 1, 1, 1, 2) - style_label = QtGui.QLabel(tab) + style_label = QtWidgets.QLabel(tab) style_label.setObjectName(prefix + 'StyleLabel') layout.addWidget(style_label, idx + 2, 0, QtCore.Qt.AlignRight) style_combo_box = create_horizontal_adjusting_combo_box(tab, prefix + 'StyleComboBox') style_combo_box.addItems(['', '', '']) layout.addWidget(style_combo_box, idx + 2, 1, 1, 2) - search_button_layout = QtGui.QHBoxLayout() + search_button_layout = QtWidgets.QHBoxLayout() search_button_layout.setObjectName(prefix + 'search_button_layout') search_button_layout.addStretch() - lock_button = QtGui.QToolButton(tab) + lock_button = QtWidgets.QToolButton(tab) lock_button.setIcon(self.unlock_icon) lock_button.setCheckable(True) lock_button.setObjectName(prefix + 'LockButton') search_button_layout.addWidget(lock_button) - search_button = QtGui.QPushButton(tab) + search_button = QtWidgets.QPushButton(tab) search_button.setObjectName(prefix + 'SearchButton') search_button_layout.addWidget(search_button) layout.addLayout(search_button_layout, idx + 3, 1, 1, 2) @@ -177,17 +181,17 @@ class BibleMediaItem(MediaManagerItem): setattr(self, prefix + 'SearchButton', search_button) def add_end_header_bar(self): - self.search_tab_bar = QtGui.QTabBar(self) + self.search_tab_bar = QtWidgets.QTabBar(self) self.search_tab_bar.setExpanding(False) self.search_tab_bar.setObjectName('search_tab_bar') self.page_layout.addWidget(self.search_tab_bar) # Add the Quick Search tab. self.add_search_tab('quick', translate('BiblesPlugin.MediaItem', 'Quick')) - self.quick_search_label = QtGui.QLabel(self.quickTab) + self.quick_search_label = QtWidgets.QLabel(self.quickTab) self.quick_search_label.setObjectName('quick_search_label') self.quickLayout.addWidget(self.quick_search_label, 0, 0, QtCore.Qt.AlignRight) self.quick_search_edit = SearchEdit(self.quickTab) - self.quick_search_edit.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Fixed) + self.quick_search_edit.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Fixed) self.quick_search_edit.setObjectName('quick_search_edit') self.quick_search_label.setBuddy(self.quick_search_edit) self.quickLayout.addWidget(self.quick_search_edit, 0, 1, 1, 2) @@ -195,35 +199,35 @@ class BibleMediaItem(MediaManagerItem): self.quickTab.setVisible(True) # Add the Advanced Search tab. self.add_search_tab('advanced', translate('BiblesPlugin.MediaItem', 'Advanced')) - self.advanced_book_label = QtGui.QLabel(self.advancedTab) + self.advanced_book_label = QtWidgets.QLabel(self.advancedTab) self.advanced_book_label.setObjectName('advanced_book_label') self.advancedLayout.addWidget(self.advanced_book_label, 0, 0, QtCore.Qt.AlignRight) self.advanced_book_combo_box = create_horizontal_adjusting_combo_box(self.advancedTab, 'advanced_book_combo_box') self.advanced_book_label.setBuddy(self.advanced_book_combo_box) self.advancedLayout.addWidget(self.advanced_book_combo_box, 0, 1, 1, 2) - self.advanced_chapter_label = QtGui.QLabel(self.advancedTab) + self.advanced_chapter_label = QtWidgets.QLabel(self.advancedTab) self.advanced_chapter_label.setObjectName('advanced_chapter_label') self.advancedLayout.addWidget(self.advanced_chapter_label, 1, 1, 1, 2) - self.advanced_verse_label = QtGui.QLabel(self.advancedTab) + self.advanced_verse_label = QtWidgets.QLabel(self.advancedTab) self.advanced_verse_label.setObjectName('advanced_verse_label') self.advancedLayout.addWidget(self.advanced_verse_label, 1, 2) - self.advanced_from_label = QtGui.QLabel(self.advancedTab) + self.advanced_from_label = QtWidgets.QLabel(self.advancedTab) self.advanced_from_label.setObjectName('advanced_from_label') self.advancedLayout.addWidget(self.advanced_from_label, 3, 0, QtCore.Qt.AlignRight) - self.advanced_from_chapter = QtGui.QComboBox(self.advancedTab) + self.advanced_from_chapter = QtWidgets.QComboBox(self.advancedTab) self.advanced_from_chapter.setObjectName('advanced_from_chapter') self.advancedLayout.addWidget(self.advanced_from_chapter, 3, 1) - self.advanced_from_verse = QtGui.QComboBox(self.advancedTab) + self.advanced_from_verse = QtWidgets.QComboBox(self.advancedTab) self.advanced_from_verse.setObjectName('advanced_from_verse') self.advancedLayout.addWidget(self.advanced_from_verse, 3, 2) - self.advanced_to_label = QtGui.QLabel(self.advancedTab) + self.advanced_to_label = QtWidgets.QLabel(self.advancedTab) self.advanced_to_label.setObjectName('advanced_to_label') self.advancedLayout.addWidget(self.advanced_to_label, 4, 0, QtCore.Qt.AlignRight) - self.advanced_to_chapter = QtGui.QComboBox(self.advancedTab) + self.advanced_to_chapter = QtWidgets.QComboBox(self.advancedTab) self.advanced_to_chapter.setObjectName('advanced_to_chapter') self.advancedLayout.addWidget(self.advanced_to_chapter, 4, 1) - self.advanced_to_verse = QtGui.QComboBox(self.advancedTab) + self.advanced_to_verse = QtWidgets.QComboBox(self.advancedTab) self.advanced_to_verse.setObjectName('advanced_to_verse') self.advancedLayout.addWidget(self.advanced_to_verse, 4, 2) self.add_search_fields('advanced', UiStrings().Advanced) @@ -236,8 +240,7 @@ class BibleMediaItem(MediaManagerItem): self.advanced_from_chapter.activated.connect(self.on_advanced_from_chapter) self.advanced_from_verse.activated.connect(self.on_advanced_from_verse) self.advanced_to_chapter.activated.connect(self.on_advanced_to_chapter) - QtCore.QObject.connect(self.quick_search_edit, QtCore.SIGNAL('searchTypeChanged(int)'), - self.update_auto_completer) + self.quick_search_edit.searchTypeChanged.connect(self.update_auto_completer) self.quickVersionComboBox.activated.connect(self.update_auto_completer) self.quickStyleComboBox.activated.connect(self.on_quick_style_combo_box_changed) self.advancedStyleComboBox.activated.connect(self.on_advanced_style_combo_box_changed) @@ -472,7 +475,7 @@ class BibleMediaItem(MediaManagerItem): if not hasattr(self, 'import_wizard'): self.import_wizard = BibleImportForm(self, self.plugin.manager, self.plugin) # If the import was not cancelled then reload. - if self.import_wizard.exec_(): + if self.import_wizard.exec(): self.reload_bibles() def on_edit_click(self): @@ -483,7 +486,7 @@ class BibleMediaItem(MediaManagerItem): if bible: self.edit_bible_form = EditBibleForm(self, self.main_window, self.plugin.manager) self.edit_bible_form.load_bible(bible) - if self.edit_bible_form.exec_(): + if self.edit_bible_form.exec(): self.reload_bibles() def on_delete_click(self): @@ -496,13 +499,13 @@ class BibleMediaItem(MediaManagerItem): elif self.advancedTab.isVisible(): bible = self.advancedVersionComboBox.currentText() if bible: - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('BiblesPlugin.MediaItem', 'Are you sure you want to completely delete "%s" Bible from ' 'OpenLP?\n\nYou will need to re-import this Bible to use it ' 'again.') % bible, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return self.plugin.manager.delete_bible(bible) self.reload_bibles() @@ -682,12 +685,12 @@ class BibleMediaItem(MediaManagerItem): new_search_results.append(verse) text.append((verse.book.book_reference_id, verse.chapter, verse.verse, verse.verse)) if passage_not_found: - QtGui.QMessageBox.information( + QtWidgets.QMessageBox.information( self, translate('BiblesPlugin.MediaItem', 'Information'), translate('BiblesPlugin.MediaItem', 'The second Bible does not contain all the verses ' 'that are in the main Bible. Only verses found in both Bibles will be shown. %d ' 'verses have not been included in the results.') % count, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) self.search_results = new_search_results self.second_search_results = bibles[second_bible].get_verses(text) if not self.quickLockButton.isChecked(): @@ -764,7 +767,7 @@ class BibleMediaItem(MediaManagerItem): second_version) else: bible_text = '%s %d%s%d (%s)' % (book, verse.chapter, verse_separator, verse.verse, version) - bible_verse = QtGui.QListWidgetItem(bible_text) + bible_verse = QtWidgets.QListWidgetItem(bible_text) bible_verse.setData(QtCore.Qt.UserRole, data) items.append(bible_verse) return items diff --git a/openlp/plugins/custom/forms/editcustomdialog.py b/openlp/plugins/custom/forms/editcustomdialog.py index c29acacc7..16bb1413b 100644 --- a/openlp/plugins/custom/forms/editcustomdialog.py +++ b/openlp/plugins/custom/forms/editcustomdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -36,34 +36,34 @@ class Ui_CustomEditDialog(object): custom_edit_dialog.setObjectName('custom_edit_dialog') custom_edit_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) custom_edit_dialog.resize(450, 350) - self.dialog_layout = QtGui.QVBoxLayout(custom_edit_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(custom_edit_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.title_layout = QtGui.QHBoxLayout() + self.title_layout = QtWidgets.QHBoxLayout() self.title_layout.setObjectName('title_layout') - self.title_label = QtGui.QLabel(custom_edit_dialog) + self.title_label = QtWidgets.QLabel(custom_edit_dialog) self.title_label.setObjectName('title_label') self.title_layout.addWidget(self.title_label) - self.title_edit = QtGui.QLineEdit(custom_edit_dialog) + self.title_edit = QtWidgets.QLineEdit(custom_edit_dialog) self.title_label.setBuddy(self.title_edit) self.title_edit.setObjectName('title_edit') self.title_layout.addWidget(self.title_edit) self.dialog_layout.addLayout(self.title_layout) - self.central_layout = QtGui.QHBoxLayout() + self.central_layout = QtWidgets.QHBoxLayout() self.central_layout.setObjectName('central_layout') - self.slide_list_view = QtGui.QListWidget(custom_edit_dialog) + self.slide_list_view = QtWidgets.QListWidget(custom_edit_dialog) self.slide_list_view.setAlternatingRowColors(True) self.slide_list_view.setObjectName('slide_list_view') self.central_layout.addWidget(self.slide_list_view) - self.button_layout = QtGui.QVBoxLayout() + self.button_layout = QtWidgets.QVBoxLayout() self.button_layout.setObjectName('button_layout') - self.add_button = QtGui.QPushButton(custom_edit_dialog) + self.add_button = QtWidgets.QPushButton(custom_edit_dialog) self.add_button.setObjectName('add_button') self.button_layout.addWidget(self.add_button) - self.edit_button = QtGui.QPushButton(custom_edit_dialog) + self.edit_button = QtWidgets.QPushButton(custom_edit_dialog) self.edit_button.setEnabled(False) self.edit_button.setObjectName('edit_button') self.button_layout.addWidget(self.edit_button) - self.edit_all_button = QtGui.QPushButton(custom_edit_dialog) + self.edit_all_button = QtWidgets.QPushButton(custom_edit_dialog) self.edit_all_button.setObjectName('edit_all_button') self.button_layout.addWidget(self.edit_all_button) self.delete_button = create_button(custom_edit_dialog, 'delete_button', role='delete', @@ -79,23 +79,23 @@ class Ui_CustomEditDialog(object): self.button_layout.addWidget(self.down_button) self.central_layout.addLayout(self.button_layout) self.dialog_layout.addLayout(self.central_layout) - self.bottom_form_layout = QtGui.QFormLayout() + self.bottom_form_layout = QtWidgets.QFormLayout() self.bottom_form_layout.setObjectName('bottom_form_layout') - self.theme_label = QtGui.QLabel(custom_edit_dialog) + self.theme_label = QtWidgets.QLabel(custom_edit_dialog) self.theme_label.setObjectName('theme_label') - self.theme_combo_box = QtGui.QComboBox(custom_edit_dialog) - self.theme_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.theme_combo_box = QtWidgets.QComboBox(custom_edit_dialog) + self.theme_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents) self.theme_combo_box.setObjectName('theme_combo_box') self.theme_label.setBuddy(self.theme_combo_box) self.bottom_form_layout.addRow(self.theme_label, self.theme_combo_box) - self.credit_label = QtGui.QLabel(custom_edit_dialog) + self.credit_label = QtWidgets.QLabel(custom_edit_dialog) self.credit_label.setObjectName('credit_label') - self.credit_edit = QtGui.QLineEdit(custom_edit_dialog) + self.credit_edit = QtWidgets.QLineEdit(custom_edit_dialog) self.credit_edit.setObjectName('credit_edit') self.credit_label.setBuddy(self.credit_edit) self.bottom_form_layout.addRow(self.credit_label, self.credit_edit) self.dialog_layout.addLayout(self.bottom_form_layout) - self.preview_button = QtGui.QPushButton() + self.preview_button = QtWidgets.QPushButton() self.button_box = create_button_box(custom_edit_dialog, 'button_box', ['cancel', 'save'], [self.preview_button]) self.dialog_layout.addWidget(self.button_box) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 6b8a302c7..42dad7410 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Registry, translate from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box @@ -34,7 +34,7 @@ from .editcustomslideform import EditCustomSlideForm log = logging.getLogger(__name__) -class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): +class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog): """ Class documentation goes here. """ @@ -101,7 +101,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): """ log.debug('accept') if self.save_custom(): - QtGui.QDialog.accept(self) + QtWidgets.QDialog.accept(self) def save_custom(self): """ @@ -146,7 +146,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Add a new blank slide. """ self.edit_slide_form.set_text('') - if self.edit_slide_form.exec_(): + if self.edit_slide_form.exec(): self.slide_list_view.addItems(self.edit_slide_form.get_text()) def on_edit_button_clicked(self): @@ -154,7 +154,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Edit the currently selected slide. """ self.edit_slide_form.set_text(self.slide_list_view.currentItem().text()) - if self.edit_slide_form.exec_(): + if self.edit_slide_form.exec(): self.update_slide_list(self.edit_slide_form.get_text()) def on_edit_all_button_clicked(self): @@ -168,7 +168,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): if row != self.slide_list_view.count() - 1: slide_text += '\n[===]\n' self.edit_slide_form.set_text(slide_text) - if self.edit_slide_form.exec_(): + if self.edit_slide_form.exec(): self.update_slide_list(self.edit_slide_form.get_text(), True) def on_preview_button_clicked(self): diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index 2abea2014..22e5f4209 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import SpellTextEdit, build_icon @@ -32,7 +32,7 @@ class Ui_CustomSlideEditDialog(object): custom_slide_edit_dialog.setObjectName('custom_slide_edit_dialog') custom_slide_edit_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) custom_slide_edit_dialog.resize(350, 300) - self.dialog_layout = QtGui.QVBoxLayout(custom_slide_edit_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(custom_slide_edit_dialog) self.slide_text_edit = SpellTextEdit(self) self.slide_text_edit.setObjectName('slide_text_edit') self.dialog_layout.addWidget(self.slide_text_edit) diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index 7370067b7..fb4ba3535 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -22,14 +22,14 @@ import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from .editcustomslidedialog import Ui_CustomSlideEditDialog log = logging.getLogger(__name__) -class EditCustomSlideForm(QtGui.QDialog, Ui_CustomSlideEditDialog): +class EditCustomSlideForm(QtWidgets.QDialog, Ui_CustomSlideEditDialog): """ Class documentation goes here. """ diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index 15dbf328f..5f886e783 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -24,7 +24,7 @@ The :mod:`~openlp.plugins.custom.lib.customtab` module contains the settings tab for the Custom Slides plugin, which is inserted into the configuration dialog. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Settings, translate from openlp.core.lib import SettingsTab @@ -40,14 +40,14 @@ class CustomTab(SettingsTab): def setupUi(self): self.setObjectName('CustomTab') super(CustomTab, self).setupUi() - self.custom_mode_group_box = QtGui.QGroupBox(self.left_column) + self.custom_mode_group_box = QtWidgets.QGroupBox(self.left_column) self.custom_mode_group_box.setObjectName('custom_mode_group_box') - self.custom_mode_layout = QtGui.QFormLayout(self.custom_mode_group_box) + self.custom_mode_layout = QtWidgets.QFormLayout(self.custom_mode_group_box) self.custom_mode_layout.setObjectName('custom_mode_layout') - self.display_footer_check_box = QtGui.QCheckBox(self.custom_mode_group_box) + self.display_footer_check_box = QtWidgets.QCheckBox(self.custom_mode_group_box) self.display_footer_check_box.setObjectName('display_footer_check_box') self.custom_mode_layout.addRow(self.display_footer_check_box) - self.add_from_service_checkbox = QtGui.QCheckBox(self.custom_mode_group_box) + self.add_from_service_checkbox = QtWidgets.QCheckBox(self.custom_mode_group_box) self.add_from_service_checkbox.setObjectName('add_from_service_checkbox') self.custom_mode_layout.addRow(self.add_from_service_checkbox) self.left_layout.addWidget(self.custom_mode_group_box) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index a2799618e..08e647580 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from sqlalchemy.sql import or_, func, and_ from openlp.core.common import Registry, Settings, UiStrings, translate @@ -47,6 +47,8 @@ class CustomMediaItem(MediaManagerItem): """ This is the custom media manager item for Custom Slides. """ + custom_go_live = QtCore.pyqtSignal(list) + custom_add_to_service = QtCore.pyqtSignal(list) log.info('Custom Media Item loaded') def __init__(self, parent, plugin): @@ -57,6 +59,8 @@ class CustomMediaItem(MediaManagerItem): """ Do some additional setup. """ + self.custom_go_live.connect(self.go_live_remote) + self.custom_add_to_service.connect(self.add_to_service_remote) self.edit_custom_form = EditCustomForm(self, self.main_window, self.plugin.db_manager) self.single_service_item = False self.quick_preview_allowed = True @@ -72,9 +76,8 @@ class CustomMediaItem(MediaManagerItem): self.toolbar.addSeparator() self.add_search_to_toolbar() # Signals and slots - QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL('cleared()'), self.on_clear_text_button_click) - QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL('searchTypeChanged(int)'), - self.on_search_text_button_clicked) + self.search_text_edit.cleared.connect(self.on_clear_text_button_click) + self.search_text_edit.searchTypeChanged.connect(self.on_search_text_button_clicked) Registry().register_function('custom_load_list', self.load_list) Registry().register_function('custom_preview', self.on_preview_click) Registry().register_function('custom_create_from_service', self.create_from_service_item) @@ -117,7 +120,7 @@ class CustomMediaItem(MediaManagerItem): self.list_view.clear() custom_slides.sort() for custom_slide in custom_slides: - custom_name = QtGui.QListWidgetItem(custom_slide.title) + custom_name = QtWidgets.QListWidgetItem(custom_slide.title) custom_name.setData(QtCore.Qt.UserRole, custom_slide.id) self.list_view.addItem(custom_name) # Auto-select the custom. @@ -134,7 +137,7 @@ class CustomMediaItem(MediaManagerItem): Handle the New item event """ self.edit_custom_form.load_custom(0) - self.edit_custom_form.exec_() + self.edit_custom_form.exec() self.on_clear_text_button_click() self.on_selection_change() @@ -150,7 +153,7 @@ class CustomMediaItem(MediaManagerItem): valid = self.plugin.db_manager.get_object(CustomSlide, custom_id) if valid: self.edit_custom_form.load_custom(custom_id, preview) - if self.edit_custom_form.exec_() == QtGui.QDialog.Accepted: + if self.edit_custom_form.exec() == QtWidgets.QDialog.Accepted: self.remote_triggered = True self.remote_custom = custom_id self.auto_select_id = -1 @@ -174,7 +177,7 @@ class CustomMediaItem(MediaManagerItem): item = self.list_view.currentItem() item_id = item.data(QtCore.Qt.UserRole) self.edit_custom_form.load_custom(item_id, False) - self.edit_custom_form.exec_() + self.edit_custom_form.exec() self.auto_select_id = -1 self.on_search_text_button_clicked() @@ -184,13 +187,14 @@ class CustomMediaItem(MediaManagerItem): """ if check_item_selected(self.list_view, UiStrings().SelectDelete): items = self.list_view.selectedIndexes() - if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, - translate('CustomPlugin.MediaItem', - 'Are you sure you want to delete the %n selected custom slide(s)?', - '', QtCore.QCoreApplication.CodecForTr, len(items)), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: + if QtWidgets.QMessageBox.question( + self, UiStrings().ConfirmDelete, + translate('CustomPlugin.MediaItem', + 'Are you sure you want to delete the %n selected custom slide(s)?', + '', QtCore.QCoreApplication.CodecForTr, len(items)), + QtWidgets.QMessageBox.StandardButtons( + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return row_list = [item.row() for item in self.list_view.selectedIndexes()] row_list.sort(reverse=True) diff --git a/openlp/plugins/images/forms/__init__.py b/openlp/plugins/images/forms/__init__.py index 759495b95..17a07fcc6 100644 --- a/openlp/plugins/images/forms/__init__.py +++ b/openlp/plugins/images/forms/__init__.py @@ -24,14 +24,14 @@ Forms in OpenLP are made up of two classes. One class holds all the graphical el other class holds all the functional code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly -modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be +modified version of the class that the ``pyuic5`` command produces from Qt5's .ui file. Typical modifications will be converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which -is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned -above, like so:: +is instantiated and used. It uses dual inheritance to inherit from (usually) QtWidgets.QDialog and the Ui class +mentioned above, like so:: - class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): + class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): def __init__(self, parent=None): super(AuthorsForm, self).__init__(parent) diff --git a/openlp/plugins/images/forms/addgroupdialog.py b/openlp/plugins/images/forms/addgroupdialog.py index 1babf6ac3..b34cb177e 100644 --- a/openlp/plugins/images/forms/addgroupdialog.py +++ b/openlp/plugins/images/forms/addgroupdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib.ui import create_button_box @@ -30,18 +30,18 @@ class Ui_AddGroupDialog(object): def setupUi(self, add_group_dialog): add_group_dialog.setObjectName('add_group_dialog') add_group_dialog.resize(300, 10) - self.dialog_layout = QtGui.QVBoxLayout(add_group_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(add_group_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.name_layout = QtGui.QFormLayout() + self.name_layout = QtWidgets.QFormLayout() self.name_layout.setObjectName('name_layout') - self.parent_group_label = QtGui.QLabel(add_group_dialog) + self.parent_group_label = QtWidgets.QLabel(add_group_dialog) self.parent_group_label.setObjectName('parent_group_label') - self.parent_group_combobox = QtGui.QComboBox(add_group_dialog) + self.parent_group_combobox = QtWidgets.QComboBox(add_group_dialog) self.parent_group_combobox.setObjectName('parent_group_combobox') self.name_layout.addRow(self.parent_group_label, self.parent_group_combobox) - self.name_label = QtGui.QLabel(add_group_dialog) + self.name_label = QtWidgets.QLabel(add_group_dialog) self.name_label.setObjectName('name_label') - self.name_edit = QtGui.QLineEdit(add_group_dialog) + self.name_edit = QtWidgets.QLineEdit(add_group_dialog) self.name_edit.setObjectName('name_edit') self.name_label.setBuddy(self.name_edit) self.name_layout.addRow(self.name_label, self.name_edit) diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index 4d0dc24cc..6dc5c51d3 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -20,14 +20,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.images.forms.addgroupdialog import Ui_AddGroupDialog -class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): +class AddGroupForm(QtWidgets.QDialog, Ui_AddGroupDialog): """ This class implements the 'Add group' form for the Images plugin. """ @@ -38,7 +38,7 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): super(AddGroupForm, self).__init__(parent) self.setupUi(self) - def exec_(self, clear=True, show_top_level_group=False, selected_group=None): + def exec(self, clear=True, show_top_level_group=False, selected_group=None): """ Show the form. @@ -57,7 +57,7 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): for i in range(self.parent_group_combobox.count()): if self.parent_group_combobox.itemData(i) == selected_group: self.parent_group_combobox.setCurrentIndex(i) - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def accept(self): """ @@ -69,4 +69,4 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): self.name_edit.setFocus() return False else: - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) diff --git a/openlp/plugins/images/forms/choosegroupdialog.py b/openlp/plugins/images/forms/choosegroupdialog.py index 27f891e58..c3a92a6ea 100644 --- a/openlp/plugins/images/forms/choosegroupdialog.py +++ b/openlp/plugins/images/forms/choosegroupdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib.ui import create_button_box @@ -38,36 +38,36 @@ class Ui_ChooseGroupDialog(object): """ choose_group_dialog.setObjectName('choose_group_dialog') choose_group_dialog.resize(399, 119) - self.choose_group_layout = QtGui.QFormLayout(choose_group_dialog) - self.choose_group_layout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow) - self.choose_group_layout.setMargin(8) + self.choose_group_layout = QtWidgets.QFormLayout(choose_group_dialog) + self.choose_group_layout.setFieldGrowthPolicy(QtWidgets.QFormLayout.ExpandingFieldsGrow) + self.choose_group_layout.setContentsMargins(8, 8, 8, 8) self.choose_group_layout.setSpacing(8) self.choose_group_layout.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.choose_group_layout.setObjectName('choose_group_layout') - self.group_question_label = QtGui.QLabel(choose_group_dialog) + self.group_question_label = QtWidgets.QLabel(choose_group_dialog) self.group_question_label.setWordWrap(True) self.group_question_label.setObjectName('group_question_label') - self.choose_group_layout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.group_question_label) - self.nogroup_radio_button = QtGui.QRadioButton(choose_group_dialog) + self.choose_group_layout.setWidget(1, QtWidgets.QFormLayout.SpanningRole, self.group_question_label) + self.nogroup_radio_button = QtWidgets.QRadioButton(choose_group_dialog) self.nogroup_radio_button.setChecked(True) self.nogroup_radio_button.setObjectName('nogroup_radio_button') - self.choose_group_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.nogroup_radio_button) - self.existing_radio_button = QtGui.QRadioButton(choose_group_dialog) + self.choose_group_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.nogroup_radio_button) + self.existing_radio_button = QtWidgets.QRadioButton(choose_group_dialog) self.existing_radio_button.setChecked(False) self.existing_radio_button.setObjectName('existing_radio_button') - self.choose_group_layout.setWidget(3, QtGui.QFormLayout.LabelRole, self.existing_radio_button) - self.group_combobox = QtGui.QComboBox(choose_group_dialog) + self.choose_group_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.existing_radio_button) + self.group_combobox = QtWidgets.QComboBox(choose_group_dialog) self.group_combobox.setObjectName('group_combobox') - self.choose_group_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.group_combobox) - self.new_radio_button = QtGui.QRadioButton(choose_group_dialog) + self.choose_group_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.group_combobox) + self.new_radio_button = QtWidgets.QRadioButton(choose_group_dialog) self.new_radio_button.setChecked(False) self.new_radio_button.setObjectName('new_radio_button') - self.choose_group_layout.setWidget(4, QtGui.QFormLayout.LabelRole, self.new_radio_button) - self.new_group_edit = QtGui.QLineEdit(choose_group_dialog) + self.choose_group_layout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.new_radio_button) + self.new_group_edit = QtWidgets.QLineEdit(choose_group_dialog) self.new_group_edit.setObjectName('new_group_edit') - self.choose_group_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.new_group_edit) + self.choose_group_layout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.new_group_edit) self.group_button_box = create_button_box(choose_group_dialog, 'buttonBox', ['ok']) - self.choose_group_layout.setWidget(5, QtGui.QFormLayout.FieldRole, self.group_button_box) + self.choose_group_layout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.group_button_box) self.retranslateUi(choose_group_dialog) QtCore.QMetaObject.connectSlotsByName(choose_group_dialog) diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index ede7b82a2..6ab560bf4 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -20,12 +20,12 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog -class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): +class ChooseGroupForm(QtWidgets.QDialog, Ui_ChooseGroupDialog): """ This class implements the 'Choose group' form for the Images plugin. """ @@ -36,7 +36,7 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): super(ChooseGroupForm, self).__init__(parent) self.setupUi(self) - def exec_(self, selected_group=None): + def exec(self, selected_group=None): """ Show the form @@ -47,4 +47,4 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): for index in range(self.group_combobox.count()): if self.group_combobox.itemData(index) == selected_group: self.group_combobox.setCurrentIndex(index) - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index a1a09854f..9d4b82254 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtGui import logging import os diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index 6e5e0b432..00e7fef0a 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Settings, UiStrings, translate from openlp.core.lib import ColorButton, SettingsTab @@ -36,25 +36,25 @@ class ImageTab(SettingsTab): def setupUi(self): self.setObjectName('ImagesTab') super(ImageTab, self).setupUi() - self.background_color_group_box = QtGui.QGroupBox(self.left_column) + self.background_color_group_box = QtWidgets.QGroupBox(self.left_column) self.background_color_group_box.setObjectName('background_color_group_box') - self.form_layout = QtGui.QFormLayout(self.background_color_group_box) + self.form_layout = QtWidgets.QFormLayout(self.background_color_group_box) self.form_layout.setObjectName('form_layout') - self.color_layout = QtGui.QHBoxLayout() - self.background_color_label = QtGui.QLabel(self.background_color_group_box) + self.color_layout = QtWidgets.QHBoxLayout() + self.background_color_label = QtWidgets.QLabel(self.background_color_group_box) self.background_color_label.setObjectName('background_color_label') self.color_layout.addWidget(self.background_color_label) self.background_color_button = ColorButton(self.background_color_group_box) self.background_color_button.setObjectName('background_color_button') self.color_layout.addWidget(self.background_color_button) self.form_layout.addRow(self.color_layout) - self.information_label = QtGui.QLabel(self.background_color_group_box) + self.information_label = QtWidgets.QLabel(self.background_color_group_box) self.information_label.setObjectName('information_label') self.information_label.setWordWrap(True) self.form_layout.addRow(self.information_label) self.left_layout.addWidget(self.background_color_group_box) self.left_layout.addStretch() - self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) + self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.right_layout.addStretch() # Signals and slots self.background_color_button.colorChanged.connect(self.on_background_color_changed) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index e2e1d26e8..96c2c6cc5 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -23,7 +23,7 @@ import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, AppLocation, Settings, UiStrings, check_directory_exists, translate from openlp.core.lib import ItemCapabilities, MediaManagerItem, ServiceItemContext, StringContent, TreeWidgetWithDnD,\ @@ -41,6 +41,8 @@ class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. """ + images_go_live = QtCore.pyqtSignal(list) + images_add_to_service = QtCore.pyqtSignal(list) log.info('Image Media Item loaded') def __init__(self, parent, plugin): @@ -54,6 +56,8 @@ class ImageMediaItem(MediaManagerItem): """ Do some additional setup. """ + self.images_go_live.connect(self.go_live_remote) + self.images_add_to_service.connect(self.add_to_service_remote) self.quick_preview_allowed = True self.has_search = True self.manager = self.plugin.manager @@ -105,7 +109,7 @@ class ImageMediaItem(MediaManagerItem): """ # Add the List widget self.list_view = TreeWidgetWithDnD(self, self.plugin.name) - self.list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.list_view.setAlternatingRowColors(True) self.list_view.setObjectName('%sTreeView' % self.plugin.name) # Add to pageLayout @@ -157,7 +161,7 @@ class ImageMediaItem(MediaManagerItem): can_shortcuts=True, triggers=self.on_delete_click) self.add_custom_context_actions() # Create the context menu and add all actions from the list_view. - self.menu = QtGui.QMenu() + self.menu = QtWidgets.QMenu() self.menu.addActions(self.list_view.actions()) self.list_view.doubleClicked.connect(self.on_double_clicked) self.list_view.itemSelectionChanged.connect(self.on_selection_change) @@ -235,14 +239,15 @@ class ImageMediaItem(MediaManagerItem): row_item.parent().removeChild(row_item) self.manager.delete_object(ImageFilenames, row_item.data(0, QtCore.Qt.UserRole).id) elif isinstance(item_data, ImageGroups): - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self.list_view.parent(), translate('ImagePlugin.MediaItem', 'Remove group'), translate('ImagePlugin.MediaItem', 'Are you sure you want to remove "%s" and everything in it?') % item_data.group_name, - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | + QtWidgets.QMessageBox.No) + ) == QtWidgets.QMessageBox.Yes: self.recursively_delete_group(item_data) self.manager.delete_object(ImageGroups, row_item.data(0, QtCore.Qt.UserRole).id) if item_data.parent_id == 0: @@ -267,7 +272,7 @@ class ImageMediaItem(MediaManagerItem): image_groups.sort(key=lambda group_object: get_locale_key(group_object.group_name)) folder_icon = build_icon(':/images/image_group.png') for image_group in image_groups: - group = QtGui.QTreeWidgetItem() + group = QtWidgets.QTreeWidgetItem() group.setText(0, image_group.group_name) group.setData(0, QtCore.Qt.UserRole, image_group) group.setIcon(0, folder_icon) @@ -358,7 +363,7 @@ class ImageMediaItem(MediaManagerItem): icon = build_icon(thumb) else: icon = create_thumb(image_file.filename, thumb) - item_name = QtGui.QTreeWidgetItem([filename]) + item_name = QtWidgets.QTreeWidgetItem([filename]) item_name.setText(0, filename) item_name.setIcon(0, icon) item_name.setToolTip(0, image_file.filename) @@ -403,7 +408,7 @@ class ImageMediaItem(MediaManagerItem): selected_item = selected_items[0] if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageFilenames): selected_item = selected_item.parent() - if isinstance(selected_item, QtGui.QTreeWidgetItem): + if isinstance(selected_item, QtWidgets.QTreeWidgetItem): if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageGroups): preselect_group = selected_item.data(0, QtCore.Qt.UserRole).id # Enable and disable parts of the 'choose group' form @@ -424,7 +429,7 @@ class ImageMediaItem(MediaManagerItem): self.choose_group_form.existing_radio_button.setDisabled(False) self.choose_group_form.group_combobox.setDisabled(False) # Ask which group the images should be saved in - if self.choose_group_form.exec_(selected_group=preselect_group): + if self.choose_group_form.exec(selected_group=preselect_group): if self.choose_group_form.nogroup_radio_button.isChecked(): # User chose 'No group' parent_group = ImageGroups() @@ -503,7 +508,7 @@ class ImageMediaItem(MediaManagerItem): items_to_save = [] for item in items_to_move: if isinstance(item.data(0, QtCore.Qt.UserRole), ImageFilenames): - if isinstance(item.parent(), QtGui.QTreeWidgetItem): + if isinstance(item.parent(), QtWidgets.QTreeWidgetItem): item.parent().removeChild(item) else: self.list_view.invisibleRootItem().removeChild(item) @@ -586,12 +591,12 @@ class ImageMediaItem(MediaManagerItem): % '\n'.join(missing_items_file_names)) return False # We have missing as well as existing images. We ask what to do. - elif missing_items_file_names and QtGui.QMessageBox.question( + elif missing_items_file_names and QtWidgets.QMessageBox.question( self, translate('ImagePlugin.MediaItem', 'Missing Image(s)'), translate('ImagePlugin.MediaItem', 'The following image(s) no longer exist: %s\n' 'Do you want to add the other images anyway?') % '\n'.join(missing_items_file_names), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == \ - QtGui.QMessageBox.No: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)) == \ + QtWidgets.QMessageBox.No: return False # Continue with the existing images. for image in images: @@ -623,11 +628,11 @@ class ImageMediaItem(MediaManagerItem): selected_item = selected_items[0] if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageFilenames): selected_item = selected_item.parent() - if isinstance(selected_item, QtGui.QTreeWidgetItem): + if isinstance(selected_item, QtWidgets.QTreeWidgetItem): if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageGroups): preselect_group = selected_item.data(0, QtCore.Qt.UserRole).id # Show 'add group' dialog - if self.add_group_form.exec_(show_top_level_group=True, selected_group=preselect_group): + if self.add_group_form.exec(show_top_level_group=True, selected_group=preselect_group): new_group = ImageGroups.populate(parent_id=self.add_group_form.parent_group_combobox.itemData( self.add_group_form.parent_group_combobox.currentIndex(), QtCore.Qt.UserRole), group_name=self.add_group_form.name_edit.text()) @@ -705,7 +710,7 @@ class ImageMediaItem(MediaManagerItem): :param item_id: Id to make live """ - item = QtGui.QTreeWidgetItem() + item = QtWidgets.QTreeWidgetItem() item_data = self.manager.get_object_filtered(ImageFilenames, ImageFilenames.filename == item_id) item.setText(0, os.path.basename(item_data.filename)) item.setData(0, QtCore.Qt.UserRole, item_data) diff --git a/openlp/plugins/media/forms/mediaclipselectordialog.py b/openlp/plugins/media/forms/mediaclipselectordialog.py index ee7fc0b4c..2b1276b6f 100644 --- a/openlp/plugins/media/forms/mediaclipselectordialog.py +++ b/openlp/plugins/media/forms/mediaclipselectordialog.py @@ -21,7 +21,8 @@ ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets + from openlp.core.common import translate from openlp.core.lib import build_icon @@ -30,133 +31,134 @@ class Ui_MediaClipSelector(object): def setupUi(self, media_clip_selector): media_clip_selector.setObjectName('media_clip_selector') media_clip_selector.resize(554, 654) - self.combobox_size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + self.combobox_size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, + QtWidgets.QSizePolicy.Fixed) media_clip_selector.setSizePolicy( - QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)) - self.main_layout = QtGui.QVBoxLayout(media_clip_selector) + QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)) + self.main_layout = QtWidgets.QVBoxLayout(media_clip_selector) self.main_layout.setContentsMargins(8, 8, 8, 8) self.main_layout.setObjectName('main_layout') # Source groupbox - self.source_groupbox = QtGui.QGroupBox(media_clip_selector) + self.source_groupbox = QtWidgets.QGroupBox(media_clip_selector) self.source_groupbox.setObjectName('source_groupbox') - self.source_layout = QtGui.QHBoxLayout() + self.source_layout = QtWidgets.QHBoxLayout() self.source_layout.setContentsMargins(8, 8, 8, 8) self.source_layout.setObjectName('source_layout') self.source_groupbox.setLayout(self.source_layout) # Media path label - self.media_path_label = QtGui.QLabel(self.source_groupbox) + self.media_path_label = QtWidgets.QLabel(self.source_groupbox) self.media_path_label.setObjectName('media_path_label') self.source_layout.addWidget(self.media_path_label) # Media path combobox - self.media_path_combobox = QtGui.QComboBox(self.source_groupbox) + self.media_path_combobox = QtWidgets.QComboBox(self.source_groupbox) # Make the combobox expand self.media_path_combobox.setSizePolicy(self.combobox_size_policy) self.media_path_combobox.setEditable(True) self.media_path_combobox.setObjectName('media_path_combobox') self.source_layout.addWidget(self.media_path_combobox) # Load disc button - self.load_disc_button = QtGui.QPushButton(media_clip_selector) + self.load_disc_button = QtWidgets.QPushButton(media_clip_selector) self.load_disc_button.setEnabled(True) self.load_disc_button.setObjectName('load_disc_button') self.source_layout.addWidget(self.load_disc_button) self.main_layout.addWidget(self.source_groupbox) # Track details group box - self.track_groupbox = QtGui.QGroupBox(media_clip_selector) + self.track_groupbox = QtWidgets.QGroupBox(media_clip_selector) self.track_groupbox.setObjectName('track_groupbox') - self.track_layout = QtGui.QFormLayout() + self.track_layout = QtWidgets.QFormLayout() self.track_layout.setContentsMargins(8, 8, 8, 8) self.track_layout.setObjectName('track_layout') self.label_alignment = self.track_layout.labelAlignment() self.track_groupbox.setLayout(self.track_layout) # Title track - self.title_label = QtGui.QLabel(self.track_groupbox) + self.title_label = QtWidgets.QLabel(self.track_groupbox) self.title_label.setObjectName('title_label') - self.titles_combo_box = QtGui.QComboBox(self.track_groupbox) + self.titles_combo_box = QtWidgets.QComboBox(self.track_groupbox) self.titles_combo_box.setSizePolicy(self.combobox_size_policy) self.titles_combo_box.setEditText('') self.titles_combo_box.setObjectName('titles_combo_box') self.track_layout.addRow(self.title_label, self.titles_combo_box) # Audio track - self.audio_track_label = QtGui.QLabel(self.track_groupbox) + self.audio_track_label = QtWidgets.QLabel(self.track_groupbox) self.audio_track_label.setObjectName('audio_track_label') - self.audio_tracks_combobox = QtGui.QComboBox(self.track_groupbox) + self.audio_tracks_combobox = QtWidgets.QComboBox(self.track_groupbox) self.audio_tracks_combobox.setSizePolicy(self.combobox_size_policy) self.audio_tracks_combobox.setObjectName('audio_tracks_combobox') self.track_layout.addRow(self.audio_track_label, self.audio_tracks_combobox) self.main_layout.addWidget(self.track_groupbox) # Subtitle track - self.subtitle_track_label = QtGui.QLabel(self.track_groupbox) + self.subtitle_track_label = QtWidgets.QLabel(self.track_groupbox) self.subtitle_track_label.setObjectName('subtitle_track_label') - self.subtitle_tracks_combobox = QtGui.QComboBox(self.track_groupbox) + self.subtitle_tracks_combobox = QtWidgets.QComboBox(self.track_groupbox) self.subtitle_tracks_combobox.setSizePolicy(self.combobox_size_policy) self.subtitle_tracks_combobox.setObjectName('subtitle_tracks_combobox') self.track_layout.addRow(self.subtitle_track_label, self.subtitle_tracks_combobox) # Preview frame - self.preview_frame = QtGui.QFrame(media_clip_selector) + self.preview_frame = QtWidgets.QFrame(media_clip_selector) self.preview_frame.setMinimumSize(QtCore.QSize(320, 240)) - self.preview_frame.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, - QtGui.QSizePolicy.MinimumExpanding)) + self.preview_frame.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, + QtWidgets.QSizePolicy.MinimumExpanding)) self.preview_frame.setStyleSheet('background-color:black;') - self.preview_frame.setFrameShape(QtGui.QFrame.NoFrame) + self.preview_frame.setFrameShape(QtWidgets.QFrame.NoFrame) self.preview_frame.setObjectName('preview_frame') self.main_layout.addWidget(self.preview_frame) # player controls - self.controls_layout = QtGui.QHBoxLayout() + self.controls_layout = QtWidgets.QHBoxLayout() self.controls_layout.setObjectName('controls_layout') - self.play_button = QtGui.QToolButton(media_clip_selector) + self.play_button = QtWidgets.QToolButton(media_clip_selector) self.play_button.setIcon(build_icon(':/slides/media_playback_start.png')) self.play_button.setObjectName('play_button') self.controls_layout.addWidget(self.play_button) - self.position_slider = QtGui.QSlider(media_clip_selector) + self.position_slider = QtWidgets.QSlider(media_clip_selector) self.position_slider.setTracking(False) self.position_slider.setOrientation(QtCore.Qt.Horizontal) self.position_slider.setObjectName('position_slider') self.controls_layout.addWidget(self.position_slider) - self.position_timeedit = QtGui.QTimeEdit(media_clip_selector) + self.position_timeedit = QtWidgets.QTimeEdit(media_clip_selector) self.position_timeedit.setReadOnly(True) self.position_timeedit.setObjectName('position_timeedit') self.controls_layout.addWidget(self.position_timeedit) self.main_layout.addLayout(self.controls_layout) # Range - self.range_groupbox = QtGui.QGroupBox(media_clip_selector) + self.range_groupbox = QtWidgets.QGroupBox(media_clip_selector) self.range_groupbox.setObjectName('range_groupbox') - self.range_layout = QtGui.QGridLayout() + self.range_layout = QtWidgets.QGridLayout() self.range_layout.setContentsMargins(8, 8, 8, 8) self.range_layout.setObjectName('range_layout') self.range_groupbox.setLayout(self.range_layout) # Start position - self.start_position_label = QtGui.QLabel(self.range_groupbox) + self.start_position_label = QtWidgets.QLabel(self.range_groupbox) self.start_position_label.setObjectName('start_position_label') self.range_layout.addWidget(self.start_position_label, 0, 0, self.label_alignment) - self.start_position_edit = QtGui.QTimeEdit(self.range_groupbox) + self.start_position_edit = QtWidgets.QTimeEdit(self.range_groupbox) self.start_position_edit.setObjectName('start_position_edit') self.range_layout.addWidget(self.start_position_edit, 0, 1) - self.set_start_button = QtGui.QPushButton(self.range_groupbox) + self.set_start_button = QtWidgets.QPushButton(self.range_groupbox) self.set_start_button.setObjectName('set_start_button') self.range_layout.addWidget(self.set_start_button, 0, 2) - self.jump_start_button = QtGui.QPushButton(self.range_groupbox) + self.jump_start_button = QtWidgets.QPushButton(self.range_groupbox) self.jump_start_button.setObjectName('jump_start_button') self.range_layout.addWidget(self.jump_start_button, 0, 3) # End position - self.end_position_label = QtGui.QLabel(self.range_groupbox) + self.end_position_label = QtWidgets.QLabel(self.range_groupbox) self.end_position_label.setObjectName('end_position_label') self.range_layout.addWidget(self.end_position_label, 1, 0, self.label_alignment) - self.end_timeedit = QtGui.QTimeEdit(self.range_groupbox) + self.end_timeedit = QtWidgets.QTimeEdit(self.range_groupbox) self.end_timeedit.setObjectName('end_timeedit') self.range_layout.addWidget(self.end_timeedit, 1, 1) - self.set_end_button = QtGui.QPushButton(self.range_groupbox) + self.set_end_button = QtWidgets.QPushButton(self.range_groupbox) self.set_end_button.setObjectName('set_end_button') self.range_layout.addWidget(self.set_end_button, 1, 2) - self.jump_end_button = QtGui.QPushButton(self.range_groupbox) + self.jump_end_button = QtWidgets.QPushButton(self.range_groupbox) self.jump_end_button.setObjectName('jump_end_button') self.range_layout.addWidget(self.jump_end_button, 1, 3) self.main_layout.addWidget(self.range_groupbox) # Save and close buttons - self.button_box = QtGui.QDialogButtonBox(media_clip_selector) - self.button_box.addButton(QtGui.QDialogButtonBox.Save) - self.button_box.addButton(QtGui.QDialogButtonBox.Close) - self.close_button = self.button_box.button(QtGui.QDialogButtonBox.Close) - self.save_button = self.button_box.button(QtGui.QDialogButtonBox.Save) + self.button_box = QtWidgets.QDialogButtonBox(media_clip_selector) + self.button_box.addButton(QtWidgets.QDialogButtonBox.Save) + self.button_box.addButton(QtWidgets.QDialogButtonBox.Close) + self.close_button = self.button_box.button(QtWidgets.QDialogButtonBox.Close) + self.save_button = self.button_box.button(QtWidgets.QDialogButtonBox.Save) self.main_layout.addWidget(self.button_box) self.retranslateUi(media_clip_selector) diff --git a/openlp/plugins/media/forms/mediaclipselectorform.py b/openlp/plugins/media/forms/mediaclipselectorform.py index 61d7a8455..1d6fede42 100644 --- a/openlp/plugins/media/forms/mediaclipselectorform.py +++ b/openlp/plugins/media/forms/mediaclipselectorform.py @@ -26,7 +26,7 @@ import re from time import sleep from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import translate, is_win, is_linux, is_macosx, RegistryProperties from openlp.plugins.media.forms.mediaclipselectordialog import Ui_MediaClipSelector @@ -52,7 +52,7 @@ except OSError as e: log = logging.getLogger(__name__) -class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryProperties): +class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryProperties): """ Class to manage the clip selection """ @@ -96,15 +96,15 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryPropert if self.vlc_media: self.vlc_media.release() self.vlc_media = None - return QtGui.QDialog.reject(self) + return QtWidgets.QDialog.reject(self) - def exec_(self): + def exec(self): """ Start dialog """ self.reset_ui() self.setup_vlc() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def reset_ui(self): """ @@ -138,7 +138,7 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryPropert if is_win(): self.vlc_media_player.set_hwnd(win_id) elif is_macosx(): - # We have to use 'set_nsobject' since Qt4 on OSX uses Cocoa + # We have to use 'set_nsobject' since Qt5 on OSX uses Cocoa # framework and not the old Carbon. self.vlc_media_player.set_nsobject(win_id) else: @@ -585,11 +585,11 @@ class MediaClipSelectorForm(QtGui.QDialog, Ui_MediaClipSelector, RegistryPropert optical = 'optical:%d:%d:%d:%d:%d:' % (title, audio_track, subtitle_track, start_time_ms, end_time_ms) # Ask for an alternative name for the mediaclip while True: - new_optical_name, ok = QtGui.QInputDialog.getText(self, translate('MediaPlugin.MediaClipSelectorForm', - 'Set name of mediaclip'), - translate('MediaPlugin.MediaClipSelectorForm', - 'Name of mediaclip:'), - QtGui.QLineEdit.Normal) + new_optical_name, ok = QtWidgets.QInputDialog.getText(self, translate('MediaPlugin.MediaClipSelectorForm', + 'Set name of mediaclip'), + translate('MediaPlugin.MediaClipSelectorForm', + 'Name of mediaclip:'), + QtWidgets.QLineEdit.Normal) # User pressed cancel, don't save the clip if not ok: return diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 6a4fb51da..21af839aa 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -23,7 +23,7 @@ import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, UiStrings,\ translate @@ -49,6 +49,8 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): """ This is the custom media manager item for Media Slides. """ + media_go_live = QtCore.pyqtSignal(list) + media_add_to_service = QtCore.pyqtSignal(list) log.info('%s MediaMediaItem loaded', __name__) def __init__(self, parent, plugin): @@ -71,11 +73,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): """ Do some additional setup. """ + self.media_go_live.connect(self.go_live_remote) + self.media_add_to_service.connect(self.add_to_service_remote) self.single_service_item = False self.has_search = True self.media_object = None self.display_controller = DisplayController(self.parent()) - self.display_controller.controller_layout = QtGui.QVBoxLayout() + self.display_controller.controller_layout = QtWidgets.QVBoxLayout() self.media_controller.register_controller(self.display_controller) self.media_controller.set_controls_visible(self.display_controller, False) self.display_controller.preview_display = Display(self.display_controller) @@ -153,12 +157,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): self.replace_action.setDisabled(True) self.reset_action = self.toolbar.add_toolbar_action('reset_action', icon=':/system/system_close.png', visible=False, triggers=self.on_reset_click) - self.media_widget = QtGui.QWidget(self) + self.media_widget = QtWidgets.QWidget(self) self.media_widget.setObjectName('media_widget') - self.display_layout = QtGui.QFormLayout(self.media_widget) - self.display_layout.setMargin(self.display_layout.spacing()) + self.display_layout = QtWidgets.QFormLayout(self.media_widget) + self.display_layout.setContentsMargins(self.display_layout.spacing(), self.display_layout.spacing(), + self.display_layout.spacing(), self.display_layout.spacing()) self.display_layout.setObjectName('display_layout') - self.display_type_label = QtGui.QLabel(self.media_widget) + self.display_type_label = QtWidgets.QLabel(self.media_widget) self.display_type_label.setObjectName('display_type_label') self.display_type_combo_box = create_horizontal_adjusting_combo_box( self.media_widget, 'display_type_combo_box') @@ -356,21 +361,21 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): if track.startswith('optical:'): # Handle optical based item (file_name, title, audio_track, subtitle_track, start, end, clip_name) = parse_optical_path(track) - item_name = QtGui.QListWidgetItem(clip_name) + item_name = QtWidgets.QListWidgetItem(clip_name) item_name.setIcon(self.optical_icon) item_name.setData(QtCore.Qt.UserRole, track) item_name.setToolTip('%s@%s-%s' % (file_name, format_milliseconds(start), format_milliseconds(end))) elif not os.path.exists(track): # File doesn't exist, mark as error. file_name = os.path.split(str(track))[1] - item_name = QtGui.QListWidgetItem(file_name) + item_name = QtWidgets.QListWidgetItem(file_name) item_name.setIcon(self.error_icon) item_name.setData(QtCore.Qt.UserRole, track) item_name.setToolTip(track) elif track_info.isFile(): # Normal media file handling. file_name = os.path.split(str(track))[1] - item_name = QtGui.QListWidgetItem(file_name) + item_name = QtWidgets.QListWidgetItem(file_name) if '*.%s' % (file_name.split('.')[-1].lower()) in self.media_controller.audio_extensions_list: item_name.setIcon(self.audio_icon) else: @@ -418,13 +423,13 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): """ When the load optical button is clicked, open the clip selector window. """ - # self.media_clip_selector_form.exec_() + # self.media_clip_selector_form.exec() if get_vlc(): media_clip_selector_form = MediaClipSelectorForm(self, self.main_window, None) - media_clip_selector_form.exec_() + media_clip_selector_form.exec() del media_clip_selector_form else: - QtGui.QMessageBox.critical(self, 'VLC is not available', 'VLC is not available') + QtWidgets.QMessageBox.critical(self, 'VLC is not available', 'VLC is not available') def add_optical_clip(self, optical): """ diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index c38cbe500..0b51aebf9 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Settings, UiStrings, translate from openlp.core.lib import SettingsTab @@ -37,14 +37,14 @@ class MediaTab(SettingsTab): def setupUi(self): self.setObjectName('MediaTab') super(MediaTab, self).setupUi() - self.advanced_group_box = QtGui.QGroupBox(self.left_column) + self.advanced_group_box = QtWidgets.QGroupBox(self.left_column) self.advanced_group_box.setObjectName('advanced_group_box') - self.advanced_layout = QtGui.QVBoxLayout(self.advanced_group_box) + self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout.setObjectName('advanced_layout') - self.override_player_check_box = QtGui.QCheckBox(self.advanced_group_box) + self.override_player_check_box = QtWidgets.QCheckBox(self.advanced_group_box) self.override_player_check_box.setObjectName('override_player_check_box') self.advanced_layout.addWidget(self.override_player_check_box) - self.auto_start_check_box = QtGui.QCheckBox(self.advanced_group_box) + self.auto_start_check_box = QtWidgets.QCheckBox(self.advanced_group_box) self.auto_start_check_box.setObjectName('auto_start_check_box') self.advanced_layout.addWidget(self.auto_start_check_box) self.left_layout.addWidget(self.advanced_group_box) diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 1aa410af0..a1688ab7e 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -25,7 +25,7 @@ The Media plugin import logging -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Settings, translate from openlp.core.lib import Plugin, StringContent, build_icon diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 0f3574459..5ac48dded 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -54,7 +54,7 @@ else: except ImportError: uno_available = False -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.lib import ScreenList from openlp.core.utils import delete_file, get_uno_command, get_uno_instance diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index b031da203..c99bc3ba2 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -23,7 +23,7 @@ import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import Registry, Settings, UiStrings, translate from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext,\ @@ -44,6 +44,8 @@ class PresentationMediaItem(MediaManagerItem): This is the Presentation media manager item for Presentation Items. It can present files using Openoffice and Powerpoint """ + presentations_go_live = QtCore.pyqtSignal(list) + presentations_add_to_service = QtCore.pyqtSignal(list) log.info('Presentations Media Item loaded') def __init__(self, parent, plugin, controllers): @@ -66,6 +68,8 @@ class PresentationMediaItem(MediaManagerItem): """ Do some additional setup. """ + self.presentations_go_live.connect(self.go_live_remote) + self.presentations_add_to_service.connect(self.add_to_service_remote) self.message_listener = MessageListener(self) self.has_search = True self.single_service_item = False @@ -101,12 +105,13 @@ class PresentationMediaItem(MediaManagerItem): """ Display custom media manager items for presentations. """ - self.presentation_widget = QtGui.QWidget(self) + self.presentation_widget = QtWidgets.QWidget(self) self.presentation_widget.setObjectName('presentation_widget') - self.display_layout = QtGui.QFormLayout(self.presentation_widget) - self.display_layout.setMargin(self.display_layout.spacing()) + self.display_layout = QtWidgets.QFormLayout(self.presentation_widget) + self.display_layout.setContentsMargins(self.display_layout.spacing(), self.display_layout.spacing(), + self.display_layout.spacing(), self.display_layout.spacing()) self.display_layout.setObjectName('display_layout') - self.display_type_label = QtGui.QLabel(self.presentation_widget) + self.display_type_label = QtWidgets.QLabel(self.presentation_widget) self.display_type_label.setObjectName('display_type_label') self.display_type_combo_box = create_horizontal_adjusting_combo_box(self.presentation_widget, 'display_type_combo_box') @@ -164,7 +169,7 @@ class PresentationMediaItem(MediaManagerItem): continue filename = os.path.split(file)[1] if not os.path.exists(file): - item_name = QtGui.QListWidgetItem(filename) + item_name = QtWidgets.QListWidgetItem(filename) item_name.setIcon(build_icon(ERROR_IMAGE)) item_name.setData(QtCore.Qt.UserRole, file) item_name.setToolTip(file) @@ -201,7 +206,7 @@ class PresentationMediaItem(MediaManagerItem): translate('PresentationPlugin.MediaItem', 'This type of presentation is not supported.')) continue - item_name = QtGui.QListWidgetItem(filename) + item_name = QtWidgets.QListWidgetItem(filename) item_name.setData(QtCore.Qt.UserRole, file) item_name.setIcon(icon) item_name.setToolTip(file) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 48d5722e0..219328c3c 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -24,7 +24,7 @@ import logging import copy import os -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry from openlp.core.ui import HideMode diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index b797f8a7c..f3685940c 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -21,12 +21,12 @@ ############################################################################### import sys -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets from ctypes import * from ctypes.wintypes import RECT -class PPTViewer(QtGui.QWidget): +class PPTViewer(QtWidgets.QWidget): """ Standalone Test Harness for the pptviewlib library """ @@ -35,33 +35,33 @@ class PPTViewer(QtGui.QWidget): self.pptid = -1 self.setWindowTitle('PowerPoint Viewer Test') - ppt_label = QtGui.QLabel('Open PowerPoint file') - slide_label = QtGui.QLabel('Go to slide #') - self.pptEdit = QtGui.QLineEdit() - self.slideEdit = QtGui.QLineEdit() - x_label = QtGui.QLabel('X pos') - y_label = QtGui.QLabel('Y pos') - width_label = QtGui.QLabel('Width') - height_label = QtGui.QLabel('Height') - self.xEdit = QtGui.QLineEdit('100') - self.yEdit = QtGui.QLineEdit('100') - self.widthEdit = QtGui.QLineEdit('900') - self.heightEdit = QtGui.QLineEdit('700') - self.total = QtGui.QLabel() - ppt_btn = QtGui.QPushButton('Open') - ppt_dlg_btn = QtGui.QPushButton('...') - folder_label = QtGui.QLabel('Slide .bmp path') - self.folderEdit = QtGui.QLineEdit('slide') - slide_btn = QtGui.QPushButton('Go') - prev = QtGui.QPushButton('Prev') - next = QtGui.QPushButton('Next') - blank = QtGui.QPushButton('Blank') - unblank = QtGui.QPushButton('Unblank') - restart = QtGui.QPushButton('Restart') - close = QtGui.QPushButton('Close') - resume = QtGui.QPushButton('Resume') - stop = QtGui.QPushButton('Stop') - grid = QtGui.QGridLayout() + ppt_label = QtWidgets.QLabel('Open PowerPoint file') + slide_label = QtWidgets.QLabel('Go to slide #') + self.pptEdit = QtWidgets.QLineEdit() + self.slideEdit = QtWidgets.QLineEdit() + x_label = QtWidgets.QLabel('X pos') + y_label = QtWidgets.QLabel('Y pos') + width_label = QtWidgets.QLabel('Width') + height_label = QtWidgets.QLabel('Height') + self.xEdit = QtWidgets.QLineEdit('100') + self.yEdit = QtWidgets.QLineEdit('100') + self.widthEdit = QtWidgets.QLineEdit('900') + self.heightEdit = QtWidgets.QLineEdit('700') + self.total = QtWidgets.QLabel() + ppt_btn = QtWidgets.QPushButton('Open') + ppt_dlg_btn = QtWidgets.QPushButton('...') + folder_label = QtWidgets.QLabel('Slide .bmp path') + self.folderEdit = QtWidgets.QLineEdit('slide') + slide_btn = QtWidgets.QPushButton('Go') + prev = QtWidgets.QPushButton('Prev') + next = QtWidgets.QPushButton('Next') + blank = QtWidgets.QPushButton('Blank') + unblank = QtWidgets.QPushButton('Unblank') + restart = QtWidgets.QPushButton('Restart') + close = QtWidgets.QPushButton('Close') + resume = QtWidgets.QPushButton('Resume') + stop = QtWidgets.QPushButton('Stop') + grid = QtWidgets.QGridLayout() row = 0 grid.addWidget(folder_label, 0, 0) grid.addWidget(self.folderEdit, 0, 1) @@ -96,17 +96,17 @@ class PPTViewer(QtGui.QWidget): row += 1 grid.addWidget(stop, row, 0) grid.addWidget(resume, row, 1) - self.connect(ppt_btn, QtCore.SIGNAL('clicked()'), self.openClick) - self.connect(ppt_dlg_btn, QtCore.SIGNAL('clicked()'), self.openDialog) - self.connect(slide_btn, QtCore.SIGNAL('clicked()'), self.gotoClick) - self.connect(prev, QtCore.SIGNAL('clicked()'), self.prevClick) - self.connect(next, QtCore.SIGNAL('clicked()'), self.nextClick) - self.connect(blank, QtCore.SIGNAL('clicked()'), self.blankClick) - self.connect(unblank, QtCore.SIGNAL('clicked()'), self.unblankClick) - self.connect(restart, QtCore.SIGNAL('clicked()'), self.restartClick) - self.connect(close, QtCore.SIGNAL('clicked()'), self.closeClick) - self.connect(stop, QtCore.SIGNAL('clicked()'), self.stopClick) - self.connect(resume, QtCore.SIGNAL('clicked()'), self.resumeClick) + ppt_btn.clicked.connect(self.openClick) + ppt_dlg_btn.clicked.connect(self.openDialog) + slide_btn.clicked.connect(self.gotoClick) + prev.clicked.connect(self.prevClick) + next.clicked.connect(self.nextClick) + blank.clicked.connect(self.blankClick) + unblank.clicked.connect(self.unblankClick) + restart.clicked.connect(self.restartClick) + close.clicked.connect(self.closeClick) + stop.clicked.connect(self.stopClick) + resume.clicked.connect(self.resumeClick) self.setLayout(grid) self.resize(300, 150) @@ -195,14 +195,14 @@ class PPTViewer(QtGui.QWidget): app.processEvents() def openDialog(self): - self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file')) + self.pptEdit.setText(QtWidgets.QFileDialog.getOpenFileName(self, 'Open file')[0]) if __name__ == '__main__': pptdll = cdll.LoadLibrary(r'pptviewlib.dll') pptdll.SetDebug(1) print('Begin...') - app = QtGui.QApplication(sys.argv) + app = QtWidgets.QApplication(sys.argv) window = PPTViewer() window.pptdll = pptdll window.show() - sys.exit(app.exec_()) + sys.exit(app.exec()) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 6deba3955..e9ada675e 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -24,7 +24,7 @@ import logging import os import shutil -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, md5_hash from openlp.core.lib import create_thumb, validate_thumb diff --git a/openlp/plugins/presentations/lib/presentationtab.py b/openlp/plugins/presentations/lib/presentationtab.py index f15012c70..28e7ccf6d 100644 --- a/openlp/plugins/presentations/lib/presentationtab.py +++ b/openlp/plugins/presentations/lib/presentationtab.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.common import Settings, UiStrings, translate from openlp.core.lib import SettingsTab, build_icon @@ -47,55 +47,55 @@ class PresentationTab(SettingsTab): """ self.setObjectName('PresentationTab') super(PresentationTab, self).setupUi() - self.controllers_group_box = QtGui.QGroupBox(self.left_column) + self.controllers_group_box = QtWidgets.QGroupBox(self.left_column) self.controllers_group_box.setObjectName('controllers_group_box') - self.controllers_layout = QtGui.QVBoxLayout(self.controllers_group_box) + self.controllers_layout = QtWidgets.QVBoxLayout(self.controllers_group_box) self.controllers_layout.setObjectName('ccontrollers_layout') self.presenter_check_boxes = {} for key in self.controllers: controller = self.controllers[key] - checkbox = QtGui.QCheckBox(self.controllers_group_box) + checkbox = QtWidgets.QCheckBox(self.controllers_group_box) checkbox.setObjectName(controller.name + 'CheckBox') self.presenter_check_boxes[controller.name] = checkbox self.controllers_layout.addWidget(checkbox) self.left_layout.addWidget(self.controllers_group_box) # Advanced - self.advanced_group_box = QtGui.QGroupBox(self.left_column) + self.advanced_group_box = QtWidgets.QGroupBox(self.left_column) self.advanced_group_box.setObjectName('advanced_group_box') - self.advanced_layout = QtGui.QVBoxLayout(self.advanced_group_box) + self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout.setObjectName('advanced_layout') - self.override_app_check_box = QtGui.QCheckBox(self.advanced_group_box) + self.override_app_check_box = QtWidgets.QCheckBox(self.advanced_group_box) self.override_app_check_box.setObjectName('override_app_check_box') self.advanced_layout.addWidget(self.override_app_check_box) self.left_layout.addWidget(self.advanced_group_box) # PowerPoint - self.powerpoint_group_box = QtGui.QGroupBox(self.left_column) + self.powerpoint_group_box = QtWidgets.QGroupBox(self.left_column) self.powerpoint_group_box.setObjectName('powerpoint_group_box') - self.powerpoint_layout = QtGui.QVBoxLayout(self.powerpoint_group_box) + self.powerpoint_layout = QtWidgets.QVBoxLayout(self.powerpoint_group_box) self.powerpoint_layout.setObjectName('powerpoint_layout') - self.ppt_slide_click_check_box = QtGui.QCheckBox(self.powerpoint_group_box) + self.ppt_slide_click_check_box = QtWidgets.QCheckBox(self.powerpoint_group_box) self.ppt_slide_click_check_box.setObjectName('ppt_slide_click_check_box') self.powerpoint_layout.addWidget(self.ppt_slide_click_check_box) - self.ppt_window_check_box = QtGui.QCheckBox(self.powerpoint_group_box) + self.ppt_window_check_box = QtWidgets.QCheckBox(self.powerpoint_group_box) self.ppt_window_check_box.setObjectName('ppt_window_check_box') self.powerpoint_layout.addWidget(self.ppt_window_check_box) self.left_layout.addWidget(self.powerpoint_group_box) # Pdf options - self.pdf_group_box = QtGui.QGroupBox(self.left_column) + self.pdf_group_box = QtWidgets.QGroupBox(self.left_column) self.pdf_group_box.setObjectName('pdf_group_box') - self.pdf_layout = QtGui.QFormLayout(self.pdf_group_box) + self.pdf_layout = QtWidgets.QFormLayout(self.pdf_group_box) self.pdf_layout.setObjectName('pdf_layout') - self.pdf_program_check_box = QtGui.QCheckBox(self.pdf_group_box) + self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box) self.pdf_program_check_box.setObjectName('pdf_program_check_box') self.pdf_layout.addRow(self.pdf_program_check_box) - self.pdf_program_path_layout = QtGui.QHBoxLayout() + self.pdf_program_path_layout = QtWidgets.QHBoxLayout() self.pdf_program_path_layout.setObjectName('pdf_program_path_layout') - self.pdf_program_path = QtGui.QLineEdit(self.pdf_group_box) + self.pdf_program_path = QtWidgets.QLineEdit(self.pdf_group_box) self.pdf_program_path.setObjectName('pdf_program_path') self.pdf_program_path.setReadOnly(True) self.pdf_program_path.setPalette(self.get_grey_text_palette(True)) self.pdf_program_path_layout.addWidget(self.pdf_program_path) - self.pdf_program_browse_button = QtGui.QToolButton(self.pdf_group_box) + self.pdf_program_browse_button = QtWidgets.QToolButton(self.pdf_group_box) self.pdf_program_browse_button.setObjectName('pdf_program_browse_button') self.pdf_program_browse_button.setIcon(build_icon(':/general/general_open.png')) self.pdf_program_browse_button.setEnabled(False) @@ -103,7 +103,7 @@ class PresentationTab(SettingsTab): self.pdf_layout.addRow(self.pdf_program_path_layout) self.left_layout.addWidget(self.pdf_group_box) self.left_layout.addStretch() - self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) + self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.right_layout.addStretch() # Signals and slots self.pdf_program_browse_button.clicked.connect(self.on_pdf_program_browse_button_clicked) @@ -231,9 +231,9 @@ class PresentationTab(SettingsTab): """ Select the mudraw or ghostscript binary that should be used. """ - filename = QtGui.QFileDialog.getOpenFileName(self, translate('PresentationPlugin.PresentationTab', - 'Select mudraw or ghostscript binary.'), - self.pdf_program_path.text()) + filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( + self, translate('PresentationPlugin.PresentationTab', 'Select mudraw or ghostscript binary.'), + self.pdf_program_path.text()) if filename: program_type = PdfController.check_binary(filename) if not program_type: diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index b2118ce46..5e94645d9 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -26,7 +26,7 @@ formats. import os import logging -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import AppLocation, Settings, translate from openlp.core.lib import Plugin, StringContent, build_icon diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index 000d743cd..dedefdc90 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -115,7 +115,6 @@ import urllib.error from urllib.parse import urlparse, parse_qs from mako.template import Template -from PyQt4 import QtCore from openlp.core.common import RegistryProperties, AppLocation, Settings, translate, UiStrings from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities, create_thumb @@ -471,7 +470,7 @@ class HttpRouter(RegistryProperties): :param action: This is the action, either ``hide`` or ``show``. """ - self.live_controller.emit(QtCore.SIGNAL('slidecontroller_toggle_display'), action) + self.live_controller.slidecontroller_toggle_display.emit(action) self.do_json_header() return json.dumps({'results': {'success': True}}).encode() @@ -486,7 +485,7 @@ class HttpRouter(RegistryProperties): except KeyError: return self.do_http_error() text = urllib.parse.unquote(text) - self.alerts_manager.emit(QtCore.SIGNAL('alerts_text'), [text]) + self.alerts_manager.alerts_text.emit([text]) success = True else: success = False @@ -552,7 +551,7 @@ class HttpRouter(RegistryProperties): :param display_type: This is the type of slide controller, either ``preview`` or ``live``. :param action: The action to perform. """ - event = 'slidecontroller_%s_%s' % (display_type, action) + event = getattr(self.live_controller, 'slidecontroller_%s_%s' % (display_type, action)) if self.request_data: try: data = json.loads(self.request_data)['request']['id'] @@ -560,9 +559,9 @@ class HttpRouter(RegistryProperties): return self.do_http_error() log.info(data) # This slot expects an int within a list. - self.live_controller.emit(QtCore.SIGNAL(event), [data]) + event.emit([data]) else: - self.live_controller.emit(QtCore.SIGNAL(event)) + event.emit() json_data = {'results': {'success': True}} self.do_json_header() return json.dumps(json_data).encode() @@ -581,15 +580,15 @@ class HttpRouter(RegistryProperties): :param action: The action to perform. """ - event = 'servicemanager_%s_item' % action + event = getattr(self.service_manager, 'servicemanager_%s_item' % action) if self.request_data: try: data = json.loads(self.request_data)['request']['id'] except KeyError: return self.do_http_error() - self.service_manager.emit(QtCore.SIGNAL(event), data) + event.emit(data) else: - self.service_manager.emit(QtCore.SIGNAL(event)) + event.emit() self.do_json_header() return json.dumps({'results': {'success': True}}).encode() @@ -636,7 +635,7 @@ class HttpRouter(RegistryProperties): return self.do_http_error() plugin = self.plugin_manager.get_plugin_by_name(plugin_name) if plugin.status == PluginStatus.Active and plugin.media_item: - plugin.media_item.emit(QtCore.SIGNAL('%s_go_live' % plugin_name), [request_id, True]) + getattr(plugin.media_item, '%s_go_live' % plugin_name).emit([request_id, True]) return self.do_http_success() def add_to_service(self, plugin_name): @@ -650,5 +649,5 @@ class HttpRouter(RegistryProperties): plugin = self.plugin_manager.get_plugin_by_name(plugin_name) if plugin.status == PluginStatus.Active and plugin.media_item: item_id = plugin.media_item.create_item_from_id(request_id) - plugin.media_item.emit(QtCore.SIGNAL('%s_add_to_service' % plugin_name), [item_id, True]) + getattr(plugin.media_item, '%s_add_to_service' % plugin_name).emit([item_id, True]) self.do_http_success() diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index fa1348314..d890bb773 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -31,7 +31,7 @@ import os import logging import time -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import AppLocation, Settings, RegistryProperties diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 6515a32f6..90f191f89 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -22,7 +22,7 @@ import os.path -from PyQt4 import QtCore, QtGui, QtNetwork +from PyQt5 import QtCore, QtGui, QtNetwork, QtWidgets from openlp.core.common import AppLocation, Settings, translate from openlp.core.lib import SettingsTab, build_icon @@ -40,118 +40,118 @@ class RemoteTab(SettingsTab): def setupUi(self): self.setObjectName('RemoteTab') super(RemoteTab, self).setupUi() - self.server_settings_group_box = QtGui.QGroupBox(self.left_column) + self.server_settings_group_box = QtWidgets.QGroupBox(self.left_column) self.server_settings_group_box.setObjectName('server_settings_group_box') - self.server_settings_layout = QtGui.QFormLayout(self.server_settings_group_box) + self.server_settings_layout = QtWidgets.QFormLayout(self.server_settings_group_box) self.server_settings_layout.setObjectName('server_settings_layout') - self.address_label = QtGui.QLabel(self.server_settings_group_box) + self.address_label = QtWidgets.QLabel(self.server_settings_group_box) self.address_label.setObjectName('address_label') - self.address_edit = QtGui.QLineEdit(self.server_settings_group_box) - self.address_edit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) + self.address_edit = QtWidgets.QLineEdit(self.server_settings_group_box) + self.address_edit.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), self)) self.address_edit.setObjectName('address_edit') self.server_settings_layout.addRow(self.address_label, self.address_edit) - self.twelve_hour_check_box = QtGui.QCheckBox(self.server_settings_group_box) + self.twelve_hour_check_box = QtWidgets.QCheckBox(self.server_settings_group_box) self.twelve_hour_check_box.setObjectName('twelve_hour_check_box') self.server_settings_layout.addRow(self.twelve_hour_check_box) - self.thumbnails_check_box = QtGui.QCheckBox(self.server_settings_group_box) + self.thumbnails_check_box = QtWidgets.QCheckBox(self.server_settings_group_box) self.thumbnails_check_box.setObjectName('thumbnails_check_box') self.server_settings_layout.addRow(self.thumbnails_check_box) self.left_layout.addWidget(self.server_settings_group_box) - self.http_settings_group_box = QtGui.QGroupBox(self.left_column) + self.http_settings_group_box = QtWidgets.QGroupBox(self.left_column) self.http_settings_group_box.setObjectName('http_settings_group_box') - self.http_setting_layout = QtGui.QFormLayout(self.http_settings_group_box) + self.http_setting_layout = QtWidgets.QFormLayout(self.http_settings_group_box) self.http_setting_layout.setObjectName('http_setting_layout') - self.port_label = QtGui.QLabel(self.http_settings_group_box) + self.port_label = QtWidgets.QLabel(self.http_settings_group_box) self.port_label.setObjectName('port_label') - self.port_spin_box = QtGui.QSpinBox(self.http_settings_group_box) + self.port_spin_box = QtWidgets.QSpinBox(self.http_settings_group_box) self.port_spin_box.setMaximum(32767) self.port_spin_box.setObjectName('port_spin_box') self.http_setting_layout.addRow(self.port_label, self.port_spin_box) - self.remote_url_label = QtGui.QLabel(self.http_settings_group_box) + self.remote_url_label = QtWidgets.QLabel(self.http_settings_group_box) self.remote_url_label.setObjectName('remote_url_label') - self.remote_url = QtGui.QLabel(self.http_settings_group_box) + self.remote_url = QtWidgets.QLabel(self.http_settings_group_box) self.remote_url.setObjectName('remote_url') self.remote_url.setOpenExternalLinks(True) self.http_setting_layout.addRow(self.remote_url_label, self.remote_url) - self.stage_url_label = QtGui.QLabel(self.http_settings_group_box) + self.stage_url_label = QtWidgets.QLabel(self.http_settings_group_box) self.stage_url_label.setObjectName('stage_url_label') - self.stage_url = QtGui.QLabel(self.http_settings_group_box) + self.stage_url = QtWidgets.QLabel(self.http_settings_group_box) self.stage_url.setObjectName('stage_url') self.stage_url.setOpenExternalLinks(True) self.http_setting_layout.addRow(self.stage_url_label, self.stage_url) - self.live_url_label = QtGui.QLabel(self.http_settings_group_box) + self.live_url_label = QtWidgets.QLabel(self.http_settings_group_box) self.live_url_label.setObjectName('live_url_label') - self.live_url = QtGui.QLabel(self.http_settings_group_box) + self.live_url = QtWidgets.QLabel(self.http_settings_group_box) self.live_url.setObjectName('live_url') self.live_url.setOpenExternalLinks(True) self.http_setting_layout.addRow(self.live_url_label, self.live_url) self.left_layout.addWidget(self.http_settings_group_box) - self.https_settings_group_box = QtGui.QGroupBox(self.left_column) + self.https_settings_group_box = QtWidgets.QGroupBox(self.left_column) self.https_settings_group_box.setCheckable(True) self.https_settings_group_box.setChecked(False) self.https_settings_group_box.setObjectName('https_settings_group_box') - self.https_settings_layout = QtGui.QFormLayout(self.https_settings_group_box) + self.https_settings_layout = QtWidgets.QFormLayout(self.https_settings_group_box) self.https_settings_layout.setObjectName('https_settings_layout') - self.https_error_label = QtGui.QLabel(self.https_settings_group_box) + self.https_error_label = QtWidgets.QLabel(self.https_settings_group_box) self.https_error_label.setVisible(False) self.https_error_label.setWordWrap(True) self.https_error_label.setObjectName('https_error_label') self.https_settings_layout.addRow(self.https_error_label) - self.https_port_label = QtGui.QLabel(self.https_settings_group_box) + self.https_port_label = QtWidgets.QLabel(self.https_settings_group_box) self.https_port_label.setObjectName('https_port_label') - self.https_port_spin_box = QtGui.QSpinBox(self.https_settings_group_box) + self.https_port_spin_box = QtWidgets.QSpinBox(self.https_settings_group_box) self.https_port_spin_box.setMaximum(32767) self.https_port_spin_box.setObjectName('https_port_spin_box') self.https_settings_layout.addRow(self.https_port_label, self.https_port_spin_box) - self.remote_https_url = QtGui.QLabel(self.https_settings_group_box) + self.remote_https_url = QtWidgets.QLabel(self.https_settings_group_box) self.remote_https_url.setObjectName('remote_http_url') self.remote_https_url.setOpenExternalLinks(True) - self.remote_https_url_label = QtGui.QLabel(self.https_settings_group_box) + self.remote_https_url_label = QtWidgets.QLabel(self.https_settings_group_box) self.remote_https_url_label.setObjectName('remote_http_url_label') self.https_settings_layout.addRow(self.remote_https_url_label, self.remote_https_url) - self.stage_https_url_label = QtGui.QLabel(self.http_settings_group_box) + self.stage_https_url_label = QtWidgets.QLabel(self.http_settings_group_box) self.stage_https_url_label.setObjectName('stage_https_url_label') - self.stage_https_url = QtGui.QLabel(self.https_settings_group_box) + self.stage_https_url = QtWidgets.QLabel(self.https_settings_group_box) self.stage_https_url.setObjectName('stage_https_url') self.stage_https_url.setOpenExternalLinks(True) self.https_settings_layout.addRow(self.stage_https_url_label, self.stage_https_url) - self.live_https_url_label = QtGui.QLabel(self.https_settings_group_box) + self.live_https_url_label = QtWidgets.QLabel(self.https_settings_group_box) self.live_https_url_label.setObjectName('live_url_label') - self.live_https_url = QtGui.QLabel(self.https_settings_group_box) + self.live_https_url = QtWidgets.QLabel(self.https_settings_group_box) self.live_https_url.setObjectName('live_https_url') self.live_https_url.setOpenExternalLinks(True) self.https_settings_layout.addRow(self.live_https_url_label, self.live_https_url) self.left_layout.addWidget(self.https_settings_group_box) - self.user_login_group_box = QtGui.QGroupBox(self.left_column) + self.user_login_group_box = QtWidgets.QGroupBox(self.left_column) self.user_login_group_box.setCheckable(True) self.user_login_group_box.setChecked(False) self.user_login_group_box.setObjectName('user_login_group_box') - self.user_login_layout = QtGui.QFormLayout(self.user_login_group_box) + self.user_login_layout = QtWidgets.QFormLayout(self.user_login_group_box) self.user_login_layout.setObjectName('user_login_layout') - self.user_id_label = QtGui.QLabel(self.user_login_group_box) + self.user_id_label = QtWidgets.QLabel(self.user_login_group_box) self.user_id_label.setObjectName('user_id_label') - self.user_id = QtGui.QLineEdit(self.user_login_group_box) + self.user_id = QtWidgets.QLineEdit(self.user_login_group_box) self.user_id.setObjectName('user_id') self.user_login_layout.addRow(self.user_id_label, self.user_id) - self.password_label = QtGui.QLabel(self.user_login_group_box) + self.password_label = QtWidgets.QLabel(self.user_login_group_box) self.password_label.setObjectName('password_label') - self.password = QtGui.QLineEdit(self.user_login_group_box) + self.password = QtWidgets.QLineEdit(self.user_login_group_box) self.password.setObjectName('password') self.user_login_layout.addRow(self.password_label, self.password) self.left_layout.addWidget(self.user_login_group_box) - self.android_app_group_box = QtGui.QGroupBox(self.right_column) + self.android_app_group_box = QtWidgets.QGroupBox(self.right_column) self.android_app_group_box.setObjectName('android_app_group_box') self.right_layout.addWidget(self.android_app_group_box) - self.qr_layout = QtGui.QVBoxLayout(self.android_app_group_box) + self.qr_layout = QtWidgets.QVBoxLayout(self.android_app_group_box) self.qr_layout.setObjectName('qr_layout') - self.qr_code_label = QtGui.QLabel(self.android_app_group_box) + self.qr_code_label = QtWidgets.QLabel(self.android_app_group_box) self.qr_code_label.setPixmap(QtGui.QPixmap(':/remotes/android_app_qr.png')) self.qr_code_label.setAlignment(QtCore.Qt.AlignCenter) self.qr_code_label.setObjectName('qr_code_label') self.qr_layout.addWidget(self.qr_code_label) - self.qr_description_label = QtGui.QLabel(self.android_app_group_box) + self.qr_description_label = QtWidgets.QLabel(self.android_app_group_box) self.qr_description_label.setObjectName('qr_description_label') self.qr_description_label.setOpenExternalLinks(True) self.qr_description_label.setWordWrap(True) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 514ae5176..137e5a7f0 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -22,7 +22,7 @@ import logging -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import Plugin, StringContent, translate, build_icon from openlp.plugins.remotes.lib import RemoteTab, OpenLPServer @@ -63,13 +63,13 @@ class RemotesPlugin(Plugin): super(RemotesPlugin, self).initialise() self.server = OpenLPServer() if not hasattr(self, 'remote_server_icon'): - self.remote_server_icon = QtGui.QLabel(self.main_window.status_bar) - size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.remote_server_icon = QtWidgets.QLabel(self.main_window.status_bar) + size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) size_policy.setHorizontalStretch(0) size_policy.setVerticalStretch(0) size_policy.setHeightForWidth(self.remote_server_icon.sizePolicy().hasHeightForWidth()) self.remote_server_icon.setSizePolicy(size_policy) - self.remote_server_icon.setFrameShadow(QtGui.QFrame.Plain) + self.remote_server_icon.setFrameShadow(QtWidgets.QFrame.Plain) self.remote_server_icon.setLineWidth(1) self.remote_server_icon.setScaledContents(True) self.remote_server_icon.setFixedSize(20, 20) @@ -117,8 +117,9 @@ class RemotesPlugin(Plugin): Called when Config is changed to requests a restart with the server on new address or port """ log.debug('remote config changed') - QtGui.QMessageBox.information(self.main_window, - translate('RemotePlugin', 'Server Config Change'), - translate('RemotePlugin', 'Server configuration changes will require a restart ' - 'to take effect.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.information(self.main_window, + translate('RemotePlugin', 'Server Config Change'), + translate('RemotePlugin', + 'Server configuration changes will require a restart ' + 'to take effect.'), + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) diff --git a/openlp/plugins/songs/forms/__init__.py b/openlp/plugins/songs/forms/__init__.py index 5e1e4cc80..bfe6e0004 100644 --- a/openlp/plugins/songs/forms/__init__.py +++ b/openlp/plugins/songs/forms/__init__.py @@ -26,16 +26,16 @@ code, like slots and loading and saving. The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly modified version of the class that the -``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be +``pyuic5`` command produces from Qt5's .ui file. Typical modifications will be converting most strings from "" to '' and using OpenLP's ``translate()`` function for translating strings. The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which is instantiated and used. It uses -dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class +dual inheritance to inherit from (usually) QtWidgets.QDialog and the Ui class mentioned above, like so:: - class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): + class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): def __init__(self, parent=None): super(AuthorsForm, self).__init__(parent) diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index 5af9dcde7..d93a1b1f7 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box @@ -39,25 +39,25 @@ class Ui_AuthorsDialog(object): authors_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) authors_dialog.resize(300, 10) authors_dialog.setModal(True) - self.dialog_layout = QtGui.QVBoxLayout(authors_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(authors_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.author_layout = QtGui.QFormLayout() + self.author_layout = QtWidgets.QFormLayout() self.author_layout.setObjectName('author_layout') - self.first_name_label = QtGui.QLabel(authors_dialog) + self.first_name_label = QtWidgets.QLabel(authors_dialog) self.first_name_label.setObjectName('first_name_label') - self.first_name_edit = QtGui.QLineEdit(authors_dialog) + self.first_name_edit = QtWidgets.QLineEdit(authors_dialog) self.first_name_edit.setObjectName('first_name_edit') self.first_name_label.setBuddy(self.first_name_edit) self.author_layout.addRow(self.first_name_label, self.first_name_edit) - self.last_name_label = QtGui.QLabel(authors_dialog) + self.last_name_label = QtWidgets.QLabel(authors_dialog) self.last_name_label.setObjectName('last_name_label') - self.last_name_edit = QtGui.QLineEdit(authors_dialog) + self.last_name_edit = QtWidgets.QLineEdit(authors_dialog) self.last_name_edit.setObjectName('last_name_edit') self.last_name_label.setBuddy(self.last_name_edit) self.author_layout.addRow(self.last_name_label, self.last_name_edit) - self.display_label = QtGui.QLabel(authors_dialog) + self.display_label = QtWidgets.QLabel(authors_dialog) self.display_label.setObjectName('display_label') - self.display_edit = QtGui.QLineEdit(authors_dialog) + self.display_edit = QtWidgets.QLineEdit(authors_dialog) self.display_edit.setObjectName('display_edit') self.display_label.setBuddy(self.display_edit) self.author_layout.addRow(self.display_label, self.display_edit) diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 1ed609099..3f0ef62cc 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -20,14 +20,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.authorsdialog import Ui_AuthorsDialog -class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): +class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): """ Class to control the Maintenance of Authors Dialog """ @@ -41,7 +41,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): self.first_name_edit.textEdited.connect(self.on_first_name_edited) self.last_name_edit.textEdited.connect(self.on_last_name_edited) - def exec_(self, clear=True): + def exec(self, clear=True): """ Execute the dialog. @@ -52,7 +52,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): self.last_name_edit.clear() self.display_edit.clear() self.first_name_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def on_first_name_edited(self, display_name): """ @@ -102,14 +102,14 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): if critical_error_message_box( message=translate('SongsPlugin.AuthorsForm', 'You have not set a display name for the author, combine the first and last names?'), - parent=self, question=True) == QtGui.QMessageBox.Yes: + parent=self, question=True) == QtWidgets.QMessageBox.Yes: self.display_edit.setText(self.first_name_edit.text() + ' ' + self.last_name_edit.text()) - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) else: self.display_edit.setFocus() return False else: - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) def _get_first_name(self): """ diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index a2f9c3c69..d246d83c8 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -27,7 +27,7 @@ import logging import multiprocessing import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -87,42 +87,42 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): Add song wizard specific pages. """ # Add custom pages. - self.searching_page = QtGui.QWizardPage() + self.searching_page = QtWidgets.QWizardPage() self.searching_page.setObjectName('searching_page') - self.searching_vertical_layout = QtGui.QVBoxLayout(self.searching_page) + self.searching_vertical_layout = QtWidgets.QVBoxLayout(self.searching_page) self.searching_vertical_layout.setObjectName('searching_vertical_layout') - self.duplicate_search_progress_bar = QtGui.QProgressBar(self.searching_page) + self.duplicate_search_progress_bar = QtWidgets.QProgressBar(self.searching_page) self.duplicate_search_progress_bar.setObjectName('duplicate_search_progress_bar') self.duplicate_search_progress_bar.setFormat(WizardStrings.PercentSymbolFormat) self.searching_vertical_layout.addWidget(self.duplicate_search_progress_bar) - self.found_duplicates_edit = QtGui.QPlainTextEdit(self.searching_page) + self.found_duplicates_edit = QtWidgets.QPlainTextEdit(self.searching_page) self.found_duplicates_edit.setUndoRedoEnabled(False) self.found_duplicates_edit.setReadOnly(True) self.found_duplicates_edit.setObjectName('found_duplicates_edit') self.searching_vertical_layout.addWidget(self.found_duplicates_edit) self.searching_page_id = self.addPage(self.searching_page) - self.review_page = QtGui.QWizardPage() + self.review_page = QtWidgets.QWizardPage() self.review_page.setObjectName('review_page') - self.review_layout = QtGui.QVBoxLayout(self.review_page) + self.review_layout = QtWidgets.QVBoxLayout(self.review_page) self.review_layout.setObjectName('review_layout') - self.review_scroll_area = QtGui.QScrollArea(self.review_page) + self.review_scroll_area = QtWidgets.QScrollArea(self.review_page) self.review_scroll_area.setObjectName('review_scroll_area') self.review_scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.review_scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.review_scroll_area.setWidgetResizable(True) - self.review_scroll_area_widget = QtGui.QWidget(self.review_scroll_area) + self.review_scroll_area_widget = QtWidgets.QWidget(self.review_scroll_area) self.review_scroll_area_widget.setObjectName('review_scroll_area_widget') - self.review_scroll_area_layout = QtGui.QHBoxLayout(self.review_scroll_area_widget) + self.review_scroll_area_layout = QtWidgets.QHBoxLayout(self.review_scroll_area_widget) self.review_scroll_area_layout.setObjectName('review_scroll_area_layout') - self.review_scroll_area_layout.setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize) - self.review_scroll_area_layout.setMargin(0) + self.review_scroll_area_layout.setSizeConstraint(QtWidgets.QLayout.SetMinAndMaxSize) + self.review_scroll_area_layout.setContentsMargins(0, 0, 0, 0) self.review_scroll_area_layout.setSpacing(0) self.review_scroll_area.setWidget(self.review_scroll_area_widget) self.review_layout.addWidget(self.review_scroll_area) self.review_page_id = self.addPage(self.review_page) # Add a dummy page to the end, to prevent the finish button to appear and the next button do disappear on the # review page. - self.dummy_page = QtGui.QWizardPage() + self.dummy_page = QtWidgets.QWizardPage() self.dummy_page_id = self.addPage(self.dummy_page) def retranslateUi(self): @@ -158,11 +158,11 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): :param page_id: ID of the page the wizard changed to. """ # Hide back button. - self.button(QtGui.QWizard.BackButton).hide() + self.button(QtWidgets.QWizard.BackButton).hide() if page_id == self.searching_page_id: self.application.set_busy_cursor() try: - self.button(QtGui.QWizard.NextButton).hide() + self.button(QtWidgets.QWizard.NextButton).hide() # Search duplicate songs. max_songs = self.plugin.manager.get_object_count(Song) if max_songs == 0 or max_songs == 1: @@ -197,7 +197,7 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): self.found_duplicates_edit.appendPlainText(song1.title + " = " + song2.title) self.review_total_count = len(self.duplicate_song_list) if self.duplicate_song_list: - self.button(QtGui.QWizard.NextButton).show() + self.button(QtWidgets.QWizard.NextButton).show() else: self.notify_no_duplicates() finally: @@ -209,14 +209,14 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): """ Notifies the user, that there were no duplicates found in the database. """ - self.button(QtGui.QWizard.FinishButton).show() - self.button(QtGui.QWizard.FinishButton).setEnabled(True) - self.button(QtGui.QWizard.NextButton).hide() - self.button(QtGui.QWizard.CancelButton).hide() - QtGui.QMessageBox.information( + self.button(QtWidgets.QWizard.FinishButton).show() + self.button(QtWidgets.QWizard.FinishButton).setEnabled(True) + self.button(QtWidgets.QWizard.NextButton).hide() + self.button(QtWidgets.QWizard.CancelButton).hide() + QtWidgets.QMessageBox.information( self, translate('Wizard', 'Information'), translate('Wizard', 'No duplicate songs have been found in the database.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) def add_duplicates_to_song_list(self, search_song, duplicate_song): """ @@ -310,7 +310,7 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): # Remove all previous elements. for i in reversed(list(range(self.review_scroll_area_layout.count()))): item = self.review_scroll_area_layout.itemAt(i) - if isinstance(item, QtGui.QWidgetItem): + if isinstance(item, QtWidgets.QWidgetItem): # The order is important here, if the .setParent(None) call is done # before the .removeItem() call, a segfault occurs. widget = item.widget() @@ -339,7 +339,7 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): self.review_scroll_area_layout.addStretch(1) # Change next button to finish button on last review. if len(self.duplicate_song_list) == 1: - self.button(QtGui.QWizard.FinishButton).show() - self.button(QtGui.QWizard.FinishButton).setEnabled(True) - self.button(QtGui.QWizard.NextButton).hide() - self.button(QtGui.QWizard.CancelButton).hide() + self.button(QtWidgets.QWizard.FinishButton).show() + self.button(QtWidgets.QWizard.FinishButton).setEnabled(True) + self.button(QtWidgets.QWizard.NextButton).hide() + self.button(QtWidgets.QWizard.CancelButton).hide() diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 77bd0ae98..9821bc745 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.core.common import UiStrings, translate from openlp.core.lib import build_icon @@ -39,152 +39,152 @@ class Ui_EditSongDialog(object): edit_song_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) edit_song_dialog.resize(650, 400) edit_song_dialog.setModal(True) - self.dialog_layout = QtGui.QVBoxLayout(edit_song_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(edit_song_dialog) self.dialog_layout.setSpacing(8) self.dialog_layout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setObjectName('dialog_layout') - self.song_tab_widget = QtGui.QTabWidget(edit_song_dialog) + self.song_tab_widget = QtWidgets.QTabWidget(edit_song_dialog) self.song_tab_widget.setObjectName('song_tab_widget') # lyrics tab - self.lyrics_tab = QtGui.QWidget() + self.lyrics_tab = QtWidgets.QWidget() self.lyrics_tab.setObjectName('lyrics_tab') - self.lyrics_tab_layout = QtGui.QGridLayout(self.lyrics_tab) + self.lyrics_tab_layout = QtWidgets.QGridLayout(self.lyrics_tab) self.lyrics_tab_layout.setObjectName('lyrics_tab_layout') - self.title_label = QtGui.QLabel(self.lyrics_tab) + self.title_label = QtWidgets.QLabel(self.lyrics_tab) self.title_label.setObjectName('title_label') self.lyrics_tab_layout.addWidget(self.title_label, 0, 0) - self.title_edit = QtGui.QLineEdit(self.lyrics_tab) + self.title_edit = QtWidgets.QLineEdit(self.lyrics_tab) self.title_edit.setObjectName('title_edit') self.title_label.setBuddy(self.title_edit) self.lyrics_tab_layout.addWidget(self.title_edit, 0, 1, 1, 2) - self.alternative_title_label = QtGui.QLabel(self.lyrics_tab) + self.alternative_title_label = QtWidgets.QLabel(self.lyrics_tab) self.alternative_title_label.setObjectName('alternative_title_label') self.lyrics_tab_layout.addWidget(self.alternative_title_label, 1, 0) - self.alternative_edit = QtGui.QLineEdit(self.lyrics_tab) + self.alternative_edit = QtWidgets.QLineEdit(self.lyrics_tab) self.alternative_edit.setObjectName('alternative_edit') self.alternative_title_label.setBuddy(self.alternative_edit) self.lyrics_tab_layout.addWidget(self.alternative_edit, 1, 1, 1, 2) - self.lyrics_label = QtGui.QLabel(self.lyrics_tab) + self.lyrics_label = QtWidgets.QLabel(self.lyrics_tab) self.lyrics_label.setFixedHeight(self.title_edit.sizeHint().height()) self.lyrics_label.setObjectName('lyrics_label') self.lyrics_tab_layout.addWidget(self.lyrics_label, 2, 0, QtCore.Qt.AlignTop) self.verse_list_widget = SingleColumnTableWidget(self.lyrics_tab) self.verse_list_widget.setAlternatingRowColors(True) - self.verse_list_widget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) - self.verse_list_widget.setSelectionMode(QtGui.QAbstractItemView.SingleSelection) - self.verse_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.verse_list_widget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.verse_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) + self.verse_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.verse_list_widget.setObjectName('verse_list_widget') self.lyrics_label.setBuddy(self.verse_list_widget) self.lyrics_tab_layout.addWidget(self.verse_list_widget, 2, 1) - self.verse_order_label = QtGui.QLabel(self.lyrics_tab) + self.verse_order_label = QtWidgets.QLabel(self.lyrics_tab) self.verse_order_label.setObjectName('verse_order_label') self.lyrics_tab_layout.addWidget(self.verse_order_label, 3, 0) - self.verse_order_edit = QtGui.QLineEdit(self.lyrics_tab) + self.verse_order_edit = QtWidgets.QLineEdit(self.lyrics_tab) self.verse_order_edit.setObjectName('verse_order_edit') self.verse_order_label.setBuddy(self.verse_order_edit) self.lyrics_tab_layout.addWidget(self.verse_order_edit, 3, 1, 1, 2) - self.verse_buttons_layout = QtGui.QVBoxLayout() + self.verse_buttons_layout = QtWidgets.QVBoxLayout() self.verse_buttons_layout.setObjectName('verse_buttons_layout') - self.verse_add_button = QtGui.QPushButton(self.lyrics_tab) + self.verse_add_button = QtWidgets.QPushButton(self.lyrics_tab) self.verse_add_button.setObjectName('verse_add_button') self.verse_buttons_layout.addWidget(self.verse_add_button) - self.verse_edit_button = QtGui.QPushButton(self.lyrics_tab) + self.verse_edit_button = QtWidgets.QPushButton(self.lyrics_tab) self.verse_edit_button.setObjectName('verse_edit_button') self.verse_buttons_layout.addWidget(self.verse_edit_button) - self.verse_edit_all_button = QtGui.QPushButton(self.lyrics_tab) + self.verse_edit_all_button = QtWidgets.QPushButton(self.lyrics_tab) self.verse_edit_all_button.setObjectName('verse_edit_all_button') self.verse_buttons_layout.addWidget(self.verse_edit_all_button) - self.verse_delete_button = QtGui.QPushButton(self.lyrics_tab) + self.verse_delete_button = QtWidgets.QPushButton(self.lyrics_tab) self.verse_delete_button.setObjectName('verse_delete_button') self.verse_buttons_layout.addWidget(self.verse_delete_button) self.verse_buttons_layout.addStretch() self.lyrics_tab_layout.addLayout(self.verse_buttons_layout, 2, 2) self.song_tab_widget.addTab(self.lyrics_tab, '') # authors tab - self.authors_tab = QtGui.QWidget() + self.authors_tab = QtWidgets.QWidget() self.authors_tab.setObjectName('authors_tab') - self.authors_tab_layout = QtGui.QHBoxLayout(self.authors_tab) + self.authors_tab_layout = QtWidgets.QHBoxLayout(self.authors_tab) self.authors_tab_layout.setObjectName('authors_tab_layout') - self.authors_left_layout = QtGui.QVBoxLayout() + self.authors_left_layout = QtWidgets.QVBoxLayout() self.authors_left_layout.setObjectName('authors_left_layout') - self.authors_group_box = QtGui.QGroupBox(self.authors_tab) + self.authors_group_box = QtWidgets.QGroupBox(self.authors_tab) self.authors_group_box.setObjectName('authors_group_box') - self.authors_layout = QtGui.QVBoxLayout(self.authors_group_box) + self.authors_layout = QtWidgets.QVBoxLayout(self.authors_group_box) self.authors_layout.setObjectName('authors_layout') - self.author_add_layout = QtGui.QVBoxLayout() + self.author_add_layout = QtWidgets.QVBoxLayout() self.author_add_layout.setObjectName('author_add_layout') - self.author_type_layout = QtGui.QHBoxLayout() + self.author_type_layout = QtWidgets.QHBoxLayout() self.author_type_layout.setObjectName('author_type_layout') self.authors_combo_box = create_combo_box(self.authors_group_box, 'authors_combo_box') self.author_add_layout.addWidget(self.authors_combo_box) self.author_types_combo_box = create_combo_box(self.authors_group_box, 'author_types_combo_box', editable=False) self.author_type_layout.addWidget(self.author_types_combo_box) - self.author_add_button = QtGui.QPushButton(self.authors_group_box) + self.author_add_button = QtWidgets.QPushButton(self.authors_group_box) self.author_add_button.setObjectName('author_add_button') self.author_type_layout.addWidget(self.author_add_button) self.author_add_layout.addLayout(self.author_type_layout) self.authors_layout.addLayout(self.author_add_layout) - self.authors_list_view = QtGui.QListWidget(self.authors_group_box) + self.authors_list_view = QtWidgets.QListWidget(self.authors_group_box) self.authors_list_view.setAlternatingRowColors(True) self.authors_list_view.setObjectName('authors_list_view') self.authors_layout.addWidget(self.authors_list_view) - self.author_remove_layout = QtGui.QHBoxLayout() + self.author_remove_layout = QtWidgets.QHBoxLayout() self.author_remove_layout.setObjectName('author_remove_layout') self.author_remove_layout.addStretch() - self.author_edit_button = QtGui.QPushButton(self.authors_group_box) + self.author_edit_button = QtWidgets.QPushButton(self.authors_group_box) self.author_edit_button.setObjectName('author_edit_button') self.author_remove_layout.addWidget(self.author_edit_button) - self.author_remove_button = QtGui.QPushButton(self.authors_group_box) + self.author_remove_button = QtWidgets.QPushButton(self.authors_group_box) self.author_remove_button.setObjectName('author_remove_button') self.author_remove_layout.addWidget(self.author_remove_button) self.authors_layout.addLayout(self.author_remove_layout) self.authors_left_layout.addWidget(self.authors_group_box) - self.maintenance_layout = QtGui.QHBoxLayout() + self.maintenance_layout = QtWidgets.QHBoxLayout() self.maintenance_layout.setObjectName('maintenance_layout') - self.maintenance_button = QtGui.QPushButton(self.authors_tab) + self.maintenance_button = QtWidgets.QPushButton(self.authors_tab) self.maintenance_button.setObjectName('maintenance_button') self.maintenance_layout.addWidget(self.maintenance_button) self.maintenance_layout.addStretch() self.authors_left_layout.addLayout(self.maintenance_layout) self.authors_tab_layout.addLayout(self.authors_left_layout) - self.authors_right_layout = QtGui.QVBoxLayout() + self.authors_right_layout = QtWidgets.QVBoxLayout() self.authors_right_layout.setObjectName('authors_right_layout') - self.topics_group_box = QtGui.QGroupBox(self.authors_tab) + self.topics_group_box = QtWidgets.QGroupBox(self.authors_tab) self.topics_group_box.setObjectName('topics_group_box') - self.topics_layout = QtGui.QVBoxLayout(self.topics_group_box) + self.topics_layout = QtWidgets.QVBoxLayout(self.topics_group_box) self.topics_layout.setObjectName('topics_layout') - self.topic_add_layout = QtGui.QHBoxLayout() + self.topic_add_layout = QtWidgets.QHBoxLayout() self.topic_add_layout.setObjectName('topic_add_layout') self.topics_combo_box = create_combo_box(self.topics_group_box, 'topics_combo_box') self.topic_add_layout.addWidget(self.topics_combo_box) - self.topic_add_button = QtGui.QPushButton(self.topics_group_box) + self.topic_add_button = QtWidgets.QPushButton(self.topics_group_box) self.topic_add_button.setObjectName('topic_add_button') self.topic_add_layout.addWidget(self.topic_add_button) self.topics_layout.addLayout(self.topic_add_layout) - self.topics_list_view = QtGui.QListWidget(self.topics_group_box) + self.topics_list_view = QtWidgets.QListWidget(self.topics_group_box) self.topics_list_view.setAlternatingRowColors(True) self.topics_list_view.setObjectName('topics_list_view') self.topics_layout.addWidget(self.topics_list_view) - self.topic_remove_layout = QtGui.QHBoxLayout() + self.topic_remove_layout = QtWidgets.QHBoxLayout() self.topic_remove_layout.setObjectName('topic_remove_layout') self.topic_remove_layout.addStretch() - self.topic_remove_button = QtGui.QPushButton(self.topics_group_box) + self.topic_remove_button = QtWidgets.QPushButton(self.topics_group_box) self.topic_remove_button.setObjectName('topic_remove_button') self.topic_remove_layout.addWidget(self.topic_remove_button) self.topics_layout.addLayout(self.topic_remove_layout) self.authors_right_layout.addWidget(self.topics_group_box) - self.song_book_group_box = QtGui.QGroupBox(self.authors_tab) + self.song_book_group_box = QtWidgets.QGroupBox(self.authors_tab) self.song_book_group_box.setObjectName('song_book_group_box') - self.song_book_layout = QtGui.QFormLayout(self.song_book_group_box) + self.song_book_layout = QtWidgets.QFormLayout(self.song_book_group_box) self.song_book_layout.setObjectName('song_book_layout') - self.song_book_name_label = QtGui.QLabel(self.song_book_group_box) + self.song_book_name_label = QtWidgets.QLabel(self.song_book_group_box) self.song_book_name_label.setObjectName('song_book_name_label') self.song_book_combo_box = create_combo_box(self.song_book_group_box, 'song_book_combo_box') self.song_book_name_label.setBuddy(self.song_book_combo_box) self.song_book_layout.addRow(self.song_book_name_label, self.song_book_combo_box) - self.song_book_number_label = QtGui.QLabel(self.song_book_group_box) + self.song_book_number_label = QtWidgets.QLabel(self.song_book_group_box) self.song_book_number_label.setObjectName('song_book_number_label') - self.song_book_number_edit = QtGui.QLineEdit(self.song_book_group_box) + self.song_book_number_edit = QtWidgets.QLineEdit(self.song_book_group_box) self.song_book_number_edit.setObjectName('song_book_number_edit') self.song_book_number_label.setBuddy(self.song_book_number_edit) self.song_book_layout.addRow(self.song_book_number_label, self.song_book_number_edit) @@ -192,41 +192,41 @@ class Ui_EditSongDialog(object): self.authors_tab_layout.addLayout(self.authors_right_layout) self.song_tab_widget.addTab(self.authors_tab, '') # theme tab - self.theme_tab = QtGui.QWidget() + self.theme_tab = QtWidgets.QWidget() self.theme_tab.setObjectName('theme_tab') - self.theme_tab_layout = QtGui.QHBoxLayout(self.theme_tab) + self.theme_tab_layout = QtWidgets.QHBoxLayout(self.theme_tab) self.theme_tab_layout.setObjectName('theme_tab_layout') - self.theme_left_layout = QtGui.QVBoxLayout() + self.theme_left_layout = QtWidgets.QVBoxLayout() self.theme_left_layout.setObjectName('theme_left_layout') - self.theme_group_box = QtGui.QGroupBox(self.theme_tab) + self.theme_group_box = QtWidgets.QGroupBox(self.theme_tab) self.theme_group_box.setObjectName('theme_group_box') - self.theme_layout = QtGui.QHBoxLayout(self.theme_group_box) + self.theme_layout = QtWidgets.QHBoxLayout(self.theme_group_box) self.theme_layout.setObjectName('theme_layout') self.theme_combo_box = create_combo_box(self.theme_group_box, 'theme_combo_box') self.theme_layout.addWidget(self.theme_combo_box) - self.theme_add_button = QtGui.QPushButton(self.theme_group_box) + self.theme_add_button = QtWidgets.QPushButton(self.theme_group_box) self.theme_add_button.setObjectName('theme_add_button') self.theme_layout.addWidget(self.theme_add_button) self.theme_left_layout.addWidget(self.theme_group_box) - self.rights_group_box = QtGui.QGroupBox(self.theme_tab) + self.rights_group_box = QtWidgets.QGroupBox(self.theme_tab) self.rights_group_box.setObjectName('rights_group_box') - self.rights_layout = QtGui.QVBoxLayout(self.rights_group_box) + self.rights_layout = QtWidgets.QVBoxLayout(self.rights_group_box) self.rights_layout.setObjectName('rights_layout') - self.copyright_layout = QtGui.QHBoxLayout() + self.copyright_layout = QtWidgets.QHBoxLayout() self.copyright_layout.setObjectName('copyright_layout') - self.copyright_edit = QtGui.QLineEdit(self.rights_group_box) + self.copyright_edit = QtWidgets.QLineEdit(self.rights_group_box) self.copyright_edit.setObjectName('copyright_edit') self.copyright_layout.addWidget(self.copyright_edit) - self.copyright_insert_button = QtGui.QToolButton(self.rights_group_box) + self.copyright_insert_button = QtWidgets.QToolButton(self.rights_group_box) self.copyright_insert_button.setObjectName('copyright_insert_button') self.copyright_layout.addWidget(self.copyright_insert_button) self.rights_layout.addLayout(self.copyright_layout) - self.ccli_layout = QtGui.QHBoxLayout() + self.ccli_layout = QtWidgets.QHBoxLayout() self.ccli_layout.setObjectName('ccli_layout') - self.ccli_label = QtGui.QLabel(self.rights_group_box) + self.ccli_label = QtWidgets.QLabel(self.rights_group_box) self.ccli_label.setObjectName('ccli_label') self.ccli_layout.addWidget(self.ccli_label) - self.ccli_number_edit = QtGui.QLineEdit(self.rights_group_box) + self.ccli_number_edit = QtWidgets.QLineEdit(self.rights_group_box) self.ccli_number_edit.setValidator(QtGui.QIntValidator()) self.ccli_number_edit.setObjectName('ccli_number_edit') self.ccli_layout.addWidget(self.ccli_number_edit) @@ -234,35 +234,35 @@ class Ui_EditSongDialog(object): self.theme_left_layout.addWidget(self.rights_group_box) self.theme_left_layout.addStretch() self.theme_tab_layout.addLayout(self.theme_left_layout) - self.comments_group_box = QtGui.QGroupBox(self.theme_tab) + self.comments_group_box = QtWidgets.QGroupBox(self.theme_tab) self.comments_group_box.setObjectName('comments_group_box') - self.comments_layout = QtGui.QVBoxLayout(self.comments_group_box) + self.comments_layout = QtWidgets.QVBoxLayout(self.comments_group_box) self.comments_layout.setObjectName('comments_layout') - self.comments_edit = QtGui.QTextEdit(self.comments_group_box) + self.comments_edit = QtWidgets.QTextEdit(self.comments_group_box) self.comments_edit.setObjectName('comments_edit') self.comments_layout.addWidget(self.comments_edit) self.theme_tab_layout.addWidget(self.comments_group_box) self.song_tab_widget.addTab(self.theme_tab, '') # audio tab - self.audio_tab = QtGui.QWidget() + self.audio_tab = QtWidgets.QWidget() self.audio_tab.setObjectName('audio_tab') - self.audio_layout = QtGui.QHBoxLayout(self.audio_tab) + self.audio_layout = QtWidgets.QHBoxLayout(self.audio_tab) self.audio_layout.setObjectName('audio_layout') - self.audio_list_widget = QtGui.QListWidget(self.audio_tab) + self.audio_list_widget = QtWidgets.QListWidget(self.audio_tab) self.audio_list_widget.setObjectName('audio_list_widget') self.audio_layout.addWidget(self.audio_list_widget) - self.audio_buttons_layout = QtGui.QVBoxLayout() + self.audio_buttons_layout = QtWidgets.QVBoxLayout() self.audio_buttons_layout.setObjectName('audio_buttons_layout') - self.from_file_button = QtGui.QPushButton(self.audio_tab) + self.from_file_button = QtWidgets.QPushButton(self.audio_tab) self.from_file_button.setObjectName('from_file_button') self.audio_buttons_layout.addWidget(self.from_file_button) - self.from_media_button = QtGui.QPushButton(self.audio_tab) + self.from_media_button = QtWidgets.QPushButton(self.audio_tab) self.from_media_button.setObjectName('from_media_button') self.audio_buttons_layout.addWidget(self.from_media_button) - self.audio_remove_button = QtGui.QPushButton(self.audio_tab) + self.audio_remove_button = QtWidgets.QPushButton(self.audio_tab) self.audio_remove_button.setObjectName('audio_remove_button') self.audio_buttons_layout.addWidget(self.audio_remove_button) - self.audio_remove_all_button = QtGui.QPushButton(self.audio_tab) + self.audio_remove_all_button = QtWidgets.QPushButton(self.audio_tab) self.audio_remove_all_button.setObjectName('audio_remove_all_button') self.audio_buttons_layout.addWidget(self.audio_remove_all_button) self.audio_buttons_layout.addStretch(1) @@ -274,9 +274,9 @@ class Ui_EditSongDialog(object): self.song_tab_widget.addTab(self.audio_tab, '') # Last few bits self.dialog_layout.addWidget(self.song_tab_widget) - self.bottom_layout = QtGui.QHBoxLayout() + self.bottom_layout = QtWidgets.QHBoxLayout() self.bottom_layout.setObjectName('bottom_layout') - self.warning_label = QtGui.QLabel(edit_song_dialog) + self.warning_label = QtWidgets.QLabel(edit_song_dialog) self.warning_label.setObjectName('warning_label') self.bottom_layout.addWidget(self.warning_label) self.button_box = create_button_box(edit_song_dialog, 'button_box', ['cancel', 'save']) @@ -339,10 +339,10 @@ def create_combo_box(parent, name, editable=True): :param parent: The parent widget for this combo box. :param name: The object name """ - combo_box = QtGui.QComboBox(parent) - combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) - combo_box.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) + combo_box = QtWidgets.QComboBox(parent) + combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToMinimumContentsLength) + combo_box.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) combo_box.setEditable(editable) - combo_box.setInsertPolicy(QtGui.QComboBox.NoInsert) + combo_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert) combo_box.setObjectName(name) return combo_box diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 6be8cb52c..23107063f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -29,7 +29,7 @@ import re import os import shutil -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, translate from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list @@ -45,7 +45,7 @@ from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm log = logging.getLogger(__name__) -class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): +class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): """ Class to manage the editing of a song """ @@ -84,10 +84,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.audio_remove_button.clicked.connect(self.on_audio_remove_button_clicked) self.audio_remove_all_button.clicked.connect(self.on_audio_remove_all_button_clicked) Registry().register_function('theme_update_list', self.load_themes) - self.preview_button = QtGui.QPushButton() + self.preview_button = QtWidgets.QPushButton() self.preview_button.setObjectName('preview_button') self.preview_button.setText(UiStrings().SaveAndPreview) - self.button_box.addButton(self.preview_button, QtGui.QDialogButtonBox.ActionRole) + self.button_box.addButton(self.preview_button, QtWidgets.QDialogButtonBox.ActionRole) self.button_box.clicked.connect(self.on_preview) # Create other objects and forms self.manager = manager @@ -121,7 +121,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): """ Add an author to the author list. """ - author_item = QtGui.QListWidgetItem(author.get_display_name(author_type)) + author_item = QtWidgets.QListWidgetItem(author.get_display_name(author_type)) author_item.setData(QtCore.Qt.UserRole, (author.id, author_type)) self.authors_list_view.addItem(author_item) @@ -221,10 +221,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): return False text = self.song_book_combo_box.currentText() if self.song_book_combo_box.findText(text, QtCore.Qt.MatchExactly) < 0: - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self, translate('SongsPlugin.EditSongForm', 'Add Book'), translate('SongsPlugin.EditSongForm', 'This song book does not exist, do you want to add it?'), - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes: book = Book.populate(name=text, publisher='') self.manager.save_object(book) else: @@ -317,7 +318,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): Re-implement the keyPressEvent to react on Return/Enter keys. When some combo boxes have focus we do not want dialog's default action be triggered but instead our own. - :param event: A QtGui.QKeyEvent event. + :param event: A QtWidgets.QKeyEvent event. """ if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return): if self.authors_combo_box.hasFocus() and self.authors_combo_box.currentText(): @@ -326,7 +327,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if self.topics_combo_box.hasFocus() and self.topics_combo_box.currentText(): self.on_topic_add_button_clicked() return - QtGui.QDialog.keyPressEvent(self, event) + QtWidgets.QDialog.keyPressEvent(self, event) def initialise(self): """ @@ -483,14 +484,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if verse[0]['label'] == '': verse[0]['label'] = '1' verse_def = '%s%s' % (verse[0]['type'], verse[0]['label']) - item = QtGui.QTableWidgetItem(verse[1]) + item = QtWidgets.QTableWidgetItem(verse[1]) item.setData(QtCore.Qt.UserRole, verse_def) self.verse_list_widget.setItem(count, 0, item) else: verses = self.song.lyrics.split('\n\n') for count, verse in enumerate(verses): self.verse_list_widget.setRowCount(self.verse_list_widget.rowCount() + 1) - item = QtGui.QTableWidgetItem(verse) + item = QtWidgets.QTableWidgetItem(verse) verse_def = '%s%s' % (VerseType.tags[VerseType.Verse], str(count + 1)) item.setData(QtCore.Qt.UserRole, verse_def) self.verse_list_widget.setItem(count, 0, item) @@ -516,12 +517,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): # clear the results self.topics_list_view.clear() for topic in self.song.topics: - topic_name = QtGui.QListWidgetItem(str(topic.name)) + topic_name = QtWidgets.QListWidgetItem(str(topic.name)) topic_name.setData(QtCore.Qt.UserRole, topic.id) self.topics_list_view.addItem(topic_name) self.audio_list_widget.clear() for media in self.song.media_files: - media_file = QtGui.QListWidgetItem(os.path.split(media.file_name)[1]) + media_file = QtWidgets.QListWidgetItem(os.path.split(media.file_name)[1]) media_file.setData(QtCore.Qt.UserRole, media.file_name) self.audio_list_widget.addItem(media_file) self.title_edit.setFocus() @@ -558,11 +559,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): # Index 0 is a blank string, so add 1 item = self.authors.index(text) + 1 if item == 0 and text: - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self, translate('SongsPlugin.EditSongForm', 'Add Author'), translate('SongsPlugin.EditSongForm', 'This author does not exist, do you want to add them?'), - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes: if text.find(' ') == -1: author = Author.populate(first_name='', last_name='', display_name=text) else: @@ -584,7 +586,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self._add_author_to_list(author, author_type) self.authors_combo_box.setCurrentIndex(0) else: - QtGui.QMessageBox.warning( + QtWidgets.QMessageBox.warning( self, UiStrings().NISs, translate('SongsPlugin.EditSongForm', 'You have not selected a valid author. Either select an author ' 'from the list, or type in a new author and click the "Add Author to Song" button to add ' @@ -608,11 +610,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.author_edit_button.setEnabled(False) item = self.authors_list_view.currentItem() author_id, author_type = item.data(QtCore.Qt.UserRole) - choice, ok = QtGui.QInputDialog.getItem(self, translate('SongsPlugin.EditSongForm', 'Edit Author Type'), - translate('SongsPlugin.EditSongForm', 'Choose type for this author'), - AuthorType.TranslatedTypes, - current=AuthorType.SortedTypes.index(author_type), - editable=False) + choice, ok = QtWidgets.QInputDialog.getItem(self, translate('SongsPlugin.EditSongForm', 'Edit Author Type'), + translate('SongsPlugin.EditSongForm', + 'Choose type for this author'), + AuthorType.TranslatedTypes, + current=AuthorType.SortedTypes.index(author_type), + editable=False) if not ok: return author = self.manager.get_object(Author, author_id) @@ -634,13 +637,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): item = int(self.topics_combo_box.currentIndex()) text = self.topics_combo_box.currentText() if item == 0 and text: - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self, translate('SongsPlugin.EditSongForm', 'Add Topic'), translate('SongsPlugin.EditSongForm', 'This topic does not exist, do you want to add it?'), - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes: topic = Topic.populate(name=text) self.manager.save_object(topic) - topic_item = QtGui.QListWidgetItem(str(topic.name)) + topic_item = QtWidgets.QListWidgetItem(str(topic.name)) topic_item.setData(QtCore.Qt.UserRole, topic.id) self.topics_list_view.addItem(topic_item) self.load_topics() @@ -654,12 +658,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): critical_error_message_box( message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.')) else: - topic_item = QtGui.QListWidgetItem(str(topic.name)) + topic_item = QtWidgets.QListWidgetItem(str(topic.name)) topic_item.setData(QtCore.Qt.UserRole, topic.id) self.topics_list_view.addItem(topic_item) self.topics_combo_box.setCurrentIndex(0) else: - QtGui.QMessageBox.warning( + QtWidgets.QMessageBox.warning( self, UiStrings().NISs, translate('SongsPlugin.EditSongForm', 'You have not selected a valid topic. Either select a topic ' 'from the list, or type in a new topic and click the "Add Topic to Song" button to add the ' @@ -680,10 +684,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): def on_verse_add_button_clicked(self): self.verse_form.set_verse('', True) - if self.verse_form.exec_(): + if self.verse_form.exec(): after_text, verse_tag, verse_num = self.verse_form.get_verse() verse_def = '%s%s' % (verse_tag, verse_num) - item = QtGui.QTableWidgetItem(after_text) + item = QtWidgets.QTableWidgetItem(after_text) item.setData(QtCore.Qt.UserRole, verse_def) item.setText(after_text) self.verse_list_widget.setRowCount(self.verse_list_widget.rowCount() + 1) @@ -698,7 +702,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): temp_text = item.text() verse_id = item.data(QtCore.Qt.UserRole) self.verse_form.set_verse(temp_text, True, verse_id) - if self.verse_form.exec_(): + if self.verse_form.exec(): after_text, verse_tag, verse_num = self.verse_form.get_verse() verse_def = '%s%s' % (verse_tag, verse_num) item.setData(QtCore.Qt.UserRole, verse_def) @@ -713,7 +717,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): temp_ids.append(item.data(QtCore.Qt.UserRole)) self.verse_list_widget.clear() for row, entry in enumerate(temp_list): - item = QtGui.QTableWidgetItem(entry, 0) + item = QtWidgets.QTableWidgetItem(entry, 0) item.setData(QtCore.Qt.UserRole, temp_ids[row]) self.verse_list_widget.setItem(row, 0, item) self.tag_rows() @@ -739,7 +743,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.verse_form.set_verse(verse_list) else: self.verse_form.set_verse('') - if not self.verse_form.exec_(): + if not self.verse_form.exec(): return verse_list = self.verse_form.get_all_verses() verse_list = str(verse_list.replace('\r\n', '\n')) @@ -772,7 +776,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): else: if parts.endswith('\n'): parts = parts.rstrip('\n') - item = QtGui.QTableWidgetItem(parts) + item = QtWidgets.QTableWidgetItem(parts) item.setData(QtCore.Qt.UserRole, verse_def) self.verse_list_widget.setRowCount(self.verse_list_widget.rowCount() + 1) self.verse_list_widget.setItem(self.verse_list_widget.rowCount() - 1, 0, item) @@ -839,7 +843,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): text = self.song_book_combo_box.currentText() if item == 0 and text: temp_song_book = text - self.media_item.song_maintenance_form.exec_(True) + self.media_item.song_maintenance_form.exec(True) self.load_authors() self.load_books() self.load_topics() @@ -866,7 +870,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): file_names = FileDialog.getOpenFileNames(self, translate('SongsPlugin.EditSongForm', 'Open File(s)'), '', filters) for filename in file_names: - item = QtGui.QListWidgetItem(os.path.split(str(filename))[1]) + item = QtWidgets.QListWidgetItem(os.path.split(str(filename))[1]) item.setData(QtCore.Qt.UserRole, filename) self.audio_list_widget.addItem(item) @@ -874,9 +878,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): """ Loads file(s) from the media plugin. """ - if self.media_form.exec_(): + if self.media_form.exec(): for filename in self.media_form.get_selected_files(): - item = QtGui.QListWidgetItem(os.path.split(str(filename))[1]) + item = QtWidgets.QListWidgetItem(os.path.split(str(filename))[1]) item.setData(QtCore.Qt.UserRole, filename) self.audio_list_widget.addItem(item) @@ -933,7 +937,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): """ log.debug('SongEditForm.reject') self.clear_caches() - QtGui.QDialog.reject(self) + QtWidgets.QDialog.reject(self) def accept(self): """ @@ -944,7 +948,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if self._validate_song(): self.save_song() self.song = None - QtGui.QDialog.accept(self) + QtWidgets.QDialog.accept(self) def save_song(self, preview=False): """ diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index 2b3f20483..de000f4f0 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import SpellTextEdit, build_icon, translate from openlp.core.lib.ui import UiStrings, create_button_box @@ -33,30 +33,30 @@ class Ui_EditVerseDialog(object): edit_verse_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) edit_verse_dialog.resize(400, 400) edit_verse_dialog.setModal(True) - self.dialog_layout = QtGui.QVBoxLayout(edit_verse_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(edit_verse_dialog) self.dialog_layout.setObjectName('dialog_layout') self.verse_text_edit = SpellTextEdit(edit_verse_dialog) self.verse_text_edit.setObjectName('verse_text_edit') self.dialog_layout.addWidget(self.verse_text_edit) - self.verse_type_layout = QtGui.QHBoxLayout() + self.verse_type_layout = QtWidgets.QHBoxLayout() self.verse_type_layout.setObjectName('verse_type_layout') - self.split_button = QtGui.QPushButton(edit_verse_dialog) + self.split_button = QtWidgets.QPushButton(edit_verse_dialog) self.split_button.setIcon(build_icon(':/general/general_add.png')) self.split_button.setObjectName('split_button') self.verse_type_layout.addWidget(self.split_button) - self.verse_type_label = QtGui.QLabel(edit_verse_dialog) + self.verse_type_label = QtWidgets.QLabel(edit_verse_dialog) self.verse_type_label.setObjectName('verse_type_label') self.verse_type_layout.addWidget(self.verse_type_label) - self.verse_type_combo_box = QtGui.QComboBox(edit_verse_dialog) + self.verse_type_combo_box = QtWidgets.QComboBox(edit_verse_dialog) self.verse_type_combo_box.addItems(['', '', '', '', '', '', '']) self.verse_type_combo_box.setObjectName('verse_type_combo_box') self.verse_type_label.setBuddy(self.verse_type_combo_box) self.verse_type_layout.addWidget(self.verse_type_combo_box) - self.verse_number_box = QtGui.QSpinBox(edit_verse_dialog) + self.verse_number_box = QtWidgets.QSpinBox(edit_verse_dialog) self.verse_number_box.setMinimum(1) self.verse_number_box.setObjectName('verse_number_box') self.verse_type_layout.addWidget(self.verse_number_box) - self.insert_button = QtGui.QPushButton(edit_verse_dialog) + self.insert_button = QtWidgets.QPushButton(edit_verse_dialog) self.insert_button.setIcon(build_icon(':/general/general_add.png')) self.insert_button.setObjectName('insert_button') self.verse_type_layout.addWidget(self.insert_button) diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 5fe96e7f0..83e667660 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -23,7 +23,7 @@ import re import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtGui, QtWidgets from openlp.plugins.songs.lib import VerseType from .editversedialog import Ui_EditVerseDialog @@ -33,7 +33,7 @@ log = logging.getLogger(__name__) VERSE_REGEX = re.compile(r'---\[(.+):\D*(\d*)\D*.*\]---') -class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): +class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog): """ This is the form that is used to edit the verses of the song. """ diff --git a/openlp/plugins/songs/forms/mediafilesdialog.py b/openlp/plugins/songs/forms/mediafilesdialog.py index 15c1693b0..8b387e383 100644 --- a/openlp/plugins/songs/forms/mediafilesdialog.py +++ b/openlp/plugins/songs/forms/mediafilesdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box @@ -39,17 +39,17 @@ class Ui_MediaFilesDialog(object): media_files_dialog.setWindowModality(QtCore.Qt.ApplicationModal) media_files_dialog.resize(400, 300) media_files_dialog.setModal(True) - self.files_vertical_layout = QtGui.QVBoxLayout(media_files_dialog) + self.files_vertical_layout = QtWidgets.QVBoxLayout(media_files_dialog) self.files_vertical_layout.setSpacing(8) - self.files_vertical_layout.setMargin(8) + self.files_vertical_layout.setContentsMargins(8, 8, 8, 8) self.files_vertical_layout.setObjectName('files_vertical_layout') - self.select_label = QtGui.QLabel(media_files_dialog) + self.select_label = QtWidgets.QLabel(media_files_dialog) self.select_label.setWordWrap(True) self.select_label.setObjectName('select_label') self.files_vertical_layout.addWidget(self.select_label) - self.file_list_widget = QtGui.QListWidget(media_files_dialog) + self.file_list_widget = QtWidgets.QListWidget(media_files_dialog) self.file_list_widget.setAlternatingRowColors(True) - self.file_list_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.file_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.file_list_widget.setObjectName('file_list_widget') self.files_vertical_layout.addWidget(self.file_list_widget) self.button_box = create_button_box(media_files_dialog, 'button_box', ['cancel', 'ok']) diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 42f6f839d..9ff328f9e 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -23,14 +23,14 @@ import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from .mediafilesdialog import Ui_MediaFilesDialog log = logging.getLogger(__name__) -class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): +class MediaFilesForm(QtWidgets.QDialog, Ui_MediaFilesDialog): """ Class to show a list of files from the """ @@ -43,7 +43,7 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): def populate_files(self, files): self.file_list_widget.clear() for file in files: - item = QtGui.QListWidgetItem(os.path.split(file)[1]) + item = QtWidgets.QListWidgetItem(os.path.split(file)[1]) item.setData(QtCore.Qt.UserRole, file) self.file_list_widget.addItem(item) diff --git a/openlp/plugins/songs/forms/songbookdialog.py b/openlp/plugins/songs/forms/songbookdialog.py index d52ff45aa..5bfed8e87 100644 --- a/openlp/plugins/songs/forms/songbookdialog.py +++ b/openlp/plugins/songs/forms/songbookdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box @@ -37,19 +37,19 @@ class Ui_SongBookDialog(object): song_book_dialog.setObjectName('song_book_dialog') song_book_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) song_book_dialog.resize(300, 10) - self.dialog_layout = QtGui.QVBoxLayout(song_book_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(song_book_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.book_layout = QtGui.QFormLayout() + self.book_layout = QtWidgets.QFormLayout() self.book_layout.setObjectName('book_layout') - self.name_label = QtGui.QLabel(song_book_dialog) + self.name_label = QtWidgets.QLabel(song_book_dialog) self.name_label.setObjectName('name_label') - self.name_edit = QtGui.QLineEdit(song_book_dialog) + self.name_edit = QtWidgets.QLineEdit(song_book_dialog) self.name_edit.setObjectName('name_edit') self.name_label.setBuddy(self.name_edit) self.book_layout.addRow(self.name_label, self.name_edit) - self.publisher_label = QtGui.QLabel(song_book_dialog) + self.publisher_label = QtWidgets.QLabel(song_book_dialog) self.publisher_label.setObjectName('publisher_label') - self.publisher_edit = QtGui.QLineEdit(song_book_dialog) + self.publisher_edit = QtWidgets.QLineEdit(song_book_dialog) self.publisher_edit.setObjectName('publisher_edit') self.publisher_label.setBuddy(self.publisher_edit) self.book_layout.addRow(self.publisher_label, self.publisher_edit) diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index a276e6cd5..7207a3859 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -23,14 +23,14 @@ This module contains the song book form """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.songbookdialog import Ui_SongBookDialog -class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): +class SongBookForm(QtWidgets.QDialog, Ui_SongBookDialog): """ Class documentation goes here. """ @@ -41,7 +41,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): super(SongBookForm, self).__init__(parent) self.setupUi(self) - def exec_(self, clear=True): + def exec(self, clear=True): """ Execute the song book form. @@ -51,7 +51,7 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): self.name_edit.clear() self.publisher_edit.clear() self.name_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def accept(self): """ @@ -63,4 +63,4 @@ class SongBookForm(QtGui.QDialog, Ui_SongBookDialog): self.name_edit.setFocus() return False else: - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) diff --git a/openlp/plugins/songs/forms/songexportform.py b/openlp/plugins/songs/forms/songexportform.py index f96c46638..73644b587 100644 --- a/openlp/plugins/songs/forms/songexportform.py +++ b/openlp/plugins/songs/forms/songexportform.py @@ -25,7 +25,7 @@ OpenLyrics format. """ import logging -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, UiStrings, translate from openlp.core.lib import create_separated_list, build_icon @@ -83,54 +83,54 @@ class SongExportForm(OpenLPWizard): Add song wizard specific pages. """ # The page with all available songs. - self.available_songs_page = QtGui.QWizardPage() + self.available_songs_page = QtWidgets.QWizardPage() self.available_songs_page.setObjectName('available_songs_page') - self.available_songs_layout = QtGui.QHBoxLayout(self.available_songs_page) + self.available_songs_layout = QtWidgets.QHBoxLayout(self.available_songs_page) self.available_songs_layout.setObjectName('available_songs_layout') - self.vertical_layout = QtGui.QVBoxLayout() + self.vertical_layout = QtWidgets.QVBoxLayout() self.vertical_layout.setObjectName('vertical_layout') - self.available_list_widget = QtGui.QListWidget(self.available_songs_page) + self.available_list_widget = QtWidgets.QListWidget(self.available_songs_page) self.available_list_widget.setObjectName('available_list_widget') self.vertical_layout.addWidget(self.available_list_widget) - self.horizontal_layout = QtGui.QHBoxLayout() + self.horizontal_layout = QtWidgets.QHBoxLayout() self.horizontal_layout.setObjectName('horizontal_layout') - self.search_label = QtGui.QLabel(self.available_songs_page) + self.search_label = QtWidgets.QLabel(self.available_songs_page) self.search_label.setObjectName('search_label') self.horizontal_layout.addWidget(self.search_label) - self.search_line_edit = QtGui.QLineEdit(self.available_songs_page) + self.search_line_edit = QtWidgets.QLineEdit(self.available_songs_page) self.search_line_edit.setObjectName('search_line_edit') self.horizontal_layout.addWidget(self.search_line_edit) - spacer_item = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + spacer_item = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontal_layout.addItem(spacer_item) - self.uncheck_button = QtGui.QPushButton(self.available_songs_page) + self.uncheck_button = QtWidgets.QPushButton(self.available_songs_page) self.uncheck_button.setObjectName('uncheck_button') self.horizontal_layout.addWidget(self.uncheck_button) - self.check_button = QtGui.QPushButton(self.available_songs_page) + self.check_button = QtWidgets.QPushButton(self.available_songs_page) self.check_button.setObjectName('selectButton') self.horizontal_layout.addWidget(self.check_button) self.vertical_layout.addLayout(self.horizontal_layout) self.available_songs_layout.addLayout(self.vertical_layout) self.addPage(self.available_songs_page) # The page with the selected songs. - self.export_song_page = QtGui.QWizardPage() + self.export_song_page = QtWidgets.QWizardPage() self.export_song_page.setObjectName('available_songs_page') - self.export_song_layout = QtGui.QHBoxLayout(self.export_song_page) + self.export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) self.export_song_layout.setObjectName('export_song_layout') - self.grid_layout = QtGui.QGridLayout() + self.grid_layout = QtWidgets.QGridLayout() self.grid_layout.setObjectName('range_layout') - self.selected_list_widget = QtGui.QListWidget(self.export_song_page) + self.selected_list_widget = QtWidgets.QListWidget(self.export_song_page) self.selected_list_widget.setObjectName('selected_list_widget') self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 1) # FIXME: self.horizontal_layout is already defined above?!?!? - self.horizontal_layout = QtGui.QHBoxLayout() + self.horizontal_layout = QtWidgets.QHBoxLayout() self.horizontal_layout.setObjectName('horizontal_layout') - self.directory_label = QtGui.QLabel(self.export_song_page) + self.directory_label = QtWidgets.QLabel(self.export_song_page) self.directory_label.setObjectName('directory_label') self.horizontal_layout.addWidget(self.directory_label) - self.directory_line_edit = QtGui.QLineEdit(self.export_song_page) + self.directory_line_edit = QtWidgets.QLineEdit(self.export_song_page) self.directory_line_edit.setObjectName('directory_line_edit') self.horizontal_layout.addWidget(self.directory_line_edit) - self.directory_button = QtGui.QToolButton(self.export_song_page) + self.directory_button = QtWidgets.QToolButton(self.export_song_page) self.directory_button.setIcon(build_icon(':/exports/export_load.png')) self.directory_button.setObjectName('directory_button') self.horizontal_layout.addWidget(self.directory_button) @@ -182,7 +182,7 @@ class SongExportForm(OpenLPWizard): self.selected_list_widget.clear() # Add the songs to the list of selected songs. for item in items: - song = QtGui.QListWidgetItem(item.text()) + song = QtWidgets.QListWidgetItem(item.text()) song.setData(QtCore.Qt.UserRole, item.data(QtCore.Qt.UserRole)) song.setFlags(QtCore.Qt.ItemIsEnabled) self.selected_list_widget.addItem(song) @@ -220,7 +220,7 @@ class SongExportForm(OpenLPWizard): continue authors = create_separated_list([author.display_name for author in song.authors]) title = '%s (%s)' % (str(song.title), authors) - item = QtGui.QListWidgetItem(title) + item = QtWidgets.QListWidgetItem(title) item.setData(QtCore.Qt.UserRole, song) item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) item.setCheckState(QtCore.Qt.Unchecked) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index cc4aa6eaa..7f4e5ce44 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -26,7 +26,7 @@ import codecs import logging import os -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import FileDialog @@ -42,6 +42,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): This is the Song Import Wizard, which allows easy importing of Songs into OpenLP from other formats like OpenLyrics, OpenSong and CCLI. """ + completeChanged = QtCore.pyqtSignal() log.info('SongImportForm loaded') def __init__(self, parent, plugin): @@ -70,7 +71,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): """ self.current_format = index self.format_stack.setCurrentIndex(index) - self.source_page.emit(QtCore.SIGNAL('completeChanged()')) + self.source_page.completeChanged.emit() def custom_init(self): """ @@ -102,23 +103,23 @@ class SongImportForm(OpenLPWizard, RegistryProperties): # Source Page self.source_page = SongImportSourcePage() self.source_page.setObjectName('source_page') - self.source_layout = QtGui.QVBoxLayout(self.source_page) + self.source_layout = QtWidgets.QVBoxLayout(self.source_page) self.source_layout.setObjectName('source_layout') - self.format_layout = QtGui.QFormLayout() + self.format_layout = QtWidgets.QFormLayout() self.format_layout.setObjectName('format_layout') - self.format_label = QtGui.QLabel(self.source_page) + self.format_label = QtWidgets.QLabel(self.source_page) self.format_label.setObjectName('format_label') - self.format_combo_box = QtGui.QComboBox(self.source_page) + self.format_combo_box = QtWidgets.QComboBox(self.source_page) self.format_combo_box.setObjectName('format_combo_box') self.format_layout.addRow(self.format_label, self.format_combo_box) - self.format_spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.format_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.format_spacer) + self.format_spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) + self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.format_spacer) self.source_layout.addLayout(self.format_layout) self.format_h_spacing = self.format_layout.horizontalSpacing() self.format_v_spacing = self.format_layout.verticalSpacing() self.format_layout.setVerticalSpacing(0) - self.stack_spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) - self.format_stack = QtGui.QStackedLayout() + self.stack_spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) + self.format_stack = QtWidgets.QStackedLayout() self.format_stack.setObjectName('format_stack') self.disablable_formats = [] for self.current_format in SongFormat.get_format_list(): @@ -174,17 +175,18 @@ class SongImportForm(OpenLPWizard, RegistryProperties): # Get max width of all labels max_label_width = max(self.format_label.minimumSizeHint().width(), max([label.minimumSizeHint().width() for label in labels])) - self.format_spacer.changeSize(max_label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.format_spacer.changeSize(max_label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) spacers = [self.format_widgets[f]['filepathSpacer'] for f in formats] for index, spacer in enumerate(spacers): spacer.changeSize( max_label_width - labels[index].minimumSizeHint().width(), 0, - QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) # Align descriptionLabels with rest of layout for format_list in SongFormat.get_format_list(): if SongFormat.get(format_list, 'descriptionText') is not None: self.format_widgets[format_list]['descriptionSpacer'].changeSize( - max_label_width + self.format_h_spacing, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + max_label_width + self.format_h_spacing, 0, QtWidgets.QSizePolicy.Fixed, + QtWidgets.QSizePolicy.Fixed) def custom_page_changed(self, page_id): """ @@ -198,6 +200,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): Re-implement the validateCurrentPage() method. Validate the current page before moving on to the next page. Provide each song format class with a chance to validate its input by overriding is_valid_source(). """ + completeChanged = QtCore.pyqtSignal() if self.currentPage() == self.welcome_page: return True elif self.currentPage() == self.source_page: @@ -283,20 +286,20 @@ class SongImportForm(OpenLPWizard, RegistryProperties): title = custom_title if custom_title else WizardStrings.OpenTypeFile % format_name if select_mode == SongFormatSelect.MultipleFiles: self.get_files(title, self.format_widgets[this_format]['file_list_widget'], ext_filter) - self.source_page.emit(QtCore.SIGNAL('completeChanged()')) + self.source_page.completeChanged.emit() def on_remove_button_clicked(self): """ Remove a file from the list. """ self.remove_selected_items(self.format_widgets[self.current_format]['file_list_widget']) - self.source_page.emit(QtCore.SIGNAL('completeChanged()')) + self.source_page.completeChanged.emit() def on_filepath_edit_text_changed(self): """ Called when the content of the Filename/Folder edit box changes. """ - self.source_page.emit(QtCore.SIGNAL('completeChanged()')) + self.source_page.completeChanged.emit() def set_defaults(self): """ @@ -358,7 +361,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): """ Save the error report to a file. """ - filename = QtGui.QFileDialog.getSaveFileName( + filename, filter_used = QtWidgets.QFileDialog.getSaveFileName( self, Settings().value(self.plugin.settings_section + '/last directory import')) if not filename: return @@ -373,21 +376,21 @@ class SongImportForm(OpenLPWizard, RegistryProperties): this_format = self.current_format prefix, can_disable, description_text, select_mode = \ SongFormat.get(this_format, 'prefix', 'canDisable', 'descriptionText', 'selectMode') - page = QtGui.QWidget() + page = QtWidgets.QWidget() page.setObjectName(prefix + 'Page') if can_disable: import_widget = self.disablable_widget(page, prefix) else: import_widget = page - import_layout = QtGui.QVBoxLayout(import_widget) - import_layout.setMargin(0) + import_layout = QtWidgets.QVBoxLayout(import_widget) + import_layout.setContentsMargins(0, 0, 0, 0) import_layout.setObjectName(prefix + 'ImportLayout') if description_text is not None: - description_layout = QtGui.QHBoxLayout() + description_layout = QtWidgets.QHBoxLayout() description_layout.setObjectName(prefix + 'DescriptionLayout') - description_spacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + description_spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) description_layout.addSpacerItem(description_spacer) - description_label = QtGui.QLabel(import_widget) + description_label = QtWidgets.QLabel(import_widget) description_label.setWordWrap(True) description_label.setOpenExternalLinks(True) description_label.setObjectName(prefix + '_description_label') @@ -396,18 +399,18 @@ class SongImportForm(OpenLPWizard, RegistryProperties): self.format_widgets[this_format]['description_label'] = description_label self.format_widgets[this_format]['descriptionSpacer'] = description_spacer if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder: - file_path_layout = QtGui.QHBoxLayout() + file_path_layout = QtWidgets.QHBoxLayout() file_path_layout.setObjectName(prefix + '_file_path_layout') file_path_layout.setContentsMargins(0, self.format_v_spacing, 0, 0) - file_path_label = QtGui.QLabel(import_widget) + file_path_label = QtWidgets.QLabel(import_widget) file_path_label.setObjectName(prefix + 'FilepathLabel') file_path_layout.addWidget(file_path_label) - file_path_spacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + file_path_spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) file_path_layout.addSpacerItem(file_path_spacer) - file_path_edit = QtGui.QLineEdit(import_widget) + file_path_edit = QtWidgets.QLineEdit(import_widget) file_path_edit.setObjectName(prefix + '_file_path_edit') file_path_layout.addWidget(file_path_edit) - browse_button = QtGui.QToolButton(import_widget) + browse_button = QtWidgets.QToolButton(import_widget) browse_button.setIcon(self.open_icon) browse_button.setObjectName(prefix + 'BrowseButton') file_path_layout.addWidget(browse_button) @@ -419,18 +422,18 @@ class SongImportForm(OpenLPWizard, RegistryProperties): self.format_widgets[this_format]['file_path_edit'] = file_path_edit self.format_widgets[this_format]['browseButton'] = browse_button elif select_mode == SongFormatSelect.MultipleFiles: - file_list_widget = QtGui.QListWidget(import_widget) - file_list_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + file_list_widget = QtWidgets.QListWidget(import_widget) + file_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) file_list_widget.setObjectName(prefix + 'FileListWidget') import_layout.addWidget(file_list_widget) - button_layout = QtGui.QHBoxLayout() + button_layout = QtWidgets.QHBoxLayout() button_layout.setObjectName(prefix + '_button_layout') - add_button = QtGui.QPushButton(import_widget) + add_button = QtWidgets.QPushButton(import_widget) add_button.setIcon(self.open_icon) add_button.setObjectName(prefix + 'AddButton') button_layout.addWidget(add_button) button_layout.addStretch() - remove_button = QtGui.QPushButton(import_widget) + remove_button = QtWidgets.QPushButton(import_widget) remove_button.setIcon(self.delete_icon) remove_button.setObjectName(prefix + 'RemoveButton') button_layout.addWidget(remove_button) @@ -450,23 +453,23 @@ class SongImportForm(OpenLPWizard, RegistryProperties): """ this_format = self.current_format self.disablable_formats.append(this_format) - layout = QtGui.QVBoxLayout(page) - layout.setMargin(0) + layout = QtWidgets.QVBoxLayout(page) + layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.setObjectName(prefix + '_layout') - disabled_widget = QtGui.QWidget(page) + disabled_widget = QtWidgets.QWidget(page) disabled_widget.setVisible(False) disabled_widget.setObjectName(prefix + '_disabled_widget') - disabled_layout = QtGui.QVBoxLayout(disabled_widget) - disabled_layout.setMargin(0) + disabled_layout = QtWidgets.QVBoxLayout(disabled_widget) + disabled_layout.setContentsMargins(0, 0, 0, 0) disabled_layout.setObjectName(prefix + '_disabled_layout') - disabled_label = QtGui.QLabel(disabled_widget) + disabled_label = QtWidgets.QLabel(disabled_widget) disabled_label.setWordWrap(True) disabled_label.setObjectName(prefix + '_disabled_label') disabled_layout.addWidget(disabled_label) disabled_layout.addSpacerItem(self.stack_spacer) layout.addWidget(disabled_widget) - import_widget = QtGui.QWidget(page) + import_widget = QtWidgets.QWidget(page) import_widget.setObjectName(prefix + '_import_widget') layout.addWidget(import_widget) self.format_widgets[this_format]['layout'] = layout @@ -477,7 +480,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): return import_widget -class SongImportSourcePage(QtGui.QWizardPage): +class SongImportSourcePage(QtWidgets.QWizardPage): """ Subclass of QtGui.QWizardPage to override isComplete() for Source Page. """ diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 645b41715..3677e05de 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import UiStrings from openlp.core.lib import build_icon @@ -40,91 +40,91 @@ class Ui_SongMaintenanceDialog(object): song_maintenance_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) song_maintenance_dialog.setWindowModality(QtCore.Qt.ApplicationModal) song_maintenance_dialog.resize(10, 350) - self.dialog_layout = QtGui.QGridLayout(song_maintenance_dialog) + self.dialog_layout = QtWidgets.QGridLayout(song_maintenance_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.type_list_widget = QtGui.QListWidget(song_maintenance_dialog) + self.type_list_widget = QtWidgets.QListWidget(song_maintenance_dialog) self.type_list_widget.setIconSize(QtCore.QSize(32, 32)) self.type_list_widget.setUniformItemSizes(True) self.type_list_widget.setObjectName('type_list_widget') - self.authors_list_item = QtGui.QListWidgetItem(self.type_list_widget) + self.authors_list_item = QtWidgets.QListWidgetItem(self.type_list_widget) self.authors_list_item.setIcon(build_icon(':/songs/author_maintenance.png')) - self.topics_list_item = QtGui.QListWidgetItem(self.type_list_widget) + self.topics_list_item = QtWidgets.QListWidgetItem(self.type_list_widget) self.topics_list_item.setIcon(build_icon(':/songs/topic_maintenance.png')) - self.books_list_item = QtGui.QListWidgetItem(self.type_list_widget) + self.books_list_item = QtWidgets.QListWidgetItem(self.type_list_widget) self.books_list_item.setIcon(build_icon(':/songs/book_maintenance.png')) self.dialog_layout.addWidget(self.type_list_widget, 0, 0) - self.stacked_layout = QtGui.QStackedLayout() + self.stacked_layout = QtWidgets.QStackedLayout() self.stacked_layout.setObjectName('stacked_layout') # authors page - self.authors_page = QtGui.QWidget(song_maintenance_dialog) + self.authors_page = QtWidgets.QWidget(song_maintenance_dialog) self.authors_page.setObjectName('authors_page') - self.authors_layout = QtGui.QVBoxLayout(self.authors_page) + self.authors_layout = QtWidgets.QVBoxLayout(self.authors_page) self.authors_layout.setObjectName('authors_layout') - self.authors_list_widget = QtGui.QListWidget(self.authors_page) + self.authors_list_widget = QtWidgets.QListWidget(self.authors_page) self.authors_list_widget.setObjectName('authors_list_widget') self.authors_layout.addWidget(self.authors_list_widget) - self.authors_buttons_layout = QtGui.QHBoxLayout() + self.authors_buttons_layout = QtWidgets.QHBoxLayout() self.authors_buttons_layout.setObjectName('authors_buttons_layout') self.authors_buttons_layout.addStretch() - self.add_author_button = QtGui.QPushButton(self.authors_page) + self.add_author_button = QtWidgets.QPushButton(self.authors_page) self.add_author_button.setIcon(build_icon(':/songs/author_add.png')) self.add_author_button.setObjectName('add_author_button') self.authors_buttons_layout.addWidget(self.add_author_button) - self.edit_author_button = QtGui.QPushButton(self.authors_page) + self.edit_author_button = QtWidgets.QPushButton(self.authors_page) self.edit_author_button.setIcon(build_icon(':/songs/author_edit.png')) self.edit_author_button.setObjectName('edit_author_button') self.authors_buttons_layout.addWidget(self.edit_author_button) - self.delete_author_button = QtGui.QPushButton(self.authors_page) + self.delete_author_button = QtWidgets.QPushButton(self.authors_page) self.delete_author_button.setIcon(build_icon(':/songs/author_delete.png')) self.delete_author_button.setObjectName('delete_author_button') self.authors_buttons_layout.addWidget(self.delete_author_button) self.authors_layout.addLayout(self.authors_buttons_layout) self.stacked_layout.addWidget(self.authors_page) # topics page - self.topics_page = QtGui.QWidget(song_maintenance_dialog) + self.topics_page = QtWidgets.QWidget(song_maintenance_dialog) self.topics_page.setObjectName('topics_page') - self.topics_layout = QtGui.QVBoxLayout(self.topics_page) + self.topics_layout = QtWidgets.QVBoxLayout(self.topics_page) self.topics_layout.setObjectName('topics_layout') - self.topics_list_widget = QtGui.QListWidget(self.topics_page) + self.topics_list_widget = QtWidgets.QListWidget(self.topics_page) self.topics_list_widget.setObjectName('topics_list_widget') self.topics_layout.addWidget(self.topics_list_widget) - self.topics_buttons_layout = QtGui.QHBoxLayout() + self.topics_buttons_layout = QtWidgets.QHBoxLayout() self.topics_buttons_layout.setObjectName('topicsButtonLayout') self.topics_buttons_layout.addStretch() - self.add_topic_button = QtGui.QPushButton(self.topics_page) + self.add_topic_button = QtWidgets.QPushButton(self.topics_page) self.add_topic_button.setIcon(build_icon(':/songs/topic_add.png')) self.add_topic_button.setObjectName('add_topic_button') self.topics_buttons_layout.addWidget(self.add_topic_button) - self.edit_topic_button = QtGui.QPushButton(self.topics_page) + self.edit_topic_button = QtWidgets.QPushButton(self.topics_page) self.edit_topic_button.setIcon(build_icon(':/songs/topic_edit.png')) self.edit_topic_button.setObjectName('edit_topic_button') self.topics_buttons_layout.addWidget(self.edit_topic_button) - self.delete_topic_button = QtGui.QPushButton(self.topics_page) + self.delete_topic_button = QtWidgets.QPushButton(self.topics_page) self.delete_topic_button.setIcon(build_icon(':/songs/topic_delete.png')) self.delete_topic_button.setObjectName('delete_topic_button') self.topics_buttons_layout.addWidget(self.delete_topic_button) self.topics_layout.addLayout(self.topics_buttons_layout) self.stacked_layout.addWidget(self.topics_page) # song books page - self.books_page = QtGui.QWidget(song_maintenance_dialog) + self.books_page = QtWidgets.QWidget(song_maintenance_dialog) self.books_page.setObjectName('books_page') - self.books_layout = QtGui.QVBoxLayout(self.books_page) + self.books_layout = QtWidgets.QVBoxLayout(self.books_page) self.books_layout.setObjectName('books_layout') - self.song_books_list_widget = QtGui.QListWidget(self.books_page) + self.song_books_list_widget = QtWidgets.QListWidget(self.books_page) self.song_books_list_widget.setObjectName('song_books_list_widget') self.books_layout.addWidget(self.song_books_list_widget) - self.books_buttons_layout = QtGui.QHBoxLayout() + self.books_buttons_layout = QtWidgets.QHBoxLayout() self.books_buttons_layout.setObjectName('booksButtonLayout') self.books_buttons_layout.addStretch() - self.add_book_button = QtGui.QPushButton(self.books_page) + self.add_book_button = QtWidgets.QPushButton(self.books_page) self.add_book_button.setIcon(build_icon(':/songs/book_add.png')) self.add_book_button.setObjectName('add_book_button') self.books_buttons_layout.addWidget(self.add_book_button) - self.edit_book_button = QtGui.QPushButton(self.books_page) + self.edit_book_button = QtWidgets.QPushButton(self.books_page) self.edit_book_button.setIcon(build_icon(':/songs/book_edit.png')) self.edit_book_button.setObjectName('edit_book_button') self.books_buttons_layout.addWidget(self.edit_book_button) - self.delete_book_button = QtGui.QPushButton(self.books_page) + self.delete_book_button = QtWidgets.QPushButton(self.books_page) self.delete_book_button.setIcon(build_icon(':/songs/book_delete.png')) self.delete_book_button.setObjectName('delete_book_button') self.books_buttons_layout.addWidget(self.delete_book_button) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index b20e52c11..1f05ae3a5 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -22,7 +22,7 @@ import logging import os -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets from sqlalchemy.sql import and_ from openlp.core.common import Registry, RegistryProperties, UiStrings, translate @@ -36,7 +36,7 @@ from .songmaintenancedialog import Ui_SongMaintenanceDialog log = logging.getLogger(__name__) -class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryProperties): +class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryProperties): """ Class documentation goes here. """ @@ -71,7 +71,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope self.topics_list_widget.currentRowChanged.connect(self.on_topics_list_row_changed) self.song_books_list_widget.currentRowChanged.connect(self.on_song_books_list_row_changed) - def exec_(self, from_song_edit=False): + def exec(self, from_song_edit=False): """ Show the dialog. @@ -85,7 +85,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope self.reset_topics() self.reset_song_books() self.type_list_widget.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def _get_current_item_id(self, list_widget): """ @@ -108,7 +108,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope if item_id != -1: item = self.manager.get_object(item_class, item_id) if item and not item.songs: - if critical_error_message_box(dlg_title, del_text, self, True) == QtGui.QMessageBox.Yes: + if critical_error_message_box(dlg_title, del_text, self, True) == QtWidgets.QMessageBox.Yes: self.manager.delete_object(item_class, item.id) reset_func() else: @@ -124,9 +124,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) for author in authors: if author.display_name: - author_name = QtGui.QListWidgetItem(author.display_name) + author_name = QtWidgets.QListWidgetItem(author.display_name) else: - author_name = QtGui.QListWidgetItem(' '.join([author.first_name, author.last_name])) + author_name = QtWidgets.QListWidgetItem(' '.join([author.first_name, author.last_name])) author_name.setData(QtCore.Qt.UserRole, author.id) self.authors_list_widget.addItem(author_name) @@ -137,7 +137,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope self.topics_list_widget.clear() topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) for topic in topics: - topic_name = QtGui.QListWidgetItem(topic.name) + topic_name = QtWidgets.QListWidgetItem(topic.name) topic_name.setData(QtCore.Qt.UserRole, topic.id) self.topics_list_widget.addItem(topic_name) @@ -148,7 +148,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope self.song_books_list_widget.clear() books = self.manager.get_all_objects(Book, order_by_ref=Book.name) for book in books: - book_name = QtGui.QListWidgetItem('%s (%s)' % (book.name, book.publisher)) + book_name = QtWidgets.QListWidgetItem('%s (%s)' % (book.name, book.publisher)) book_name.setData(QtCore.Qt.UserRole, book.id) self.song_books_list_widget.addItem(book_name) @@ -216,7 +216,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope Add an author to the list. """ self.author_form.auto_display_name = True - if self.author_form.exec_(): + if self.author_form.exec(): author = Author.populate( first_name=self.author_form.first_name, last_name=self.author_form.last_name, @@ -236,7 +236,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope """ Add a topic to the list. """ - if self.topic_form.exec_(): + if self.topic_form.exec(): topic = Topic.populate(name=self.topic_form.name) if self.check_topic_exists(topic): if self.manager.save_object(topic): @@ -252,7 +252,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope """ Add a book to the list. """ - if self.song_book_form.exec_(): + if self.song_book_form.exec(): book = Book.populate(name=self.song_book_form.name_edit.text(), publisher=self.song_book_form.publisher_edit.text()) if self.check_song_book_exists(book): @@ -282,7 +282,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope temp_first_name = author.first_name temp_last_name = author.last_name temp_display_name = author.display_name - if self.author_form.exec_(False): + if self.author_form.exec(False): author.first_name = self.author_form.first_name_edit.text() author.last_name = self.author_form.last_name_edit.text() author.display_name = self.author_form.display_edit.text() @@ -298,7 +298,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope 'SongsPlugin.SongMaintenanceForm', 'The author %s already exists. Would you like to make songs with ' 'author %s use the existing author %s?') % (author.display_name, temp_display_name, author.display_name), parent=self, question=True) == \ - QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.Yes: self._merge_objects(author, self.merge_authors, self.reset_authors) else: # We restore the author's old first and last name as well as @@ -321,7 +321,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope self.topic_form.name = topic.name # Save the topic's name for the case that he has to be restored. temp_name = topic.name - if self.topic_form.exec_(False): + if self.topic_form.exec(False): topic.name = self.topic_form.name_edit.text() if self.check_topic_exists(topic, True): if self.manager.save_object(topic): @@ -333,7 +333,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope message=translate('SongsPlugin.SongMaintenanceForm', 'The topic %s already exists. Would you like to make songs with topic %s use the ' 'existing topic %s?') % (topic.name, temp_name, topic.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: + parent=self, question=True) == QtWidgets.QMessageBox.Yes: self._merge_objects(topic, self.merge_topics, self.reset_topics) else: # We restore the topics's old name. @@ -358,7 +358,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope # be restored. temp_name = book.name temp_publisher = book.publisher - if self.song_book_form.exec_(False): + if self.song_book_form.exec(False): book.name = self.song_book_form.name_edit.text() book.publisher = self.song_book_form.publisher_edit.text() if self.check_song_book_exists(book, True): @@ -371,7 +371,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope message=translate('SongsPlugin.SongMaintenanceForm', 'The book %s already exists. Would you like to make ' 'songs with book %s use the existing book %s?') % (book.name, temp_name, book.name), - parent=self, question=True) == QtGui.QMessageBox.Yes: + parent=self, question=True) == QtWidgets.QMessageBox.Yes: self._merge_objects(book, self.merge_song_books, self.reset_song_books) else: # We restore the book's old name and publisher. diff --git a/openlp/plugins/songs/forms/songreviewwidget.py b/openlp/plugins/songs/forms/songreviewwidget.py index 67459bfb3..d1a3f46d7 100644 --- a/openlp/plugins/songs/forms/songreviewwidget.py +++ b/openlp/plugins/songs/forms/songreviewwidget.py @@ -22,14 +22,14 @@ """ A widget representing a song in the duplicate song removal wizard review page. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import build_icon from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.openlyricsxml import SongXML -class SongReviewWidget(QtGui.QWidget): +class SongReviewWidget(QtWidgets.QWidget): """ A widget representing a song on the duplicate song review page. It displays most of the information a song contains and @@ -47,7 +47,7 @@ class SongReviewWidget(QtGui.QWidget): # connect calls. # That's why we cheat a little and use QWidget instead of SongReviewWidget as parameter. # While not being entirely correct, it does work. - song_remove_button_clicked = QtCore.pyqtSignal(QtGui.QWidget) + song_remove_button_clicked = QtCore.pyqtSignal(QtWidgets.QWidget) def __init__(self, parent, song): """ @@ -61,87 +61,87 @@ class SongReviewWidget(QtGui.QWidget): self.song_remove_button.clicked.connect(self.on_remove_button_clicked) def setupUi(self): - self.song_vertical_layout = QtGui.QVBoxLayout(self) + self.song_vertical_layout = QtWidgets.QVBoxLayout(self) self.song_vertical_layout.setObjectName('song_vertical_layout') - self.song_group_box = QtGui.QGroupBox(self) + self.song_group_box = QtWidgets.QGroupBox(self) self.song_group_box.setObjectName('song_group_box') self.song_group_box.setFixedWidth(300) - self.song_group_box_layout = QtGui.QVBoxLayout(self.song_group_box) + self.song_group_box_layout = QtWidgets.QVBoxLayout(self.song_group_box) self.song_group_box_layout.setObjectName('song_group_box_layout') - self.song_info_form_layout = QtGui.QFormLayout() + self.song_info_form_layout = QtWidgets.QFormLayout() self.song_info_form_layout.setObjectName('song_info_form_layout') # Add title widget. - self.song_title_label = QtGui.QLabel(self) + self.song_title_label = QtWidgets.QLabel(self) self.song_title_label.setObjectName('song_title_label') - self.song_info_form_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.song_title_label) - self.song_title_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.song_title_label) + self.song_title_content = QtWidgets.QLabel(self) self.song_title_content.setObjectName('song_title_content') self.song_title_content.setText(self.song.title) self.song_title_content.setWordWrap(True) - self.song_info_form_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.song_title_content) + self.song_info_form_layout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.song_title_content) # Add alternate title widget. - self.song_alternate_title_label = QtGui.QLabel(self) + self.song_alternate_title_label = QtWidgets.QLabel(self) self.song_alternate_title_label.setObjectName('song_alternate_title_label') - self.song_info_form_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.song_alternate_title_label) - self.song_alternate_title_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.song_alternate_title_label) + self.song_alternate_title_content = QtWidgets.QLabel(self) self.song_alternate_title_content.setObjectName('song_alternate_title_content') self.song_alternate_title_content.setText(self.song.alternate_title) self.song_alternate_title_content.setWordWrap(True) - self.song_info_form_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.song_alternate_title_content) + self.song_info_form_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.song_alternate_title_content) # Add CCLI number widget. - self.song_ccli_number_label = QtGui.QLabel(self) + self.song_ccli_number_label = QtWidgets.QLabel(self) self.song_ccli_number_label.setObjectName('song_ccli_number_label') - self.song_info_form_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.song_ccli_number_label) - self.song_ccli_number_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.song_ccli_number_label) + self.song_ccli_number_content = QtWidgets.QLabel(self) self.song_ccli_number_content.setObjectName('song_ccli_number_content') self.song_ccli_number_content.setText(self.song.ccli_number) self.song_ccli_number_content.setWordWrap(True) - self.song_info_form_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.song_ccli_number_content) + self.song_info_form_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.song_ccli_number_content) # Add copyright widget. - self.song_copyright_label = QtGui.QLabel(self) + self.song_copyright_label = QtWidgets.QLabel(self) self.song_copyright_label.setObjectName('song_copyright_label') - self.song_info_form_layout.setWidget(3, QtGui.QFormLayout.LabelRole, self.song_copyright_label) - self.song_copyright_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.song_copyright_label) + self.song_copyright_content = QtWidgets.QLabel(self) self.song_copyright_content.setObjectName('song_copyright_content') self.song_copyright_content.setWordWrap(True) self.song_copyright_content.setText(self.song.copyright) - self.song_info_form_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.song_copyright_content) + self.song_info_form_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.song_copyright_content) # Add comments widget. - self.song_comments_label = QtGui.QLabel(self) + self.song_comments_label = QtWidgets.QLabel(self) self.song_comments_label.setObjectName('song_comments_label') - self.song_info_form_layout.setWidget(4, QtGui.QFormLayout.LabelRole, self.song_comments_label) - self.song_comments_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.song_comments_label) + self.song_comments_content = QtWidgets.QLabel(self) self.song_comments_content.setObjectName('song_comments_content') self.song_comments_content.setText(self.song.comments) self.song_comments_content.setWordWrap(True) - self.song_info_form_layout.setWidget(4, QtGui.QFormLayout.FieldRole, self.song_comments_content) + self.song_info_form_layout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.song_comments_content) # Add authors widget. - self.song_authors_label = QtGui.QLabel(self) + self.song_authors_label = QtWidgets.QLabel(self) self.song_authors_label.setObjectName('song_authors_label') - self.song_info_form_layout.setWidget(5, QtGui.QFormLayout.LabelRole, self.song_authors_label) - self.song_authors_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.song_authors_label) + self.song_authors_content = QtWidgets.QLabel(self) self.song_authors_content.setObjectName('song_authors_content') self.song_authors_content.setWordWrap(True) authors_text = ', '.join([author.display_name for author in self.song.authors]) self.song_authors_content.setText(authors_text) - self.song_info_form_layout.setWidget(5, QtGui.QFormLayout.FieldRole, self.song_authors_content) + self.song_info_form_layout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.song_authors_content) # Add verse order widget. - self.song_verse_order_label = QtGui.QLabel(self) + self.song_verse_order_label = QtWidgets.QLabel(self) self.song_verse_order_label.setObjectName('song_verse_order_label') - self.song_info_form_layout.setWidget(6, QtGui.QFormLayout.LabelRole, self.song_verse_order_label) - self.song_verse_order_content = QtGui.QLabel(self) + self.song_info_form_layout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.song_verse_order_label) + self.song_verse_order_content = QtWidgets.QLabel(self) self.song_verse_order_content.setObjectName('song_verse_order_content') self.song_verse_order_content.setText(self.song.verse_order) self.song_verse_order_content.setWordWrap(True) - self.song_info_form_layout.setWidget(6, QtGui.QFormLayout.FieldRole, self.song_verse_order_content) + self.song_info_form_layout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.song_verse_order_content) self.song_group_box_layout.addLayout(self.song_info_form_layout) # Add verses widget. - self.song_info_verse_list_widget = QtGui.QTableWidget(self.song_group_box) + self.song_info_verse_list_widget = QtWidgets.QTableWidget(self.song_group_box) self.song_info_verse_list_widget.setColumnCount(1) self.song_info_verse_list_widget.horizontalHeader().setVisible(False) self.song_info_verse_list_widget.setObjectName('song_info_verse_list_widget') - self.song_info_verse_list_widget.setSelectionMode(QtGui.QAbstractItemView.NoSelection) - self.song_info_verse_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) + self.song_info_verse_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) + self.song_info_verse_list_widget.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.song_info_verse_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.song_info_verse_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.song_info_verse_list_widget.setAlternatingRowColors(True) @@ -150,7 +150,7 @@ class SongReviewWidget(QtGui.QWidget): self.song_info_verse_list_widget.setRowCount(len(verses)) song_tags = [] for verse_number, verse in enumerate(verses): - item = QtGui.QTableWidgetItem() + item = QtWidgets.QTableWidgetItem() item.setText(verse[1]) self.song_info_verse_list_widget.setItem(verse_number, 0, item) @@ -180,10 +180,10 @@ class SongReviewWidget(QtGui.QWidget): self.song_group_box_layout.addWidget(self.song_info_verse_list_widget) self.song_group_box_layout.addStretch() self.song_vertical_layout.addWidget(self.song_group_box) - self.song_remove_button = QtGui.QPushButton(self) + self.song_remove_button = QtWidgets.QPushButton(self) self.song_remove_button.setObjectName('song_remove_button') self.song_remove_button.setIcon(build_icon(':/songs/song_delete.png')) - self.song_remove_button.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + self.song_remove_button.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.song_vertical_layout.addWidget(self.song_remove_button, alignment=QtCore.Qt.AlignHCenter) def retranslateUi(self): diff --git a/openlp/plugins/songs/forms/songselectdialog.py b/openlp/plugins/songs/forms/songselectdialog.py index 13cf7b6f1..b1bd9b143 100644 --- a/openlp/plugins/songs/forms/songselectdialog.py +++ b/openlp/plugins/songs/forms/songselectdialog.py @@ -23,7 +23,7 @@ The :mod:`~openlp.plugins.songs.forms.songselectdialog` module contains the user interface code for the dialog """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import HistoryComboBox from openlp.core.lib import translate, build_icon @@ -37,148 +37,148 @@ class Ui_SongSelectDialog(object): def setup_ui(self, songselect_dialog): songselect_dialog.setObjectName('songselect_dialog') songselect_dialog.resize(616, 378) - self.songselect_layout = QtGui.QVBoxLayout(songselect_dialog) + self.songselect_layout = QtWidgets.QVBoxLayout(songselect_dialog) self.songselect_layout.setSpacing(0) - self.songselect_layout.setMargin(0) + self.songselect_layout.setContentsMargins(0, 0, 0, 0) self.songselect_layout.setObjectName('songselect_layout') - self.stacked_widget = QtGui.QStackedWidget(songselect_dialog) + self.stacked_widget = QtWidgets.QStackedWidget(songselect_dialog) self.stacked_widget.setObjectName('stacked_widget') - self.login_page = QtGui.QWidget() + self.login_page = QtWidgets.QWidget() self.login_page.setObjectName('login_page') - self.login_layout = QtGui.QFormLayout(self.login_page) + self.login_layout = QtWidgets.QFormLayout(self.login_page) self.login_layout.setContentsMargins(120, 100, 120, 100) self.login_layout.setSpacing(8) self.login_layout.setObjectName('login_layout') - self.notice_layout = QtGui.QHBoxLayout() + self.notice_layout = QtWidgets.QHBoxLayout() self.notice_layout.setObjectName('notice_layout') - self.notice_label = QtGui.QLabel(self.login_page) + self.notice_label = QtWidgets.QLabel(self.login_page) self.notice_label.setWordWrap(True) self.notice_label.setObjectName('notice_label') self.notice_layout.addWidget(self.notice_label) - self.login_layout.setLayout(0, QtGui.QFormLayout.SpanningRole, self.notice_layout) - self.username_label = QtGui.QLabel(self.login_page) + self.login_layout.setLayout(0, QtWidgets.QFormLayout.SpanningRole, self.notice_layout) + self.username_label = QtWidgets.QLabel(self.login_page) self.username_label.setObjectName('usernameLabel') - self.login_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.username_label) - self.username_edit = QtGui.QLineEdit(self.login_page) + self.login_layout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.username_label) + self.username_edit = QtWidgets.QLineEdit(self.login_page) self.username_edit.setObjectName('usernameEdit') - self.login_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.username_edit) - self.password_label = QtGui.QLabel(self.login_page) + self.login_layout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.username_edit) + self.password_label = QtWidgets.QLabel(self.login_page) self.password_label.setObjectName('passwordLabel') - self.login_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.password_label) - self.password_edit = QtGui.QLineEdit(self.login_page) - self.password_edit.setEchoMode(QtGui.QLineEdit.Password) + self.login_layout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.password_label) + self.password_edit = QtWidgets.QLineEdit(self.login_page) + self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password) self.password_edit.setObjectName('passwordEdit') - self.login_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.password_edit) - self.save_password_checkbox = QtGui.QCheckBox(self.login_page) + self.login_layout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.password_edit) + self.save_password_checkbox = QtWidgets.QCheckBox(self.login_page) self.save_password_checkbox.setTristate(False) self.save_password_checkbox.setObjectName('save_password_checkbox') - self.login_layout.setWidget(3, QtGui.QFormLayout.FieldRole, self.save_password_checkbox) - self.login_button_layout = QtGui.QHBoxLayout() + self.login_layout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.save_password_checkbox) + self.login_button_layout = QtWidgets.QHBoxLayout() self.login_button_layout.setSpacing(8) self.login_button_layout.setContentsMargins(0, -1, -1, -1) self.login_button_layout.setObjectName('login_button_layout') - self.login_spacer = QtGui.QWidget(self.login_page) - self.login_spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.login_spacer = QtWidgets.QWidget(self.login_page) + self.login_spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.login_spacer.setObjectName('login_spacer') self.login_button_layout.addWidget(self.login_spacer) - self.login_progress_bar = QtGui.QProgressBar(self.login_page) + self.login_progress_bar = QtWidgets.QProgressBar(self.login_page) self.login_progress_bar.setMinimum(0) self.login_progress_bar.setMaximum(3) self.login_progress_bar.setValue(0) self.login_progress_bar.setMinimumWidth(200) self.login_progress_bar.setVisible(False) self.login_button_layout.addWidget(self.login_progress_bar) - self.login_button = QtGui.QPushButton(self.login_page) + self.login_button = QtWidgets.QPushButton(self.login_page) self.login_button.setIcon(build_icon(':/songs/song_author_edit.png')) self.login_button.setObjectName('login_button') self.login_button_layout.addWidget(self.login_button) - self.login_layout.setLayout(4, QtGui.QFormLayout.SpanningRole, self.login_button_layout) + self.login_layout.setLayout(4, QtWidgets.QFormLayout.SpanningRole, self.login_button_layout) self.stacked_widget.addWidget(self.login_page) - self.search_page = QtGui.QWidget() + self.search_page = QtWidgets.QWidget() self.search_page.setObjectName('search_page') - self.search_layout = QtGui.QVBoxLayout(self.search_page) + self.search_layout = QtWidgets.QVBoxLayout(self.search_page) self.search_layout.setSpacing(8) - self.search_layout.setMargin(8) + self.search_layout.setContentsMargins(8, 8, 8, 8) self.search_layout.setObjectName('search_layout') - self.search_input_layout = QtGui.QHBoxLayout() + self.search_input_layout = QtWidgets.QHBoxLayout() self.search_input_layout.setSpacing(8) self.search_input_layout.setObjectName('search_input_layout') - self.search_label = QtGui.QLabel(self.search_page) + self.search_label = QtWidgets.QLabel(self.search_page) self.search_label.setObjectName('search_label') self.search_input_layout.addWidget(self.search_label) self.search_combobox = HistoryComboBox(self.search_page) self.search_combobox.setObjectName('search_combobox') self.search_input_layout.addWidget(self.search_combobox) - self.search_button = QtGui.QPushButton(self.search_page) + self.search_button = QtWidgets.QPushButton(self.search_page) self.search_button.setIcon(build_icon(':/general/general_find.png')) self.search_button.setObjectName('search_button') self.search_input_layout.addWidget(self.search_button) self.search_layout.addLayout(self.search_input_layout) - self.search_progress_bar = QtGui.QProgressBar(self.search_page) + self.search_progress_bar = QtWidgets.QProgressBar(self.search_page) self.search_progress_bar.setMinimum(0) self.search_progress_bar.setMaximum(3) self.search_progress_bar.setValue(0) self.search_progress_bar.setVisible(False) self.search_layout.addWidget(self.search_progress_bar) - self.search_results_widget = QtGui.QListWidget(self.search_page) + self.search_results_widget = QtWidgets.QListWidget(self.search_page) self.search_results_widget.setProperty("showDropIndicator", False) self.search_results_widget.setAlternatingRowColors(True) - self.search_results_widget.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) - self.search_results_widget.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) + self.search_results_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) + self.search_results_widget.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.search_results_widget.setObjectName('search_results_widget') self.search_layout.addWidget(self.search_results_widget) - self.result_count_label = QtGui.QLabel(self.search_page) + self.result_count_label = QtWidgets.QLabel(self.search_page) self.result_count_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignCenter) self.result_count_label.setObjectName('result_count_label') self.search_layout.addWidget(self.result_count_label) - self.view_layout = QtGui.QHBoxLayout() + self.view_layout = QtWidgets.QHBoxLayout() self.view_layout.setSpacing(8) self.view_layout.setObjectName('view_layout') - self.logout_button = QtGui.QPushButton(self.search_page) + self.logout_button = QtWidgets.QPushButton(self.search_page) self.logout_button.setIcon(build_icon(':/songs/song_author_edit.png')) self.view_layout.addWidget(self.logout_button) - self.view_spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.view_spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.view_layout.addItem(self.view_spacer) - self.view_button = QtGui.QPushButton(self.search_page) + self.view_button = QtWidgets.QPushButton(self.search_page) self.view_button.setIcon(build_icon(':/songs/song_search_all.png')) self.view_button.setObjectName('view_button') self.view_layout.addWidget(self.view_button) self.search_layout.addLayout(self.view_layout) self.stacked_widget.addWidget(self.search_page) - self.song_page = QtGui.QWidget() + self.song_page = QtWidgets.QWidget() self.song_page.setObjectName('song_page') - self.song_layout = QtGui.QGridLayout(self.song_page) - self.song_layout.setMargin(8) + self.song_layout = QtWidgets.QGridLayout(self.song_page) + self.song_layout.setContentsMargins(8, 8, 8, 8) self.song_layout.setSpacing(8) self.song_layout.setObjectName('song_layout') - self.title_label = QtGui.QLabel(self.song_page) + self.title_label = QtWidgets.QLabel(self.song_page) self.title_label.setObjectName('title_label') self.song_layout.addWidget(self.title_label, 0, 0, 1, 1) - self.title_edit = QtGui.QLineEdit(self.song_page) + self.title_edit = QtWidgets.QLineEdit(self.song_page) self.title_edit.setReadOnly(True) self.title_edit.setObjectName('title_edit') self.song_layout.addWidget(self.title_edit, 0, 1, 1, 1) - self.authors_label = QtGui.QLabel(self.song_page) + self.authors_label = QtWidgets.QLabel(self.song_page) self.authors_label.setObjectName('authors_label') self.song_layout.addWidget(self.authors_label, 0, 2, 1, 1) - self.author_list_widget = QtGui.QListWidget(self.song_page) + self.author_list_widget = QtWidgets.QListWidget(self.song_page) self.author_list_widget.setObjectName('author_list_widget') self.song_layout.addWidget(self.author_list_widget, 0, 3, 3, 1) - self.copyright_label = QtGui.QLabel(self.song_page) + self.copyright_label = QtWidgets.QLabel(self.song_page) self.copyright_label.setObjectName('copyright_label') self.song_layout.addWidget(self.copyright_label, 1, 0, 1, 1) - self.copyright_edit = QtGui.QLineEdit(self.song_page) + self.copyright_edit = QtWidgets.QLineEdit(self.song_page) self.copyright_edit.setReadOnly(True) self.copyright_edit.setObjectName('copyright_edit') self.song_layout.addWidget(self.copyright_edit, 1, 1, 1, 1) - self.ccli_label = QtGui.QLabel(self.song_page) + self.ccli_label = QtWidgets.QLabel(self.song_page) self.ccli_label.setObjectName('ccli_label') self.song_layout.addWidget(self.ccli_label, 2, 0, 1, 1) - self.ccli_edit = QtGui.QLineEdit(self.song_page) + self.ccli_edit = QtWidgets.QLineEdit(self.song_page) self.ccli_edit.setReadOnly(True) self.ccli_edit.setObjectName('ccli_edit') self.song_layout.addWidget(self.ccli_edit, 2, 1, 1, 1) - self.lyrics_label = QtGui.QLabel(self.song_page) + self.lyrics_label = QtWidgets.QLabel(self.song_page) self.lyrics_label.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.lyrics_label.setObjectName('lyrics_label') self.song_layout.addWidget(self.lyrics_label, 3, 0, 1, 1) @@ -186,21 +186,22 @@ class Ui_SongSelectDialog(object): self.lyrics_table_widget.setObjectName('lyrics_table_widget') self.lyrics_table_widget.setRowCount(0) self.song_layout.addWidget(self.lyrics_table_widget, 3, 1, 1, 3) - self.song_progress_bar = QtGui.QProgressBar(self.song_page) + self.song_progress_bar = QtWidgets.QProgressBar(self.song_page) self.song_progress_bar.setMinimum(0) self.song_progress_bar.setMaximum(3) self.song_progress_bar.setValue(0) self.song_progress_bar.setVisible(False) self.song_layout.addWidget(self.song_progress_bar, 4, 0, 1, 4) - self.import_layout = QtGui.QHBoxLayout() + self.import_layout = QtWidgets.QHBoxLayout() self.import_layout.setObjectName('import_layout') - self.back_button = QtGui.QPushButton(self.song_page) + self.back_button = QtWidgets.QPushButton(self.song_page) self.back_button.setIcon(build_icon(':/general/general_back.png')) self.back_button.setObjectName('back_button') self.import_layout.addWidget(self.back_button) - self.import_spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.import_spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, + QtWidgets.QSizePolicy.Minimum) self.import_layout.addItem(self.import_spacer) - self.import_button = QtGui.QPushButton(self.song_page) + self.import_button = QtWidgets.QPushButton(self.song_page) self.import_button.setIcon(build_icon(':/general/general_import.png')) self.import_button.setObjectName('import_button') self.import_layout.addWidget(self.import_button) diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index d006bde76..b8d410c43 100755 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -27,7 +27,7 @@ import logging import os from time import sleep -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core import Settings from openlp.core.common import Registry, is_win @@ -75,13 +75,13 @@ class SearchWorker(QtCore.QObject): self.found_song.emit(song) -class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): +class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog): """ The :class:`SongSelectForm` class is the SongSelect dialog. """ def __init__(self, parent=None, plugin=None, db_manager=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.plugin = plugin self.db_manager = db_manager self.setup_ui(self) @@ -106,7 +106,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): self.back_button.clicked.connect(self.on_back_button_clicked) self.import_button.clicked.connect(self.on_import_button_clicked) - def exec_(self): + def exec(self): """ Execute the dialog. This method sets everything back to its initial values. @@ -127,7 +127,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): self.search_combobox.addItems( Settings().value(self.plugin.settings_section + '/songselect searches').split('|')) self.username_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def done(self, r): """ @@ -137,7 +137,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): """ log.debug('Closing SongSelectForm') if self.stacked_widget.currentIndex() > 0: - progress_dialog = QtGui.QProgressDialog( + progress_dialog = QtWidgets.QProgressDialog( translate('SongsPlugin.SongSelectForm', 'Logging out...'), '', 0, 2, self) progress_dialog.setWindowModality(QtCore.Qt.WindowModal) progress_dialog.setCancelButton(None) @@ -150,7 +150,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): self.song_select_importer.logout() self.application.process_events() progress_dialog.setValue(2) - return QtGui.QDialog.done(self, r) + return QtWidgets.QDialog.done(self, r) def _update_login_progress(self): self.login_progress_bar.setValue(self.login_progress_bar.value() + 1) @@ -188,11 +188,11 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): # Get the full song song = self.song_select_importer.get_song(song, self._update_song_progress) if not song: - QtGui.QMessageBox.critical( + QtWidgets.QMessageBox.critical( self, translate('SongsPlugin.SongSelectForm', 'Incomplete song'), translate('SongsPlugin.SongSelectForm', 'This song is missing some information, like the lyrics, ' 'and cannot be imported.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok), QtWidgets.QMessageBox.Ok) self.stacked_widget.setCurrentIndex(1) return # Update the UI @@ -200,10 +200,10 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): self.copyright_edit.setText(song['copyright']) self.ccli_edit.setText(song['ccli_number']) for author in song['authors']: - QtGui.QListWidgetItem(author, self.author_list_widget) + QtWidgets.QListWidgetItem(author, self.author_list_widget) for counter, verse in enumerate(song['verses']): self.lyrics_table_widget.setRowCount(self.lyrics_table_widget.rowCount() + 1) - item = QtGui.QTableWidgetItem(verse['lyrics']) + item = QtWidgets.QTableWidgetItem(verse['lyrics']) item.setData(QtCore.Qt.UserRole, verse['label']) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.lyrics_table_widget.setItem(counter, 0, item) @@ -229,13 +229,14 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): :param checked: If the combobox is checked or not """ if checked and self.login_page.isVisible(): - answer = QtGui.QMessageBox.question( + answer = QtWidgets.QMessageBox.question( self, translate('SongsPlugin.SongSelectForm', 'Save Username and Password'), translate('SongsPlugin.SongSelectForm', 'WARNING: Saving your username and password is INSECURE, your ' 'password is stored in PLAIN TEXT. Click Yes to save your ' 'password or No to cancel this.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if answer == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if answer == QtWidgets.QMessageBox.No: self.save_password_checkbox.setChecked(False) def on_login_button_clicked(self): @@ -253,7 +254,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): # Log the user in if not self.song_select_importer.login( self.username_edit.text(), self.password_edit.text(), self._update_login_progress): - QtGui.QMessageBox.critical( + QtWidgets.QMessageBox.critical( self, translate('SongsPlugin.SongSelectForm', 'Error Logging In'), translate('SongsPlugin.SongSelectForm', @@ -313,7 +314,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): :param title: :param message: """ - QtGui.QMessageBox.information(self, title, message) + QtWidgets.QMessageBox.information(self, title, message) def on_search_found_song(self, song): """ @@ -323,7 +324,7 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): self.song_count += 1 self.result_count_label.setText(translate('SongsPlugin.SongSelectForm', 'Found %s song(s)') % self.song_count) item_title = song['title'] + ' (' + ', '.join(song['authors']) + ')' - song_item = QtGui.QListWidgetItem(item_title, self.search_results_widget) + song_item = QtWidgets.QListWidgetItem(item_title, self.search_results_widget) song_item.setData(QtCore.Qt.UserRole, song) def on_search_finished(self): @@ -368,15 +369,16 @@ class SongSelectForm(QtGui.QDialog, Ui_SongSelectDialog): """ self.song_select_importer.save_song(self.song) self.song = None - if QtGui.QMessageBox.question(self, translate('SongsPlugin.SongSelectForm', 'Song Imported'), - translate('SongsPlugin.SongSelectForm', 'Your song has been imported, would you ' - 'like to import more songs?'), - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, - QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: + if QtWidgets.QMessageBox.question(self, translate('SongsPlugin.SongSelectForm', 'Song Imported'), + translate('SongsPlugin.SongSelectForm', + 'Your song has been imported, would you ' + 'like to import more songs?'), + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes: self.on_back_button_clicked() else: self.application.process_events() - self.done(QtGui.QDialog.Accepted) + self.done(QtWidgets.QDialog.Accepted) @property def application(self): diff --git a/openlp/plugins/songs/forms/topicsdialog.py b/openlp/plugins/songs/forms/topicsdialog.py index 623752ebb..ab834ea0f 100644 --- a/openlp/plugins/songs/forms/topicsdialog.py +++ b/openlp/plugins/songs/forms/topicsdialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate, build_icon from openlp.core.lib.ui import create_button_box @@ -37,13 +37,13 @@ class Ui_TopicsDialog(object): topics_dialog.setObjectName('topics_dialog') topics_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) topics_dialog.resize(300, 10) - self.dialog_layout = QtGui.QVBoxLayout(topics_dialog) + self.dialog_layout = QtWidgets.QVBoxLayout(topics_dialog) self.dialog_layout.setObjectName('dialog_layout') - self.name_layout = QtGui.QFormLayout() + self.name_layout = QtWidgets.QFormLayout() self.name_layout.setObjectName('name_layout') - self.name_label = QtGui.QLabel(topics_dialog) + self.name_label = QtWidgets.QLabel(topics_dialog) self.name_label.setObjectName('name_label') - self.name_edit = QtGui.QLineEdit(topics_dialog) + self.name_edit = QtWidgets.QLineEdit(topics_dialog) self.name_edit.setObjectName('name_edit') self.name_label.setBuddy(self.name_edit) self.name_layout.addRow(self.name_label, self.name_edit) diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index d1055553d..35fdafdc3 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -23,14 +23,14 @@ This module contains the topic edit form. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.topicsdialog import Ui_TopicsDialog -class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): +class TopicsForm(QtWidgets.QDialog, Ui_TopicsDialog): """ Class documentation goes here. """ @@ -41,14 +41,14 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): super(TopicsForm, self).__init__(parent) self.setupUi(self) - def exec_(self, clear=True): + def exec(self, clear=True): """ Execute the dialog. """ if clear: self.name_edit.clear() self.name_edit.setFocus() - return QtGui.QDialog.exec_(self) + return QtWidgets.QDialog.exec(self) def accept(self): """ @@ -60,7 +60,7 @@ class TopicsForm(QtGui.QDialog, Ui_TopicsDialog): self.name_edit.setFocus() return False else: - return QtGui.QDialog.accept(self) + return QtWidgets.QDialog.accept(self) def _get_name(self): """ diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 8d1d4e65a..8faed588b 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -27,7 +27,7 @@ import logging import os import re -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import AppLocation from openlp.core.lib import translate @@ -320,7 +320,7 @@ def retrieve_windows_encoding(recommendation=None): recommended_index = index break if recommended_index > -1: - choice = QtGui.QInputDialog.getItem( + choice = QtWidgets.QInputDialog.getItem( None, translate('SongsPlugin', 'Character Encoding'), translate('SongsPlugin', 'The codepage setting is responsible\n' @@ -328,7 +328,7 @@ def retrieve_windows_encoding(recommendation=None): 'Usually you are fine with the preselected choice.'), [pair[1] for pair in encodings], recommended_index, False) else: - choice = QtGui.QInputDialog.getItem( + choice = QtWidgets.QInputDialog.getItem( None, translate('SongsPlugin', 'Character Encoding'), translate('SongsPlugin', 'Please choose the character encoding.\n' diff --git a/openlp/plugins/songs/lib/importers/openoffice.py b/openlp/plugins/songs/lib/importers/openoffice.py index c4cc06e56..bfdfafae1 100644 --- a/openlp/plugins/songs/lib/importers/openoffice.py +++ b/openlp/plugins/songs/lib/importers/openoffice.py @@ -23,7 +23,7 @@ import logging import os import time -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import is_win from openlp.core.utils import get_uno_command, get_uno_instance diff --git a/openlp/plugins/songs/lib/importers/songimport.py b/openlp/plugins/songs/lib/importers/songimport.py index 9f6caa901..fcc3c208b 100644 --- a/openlp/plugins/songs/lib/importers/songimport.py +++ b/openlp/plugins/songs/lib/importers/songimport.py @@ -25,7 +25,7 @@ import re import shutil import os -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry, AppLocation, check_directory_exists, translate from openlp.core.ui.wizard import WizardStrings diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index a45e9ed38..687aac9ac 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -25,7 +25,7 @@ import re import os import shutil -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from sqlalchemy.sql import or_ from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate @@ -60,6 +60,8 @@ class SongMediaItem(MediaManagerItem): """ This is the custom media manager item for Songs. """ + songs_go_live = QtCore.pyqtSignal(list) + songs_add_to_service = QtCore.pyqtSignal(list) log.info('Song Media Item loaded') def __init__(self, parent, plugin): @@ -70,6 +72,8 @@ class SongMediaItem(MediaManagerItem): """ Do some additional setup. """ + self.songs_go_live.connect(self.go_live_remote) + self.songs_add_to_service.connect(self.add_to_service_remote) self.single_service_item = False # Holds information about whether the edit is remotely triggered and which Song is required. self.remote_song = -1 @@ -97,9 +101,8 @@ class SongMediaItem(MediaManagerItem): # Signals and slots Registry().register_function('songs_load_list', self.on_song_list_load) Registry().register_function('songs_preview', self.on_preview_click) - QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL('cleared()'), self.on_clear_text_button_click) - QtCore.QObject.connect( - self.search_text_edit, QtCore.SIGNAL('searchTypeChanged(int)'), self.on_search_text_button_clicked) + self.search_text_edit.cleared.connect(self.on_clear_text_button_click) + self.search_text_edit.searchTypeChanged.connect(self.on_search_text_button_clicked) def add_custom_context_actions(self): create_widget_action(self.list_view, separator=True) @@ -230,7 +233,7 @@ class SongMediaItem(MediaManagerItem): continue author_list = [author.display_name for author in song.authors] song_detail = '%s (%s)' % (song.title, create_separated_list(author_list)) if author_list else song.title - song_name = QtGui.QListWidgetItem(song_detail) + song_name = QtWidgets.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) self.list_view.addItem(song_name) # Auto-select the item if name has been set @@ -247,7 +250,7 @@ class SongMediaItem(MediaManagerItem): if song.temporary: continue song_detail = '%s (%s)' % (author.display_name, song.title) - song_name = QtGui.QListWidgetItem(song_detail) + song_name = QtWidgets.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) self.list_view.addItem(song_name) @@ -263,7 +266,7 @@ class SongMediaItem(MediaManagerItem): if song_number and song_number not in song.song_number: continue song_detail = '%s - %s (%s)' % (book.name, song.song_number, song.title) - song_name = QtGui.QListWidgetItem(song_detail) + song_name = QtWidgets.QListWidgetItem(song_detail) song_name.setData(QtCore.Qt.UserRole, song.id) self.list_view.addItem(song_name) @@ -293,25 +296,25 @@ class SongMediaItem(MediaManagerItem): def on_import_click(self): if not hasattr(self, 'import_wizard'): self.import_wizard = SongImportForm(self, self.plugin) - self.import_wizard.exec_() + self.import_wizard.exec() # Run song load as list may have been cancelled but some songs loaded Registry().execute('songs_load_list') def on_export_click(self): if not hasattr(self, 'export_wizard'): self.export_wizard = SongExportForm(self, self.plugin) - self.export_wizard.exec_() + self.export_wizard.exec() def on_new_click(self): log.debug('on_new_click') self.edit_song_form.new_song() - self.edit_song_form.exec_() + self.edit_song_form.exec() self.on_clear_text_button_click() self.on_selection_change() self.auto_select_id = -1 def on_song_maintenance_click(self): - self.song_maintenance_form.exec_() + self.song_maintenance_form.exec() def on_remote_edit(self, song_id, preview=False): """ @@ -323,7 +326,7 @@ class SongMediaItem(MediaManagerItem): valid = self.plugin.manager.get_object(Song, song_id) if valid: self.edit_song_form.load_song(song_id, preview) - if self.edit_song_form.exec_() == QtGui.QDialog.Accepted: + if self.edit_song_form.exec() == QtWidgets.QDialog.Accepted: self.auto_select_id = -1 self.on_song_list_load() self.remote_song = song_id @@ -347,7 +350,7 @@ class SongMediaItem(MediaManagerItem): self.edit_item = self.list_view.currentItem() item_id = self.edit_item.data(QtCore.Qt.UserRole) self.edit_song_form.load_song(item_id, False) - self.edit_song_form.exec_() + self.edit_song_form.exec() self.auto_select_id = -1 self.on_song_list_load() self.edit_item = None @@ -358,12 +361,12 @@ class SongMediaItem(MediaManagerItem): """ if check_item_selected(self.list_view, UiStrings().SelectDelete): items = self.list_view.selectedIndexes() - if QtGui.QMessageBox.question( + if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', QtCore.QCoreApplication.CodecForTr, len(items)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), - QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return self.application.set_busy_cursor() self.main_window.display_progress_bar(len(items)) diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index c72b08bd3..3724f76f7 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Settings, translate from openlp.core.lib import SettingsTab @@ -37,23 +37,23 @@ class SongsTab(SettingsTab): """ self.setObjectName('SongsTab') super(SongsTab, self).setupUi() - self.mode_group_box = QtGui.QGroupBox(self.left_column) + self.mode_group_box = QtWidgets.QGroupBox(self.left_column) self.mode_group_box.setObjectName('mode_group_box') - self.mode_layout = QtGui.QVBoxLayout(self.mode_group_box) + self.mode_layout = QtWidgets.QVBoxLayout(self.mode_group_box) self.mode_layout.setObjectName('mode_layout') - self.tool_bar_active_check_box = QtGui.QCheckBox(self.mode_group_box) + self.tool_bar_active_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.tool_bar_active_check_box.setObjectName('tool_bar_active_check_box') self.mode_layout.addWidget(self.tool_bar_active_check_box) - self.update_on_edit_check_box = QtGui.QCheckBox(self.mode_group_box) + self.update_on_edit_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.update_on_edit_check_box.setObjectName('update_on_edit_check_box') self.mode_layout.addWidget(self.update_on_edit_check_box) - self.add_from_service_check_box = QtGui.QCheckBox(self.mode_group_box) + self.add_from_service_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.add_from_service_check_box.setObjectName('add_from_service_check_box') self.mode_layout.addWidget(self.add_from_service_check_box) - self.display_songbook_check_box = QtGui.QCheckBox(self.mode_group_box) + self.display_songbook_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.display_songbook_check_box.setObjectName('songbook_check_box') self.mode_layout.addWidget(self.display_songbook_check_box) - self.display_copyright_check_box = QtGui.QCheckBox(self.mode_group_box) + self.display_copyright_check_box = QtWidgets.QCheckBox(self.mode_group_box) self.display_copyright_check_box.setObjectName('copyright_check_box') self.mode_layout.addWidget(self.display_copyright_check_box) self.left_layout.addWidget(self.mode_group_box) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 53fac64b1..670d0d602 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -29,7 +29,7 @@ import os from tempfile import gettempdir import sqlite3 -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import UiStrings, Registry, translate from openlp.core.lib import Plugin, StringContent, build_icon @@ -173,7 +173,7 @@ class SongsPlugin(Plugin): max_songs = self.manager.get_object_count(Song) if max_songs == 0: return - progress_dialog = QtGui.QProgressDialog( + progress_dialog = QtWidgets.QProgressDialog( translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel, 0, max_songs, self.main_window) progress_dialog.setWindowTitle(translate('SongsPlugin', 'Reindexing songs')) progress_dialog.setWindowModality(QtCore.Qt.WindowModal) @@ -188,13 +188,13 @@ class SongsPlugin(Plugin): """ Search for duplicates in the song database. """ - DuplicateSongRemovalForm(self).exec_() + DuplicateSongRemovalForm(self).exec() def on_import_songselect_item_triggered(self): """ Run the SongSelect importer. """ - self.songselect_form.exec_() + self.songselect_form.exec() self.media_item.on_search_text_button_clicked() def on_song_import_item_clicked(self): @@ -300,7 +300,7 @@ class SongsPlugin(Plugin): if not song_dbs: return self.application.process_events() - progress = QtGui.QProgressDialog(self.main_window) + progress = QtWidgets.QProgressDialog(self.main_window) progress.setWindowModality(QtCore.Qt.WindowModal) progress.setWindowTitle(translate('OpenLP.Ui', 'Importing Songs')) progress.setLabelText(translate('OpenLP.Ui', 'Starting import...')) diff --git a/openlp/plugins/songusage/forms/songusagedeletedialog.py b/openlp/plugins/songusage/forms/songusagedeletedialog.py index a287137f1..2e9233b74 100644 --- a/openlp/plugins/songusage/forms/songusagedeletedialog.py +++ b/openlp/plugins/songusage/forms/songusagedeletedialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -40,17 +40,17 @@ class Ui_SongUsageDeleteDialog(object): song_usage_delete_dialog.setObjectName('song_usage_delete_dialog') song_usage_delete_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) song_usage_delete_dialog.resize(291, 243) - self.vertical_layout = QtGui.QVBoxLayout(song_usage_delete_dialog) + self.vertical_layout = QtWidgets.QVBoxLayout(song_usage_delete_dialog) self.vertical_layout.setSpacing(8) self.vertical_layout.setContentsMargins(8, 8, 8, 8) self.vertical_layout.setObjectName('vertical_layout') - self.delete_label = QtGui.QLabel(song_usage_delete_dialog) + self.delete_label = QtWidgets.QLabel(song_usage_delete_dialog) self.delete_label.setObjectName('delete_label') self.vertical_layout.addWidget(self.delete_label) - self.delete_calendar = QtGui.QCalendarWidget(song_usage_delete_dialog) + self.delete_calendar = QtWidgets.QCalendarWidget(song_usage_delete_dialog) self.delete_calendar.setFirstDayOfWeek(QtCore.Qt.Sunday) self.delete_calendar.setGridVisible(True) - self.delete_calendar.setVerticalHeaderFormat(QtGui.QCalendarWidget.NoVerticalHeader) + self.delete_calendar.setVerticalHeaderFormat(QtWidgets.QCalendarWidget.NoVerticalHeader) self.delete_calendar.setObjectName('delete_calendar') self.vertical_layout.addWidget(self.delete_calendar) self.button_box = create_button_box(song_usage_delete_dialog, 'button_box', ['cancel', 'ok']) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 09613b7d3..173f371a8 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -20,14 +20,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import RegistryProperties, translate from openlp.plugins.songusage.lib.db import SongUsageItem from .songusagedeletedialog import Ui_SongUsageDeleteDialog -class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryProperties): +class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryProperties): """ Class documentation goes here. """ @@ -46,14 +46,15 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryPrope :param button: The button pressed """ - if self.button_box.standardButton(button) == QtGui.QDialogButtonBox.Ok: - ret = QtGui.QMessageBox.question( + if self.button_box.standardButton(button) == QtWidgets.QDialogButtonBox.Ok: + ret = QtWidgets.QMessageBox.question( self, translate('SongUsagePlugin.SongUsageDeleteForm', 'Delete Selected Song Usage Events?'), translate('SongUsagePlugin.SongUsageDeleteForm', 'Are you sure you want to delete selected Song Usage data?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) - if ret == QtGui.QMessageBox.Yes: + QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), + QtWidgets.QMessageBox.No) + if ret == QtWidgets.QMessageBox.Yes: delete_date = self.delete_calendar.selectedDate().toPyDate() self.manager.delete_all_objects(SongUsageItem, SongUsageItem.usagedate <= delete_date) self.main_window.information_message( diff --git a/openlp/plugins/songusage/forms/songusagedetaildialog.py b/openlp/plugins/songusage/forms/songusagedetaildialog.py index e9ac7178d..ce2c10927 100644 --- a/openlp/plugins/songusage/forms/songusagedetaildialog.py +++ b/openlp/plugins/songusage/forms/songusagedetaildialog.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import build_icon @@ -40,39 +40,39 @@ class Ui_SongUsageDetailDialog(object): song_usage_detail_dialog.setObjectName('song_usage_detail_dialog') song_usage_detail_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg')) song_usage_detail_dialog.resize(609, 413) - self.vertical_layout = QtGui.QVBoxLayout(song_usage_detail_dialog) + self.vertical_layout = QtWidgets.QVBoxLayout(song_usage_detail_dialog) self.vertical_layout.setSpacing(8) self.vertical_layout.setContentsMargins(8, 8, 8, 8) self.vertical_layout.setObjectName('vertical_layout') - self.date_range_group_box = QtGui.QGroupBox(song_usage_detail_dialog) + self.date_range_group_box = QtWidgets.QGroupBox(song_usage_detail_dialog) self.date_range_group_box.setObjectName('date_range_group_box') - self.date_horizontal_layout = QtGui.QHBoxLayout(self.date_range_group_box) + self.date_horizontal_layout = QtWidgets.QHBoxLayout(self.date_range_group_box) self.date_horizontal_layout.setSpacing(8) self.date_horizontal_layout.setContentsMargins(8, 8, 8, 8) self.date_horizontal_layout.setObjectName('date_horizontal_layout') - self.from_date_calendar = QtGui.QCalendarWidget(self.date_range_group_box) + self.from_date_calendar = QtWidgets.QCalendarWidget(self.date_range_group_box) self.from_date_calendar.setObjectName('from_date_calendar') self.date_horizontal_layout.addWidget(self.from_date_calendar) - self.to_label = QtGui.QLabel(self.date_range_group_box) + self.to_label = QtWidgets.QLabel(self.date_range_group_box) self.to_label.setScaledContents(False) self.to_label.setAlignment(QtCore.Qt.AlignCenter) self.to_label.setObjectName('to_label') self.date_horizontal_layout.addWidget(self.to_label) - self.to_date_calendar = QtGui.QCalendarWidget(self.date_range_group_box) + self.to_date_calendar = QtWidgets.QCalendarWidget(self.date_range_group_box) self.to_date_calendar.setObjectName('to_date_calendar') self.date_horizontal_layout.addWidget(self.to_date_calendar) self.vertical_layout.addWidget(self.date_range_group_box) - self.file_group_box = QtGui.QGroupBox(self.date_range_group_box) + self.file_group_box = QtWidgets.QGroupBox(self.date_range_group_box) self.file_group_box.setObjectName('file_group_box') - self.file_horizontal_layout = QtGui.QHBoxLayout(self.file_group_box) + self.file_horizontal_layout = QtWidgets.QHBoxLayout(self.file_group_box) self.file_horizontal_layout.setSpacing(8) self.file_horizontal_layout.setContentsMargins(8, 8, 8, 8) self.file_horizontal_layout.setObjectName('file_horizontal_layout') - self.file_line_edit = QtGui.QLineEdit(self.file_group_box) + self.file_line_edit = QtWidgets.QLineEdit(self.file_group_box) self.file_line_edit.setObjectName('file_line_edit') self.file_line_edit.setReadOnly(True) self.file_horizontal_layout.addWidget(self.file_line_edit) - self.save_file_push_button = QtGui.QPushButton(self.file_group_box) + self.save_file_push_button = QtWidgets.QPushButton(self.file_group_box) self.save_file_push_button.setMaximumWidth(self.save_file_push_button.size().height()) self.save_file_push_button.setIcon(build_icon(':/general/general_open.png')) self.save_file_push_button.setObjectName('save_file_push_button') diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index a4136e88b..680b258e0 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -23,7 +23,7 @@ import logging import os -from PyQt4 import QtGui +from PyQt5 import QtWidgets from sqlalchemy.sql import and_ from openlp.core.common import RegistryProperties, Settings, check_directory_exists, translate @@ -34,7 +34,7 @@ from .songusagedetaildialog import Ui_SongUsageDetailDialog log = logging.getLogger(__name__) -class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryProperties): +class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryProperties): """ Class documentation goes here. """ @@ -60,7 +60,7 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryPrope """ Triggered when the Directory selection button is clicked """ - path = QtGui.QFileDialog.getExistingDirectory( + path = QtWidgets.QFileDialog.getExistingDirectory( self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), Settings().value(self.plugin.settings_section + '/last directory export')) if path: diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index c267f9294..2bb543835 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -23,7 +23,7 @@ import logging from datetime import datetime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, Settings, translate from openlp.core.lib import Plugin, StringContent, build_icon @@ -83,7 +83,7 @@ class SongUsagePlugin(Plugin): """ log.info('add tools menu') self.tools_menu = tools_menu - self.song_usage_menu = QtGui.QMenu(tools_menu) + self.song_usage_menu = QtWidgets.QMenu(tools_menu) self.song_usage_menu.setObjectName('song_usage_menu') self.song_usage_menu.setTitle(translate('SongUsagePlugin', '&Song Usage Tracking')) # SongUsage Delete @@ -110,7 +110,7 @@ class SongUsagePlugin(Plugin): self.song_usage_menu.addSeparator() self.song_usage_menu.addAction(self.song_usage_report) self.song_usage_menu.addAction(self.song_usage_delete) - self.song_usage_active_button = QtGui.QToolButton(self.main_window.status_bar) + self.song_usage_active_button = QtWidgets.QToolButton(self.main_window.status_bar) self.song_usage_active_button.setCheckable(True) self.song_usage_active_button.setAutoRaise(True) self.song_usage_active_button.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.')) @@ -118,8 +118,7 @@ class SongUsagePlugin(Plugin): self.main_window.status_bar.insertPermanentWidget(1, self.song_usage_active_button) self.song_usage_active_button.hide() # Signals and slots - QtCore.QObject.connect(self.song_usage_status, QtCore.SIGNAL('visibilityChanged(bool)'), - self.song_usage_status.setChecked) + self.song_usage_status.changed.connect(self.toggle_song_usage_state) self.song_usage_active_button.toggled.connect(self.toggle_song_usage_state) self.song_usage_menu.menuAction().setVisible(False) @@ -218,7 +217,7 @@ class SongUsagePlugin(Plugin): """ Request the delete form to be displayed """ - self.song_usage_delete_form.exec_() + self.song_usage_delete_form.exec() def on_song_usage_report(self): """ @@ -226,7 +225,7 @@ class SongUsagePlugin(Plugin): """ self.song_usage_detail_form.initialise() - self.song_usage_detail_form.exec_() + self.song_usage_detail_form.exec() def about(self): """ diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index 7969c1988..92fcf7a0e 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -45,8 +45,8 @@ IS_LIN = sys.platform.startswith('lin') VERS = { 'Python': '3.0', - 'PyQt4': '4.6', - 'Qt4': '4.6', + 'PyQt5': '5.0', + 'Qt5': '5.0', 'sqlalchemy': '0.5', # pyenchant 1.6 required on Windows 'enchant': '1.6' if IS_WIN else '1.3' @@ -68,15 +68,16 @@ LINUX_MODULES = [ MODULES = [ - 'PyQt4', - 'PyQt4.QtCore', - 'PyQt4.QtGui', - 'PyQt4.QtNetwork', - 'PyQt4.QtOpenGL', - 'PyQt4.QtSvg', - 'PyQt4.QtTest', - 'PyQt4.QtWebKit', - 'PyQt4.phonon', + 'PyQt5', + 'PyQt5.QtCore', + 'PyQt5.QtGui', + 'PyQt5.QtWidgets', + 'PyQt5.QtNetwork', + 'PyQt5.QtOpenGL', + 'PyQt5.QtSvg', + 'PyQt5.QtTest', + 'PyQt5.QtWebKit', + 'PyQt5.QtMultimedia', 'sqlalchemy', 'alembic', 'sqlite3', @@ -162,12 +163,12 @@ def verify_python(): def verify_versions(): print('Verifying version of modules...') try: - from PyQt4 import QtCore - check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], 'PyQt4') - check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4') + from PyQt5 import QtCore + check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt5'], 'PyQt5') + check_vers(QtCore.qVersion(), VERS['Qt5'], 'Qt5') except ImportError: - print_vers_fail(VERS['PyQt4'], 'PyQt4') - print_vers_fail(VERS['Qt4'], 'Qt4') + print_vers_fail(VERS['PyQt5'], 'PyQt5') + print_vers_fail(VERS['Qt5'], 'Qt5') try: import sqlalchemy check_vers(sqlalchemy.__version__, VERS['sqlalchemy'], 'sqlalchemy') @@ -198,11 +199,11 @@ def print_enchant_backends_and_languages(): def print_qt_image_formats(): """ - Print out the image formats that Qt4 supports. + Print out the image formats that Qt5 supports. """ - w('Qt4 image formats... ') + w('Qt5 image formats... ') try: - from PyQt4 import QtGui + from PyQt5 import QtGui read_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageReader.supportedImageFormats()]) write_f = ', '.join([bytes(fmt).decode().lower() for fmt in QtGui.QImageWriter.supportedImageFormats()]) w(os.linesep) diff --git a/scripts/resources.patch b/scripts/resources.patch index 0f361cfe8..69fdb8875 100644 --- a/scripts/resources.patch +++ b/scripts/resources.patch @@ -33,7 +33,7 @@ +The :mod:`resources` module provides application images and icons in a central +store for use by OpenLP. +""" - from PyQt4 import QtCore + from PyQt5 import QtCore qt_resource_data = "\ @@ -71953,9 +71971,14 @@ diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index fb4022b83..40e70b4c3 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -57,7 +57,7 @@ import glob from lxml import etree, objectify from optparse import OptionParser -from PyQt4 import QtCore +from PyQt5 import QtCore SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/resource/openlp-22x/' IGNORED_PATHS = ['scripts'] diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py index 12005c16e..6453aabde 100644 --- a/tests/functional/__init__.py +++ b/tests/functional/__init__.py @@ -22,25 +22,16 @@ """ Base directory for tests """ -import sip -sip.setapi('QDate', 2) -sip.setapi('QDateTime', 2) -sip.setapi('QString', 2) -sip.setapi('QTextStream', 2) -sip.setapi('QTime', 2) -sip.setapi('QUrl', 2) -sip.setapi('QVariant', 2) - import sys -from PyQt4 import QtGui +from PyQt5 import QtWidgets if sys.version_info[1] >= 3: from unittest.mock import ANY, MagicMock, patch, mock_open, call else: from mock import ANY, MagicMock, patch, mock_open, call -# Only one QApplication can be created. Use QtGui.QApplication.instance() when you need to "create" a QApplication. -application = QtGui.QApplication([]) +# Only one QApplication can be created. Use QtWidgets.QApplication.instance() when you need to "create" a QApplication. +application = QtWidgets.QApplication([]) application.setApplicationName('OpenLP') __all__ = ['ANY', 'MagicMock', 'patch', 'mock_open', 'call', 'application'] diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py index cdc67a070..5413ccd7e 100644 --- a/tests/functional/openlp_core_common/test_common.py +++ b/tests/functional/openlp_core_common/test_common.py @@ -123,15 +123,13 @@ class TestCommonFunctions(TestCase): context = 'OpenLP.Tests' text = 'Untranslated string' comment = 'A comment' - encoding = 1 - n = 1 mocked_translate = MagicMock(return_value='Translated string') # WHEN: we call the translate function - result = translate(context, text, comment, encoding, n, mocked_translate) + result = translate(context, text, comment, mocked_translate) # THEN: the translated string should be returned, and the mocked function should have been called - mocked_translate.assert_called_with(context, text, comment, encoding, n) + mocked_translate.assert_called_with(context, text, comment) self.assertEqual('Translated string', result, 'The translated string should have been returned') def is_win_test(self): diff --git a/tests/functional/openlp_core_lib/test_file_dialog.py b/tests/functional/openlp_core_lib/test_file_dialog.py index 6cfb356b6..4c9268195 100644 --- a/tests/functional/openlp_core_lib/test_file_dialog.py +++ b/tests/functional/openlp_core_lib/test_file_dialog.py @@ -14,7 +14,7 @@ class TestFileDialog(TestCase): """ def setUp(self): self.os_patcher = patch('openlp.core.lib.filedialog.os') - self.qt_gui_patcher = patch('openlp.core.lib.filedialog.QtGui') + self.qt_gui_patcher = patch('openlp.core.lib.filedialog.QtWidgets') self.ui_strings_patcher = patch('openlp.core.lib.filedialog.UiStrings') self.mocked_os = self.os_patcher.start() self.mocked_qt_gui = self.qt_gui_patcher.start() @@ -34,7 +34,7 @@ class TestFileDialog(TestCase): self.mocked_os.reset_mock() # GIVEN: An empty QStringList as a return value from QFileDialog.getOpenFileNames - self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = [] + self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = ([], []) # WHEN: FileDialog.getOpenFileNames is called result = FileDialog.getOpenFileNames(self.mocked_parent) @@ -55,8 +55,8 @@ class TestFileDialog(TestCase): # GIVEN: A List of known values as a return value from QFileDialog.getOpenFileNames and a list of valid file # names. - self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = [ - '/Valid File', '/url%20encoded%20file%20%231', '/non-existing'] + self.mocked_qt_gui.QFileDialog.getOpenFileNames.return_value = ([ + '/Valid File', '/url%20encoded%20file%20%231', '/non-existing'], []) self.mocked_os.path.exists.side_effect = lambda file_name: file_name in [ '/Valid File', '/url encoded file #1'] self.mocked_ui_strings().FileNotFound = 'File Not Found' diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 7ba63a792..7199464bc 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -4,7 +4,7 @@ Package to test the openlp.core.lib.htmlbuilder module. from unittest import TestCase -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Settings from openlp.core.lib.htmlbuilder import build_html, build_background_css, build_lyrics_css, build_lyrics_outline_css, \ diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index 8a89627d3..7c691bb4f 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -27,7 +27,7 @@ import time from threading import Lock from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtGui from openlp.core.common import Registry from openlp.core.lib import ImageManager, ScreenList diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 9fc1fa3ff..44ca08394 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -27,7 +27,7 @@ import os from unittest import TestCase from datetime import datetime, timedelta -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from openlp.core.lib import build_icon, check_item_selected, clean_tags, create_thumb, create_separated_list, \ expand_tags, get_text_file_string, image_to_byte, resize_image, str_to_bool, validate_thumb @@ -286,8 +286,8 @@ class TestLib(TestCase): """ Test that the check_item_selected() function returns True when there are selected indexes """ - # GIVEN: A mocked out QtGui module and a list widget with selected indexes - mocked_QtGui = patch('openlp.core.lib.QtGui') + # GIVEN: A mocked out QtWidgets module and a list widget with selected indexes + mocked_QtWidgets = patch('openlp.core.lib.QtWidgets') mocked_list_widget = MagicMock() mocked_list_widget.selectedIndexes.return_value = True message = 'message' @@ -303,8 +303,8 @@ class TestLib(TestCase): """ Test that the check_item_selected() function returns False when there are no selected indexes. """ - # GIVEN: A mocked out QtGui module and a list widget with selected indexes - with patch('openlp.core.lib.QtGui') as MockedQtGui, \ + # GIVEN: A mocked out QtWidgets module and a list widget with selected indexes + with patch('openlp.core.lib.QtWidgets') as MockedQtWidgets, \ patch('openlp.core.lib.translate') as mocked_translate: mocked_translate.return_value = 'mocked translate' mocked_list_widget = MagicMock() @@ -317,7 +317,7 @@ class TestLib(TestCase): # THEN: The selectedIndexes function should have been called and the result should be true mocked_list_widget.selectedIndexes.assert_called_with() - MockedQtGui.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message') + MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message') self.assertFalse(result, 'The result should be False') def clean_tags_test(self): diff --git a/tests/functional/openlp_core_lib/test_renderer.py b/tests/functional/openlp_core_lib/test_renderer.py index 4b5ff825f..fd3c17054 100644 --- a/tests/functional/openlp_core_lib/test_renderer.py +++ b/tests/functional/openlp_core_lib/test_renderer.py @@ -24,7 +24,7 @@ Package to test the openlp.core.ui.renderer package. """ from unittest import TestCase -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry from openlp.core.lib import Renderer, ScreenList, ServiceItem diff --git a/tests/functional/openlp_core_lib/test_screen.py b/tests/functional/openlp_core_lib/test_screen.py index adbb8c226..e7d4fe41d 100644 --- a/tests/functional/openlp_core_lib/test_screen.py +++ b/tests/functional/openlp_core_lib/test_screen.py @@ -24,7 +24,7 @@ Package to test the openlp.core.lib.screenlist package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry from openlp.core.lib import ScreenList @@ -49,7 +49,7 @@ class TestScreenList(TestCase): self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] - self.application = QtGui.QApplication.instance() + self.application = QtWidgets.QApplication.instance() Registry.create() self.application.setOrganizationName('OpenLP-tests') self.application.setOrganizationDomain('openlp.org') diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 156b178c1..c3a092910 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -22,7 +22,7 @@ """ Package to test the openlp.core.lib.ui package. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets from unittest import TestCase from openlp.core.common import UiStrings, translate @@ -42,70 +42,70 @@ class TestUi(TestCase): Test appending a welcome page to a wizard """ # GIVEN: A wizard - wizard = QtGui.QWizard() + wizard = QtWidgets.QWizard() # WHEN: A welcome page has been added to the wizard add_welcome_page(wizard, ':/wizards/wizard_firsttime.bmp') # THEN: The wizard should have one page with a pixmap. self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.') - self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap) + self.assertIsInstance(wizard.page(0).pixmap(QtWidgets.QWizard.WatermarkPixmap), QtGui.QPixmap) def create_button_box_test(self): """ Test creating a button box for a dialog """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create the button box with five buttons btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults']) # THEN: We should get a QDialogButtonBox with five buttons - self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox) self.assertEqual(5, len(btnbox.buttons())) # WHEN: We create the button box with a custom button - btnbox = create_button_box(dialog, 'my_btns', None, [QtGui.QPushButton('Custom')]) + btnbox = create_button_box(dialog, 'my_btns', None, [QtWidgets.QPushButton('Custom')]) # THEN: We should get a QDialogButtonBox with one button - self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox) self.assertEqual(1, len(btnbox.buttons())) # WHEN: We create the button box with a custom button and a custom role btnbox = create_button_box(dialog, 'my_btns', None, - [(QtGui.QPushButton('Help'), QtGui.QDialogButtonBox.HelpRole)]) + [(QtWidgets.QPushButton('Help'), QtWidgets.QDialogButtonBox.HelpRole)]) # THEN: We should get a QDialogButtonBox with one button with a certain role - self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertIsInstance(btnbox, QtWidgets.QDialogButtonBox) self.assertEqual(1, len(btnbox.buttons())) - self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) + self.assertEqual(QtWidgets.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) def create_horizontal_adjusting_combo_box_test(self): """ Test creating a horizontal adjusting combo box """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create the combobox combo = create_horizontal_adjusting_combo_box(dialog, 'combo1') # THEN: We should get a ComboBox - self.assertIsInstance(combo, QtGui.QComboBox) + self.assertIsInstance(combo, QtWidgets.QComboBox) self.assertEqual('combo1', combo.objectName()) - self.assertEqual(QtGui.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy()) + self.assertEqual(QtWidgets.QComboBox.AdjustToMinimumContentsLength, combo.sizeAdjustPolicy()) def create_button_test(self): """ Test creating a button """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create the button btn = create_button(dialog, 'my_btn') # THEN: We should get a button with a name - self.assertIsInstance(btn, QtGui.QPushButton) + self.assertIsInstance(btn, QtWidgets.QPushButton) self.assertEqual('my_btn', btn.objectName()) self.assertTrue(btn.isEnabled()) @@ -113,7 +113,7 @@ class TestUi(TestCase): btn = create_button(dialog, 'my_btn', text='Hello', tooltip='How are you?', enabled=False) # THEN: We should get a button with those attributes - self.assertIsInstance(btn, QtGui.QPushButton) + self.assertIsInstance(btn, QtWidgets.QPushButton) self.assertEqual('Hello', btn.text()) self.assertEqual('How are you?', btn.toolTip()) self.assertFalse(btn.isEnabled()) @@ -122,7 +122,7 @@ class TestUi(TestCase): btn = create_button(dialog, 'my_btn', btn_class='toolbutton') # THEN: We should get a toolbutton - self.assertIsInstance(btn, QtGui.QToolButton) + self.assertIsInstance(btn, QtWidgets.QToolButton) self.assertEqual('my_btn', btn.objectName()) self.assertTrue(btn.isEnabled()) @@ -131,13 +131,13 @@ class TestUi(TestCase): Test creating an action """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create an action action = create_action(dialog, 'my_action') # THEN: We should get a QAction - self.assertIsInstance(action, QtGui.QAction) + self.assertIsInstance(action, QtWidgets.QAction) self.assertEqual('my_action', action.objectName()) # WHEN: We create an action with some properties @@ -145,7 +145,7 @@ class TestUi(TestCase): tooltip='my tooltip', statustip='my statustip') # THEN: These properties should be set - self.assertIsInstance(action, QtGui.QAction) + self.assertIsInstance(action, QtWidgets.QAction) self.assertEqual('my text', action.text()) self.assertIsInstance(action.icon(), QtGui.QIcon) self.assertEqual('my tooltip', action.toolTip()) @@ -157,11 +157,11 @@ class TestUi(TestCase): """ # GIVEN: A dialog and a mocked out is_macosx() method to always return True with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \ - patch('openlp.core.lib.ui.QtGui.QAction') as MockedQAction: + patch('openlp.core.lib.ui.QtWidgets.QAction') as MockedQAction: mocked_is_macosx.return_value = True mocked_action = MagicMock() MockedQAction.return_value = mocked_action - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: An action is created create_action(dialog, 'my_action') @@ -175,11 +175,11 @@ class TestUi(TestCase): """ # GIVEN: A dialog and a mocked out is_macosx() method to always return True with patch('openlp.core.lib.ui.is_macosx') as mocked_is_macosx, \ - patch('openlp.core.lib.ui.QtGui.QAction') as MockedQAction: + patch('openlp.core.lib.ui.QtWidgets.QAction') as MockedQAction: mocked_is_macosx.return_value = False mocked_action = MagicMock() MockedQAction.return_value = mocked_action - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: An action is created create_action(dialog, 'my_action') @@ -193,7 +193,7 @@ class TestUi(TestCase): Test that an invisible, disabled, checked action is created correctly """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create an action with some properties action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False) @@ -208,7 +208,7 @@ class TestUi(TestCase): Test creating an action as separator """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create an action as a separator action = create_action(dialog, 'my_action', separator=True) @@ -221,14 +221,14 @@ class TestUi(TestCase): Test creating a combo box for valign selection """ # GIVEN: A dialog - dialog = QtGui.QDialog() + dialog = QtWidgets.QDialog() # WHEN: We create the widgets label, combo = create_valign_selection_widgets(dialog) # THEN: We should get a label and a combobox. self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text()) - self.assertIsInstance(combo, QtGui.QComboBox) + self.assertIsInstance(combo, QtWidgets.QComboBox) self.assertEqual(combo, label.buddy()) for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]: self.assertTrue(combo.findText(text) >= 0) @@ -238,7 +238,7 @@ class TestUi(TestCase): Test finding a string in a combo box and setting it as the selected item if present """ # GIVEN: A ComboBox - combo = QtGui.QComboBox() + combo = QtWidgets.QComboBox() combo.addItems(['One', 'Two', 'Three']) combo.setCurrentIndex(1) @@ -265,13 +265,13 @@ class TestUi(TestCase): Test creating an action for a widget """ # GIVEN: A button - button = QtGui.QPushButton() + button = QtWidgets.QPushButton() # WHEN: We call the function action = create_widget_action(button, 'some action') # THEN: The action should be returned - self.assertIsInstance(action, QtGui.QAction) + self.assertIsInstance(action, QtWidgets.QAction) self.assertEqual(action.objectName(), 'some action') def set_case_insensitive_completer_test(self): @@ -279,7 +279,7 @@ class TestUi(TestCase): Test setting a case insensitive completer on a widget """ # GIVEN: A QComboBox and a list of completion items - line_edit = QtGui.QLineEdit() + line_edit = QtWidgets.QLineEdit() suggestions = ['one', 'Two', 'THRee', 'FOUR'] # WHEN: We call the function @@ -287,5 +287,5 @@ class TestUi(TestCase): # THEN: The Combobox should have a completer which is case insensitive completer = line_edit.completer() - self.assertIsInstance(completer, QtGui.QCompleter) + self.assertIsInstance(completer, QtWidgets.QCompleter) self.assertEqual(completer.caseSensitivity(), QtCore.Qt.CaseInsensitive) diff --git a/tests/functional/openlp_core_ui/test_firsttimeform.py b/tests/functional/openlp_core_ui/test_firsttimeform.py index 54c1a7b1d..241aa6bd5 100644 --- a/tests/functional/openlp_core_ui/test_firsttimeform.py +++ b/tests/functional/openlp_core_ui/test_firsttimeform.py @@ -217,7 +217,7 @@ class TestFirstTimeForm(TestCase, TestMixin): self.assertFalse(first_time_form.web_access, 'There should not be web access with an invalid config file') @patch('openlp.core.ui.firsttimeform.get_web_page') - @patch('openlp.core.ui.firsttimeform.QtGui.QMessageBox') + @patch('openlp.core.ui.firsttimeform.QtWidgets.QMessageBox') def network_error_test(self, mocked_message_box, mocked_get_web_page): """ Test we catch a network error in First Time Wizard - bug 1409627 diff --git a/tests/functional/openlp_core_ui/test_formattingtagsform.py b/tests/functional/openlp_core_ui/test_formattingtagsform.py index 7402d3615..b3e6b4925 100644 --- a/tests/functional/openlp_core_ui/test_formattingtagsform.py +++ b/tests/functional/openlp_core_ui/test_formattingtagsform.py @@ -30,7 +30,7 @@ from openlp.core.ui.formattingtagform import FormattingTagForm # TODO: Tests Still TODO # __init__ -# exec_ +# exec # on_saved_clicked # _reloadTable @@ -76,7 +76,7 @@ class TestFormattingTagForm(TestCase): form.tag_table_widget.rowCount.return_value = row_count # WHEN: on_new_clicked is run (i.e. the Add new button was clicked) - with patch('openlp.core.ui.formattingtagform.QtGui.QTableWidgetItem') as MockedQTableWidgetItem: + with patch('openlp.core.ui.formattingtagform.QtWidgets.QTableWidgetItem') as MockedQTableWidgetItem: mocked_table_widget = MagicMock() MockedQTableWidgetItem.return_value = mocked_table_widget form.on_new_clicked() diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 04f2ddef5..afdd7416f 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -24,7 +24,7 @@ Package to test the openlp.core.ui.slidecontroller package. """ from unittest import TestCase -from PyQt4 import QtCore +from PyQt5 import QtCore from openlp.core.common import Registry from openlp.core.lib import ScreenList diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py index 440fd275c..aafc6b29b 100644 --- a/tests/functional/openlp_core_ui/test_mainwindow.py +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -52,8 +52,8 @@ class TestMainWindow(TestCase, TestMixin): patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ - patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \ - patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \ patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer: self.main_window = MainWindow() diff --git a/tests/functional/openlp_core_ui/test_media.py b/tests/functional/openlp_core_ui/test_media.py index 49b33e77b..fbd4d6fbe 100644 --- a/tests/functional/openlp_core_ui/test_media.py +++ b/tests/functional/openlp_core_ui/test_media.py @@ -22,7 +22,7 @@ """ Package to test the openlp.core.ui package. """ -from PyQt4 import QtCore +from PyQt5 import QtCore from unittest import TestCase from openlp.core.ui.media import get_media_players, parse_optical_path @@ -81,7 +81,7 @@ class TestMedia(TestCase, TestMixin): """ def value_results(key): if key == 'media/players': - return '[vlc,webkit,phonon]' + return '[vlc,webkit,system]' else: return False @@ -93,7 +93,7 @@ class TestMedia(TestCase, TestMixin): used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual(['vlc', 'webkit', 'phonon'], used_players, 'Used players should be correct') + self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct') self.assertEqual('', overridden_player, 'Overridden player should be an empty string') def test_get_media_players_with_overridden_player(self): @@ -102,7 +102,7 @@ class TestMedia(TestCase, TestMixin): """ def value_results(key): if key == 'media/players': - return '[vlc,webkit,phonon]' + return '[vlc,webkit,system]' else: return QtCore.Qt.Checked @@ -114,8 +114,8 @@ class TestMedia(TestCase, TestMixin): used_players, overridden_player = get_media_players() # THEN: the used_players should be an empty list, and the overridden player should be an empty string - self.assertEqual(['vlc', 'webkit', 'phonon'], used_players, 'Used players should be correct') - self.assertEqual('vlc,webkit,phonon', overridden_player, 'Overridden player should be a string of players') + self.assertEqual(['vlc', 'webkit', 'system'], used_players, 'Used players should be correct') + self.assertEqual('vlc,webkit,system', overridden_player, 'Overridden player should be a string of players') def test_parse_optical_path_linux(self): """ diff --git a/tests/functional/openlp_core_ui/test_settingsform.py b/tests/functional/openlp_core_ui/test_settingsform.py index aa7030911..b6cffbc80 100644 --- a/tests/functional/openlp_core_ui/test_settingsform.py +++ b/tests/functional/openlp_core_ui/test_settingsform.py @@ -22,7 +22,7 @@ """ Package to test the openlp.core.ui.settingsform package. """ -from PyQt4 import QtGui +from PyQt5 import QtWidgets from unittest import TestCase from openlp.core.common import Registry @@ -83,14 +83,14 @@ class TestSettingsForm(TestCase): """ # GIVEN: A visible general tab and an invisible theme tab in a Settings Form settings_form = SettingsForm(None) - general_tab = QtGui.QWidget(None) + general_tab = QtWidgets.QWidget(None) general_tab.tab_title = 'mock-general' general_tab.tab_title_visible = 'Mock General' general_tab.icon_path = ':/icon/openlp-logo-16x16.png' mocked_general_save = MagicMock() general_tab.save = mocked_general_save settings_form.insert_tab(general_tab, is_visible=True) - themes_tab = QtGui.QWidget(None) + themes_tab = QtWidgets.QWidget(None) themes_tab.tab_title = 'mock-themes' themes_tab.tab_title_visible = 'Mock Themes' themes_tab.icon_path = ':/icon/openlp-logo-16x16.png' @@ -111,7 +111,7 @@ class TestSettingsForm(TestCase): """ # GIVEN: A mocked tab inserted into a Settings Form settings_form = SettingsForm(None) - general_tab = QtGui.QWidget(None) + general_tab = QtWidgets.QWidget(None) general_tab.tab_title = 'mock' general_tab.tab_title_visible = 'Mock' general_tab.icon_path = ':/icon/openlp-logo-16x16.png' @@ -130,14 +130,14 @@ class TestSettingsForm(TestCase): """ # GIVEN: A visible general tab and an invisible theme tab in a Settings Form settings_form = SettingsForm(None) - general_tab = QtGui.QWidget(None) + general_tab = QtWidgets.QWidget(None) general_tab.tab_title = 'mock-general' general_tab.tab_title_visible = 'Mock General' general_tab.icon_path = ':/icon/openlp-logo-16x16.png' mocked_general_cancel = MagicMock() general_tab.cancel = mocked_general_cancel settings_form.insert_tab(general_tab, is_visible=True) - themes_tab = QtGui.QWidget(None) + themes_tab = QtWidgets.QWidget(None) themes_tab.tab_title = 'mock-themes' themes_tab.tab_title_visible = 'Mock Themes' themes_tab.icon_path = ':/icon/openlp-logo-16x16.png' diff --git a/tests/functional/openlp_core_ui/test_slidecontroller.py b/tests/functional/openlp_core_ui/test_slidecontroller.py index b0efb28f9..30e04b673 100644 --- a/tests/functional/openlp_core_ui/test_slidecontroller.py +++ b/tests/functional/openlp_core_ui/test_slidecontroller.py @@ -22,7 +22,7 @@ """ Package to test the openlp.core.ui.slidecontroller package. """ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from unittest import TestCase from openlp.core import Registry @@ -695,7 +695,7 @@ class TestInfoLabel(TestCase): font = QtGui.QFont() metrics = QtGui.QFontMetrics(font) - with patch('openlp.core.ui.slidecontroller.QtGui.QLabel'), \ + with patch('openlp.core.ui.slidecontroller.QtWidgets.QLabel'), \ patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter: # GIVEN: An instance of InfoLabel, with mocked text return, width and rect methods @@ -723,7 +723,7 @@ class TestInfoLabel(TestCase): font = QtGui.QFont() metrics = QtGui.QFontMetrics(font) - with patch('openlp.core.ui.slidecontroller.QtGui.QLabel'), \ + with patch('openlp.core.ui.slidecontroller.QtWidgets.QLabel'), \ patch('openlp.core.ui.slidecontroller.QtGui.QPainter') as mocked_qpainter: # GIVEN: An instance of InfoLabel, with mocked text return, width and rect methods diff --git a/tests/functional/openlp_core_ui/test_themeform.py b/tests/functional/openlp_core_ui/test_themeform.py index 24f1706b3..9595b2a88 100644 --- a/tests/functional/openlp_core_ui/test_themeform.py +++ b/tests/functional/openlp_core_ui/test_themeform.py @@ -43,8 +43,8 @@ class TestThemeManager(TestCase): with patch('openlp.core.ui.ThemeForm._setup'),\ patch('openlp.core.ui.themeform.get_images_filter', **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\ - patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName', - **{'return_value': ''}) as mocked_get_open_file_name,\ + patch('openlp.core.ui.themeform.QtWidgets.QFileDialog.getOpenFileName', + **{'return_value': ('', '')}) as mocked_get_open_file_name,\ patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\ patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_set_background_page_values: instance = ThemeForm(None) @@ -70,8 +70,8 @@ class TestThemeManager(TestCase): with patch('openlp.core.ui.ThemeForm._setup'),\ patch('openlp.core.ui.themeform.get_images_filter', **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\ - patch('openlp.core.ui.themeform.QtGui.QFileDialog.getOpenFileName', - **{'return_value': '/new_path/file.ext'}) as mocked_get_open_file_name,\ + patch('openlp.core.ui.themeform.QtWidgets.QFileDialog.getOpenFileName', + **{'return_value': ('/new_path/file.ext', '')}) as mocked_get_open_file_name,\ patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\ patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_background_page_values: instance = ThemeForm(None) diff --git a/tests/functional/openlp_core_ui/test_thememanager.py b/tests/functional/openlp_core_ui/test_thememanager.py index 3dc168f77..f5330ba18 100644 --- a/tests/functional/openlp_core_ui/test_thememanager.py +++ b/tests/functional/openlp_core_ui/test_thememanager.py @@ -28,7 +28,7 @@ import shutil from unittest import TestCase from tempfile import mkdtemp -from PyQt4 import QtGui +from PyQt5 import QtWidgets from tempfile import mkdtemp from openlp.core.ui import ThemeManager @@ -165,8 +165,8 @@ class TestThemeManager(TestCase): Test that theme_manager.over_write_message_box returns True when the user clicks yes. """ # GIVEN: A patched QMessageBox.question and an instance of ThemeManager - with patch('openlp.core.ui.thememanager.QtGui.QMessageBox.question', return_value=QtGui.QMessageBox.Yes)\ - as mocked_qmessagebox_question,\ + with patch('openlp.core.ui.thememanager.QtWidgets.QMessageBox.question', + return_value=QtWidgets.QMessageBox.Yes) as mocked_qmessagebox_question,\ patch('openlp.core.ui.thememanager.translate') as mocked_translate: mocked_translate.side_effect = lambda context, text: text theme_manager = ThemeManager(None) @@ -185,7 +185,7 @@ class TestThemeManager(TestCase): Test that theme_manager.over_write_message_box returns False when the user clicks no. """ # GIVEN: A patched QMessageBox.question and an instance of ThemeManager - with patch('openlp.core.ui.thememanager.QtGui.QMessageBox.question', return_value=QtGui.QMessageBox.No)\ + with patch('openlp.core.ui.thememanager.QtWidgets.QMessageBox.question', return_value=QtWidgets.QMessageBox.No)\ as mocked_qmessagebox_question,\ patch('openlp.core.ui.thememanager.translate') as mocked_translate: mocked_translate.side_effect = lambda context, text: text diff --git a/tests/functional/openlp_core_ui_media/test_phononplayer.py b/tests/functional/openlp_core_ui_media/test_phononplayer.py deleted file mode 100644 index 7934c1682..000000000 --- a/tests/functional/openlp_core_ui_media/test_phononplayer.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2015 OpenLP Developers # -# --------------------------------------------------------------------------- # -# 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; version 2 of the License. # -# # -# 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, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -Package to test the openlp.core.ui.media.phononplayer package. -""" -from unittest import TestCase -from tests.functional import patch - -from openlp.core.ui.media.phononplayer import PhononPlayer - - -class TestPhononPlayer(TestCase): - """ - Test the functions in the :mod:`phononplayer` module. - """ - - def check_available_mac_test(self): - """ - Simple test of phononplayer availability on Mac OS X - """ - # GIVEN: A PhononPlayer and a mocked is_macosx - with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: - mocked_is_macosx.return_value = True - phonon_player = PhononPlayer(None) - - # WHEN: An checking if the player is available - available = phonon_player.check_available() - - # THEN: The player should not be available on Mac OS X - self.assertEqual(False, available, 'The PhononPlayer should not be available on Mac OS X.') - - def check_available_non_mac_test(self): - """ - Simple test of phononplayer availability when not on Mac OS X - """ - # GIVEN: A PhononPlayer and a mocked is_macosx - with patch('openlp.core.ui.media.phononplayer.is_macosx') as mocked_is_macosx: - mocked_is_macosx.return_value = False - phonon_player = PhononPlayer(None) - - # WHEN: An checking if the player is available - available = phonon_player.check_available() - - # THEN: The player should be available when not on Mac OS X - self.assertEqual(True, available, 'The PhononPlayer should be available when not on Mac OS X.') diff --git a/tests/functional/openlp_core_ui_media/test_vlcplayer.py b/tests/functional/openlp_core_ui_media/test_vlcplayer.py index eccac6893..ab3e1d081 100644 --- a/tests/functional/openlp_core_ui_media/test_vlcplayer.py +++ b/tests/functional/openlp_core_ui_media/test_vlcplayer.py @@ -107,9 +107,9 @@ class TestVLCPlayer(TestCase, TestMixin): @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @patch('openlp.core.ui.media.vlcplayer.get_vlc') - @patch('openlp.core.ui.media.vlcplayer.QtGui') + @patch('openlp.core.ui.media.vlcplayer.QtWidgets') @patch('openlp.core.ui.media.vlcplayer.Settings') - def setup_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win): + def setup_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win): """ Test the setup method """ @@ -121,8 +121,8 @@ class TestVLCPlayer(TestCase, TestMixin): MockedSettings.return_value = mocked_settings mocked_qframe = MagicMock() mocked_qframe.winId.return_value = 2 - MockedQtGui.QFrame.NoFrame = 1 - MockedQtGui.QFrame.return_value = mocked_qframe + MockedQtWidgets.QFrame.NoFrame = 1 + MockedQtWidgets.QFrame.return_value = mocked_qframe mocked_media_player_new = MagicMock() mocked_instance = MagicMock() mocked_instance.media_player_new.return_value = mocked_media_player_new @@ -157,9 +157,9 @@ class TestVLCPlayer(TestCase, TestMixin): @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @patch('openlp.core.ui.media.vlcplayer.get_vlc') - @patch('openlp.core.ui.media.vlcplayer.QtGui') + @patch('openlp.core.ui.media.vlcplayer.QtWidgets') @patch('openlp.core.ui.media.vlcplayer.Settings') - def setup_has_audio_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win): + def setup_has_audio_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win): """ Test the setup method when has_audio is True """ @@ -171,8 +171,8 @@ class TestVLCPlayer(TestCase, TestMixin): MockedSettings.return_value = mocked_settings mocked_qframe = MagicMock() mocked_qframe.winId.return_value = 2 - MockedQtGui.QFrame.NoFrame = 1 - MockedQtGui.QFrame.return_value = mocked_qframe + MockedQtWidgets.QFrame.NoFrame = 1 + MockedQtWidgets.QFrame.return_value = mocked_qframe mocked_media_player_new = MagicMock() mocked_instance = MagicMock() mocked_instance.media_player_new.return_value = mocked_media_player_new @@ -194,9 +194,10 @@ class TestVLCPlayer(TestCase, TestMixin): @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @patch('openlp.core.ui.media.vlcplayer.get_vlc') - @patch('openlp.core.ui.media.vlcplayer.QtGui') + @patch('openlp.core.ui.media.vlcplayer.QtWidgets') @patch('openlp.core.ui.media.vlcplayer.Settings') - def setup_visible_mouse_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win): + def setup_visible_mouse_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, + mocked_is_win): """ Test the setup method when Settings().value("hide mouse") is False """ @@ -208,8 +209,8 @@ class TestVLCPlayer(TestCase, TestMixin): MockedSettings.return_value = mocked_settings mocked_qframe = MagicMock() mocked_qframe.winId.return_value = 2 - MockedQtGui.QFrame.NoFrame = 1 - MockedQtGui.QFrame.return_value = mocked_qframe + MockedQtWidgets.QFrame.NoFrame = 1 + MockedQtWidgets.QFrame.return_value = mocked_qframe mocked_media_player_new = MagicMock() mocked_instance = MagicMock() mocked_instance.media_player_new.return_value = mocked_media_player_new @@ -231,9 +232,9 @@ class TestVLCPlayer(TestCase, TestMixin): @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @patch('openlp.core.ui.media.vlcplayer.get_vlc') - @patch('openlp.core.ui.media.vlcplayer.QtGui') + @patch('openlp.core.ui.media.vlcplayer.QtWidgets') @patch('openlp.core.ui.media.vlcplayer.Settings') - def setup_windows_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win): + def setup_windows_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win): """ Test the setup method when running on Windows """ @@ -245,8 +246,8 @@ class TestVLCPlayer(TestCase, TestMixin): MockedSettings.return_value = mocked_settings mocked_qframe = MagicMock() mocked_qframe.winId.return_value = 2 - MockedQtGui.QFrame.NoFrame = 1 - MockedQtGui.QFrame.return_value = mocked_qframe + MockedQtWidgets.QFrame.NoFrame = 1 + MockedQtWidgets.QFrame.return_value = mocked_qframe mocked_media_player_new = MagicMock() mocked_instance = MagicMock() mocked_instance.media_player_new.return_value = mocked_media_player_new @@ -268,9 +269,9 @@ class TestVLCPlayer(TestCase, TestMixin): @patch('openlp.core.ui.media.vlcplayer.is_win') @patch('openlp.core.ui.media.vlcplayer.is_macosx') @patch('openlp.core.ui.media.vlcplayer.get_vlc') - @patch('openlp.core.ui.media.vlcplayer.QtGui') + @patch('openlp.core.ui.media.vlcplayer.QtWidgets') @patch('openlp.core.ui.media.vlcplayer.Settings') - def setup_osx_test(self, MockedSettings, MockedQtGui, mocked_get_vlc, mocked_is_macosx, mocked_is_win): + def setup_osx_test(self, MockedSettings, MockedQtWidgets, mocked_get_vlc, mocked_is_macosx, mocked_is_win): """ Test the setup method when running on OS X """ @@ -282,8 +283,8 @@ class TestVLCPlayer(TestCase, TestMixin): MockedSettings.return_value = mocked_settings mocked_qframe = MagicMock() mocked_qframe.winId.return_value = 2 - MockedQtGui.QFrame.NoFrame = 1 - MockedQtGui.QFrame.return_value = mocked_qframe + MockedQtWidgets.QFrame.NoFrame = 1 + MockedQtWidgets.QFrame.return_value = mocked_qframe mocked_media_player_new = MagicMock() mocked_instance = MagicMock() mocked_instance.media_player_new.return_value = mocked_media_player_new diff --git a/tests/functional/openlp_core_ui_media/test_webkitplayer.py b/tests/functional/openlp_core_ui_media/test_webkitplayer.py index cea0aa4ad..975e59ff7 100644 --- a/tests/functional/openlp_core_ui_media/test_webkitplayer.py +++ b/tests/functional/openlp_core_ui_media/test_webkitplayer.py @@ -40,7 +40,7 @@ class TestWebkitPlayer(TestCase): # GIVEN: A WebkitPlayer instance and a mocked QWebPage mocked_qwebpage = MagicMock() mocked_qwebpage.mainFrame().evaluateJavaScript.return_value = '[object HTMLUnknownElement]' - with patch('openlp.core.ui.media.webkitplayer.QtWebKit.QWebPage', **{'return_value': mocked_qwebpage}): + with patch('openlp.core.ui.media.webkitplayer.QtWebKitWidgets.QWebPage', **{'return_value': mocked_qwebpage}): webkit_player = WebkitPlayer(None) # WHEN: An checking if the player is available @@ -57,7 +57,7 @@ class TestWebkitPlayer(TestCase): # GIVEN: A WebkitPlayer instance and a mocked QWebPage mocked_qwebpage = MagicMock() mocked_qwebpage.mainFrame().evaluateJavaScript.return_value = '[object HTMLVideoElement]' - with patch('openlp.core.ui.media.webkitplayer.QtWebKit.QWebPage', **{'return_value': mocked_qwebpage}): + with patch('openlp.core.ui.media.webkitplayer.QtWebKitWidgets.QWebPage', **{'return_value': mocked_qwebpage}): webkit_player = WebkitPlayer(None) # WHEN: An checking if the player is available diff --git a/tests/functional/openlp_core_utils/test_actions.py b/tests/functional/openlp_core_utils/test_actions.py index c1e61cb10..895db488b 100644 --- a/tests/functional/openlp_core_utils/test_actions.py +++ b/tests/functional/openlp_core_utils/test_actions.py @@ -24,7 +24,7 @@ Package to test the openlp.core.utils.actions package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from openlp.core.common import Settings from openlp.core.utils import ActionList @@ -157,9 +157,9 @@ class TestActionList(TestCase, TestMixin): """ # GIVEN: Two actions with the same shortcuts. parent = QtCore.QObject() - action1 = QtGui.QAction(parent) + action1 = QtWidgets.QAction(parent) action1.setObjectName('action1') - action_with_same_shortcuts1 = QtGui.QAction(parent) + action_with_same_shortcuts1 = QtWidgets.QAction(parent) action_with_same_shortcuts1.setObjectName('action_with_same_shortcuts1') # Add default shortcuts to Settings class. default_shortcuts = { @@ -186,10 +186,10 @@ class TestActionList(TestCase, TestMixin): """ # GIVEN: Two actions with the same shortcuts. parent = QtCore.QObject() - action2 = QtGui.QAction(parent) + action2 = QtWidgets.QAction(parent) action2.setObjectName('action2') second_parent = QtCore.QObject() - action_with_same_shortcuts2 = QtGui.QAction(second_parent) + action_with_same_shortcuts2 = QtWidgets.QAction(second_parent) action_with_same_shortcuts2.setObjectName('action_with_same_shortcuts2') # Add default shortcuts to Settings class. default_shortcuts = { @@ -216,11 +216,11 @@ class TestActionList(TestCase, TestMixin): """ # GIVEN: Two actions with the same shortcuts. parent = QtCore.QObject() - action3 = QtGui.QAction(parent) + action3 = QtWidgets.QAction(parent) action3.setObjectName('action3') action3.setShortcutContext(QtCore.Qt.WidgetShortcut) second_parent = QtCore.QObject() - action_with_same_shortcuts3 = QtGui.QAction(second_parent) + action_with_same_shortcuts3 = QtWidgets.QAction(second_parent) action_with_same_shortcuts3.setObjectName('action_with_same_shortcuts3') action_with_same_shortcuts3.setShortcutContext(QtCore.Qt.WidgetShortcut) # Add default shortcuts to Settings class. diff --git a/tests/functional/openlp_core_utils/test_init.py b/tests/functional/openlp_core_utils/test_init.py index 9a6f9fc39..24df7c689 100644 --- a/tests/functional/openlp_core_utils/test_init.py +++ b/tests/functional/openlp_core_utils/test_init.py @@ -53,13 +53,14 @@ class TestInitFunctions(TestMixin, TestCase): mocked_main_window = MagicMock() Settings().setValue('core/last version test', '1950-04-01') # WHEN: We check to see if the version is different . - with patch('PyQt4.QtCore.QThread'),\ + with patch('PyQt5.QtCore.QThread'),\ patch('openlp.core.utils.get_application_version') as mocked_get_application_version: mocked_get_application_version.return_value = {'version': '1.0.0', 'build': '', 'full': '2.0.4'} version_thread = VersionThread(mocked_main_window) version_thread.run() # THEN: If the version has changed the main window is notified - self.assertTrue(mocked_main_window.emit.called, 'The main windows should have been notified') + self.assertTrue(mocked_main_window.openlp_version_check.emit.called, + 'The main windows should have been notified') def get_uno_command_libreoffice_command_exists_test(self): """ diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py index 0e94a6ca4..9bf8873e1 100644 --- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py +++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py @@ -22,8 +22,6 @@ """ This module contains tests for the lib submodule of the Presentations plugin. """ -from PyQt4 import QtGui - from unittest import TestCase from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem from tests.functional import MagicMock, patch diff --git a/tests/functional/openlp_plugins/custom/test_mediaitem.py b/tests/functional/openlp_plugins/custom/test_mediaitem.py index 67671695b..4f3eae321 100644 --- a/tests/functional/openlp_plugins/custom/test_mediaitem.py +++ b/tests/functional/openlp_plugins/custom/test_mediaitem.py @@ -3,7 +3,7 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem, PluginStatus diff --git a/tests/functional/openlp_plugins/images/test_imagetab.py b/tests/functional/openlp_plugins/images/test_imagetab.py index e8cfcb9c0..24d2d04c5 100644 --- a/tests/functional/openlp_plugins/images/test_imagetab.py +++ b/tests/functional/openlp_plugins/images/test_imagetab.py @@ -23,7 +23,7 @@ This module contains tests for the lib submodule of the Images plugin. """ from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Settings @@ -54,7 +54,7 @@ class TestImageMediaItem(TestCase, TestMixin): self.setup_application() self.build_settings() Settings().extend_default_settings(__default_settings__) - self.parent = QtGui.QMainWindow() + self.parent = QtWidgets.QMainWindow() self.form = ImageTab(self.parent, 'Images', None, None) self.form.settings_form.register_post_process = MagicMock() diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index 9d187af9e..16ed611e4 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -24,7 +24,7 @@ This module contains tests for the lib submodule of the Images plugin. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups @@ -273,7 +273,7 @@ class TestImageMediaItem(TestCase): item = self.media_item.create_item_from_id(1) # THEN: A QTreeWidgetItem should be created with the above model object as it's data - self.assertIsInstance(item, QtGui.QTreeWidgetItem) + self.assertIsInstance(item, QtWidgets.QTreeWidgetItem) self.assertEqual('test_file_1.jpg', item.text(0)) item_data = item.data(0, QtCore.Qt.UserRole) self.assertIsInstance(item_data, ImageFilenames) diff --git a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py index a7b93f1da..685a937d4 100644 --- a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py @@ -26,7 +26,7 @@ import os import shutil from unittest import TestCase, SkipTest from tempfile import mkdtemp -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument from tests.functional import MagicMock diff --git a/tests/functional/openlp_plugins/remotes/test_remotetab.py b/tests/functional/openlp_plugins/remotes/test_remotetab.py index af7abae00..68f2557ec 100644 --- a/tests/functional/openlp_plugins/remotes/test_remotetab.py +++ b/tests/functional/openlp_plugins/remotes/test_remotetab.py @@ -26,7 +26,8 @@ import os import re from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtWidgets + from openlp.core.common import Settings from openlp.plugins.remotes.lib.remotetab import RemoteTab @@ -59,7 +60,7 @@ class TestRemoteTab(TestCase, TestMixin): self.setup_application() self.build_settings() Settings().extend_default_settings(__default_settings__) - self.parent = QtGui.QMainWindow() + self.parent = QtWidgets.QMainWindow() self.form = RemoteTab(self.parent, 'Remotes', None, None) def tearDown(self): diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 70a2033a4..4da87db7b 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -25,6 +25,7 @@ This module contains tests for the lib submodule of the Remotes plugin. import os import urllib.request from unittest import TestCase + from openlp.core.common import Settings, Registry from openlp.core.ui import ServiceManager from openlp.plugins.remotes.lib.httpserver import HttpRouter diff --git a/tests/functional/openlp_plugins/songs/test_editsongform.py b/tests/functional/openlp_plugins/songs/test_editsongform.py index d386a7fd3..8497c7ef9 100644 --- a/tests/functional/openlp_plugins/songs/test_editsongform.py +++ b/tests/functional/openlp_plugins/songs/test_editsongform.py @@ -24,7 +24,7 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem diff --git a/tests/functional/openlp_plugins/songs/test_editverseform.py b/tests/functional/openlp_plugins/songs/test_editverseform.py index 4c89b4f89..cf6d17f27 100644 --- a/tests/functional/openlp_plugins/songs/test_editverseform.py +++ b/tests/functional/openlp_plugins/songs/test_editverseform.py @@ -24,7 +24,7 @@ This module contains tests for the editverseform of the Songs plugin. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index 4e28eed93..319fa4b45 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -24,7 +24,7 @@ This module contains tests for the lib submodule of the Songs plugin. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index 05627b40e..e15efc393 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -26,7 +26,7 @@ import os from unittest import TestCase from urllib.error import URLError -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core import Registry from openlp.plugins.songs.forms.songselectform import SongSelectForm, SearchWorker @@ -429,7 +429,7 @@ class TestSongSelectForm(TestCase, TestMixin): self.assertEqual(mocked_db_manager, ssform.db_manager, 'The correct db_manager should have been assigned') @patch('openlp.plugins.songs.forms.songselectform.SongSelectImport') - @patch('openlp.plugins.songs.forms.songselectform.QtGui.QMessageBox.critical') + @patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.critical') @patch('openlp.plugins.songs.forms.songselectform.translate') def login_fails_test(self, mocked_translate, mocked_critical, MockedSongSelectImport): """ @@ -482,7 +482,7 @@ class TestSongSelectForm(TestCase, TestMixin): 'perhaps your username or password is ' 'incorrect?') - @patch('openlp.plugins.songs.forms.songselectform.QtGui.QMessageBox.question') + @patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question') @patch('openlp.plugins.songs.forms.songselectform.translate') def on_import_yes_clicked_test(self, mocked_translate, mocked_question): """ @@ -490,7 +490,7 @@ class TestSongSelectForm(TestCase, TestMixin): """ # GIVEN: A valid SongSelectForm with a mocked out QMessageBox.question() method mocked_translate.side_effect = lambda *args: args[1] - mocked_question.return_value = QtGui.QMessageBox.Yes + mocked_question.return_value = QtWidgets.QMessageBox.Yes ssform = SongSelectForm(None, MagicMock(), MagicMock()) mocked_song_select_importer = MagicMock() ssform.song_select_importer = mocked_song_select_importer @@ -504,11 +504,12 @@ class TestSongSelectForm(TestCase, TestMixin): mocked_song_select_importer.save_song.assert_called_with(None) mocked_question.assert_called_with(ssform, 'Song Imported', 'Your song has been imported, would you like to import more songs?', - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) mocked_on_back_button_clicked.assert_called_with() self.assertIsNone(ssform.song) - @patch('openlp.plugins.songs.forms.songselectform.QtGui.QMessageBox.question') + @patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.question') @patch('openlp.plugins.songs.forms.songselectform.translate') def on_import_no_clicked_test(self, mocked_translate, mocked_question): """ @@ -516,7 +517,7 @@ class TestSongSelectForm(TestCase, TestMixin): """ # GIVEN: A valid SongSelectForm with a mocked out QMessageBox.question() method mocked_translate.side_effect = lambda *args: args[1] - mocked_question.return_value = QtGui.QMessageBox.No + mocked_question.return_value = QtWidgets.QMessageBox.No ssform = SongSelectForm(None, MagicMock(), MagicMock()) mocked_song_select_importer = MagicMock() ssform.song_select_importer = mocked_song_select_importer @@ -530,8 +531,9 @@ class TestSongSelectForm(TestCase, TestMixin): mocked_song_select_importer.save_song.assert_called_with(None) mocked_question.assert_called_with(ssform, 'Song Imported', 'Your song has been imported, would you like to import more songs?', - QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) - mocked_done.assert_called_with(QtGui.QDialog.Accepted) + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.Yes) + mocked_done.assert_called_with(QtWidgets.QDialog.Accepted) self.assertIsNone(ssform.song) def on_back_button_clicked_test(self): @@ -550,7 +552,7 @@ class TestSongSelectForm(TestCase, TestMixin): mocked_stacked_widget.setCurrentIndex.assert_called_with(1) mocked_search_combobox.setFocus.assert_called_with() - @patch('openlp.plugins.songs.forms.songselectform.QtGui.QMessageBox.information') + @patch('openlp.plugins.songs.forms.songselectform.QtWidgets.QMessageBox.information') def on_search_show_info_test(self, mocked_information): """ Test that when the search_show_info signal is emitted, the on_search_show_info() method shows a dialog diff --git a/tests/functional/test_init.py b/tests/functional/test_init.py index d13958a58..df554101f 100644 --- a/tests/functional/test_init.py +++ b/tests/functional/test_init.py @@ -25,7 +25,7 @@ Package to test the openlp.core.__init__ package. import os from unittest import TestCase -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core import OpenLP, parse_options from openlp.core.common import Settings @@ -97,9 +97,9 @@ class TestInit(TestCase, TestMixin): } Settings().setValue('core/application version', '2.2.0') with patch('openlp.core.get_application_version') as mocked_get_application_version,\ - patch('openlp.core.QtGui.QMessageBox.question') as mocked_question: + patch('openlp.core.QtWidgets.QMessageBox.question') as mocked_question: mocked_get_application_version.return_value = MOCKED_VERSION - mocked_question.return_value = QtGui.QMessageBox.No + mocked_question.return_value = QtWidgets.QMessageBox.No # WHEN: We check if a backup should be created self.openlp.backup_on_upgrade(old_install) @@ -121,9 +121,9 @@ class TestInit(TestCase, TestMixin): } Settings().setValue('core/application version', '2.0.5') with patch('openlp.core.get_application_version') as mocked_get_application_version,\ - patch('openlp.core.QtGui.QMessageBox.question') as mocked_question: + patch('openlp.core.QtWidgets.QMessageBox.question') as mocked_question: mocked_get_application_version.return_value = MOCKED_VERSION - mocked_question.return_value = QtGui.QMessageBox.No + mocked_question.return_value = QtWidgets.QMessageBox.No # WHEN: We check if a backup should be created self.openlp.backup_on_upgrade(old_install) diff --git a/tests/helpers/testmixin.py b/tests/helpers/testmixin.py index 5217d0fb4..1954f1863 100644 --- a/tests/helpers/testmixin.py +++ b/tests/helpers/testmixin.py @@ -25,7 +25,7 @@ Mixin class with helpers import os from tempfile import mkstemp -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Settings @@ -40,7 +40,7 @@ class TestMixin(object): """ old_app_instance = QtCore.QCoreApplication.instance() if old_app_instance is None: - self.app = QtGui.QApplication([]) + self.app = QtWidgets.QApplication([]) else: self.app = old_app_instance diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py index c98133e4d..265e44e59 100644 --- a/tests/interfaces/__init__.py +++ b/tests/interfaces/__init__.py @@ -19,15 +19,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import sip -sip.setapi('QDate', 2) -sip.setapi('QDateTime', 2) -sip.setapi('QString', 2) -sip.setapi('QTextStream', 2) -sip.setapi('QTime', 2) -sip.setapi('QUrl', 2) -sip.setapi('QVariant', 2) - import sys if sys.version_info[1] >= 3: diff --git a/tests/interfaces/openlp_core_common/test_historycombobox.py b/tests/interfaces/openlp_core_common/test_historycombobox.py index 33b42b60d..8536e946e 100644 --- a/tests/interfaces/openlp_core_common/test_historycombobox.py +++ b/tests/interfaces/openlp_core_common/test_historycombobox.py @@ -25,7 +25,7 @@ Module to test the :mod:`~openlp.core.common.historycombobox` module. from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.core.common import HistoryComboBox @@ -40,7 +40,7 @@ class TestHistoryComboBox(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.combo = HistoryComboBox(self.main_window) diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index aaf7b4909..a8717ac22 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -28,7 +28,7 @@ import gc from tempfile import mkdtemp from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Registry, Settings from openlp.core.lib.pluginmanager import PluginManager @@ -52,7 +52,7 @@ class TestPluginManager(TestCase, TestMixin): Registry.create() Registry().register('service_list', MagicMock()) self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) def tearDown(self): diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py index f5c1c6fe8..80531a4ce 100644 --- a/tests/interfaces/openlp_core_lib/test_searchedit.py +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -24,7 +24,7 @@ Module to test the EditCustomForm. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtCore, QtGui, QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.lib.searchedit import SearchEdit @@ -55,7 +55,7 @@ class TestSearchEdit(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.search_edit = SearchEdit(self.main_window) diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index dd0d39895..e999a1a50 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -24,7 +24,7 @@ """ from unittest import TestCase -from PyQt4 import QtGui, QtTest +from PyQt5 import QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import filerenameform @@ -40,7 +40,7 @@ class TestStartFileRenameForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = filerenameform.FileRenameForm() @@ -55,23 +55,23 @@ class TestStartFileRenameForm(TestCase, TestMixin): """ Test the windowTitle of the FileRenameDialog """ - # GIVEN: A mocked QDialog.exec_() method - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # GIVEN: A mocked QDialog.exec() method + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: # WHEN: The form is executed with no args - self.form.exec_() + self.form.exec() # THEN: the window title is set correctly self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"') # WHEN: The form is executed with False arg - self.form.exec_(False) + self.form.exec(False) # THEN: the window title is set correctly self.assertEqual(self.form.windowTitle(), 'File Rename', 'The window title should be "File Rename"') # WHEN: The form is executed with True arg - self.form.exec_(True) + self.form.exec(True) # THEN: the window title is set correctly self.assertEqual(self.form.windowTitle(), 'File Copy', 'The window title should be "File Copy"') @@ -81,13 +81,13 @@ class TestStartFileRenameForm(TestCase, TestMixin): Regression test for bug1067251 Test that the file_name_edit setFocus has called with True when executed """ - # GIVEN: A mocked QDialog.exec_() method and mocked file_name_edit.setFocus() method. - with patch('PyQt4.QtGui.QDialog.exec_'): + # GIVEN: A mocked QDialog.exec() method and mocked file_name_edit.setFocus() method. + with patch('PyQt5.QtWidgets.QDialog.exec'): mocked_set_focus = MagicMock() self.form.file_name_edit.setFocus = mocked_set_focus # WHEN: The form is executed - self.form.exec_() + self.form.exec() # THEN: the setFocus method of the file_name_edit has been called with True mocked_set_focus.assert_called_with() diff --git a/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py b/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py index be8ab90ce..6803d695a 100644 --- a/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py +++ b/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py @@ -25,7 +25,7 @@ from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtGui, QtWidgets from openlp.core.common import Registry from openlp.core.lib import ServiceItem @@ -43,7 +43,7 @@ class TestListPreviewWidget(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32) self.image_manager = MagicMock() self.image_manager.get_image.return_value = self.image diff --git a/tests/interfaces/openlp_core_ui/test_mainwindow.py b/tests/interfaces/openlp_core_ui/test_mainwindow.py index ae7dfd9d6..6d2a44d2d 100644 --- a/tests/interfaces/openlp_core_ui/test_mainwindow.py +++ b/tests/interfaces/openlp_core_ui/test_mainwindow.py @@ -51,8 +51,8 @@ class TestMainWindow(TestCase, TestMixin): patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ - patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \ - patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \ patch('openlp.core.ui.mainwindow.ServiceManager') as mocked_service_manager, \ patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \ diff --git a/tests/interfaces/openlp_core_ui/test_projectoreditform.py b/tests/interfaces/openlp_core_ui/test_projectoreditform.py index cdece39c8..7d2213e3e 100644 --- a/tests/interfaces/openlp_core_ui/test_projectoreditform.py +++ b/tests/interfaces/openlp_core_ui/test_projectoreditform.py @@ -71,10 +71,10 @@ class TestProjectorEditForm(TestCase, TestMixin): :return: None """ # GIVEN: Mocked setup - with patch('openlp.core.ui.projector.editform.QDialog.exec_'): + with patch('openlp.core.ui.projector.editform.QDialog.exec'): # WHEN: Calling edit form with no parameters - self.projector_form.exec_() + self.projector_form.exec() item = self.projector_form.projector # THEN: Should be creating a new instance @@ -90,10 +90,10 @@ class TestProjectorEditForm(TestCase, TestMixin): :return: """ # GIVEN: Mocked setup - with patch('openlp.core.ui.projector.editform.QDialog.exec_'): + with patch('openlp.core.ui.projector.editform.QDialog.exec'): # WHEN: Calling edit form with existing projector instance - self.projector_form.exec_(projector=TEST1_DATA) + self.projector_form.exec(projector=TEST1_DATA) item = self.projector_form.projector # THEN: Should be editing an existing entry diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index 018cbb3e7..fd675ad96 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -29,8 +29,7 @@ log = logging.getLogger(__name__) log.debug('test_projectorsourceform loaded') from unittest import TestCase -from PyQt4 import QtGui -from PyQt4.QtGui import QDialog +from PyQt5.QtWidgets import QDialog from tests.functional import patch from tests.functional.openlp_core_lib.test_projectordb import tmpfile @@ -109,7 +108,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin): self.assertEquals(check, build_source_dict(), "Source group dictionary should match test dictionary") - @patch.object(QDialog, 'exec_') + @patch.object(QDialog, 'exec') def source_select_edit_button_test(self, mocked_qdialog): """ Test source select form edit has Ok, Cancel, Reset, and Revert buttons @@ -121,7 +120,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin): # WHEN we create a source select widget and set edit=True select_form = SourceSelectSingle(parent=None, projectordb=self.projectordb) select_form.edit = True - select_form.exec_(projector=self.projector) + select_form.exec(projector=self.projector) projector = select_form.projector # THEN: Verify all 4 buttons are available @@ -129,7 +128,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin): 'SourceSelect dialog box should have "OK", "Cancel" ' '"Rest", and "Revert" buttons available') - @patch.object(QDialog, 'exec_') + @patch.object(QDialog, 'exec') def source_select_noedit_button_test(self, mocked_qdialog): """ Test source select form view has OK and Cancel buttons only @@ -141,7 +140,7 @@ class ProjectorSourceFormTest(TestCase, TestMixin): # WHEN we create a source select widget and set edit=False select_form = SourceSelectSingle(parent=None, projectordb=self.projectordb) select_form.edit = False - select_form.exec_(projector=self.projector) + select_form.exec(projector=self.projector) projector = select_form.projector # THEN: Verify only 2 buttons are available diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 7d1f6108a..24ae88e67 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -48,8 +48,8 @@ class TestServiceManager(TestCase, TestMixin): patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ - patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \ - patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \ + patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \ patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \ patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer: @@ -80,9 +80,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item @@ -122,9 +122,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item @@ -166,9 +166,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item @@ -209,9 +209,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item @@ -254,9 +254,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item @@ -297,9 +297,9 @@ class TestServiceManager(TestCase, TestMixin): """ # GIVEN: A service item added self.service_manager.setup_ui(self.service_manager) - with patch('PyQt4.QtGui.QTreeWidget.itemAt') as mocked_item_at_method, \ - patch('PyQt4.QtGui.QWidget.mapToGlobal'), \ - patch('PyQt4.QtGui.QMenu.exec_'): + with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \ + patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \ + patch('PyQt5.QtWidgets.QMenu.exec'): mocked_item = MagicMock() mocked_item.parent.return_value = None mocked_item_at_method.return_value = mocked_item diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index e772e343a..fb6206e62 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -24,7 +24,7 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtCore, QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import servicenoteform @@ -40,7 +40,7 @@ class TestStartNoteDialog(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = servicenoteform.ServiceNoteForm() @@ -59,8 +59,8 @@ class TestStartNoteDialog(TestCase, TestMixin): self.form.text_edit.setPlainText('') # WHEN displaying the UI and pressing enter - with patch('PyQt4.QtGui.QDialog.exec_'): - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec'): + self.form.exec() ok_widget = self.form.button_box.button(self.form.button_box.Save) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) @@ -70,8 +70,8 @@ class TestStartNoteDialog(TestCase, TestMixin): # WHEN displaying the UI, having set the text and pressing enter text = 'OpenLP is the best worship software' self.form.text_edit.setPlainText(text) - with patch('PyQt4.QtGui.QDialog.exec_'): - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec'): + self.form.exec() ok_widget = self.form.button_box.button(self.form.button_box.Save) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) @@ -80,8 +80,8 @@ class TestStartNoteDialog(TestCase, TestMixin): # WHEN displaying the UI, having set the text and pressing enter self.form.text_edit.setPlainText('') - with patch('PyQt4.QtGui.QDialog.exec_'): - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec'): + self.form.exec() self.form.text_edit.setPlainText(text) ok_widget = self.form.button_box.button(self.form.button_box.Save) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) diff --git a/tests/interfaces/openlp_core_ui/test_settings_form.py b/tests/interfaces/openlp_core_ui/test_settings_form.py index e24a2ccb4..79534fa3d 100644 --- a/tests/interfaces/openlp_core_ui/test_settings_form.py +++ b/tests/interfaces/openlp_core_ui/test_settings_form.py @@ -24,7 +24,7 @@ Package to test the openlp.core.lib.settingsform package. """ from unittest import TestCase -from PyQt4 import QtCore, QtTest +from PyQt5 import QtCore, QtTest from openlp.core.common import Registry from openlp.core.ui import settingsform @@ -73,7 +73,7 @@ class TestSettingsForm(TestCase, TestMixin): # GIVEN: An initial form # WHEN displaying the UI and pressing cancel - with patch('PyQt4.QtGui.QDialog.reject') as mocked_reject: + with patch('PyQt5.QtWidgets.QDialog.reject') as mocked_reject: cancel_widget = self.form.button_box.button(self.form.button_box.Cancel) QtTest.QTest.mouseClick(cancel_widget, QtCore.Qt.LeftButton) @@ -87,7 +87,7 @@ class TestSettingsForm(TestCase, TestMixin): # GIVEN: An initial form # WHEN displaying the UI and pressing Ok - with patch('PyQt4.QtGui.QDialog.accept') as mocked_accept: + with patch('PyQt5.QtWidgets.QDialog.accept') as mocked_accept: ok_widget = self.form.button_box.button(self.form.button_box.Ok) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) @@ -102,7 +102,7 @@ class TestSettingsForm(TestCase, TestMixin): self.form.register_post_process('function1') # WHEN displaying the UI and pressing Ok - with patch('PyQt4.QtGui.QDialog.accept'): + with patch('PyQt5.QtWidgets.QDialog.accept'): ok_widget = self.form.button_box.button(self.form.button_box.Ok) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) diff --git a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py index 9fa36c78d..40fa863d3 100644 --- a/tests/interfaces/openlp_core_ui/test_shortcutlistform.py +++ b/tests/interfaces/openlp_core_ui/test_shortcutlistform.py @@ -24,7 +24,7 @@ Package to test the openlp.core.ui.shortcutform package. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.core.ui.shortcutlistform import ShortcutListForm @@ -40,7 +40,7 @@ class TestShortcutform(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = ShortcutListForm() @@ -56,13 +56,13 @@ class TestShortcutform(TestCase, TestMixin): Test the _adjust_button() method """ # GIVEN: A button. - button = QtGui.QPushButton() + button = QtWidgets.QPushButton() checked = True enabled = True text = "new!" # WHEN: Call the method. - with patch('PyQt4.QtGui.QPushButton.setChecked') as mocked_check_method: + with patch('PyQt5.QtWidgets.QPushButton.setChecked') as mocked_check_method: self.form._adjust_button(button, checked, enabled, text) # THEN: The button should be changed. diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index 3e0c97b09..5cce2c5ec 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -24,7 +24,7 @@ Package to test the openlp.core.ui package. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtCore, QtTest, QtWidgets from openlp.core.common import Registry from openlp.core.ui import starttimeform @@ -40,7 +40,7 @@ class TestStartTimeDialog(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = starttimeform.StartTimeForm() @@ -90,8 +90,8 @@ class TestStartTimeDialog(TestCase, TestMixin): # WHEN displaying the UI and pressing enter self.form.item = {'service_item': mocked_serviceitem} - with patch('PyQt4.QtGui.QDialog.exec_'): - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec'): + self.form.exec() ok_widget = self.form.button_box.button(self.form.button_box.Ok) QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) @@ -103,8 +103,8 @@ class TestStartTimeDialog(TestCase, TestMixin): # WHEN displaying the UI, changing the time to 2min 3secs and pressing enter self.form.item = {'service_item': mocked_serviceitem} - with patch('PyQt4.QtGui.QDialog.exec_'): - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec'): + self.form.exec() self.form.minute_spin_box.setValue(2) self.form.second_spin_box.setValue(3) ok_widget = self.form.button_box.button(self.form.button_box.Ok) diff --git a/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py b/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py index 032a63e3c..4c8a4a9c0 100644 --- a/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py +++ b/tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.bibles.forms.bibleimportform package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm, WebDownload @@ -44,7 +44,7 @@ class TestBibleImportForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = BibleImportForm(self.main_window, MagicMock(), MagicMock()) diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index 54b5ee90d..e684153f7 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -24,7 +24,7 @@ Module to test the EditCustomForm. """ from unittest import TestCase -from PyQt4 import QtGui, QtTest, QtCore +from PyQt5 import QtTest, QtCore, QtWidgets from openlp.core.common import Registry # TODO: FIXME: Import needed due to horrible bad imports @@ -44,7 +44,7 @@ class TestEditCustomForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) media_item = MagicMock() manager = MagicMock() @@ -85,8 +85,8 @@ class TestEditCustomForm(TestCase, TestMixin): """ Test the on_add_button_clicked_test method / add_button button. """ - # GIVEN: A mocked QDialog.exec_() method - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # GIVEN: A mocked QDialog.exec() method + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: # WHEN: Add a new slide. QtTest.QTest.mouseClick(self.form.add_button, QtCore.Qt.LeftButton) diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py index 376a98dd1..652d868da 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -24,7 +24,7 @@ Module to test the EditCustomSlideForm. """ from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm @@ -42,7 +42,7 @@ class TestEditCustomSlideForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditCustomSlideForm() @@ -57,10 +57,10 @@ class TestEditCustomSlideForm(TestCase, TestMixin): """ Test if the dialog is correctly set up. """ - # GIVEN: A mocked QDialog.exec_() method - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # GIVEN: A mocked QDialog.exec() method + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: # WHEN: Show the dialog. - self.form.exec_() + self.form.exec() # THEN: The dialog should be empty. assert self.form.slide_text_edit.toPlainText() == '', 'There should not be any text in the text editor.' @@ -69,14 +69,14 @@ class TestEditCustomSlideForm(TestCase, TestMixin): """ Test the set_text() method. """ - # GIVEN: A mocked QDialog.exec_() method - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # GIVEN: A mocked QDialog.exec() method + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: mocked_set_focus = MagicMock() self.form.slide_text_edit.setFocus = mocked_set_focus wanted_text = 'THIS TEXT SHOULD BE SHOWN.' # WHEN: Show the dialog and set the text. - self.form.exec_() + self.form.exec() self.form.set_text(wanted_text) # THEN: The dialog should show the text. diff --git a/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py b/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py index 0fc66d1cb..91a96759f 100644 --- a/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py +++ b/tests/interfaces/openlp_plugins/media/forms/test_mediaclipselectorform.py @@ -30,7 +30,7 @@ from openlp.core.ui.media.vlcplayer import get_vlc if os.name == 'nt' and not get_vlc(): raise SkipTest('Windows without VLC, skipping this test since it cannot run without vlc') -from PyQt4 import QtGui, QtTest, QtCore +from PyQt5 import QtTest, QtCore, QtWidgets from openlp.core.common import Registry from openlp.plugins.media.forms.mediaclipselectorform import MediaClipSelectorForm @@ -48,7 +48,7 @@ class TestMediaClipSelectorForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) # Mock VLC so we don't actually use it self.vlc_patcher = patch('openlp.plugins.media.forms.mediaclipselectorform.vlc') @@ -77,10 +77,10 @@ class TestMediaClipSelectorForm(TestCase, TestMixin): """ Test if the dialog is correctly set up. """ - # GIVEN: A mocked QDialog.exec_() method - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: + # GIVEN: A mocked QDialog.exec() method + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: # WHEN: Show the dialog. - self.form.exec_() + self.form.exec() # THEN: The media path should be empty. assert self.form.media_path_combobox.currentText() == '', 'There should not be any text in the media path.' @@ -93,8 +93,8 @@ class TestMediaClipSelectorForm(TestCase, TestMixin): with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \ mocked_critical_error_message_box,\ patch('openlp.plugins.media.forms.mediaclipselectorform.os.path.exists') as mocked_os_path_exists,\ - patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: - self.form.exec_() + patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: + self.form.exec() # WHEN: The load button is clicked with no path set QtTest.QTest.mouseClick(self.form.load_disc_button, QtCore.Qt.LeftButton) @@ -131,8 +131,8 @@ class TestMediaClipSelectorForm(TestCase, TestMixin): Test the behavior when the title combobox is updated """ # GIVEN: Mocked methods and some entries in the title combobox. - with patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: - self.form.exec_() + with patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: + self.form.exec() self.form.vlc_media_player.get_length.return_value = 1000 self.form.audio_tracks_combobox.itemData = MagicMock() self.form.subtitle_tracks_combobox.itemData = MagicMock() @@ -160,8 +160,8 @@ class TestMediaClipSelectorForm(TestCase, TestMixin): # GIVEN: Mocked methods. with patch('openlp.plugins.media.forms.mediaclipselectorform.critical_error_message_box') as \ mocked_critical_error_message_box,\ - patch('PyQt4.QtGui.QDialog.exec_') as mocked_exec: - self.form.exec_() + patch('PyQt5.QtWidgets.QDialog.exec') as mocked_exec: + self.form.exec() # WHEN: The save button is clicked with a NoneType in start_time_ms or end_time_ms self.form.accept() diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py index 832a40cda..ddeb2e695 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.songs.forms.authorsform package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.plugins.songs.forms.authorsform import AuthorsForm @@ -42,7 +42,7 @@ class TestAuthorsForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = AuthorsForm() diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py index ba808b402..f7beae4c4 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.songs.forms.editsongform package. """ from unittest import TestCase -from PyQt4 import QtGui +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.core.common.uistrings import UiStrings @@ -44,7 +44,7 @@ class TestEditSongForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) Registry().register('theme_manager', MagicMock()) self.form = EditSongForm(MagicMock(), self.main_window, MagicMock()) diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py index 448ccf44b..40d72676b 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.songs.forms.editverseform package. """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt5 import QtCore, QtTest, QtWidgets from openlp.core.common import Registry from openlp.plugins.songs.forms.editverseform import EditVerseForm @@ -42,7 +42,7 @@ class TestEditVerseForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditVerseForm() diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py index 24a1c8fb3..31a13a2c8 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py @@ -24,7 +24,7 @@ Package to test the openlp.plugins.songs.forms.topicsform package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets from openlp.core.common import Registry from openlp.plugins.songs.forms.topicsform import TopicsForm @@ -42,7 +42,7 @@ class TestTopicsForm(TestCase, TestMixin): """ Registry.create() self.setup_application() - self.main_window = QtGui.QMainWindow() + self.main_window = QtWidgets.QMainWindow() Registry().register('main_window', self.main_window) self.form = TopicsForm()