openlp/openlp/core/ui/firsttimewizard.py

277 lines
17 KiB
Python
Raw Normal View History

2011-02-27 17:05:37 +00:00
# -*- coding: utf-8 -*-
2012-12-29 13:15:42 +00:00
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
2011-02-27 17:05:37 +00:00
2011-03-04 19:02:00 +00:00
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
2015-12-31 22:46:06 +00:00
# Copyright (c) 2008-2016 OpenLP Developers #
2011-03-04 19:02:00 +00:00
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
2013-02-01 20:36:27 +00:00
"""
The UI widgets for the first time wizard.
"""
2015-11-07 00:49:40 +00:00
from PyQt5 import QtCore, QtGui, QtWidgets
2011-02-27 17:05:37 +00:00
from openlp.core.common import translate, is_macosx, clean_button_text
from openlp.core.lib import build_icon
from openlp.core.lib.ui import add_welcome_page
2011-02-27 17:05:37 +00:00
2013-02-01 20:36:27 +00:00
class FirstTimePage(object):
2013-02-01 20:36:27 +00:00
"""
An enumeration class with each of the pages of the wizard.
"""
Welcome = 0
Download = 1
NoInternet = 2
Plugins = 3
Songs = 4
Bibles = 5
Themes = 6
Defaults = 7
Progress = 8
class UiFirstTimeWizard(object):
2013-02-01 20:36:27 +00:00
"""
The UI widgets for the first time wizard.
"""
def setup_ui(self, first_time_wizard):
2013-02-01 20:36:27 +00:00
"""
Set up the UI.
:param first_time_wizard: The wizard form
2013-02-01 20:36:27 +00:00
"""
2013-08-31 18:17:38 +00:00
first_time_wizard.setObjectName('first_time_wizard')
first_time_wizard.setWindowIcon(build_icon(u':/icon/openlp-logo.svg'))
2013-05-11 17:41:26 +00:00
first_time_wizard.resize(550, 386)
first_time_wizard.setModal(True)
2015-11-07 00:49:40 +00:00
first_time_wizard.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage |
QtWidgets.QWizard.NoBackButtonOnLastPage | QtWidgets.QWizard.HaveCustomButton1 |
QtWidgets.QWizard.HaveCustomButton2)
if is_macosx():
2015-11-07 00:49:40 +00:00
first_time_wizard.setPixmap(QtWidgets.QWizard.BackgroundPixmap,
2014-08-22 22:12:35 +00:00
QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
first_time_wizard.resize(634, 386)
else:
2015-11-07 00:49:40 +00:00
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)
2013-08-31 18:17:38 +00:00
add_welcome_page(first_time_wizard, ':/wizards/wizard_firsttime.bmp')
# The download page
2015-11-07 00:49:40 +00:00
self.download_page = QtWidgets.QWizardPage()
self.download_page.setObjectName('download_page')
2015-11-07 00:49:40 +00:00
self.download_layout = QtWidgets.QVBoxLayout(self.download_page)
self.download_layout.setContentsMargins(48, 48, 48, 48)
self.download_layout.setObjectName('download_layout')
2015-11-07 00:49:40 +00:00
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.
2015-11-07 00:49:40 +00:00
self.no_internet_page = QtWidgets.QWizardPage()
self.no_internet_page.setObjectName('no_internet_page')
2015-11-07 00:49:40 +00:00
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')
2015-11-07 00:49:40 +00:00
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
2015-11-07 00:49:40 +00:00
self.plugin_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.plugin_page.setObjectName('plugin_page')
2015-11-07 00:49:40 +00:00
self.plugin_layout = QtWidgets.QVBoxLayout(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.plugin_layout.setContentsMargins(40, 15, 40, 0)
2013-08-31 18:17:38 +00:00
self.plugin_layout.setObjectName('plugin_layout')
2015-11-07 00:49:40 +00:00
self.songs_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.songs_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.songs_check_box.setObjectName('songs_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.songs_check_box)
2015-11-07 00:49:40 +00:00
self.custom_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.custom_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.custom_check_box.setObjectName('custom_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.custom_check_box)
2015-11-07 00:49:40 +00:00
self.bible_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.bible_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.bible_check_box.setObjectName('bible_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.bible_check_box)
2015-11-07 00:49:40 +00:00
self.image_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.image_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.image_check_box.setObjectName('image_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.image_check_box)
2015-11-07 00:49:40 +00:00
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)
2015-11-07 00:49:40 +00:00
self.media_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.media_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.media_check_box.setObjectName('media_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.media_check_box)
2015-11-07 00:49:40 +00:00
self.remote_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-08-31 18:17:38 +00:00
self.remote_check_box.setObjectName('remote_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.remote_check_box)
2015-11-07 00:49:40 +00:00
self.song_usage_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.song_usage_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.song_usage_check_box.setObjectName('song_usage_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.song_usage_check_box)
2015-11-07 00:49:40 +00:00
self.alert_check_box = QtWidgets.QCheckBox(self.plugin_page)
2013-05-11 17:41:26 +00:00
self.alert_check_box.setChecked(True)
2013-08-31 18:17:38 +00:00
self.alert_check_box.setObjectName('alert_check_box')
2013-05-11 17:41:26 +00:00
self.plugin_layout.addWidget(self.alert_check_box)
first_time_wizard.setPage(FirstTimePage.Plugins, self.plugin_page)
# The song samples page
2015-11-07 00:49:40 +00:00
self.songs_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.songs_page.setObjectName('songs_page')
2015-11-07 00:49:40 +00:00
self.songs_layout = QtWidgets.QVBoxLayout(self.songs_page)
2013-05-11 17:41:26 +00:00
self.songs_layout.setContentsMargins(50, 20, 50, 20)
2013-08-31 18:17:38 +00:00
self.songs_layout.setObjectName('songs_layout')
2015-11-07 00:49:40 +00:00
self.songs_list_widget = QtWidgets.QListWidget(self.songs_page)
2013-05-11 17:41:26 +00:00
self.songs_list_widget.setAlternatingRowColors(True)
2013-08-31 18:17:38 +00:00
self.songs_list_widget.setObjectName('songs_list_widget')
2013-05-11 17:41:26 +00:00
self.songs_layout.addWidget(self.songs_list_widget)
first_time_wizard.setPage(FirstTimePage.Songs, self.songs_page)
2011-03-10 13:15:49 +00:00
# The Bible samples page
2015-11-07 00:49:40 +00:00
self.bibles_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.bibles_page.setObjectName('bibles_page')
2015-11-07 00:49:40 +00:00
self.bibles_layout = QtWidgets.QVBoxLayout(self.bibles_page)
2013-05-11 17:41:26 +00:00
self.bibles_layout.setContentsMargins(50, 20, 50, 20)
2013-08-31 18:17:38 +00:00
self.bibles_layout.setObjectName('bibles_layout')
2015-11-07 00:49:40 +00:00
self.bibles_tree_widget = QtWidgets.QTreeWidget(self.bibles_page)
2013-05-11 17:41:26 +00:00
self.bibles_tree_widget.setAlternatingRowColors(True)
self.bibles_tree_widget.header().setVisible(False)
2013-08-31 18:17:38 +00:00
self.bibles_tree_widget.setObjectName('bibles_tree_widget')
2013-05-11 17:41:26 +00:00
self.bibles_layout.addWidget(self.bibles_tree_widget)
first_time_wizard.setPage(FirstTimePage.Bibles, self.bibles_page)
2011-03-10 13:15:49 +00:00
# The theme samples page
2015-11-07 00:49:40 +00:00
self.themes_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.themes_page.setObjectName('themes_page')
2015-11-07 00:49:40 +00:00
self.themes_layout = QtWidgets.QVBoxLayout(self.themes_page)
2013-05-11 17:41:26 +00:00
self.themes_layout.setContentsMargins(20, 50, 20, 60)
2013-08-31 18:17:38 +00:00
self.themes_layout.setObjectName('themes_layout')
2015-11-07 00:49:40 +00:00
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)
2013-05-11 17:41:26 +00:00
self.themes_list_widget.setSpacing(4)
self.themes_list_widget.setUniformItemSizes(True)
self.themes_list_widget.setIconSize(QtCore.QSize(133, 100))
self.themes_list_widget.setWrapping(False)
2013-08-31 18:17:38 +00:00
self.themes_list_widget.setObjectName('themes_list_widget')
2013-05-11 17:41:26 +00:00
self.themes_layout.addWidget(self.themes_list_widget)
first_time_wizard.setPage(FirstTimePage.Themes, self.themes_page)
2011-03-10 13:15:49 +00:00
# the default settings page
2015-11-07 00:49:40 +00:00
self.defaults_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.defaults_page.setObjectName('defaults_page')
2015-11-07 00:49:40 +00:00
self.defaults_layout = QtWidgets.QFormLayout(self.defaults_page)
2013-05-11 17:41:26 +00:00
self.defaults_layout.setContentsMargins(50, 20, 50, 20)
2013-08-31 18:17:38 +00:00
self.defaults_layout.setObjectName('defaults_layout')
2015-11-07 00:49:40 +00:00
self.display_label = QtWidgets.QLabel(self.defaults_page)
2013-08-31 18:17:38 +00:00
self.display_label.setObjectName('display_label')
2015-11-07 00:49:40 +00:00
self.display_combo_box = QtWidgets.QComboBox(self.defaults_page)
2013-05-11 17:41:26 +00:00
self.display_combo_box.setEditable(False)
2015-11-07 00:49:40 +00:00
self.display_combo_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert)
2013-08-31 18:17:38 +00:00
self.display_combo_box.setObjectName('display_combo_box')
2013-05-11 17:41:26 +00:00
self.defaults_layout.addRow(self.display_label, self.display_combo_box)
2015-11-07 00:49:40 +00:00
self.theme_label = QtWidgets.QLabel(self.defaults_page)
2013-08-31 18:17:38 +00:00
self.theme_label.setObjectName('theme_label')
2015-11-07 00:49:40 +00:00
self.theme_combo_box = QtWidgets.QComboBox(self.defaults_page)
2013-05-11 17:41:26 +00:00
self.theme_combo_box.setEditable(False)
2015-11-07 00:49:40 +00:00
self.theme_combo_box.setInsertPolicy(QtWidgets.QComboBox.NoInsert)
self.theme_combo_box.setSizeAdjustPolicy(QtWidgets.QComboBox.AdjustToContents)
2013-08-31 18:17:38 +00:00
self.theme_combo_box.setObjectName('theme_combo_box')
2013-05-11 17:41:26 +00:00
self.defaults_layout.addRow(self.theme_label, self.theme_combo_box)
first_time_wizard.setPage(FirstTimePage.Defaults, self.defaults_page)
2011-03-11 10:20:09 +00:00
# Progress page
2015-11-07 00:49:40 +00:00
self.progress_page = QtWidgets.QWizardPage()
2013-08-31 18:17:38 +00:00
self.progress_page.setObjectName('progress_page')
2015-11-07 00:49:40 +00:00
self.progress_layout = QtWidgets.QVBoxLayout(self.progress_page)
self.progress_layout.setContentsMargins(48, 48, 48, 48)
2013-08-31 18:17:38 +00:00
self.progress_layout.setObjectName('progress_layout')
2015-11-07 00:49:40 +00:00
self.progress_label = QtWidgets.QLabel(self.progress_page)
2013-08-31 18:17:38 +00:00
self.progress_label.setObjectName('progress_label')
2013-05-11 17:41:26 +00:00
self.progress_layout.addWidget(self.progress_label)
2015-11-07 00:49:40 +00:00
self.progress_bar = QtWidgets.QProgressBar(self.progress_page)
2013-08-31 18:17:38 +00:00
self.progress_bar.setObjectName('progress_bar')
2013-05-11 17:41:26 +00:00
self.progress_layout.addWidget(self.progress_bar)
first_time_wizard.setPage(FirstTimePage.Progress, self.progress_page)
self.retranslate_ui(first_time_wizard)
2011-02-27 17:05:37 +00:00
def retranslate_ui(self, first_time_wizard):
2013-02-01 20:36:27 +00:00
"""
Translate the UI on the fly
:param first_time_wizard: The wizard form
2013-02-01 20:36:27 +00:00
"""
2013-05-11 17:41:26 +00:00
first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard'))
first_time_wizard.title_label.setText('<span style="font-size:14pt; font-weight:600;">%s</span>' %
translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard'))
first_time_wizard.information_label.setText(
2014-04-12 20:19:22 +00:00
translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. '
2014-08-22 22:12:35 +00:00
'Click the %s button below to start.') %
2015-11-07 00:49:40 +00:00
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.'))
self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the '
'resource index file...'))
2013-05-11 17:41:26 +00:00
self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins'))
self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. '))
self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs'))
self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides'))
self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bible'))
self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images'))
self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations'))
2013-05-11 17:41:26 +00:00
self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media (Audio and Video)'))
self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow remote access'))
self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Monitor Song Usage'))
self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow Alerts'))
self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection'))
self.no_internet_page.setSubTitle(
translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.'))
self.no_internet_text = translate('OpenLP.FirstTimeWizard',
2013-12-24 15:55:01 +00:00
'No Internet connection was found. The First Time Wizard needs an Internet '
'connection in order to be able to download sample songs, Bibles and themes.'
' Click the Finish button now to start OpenLP with initial settings and '
'no sample data.\n\nTo re-run the First Time Wizard and import this sample '
'data at a later time, check your Internet connection and re-run this '
'wizard by selecting "Tools/Re-run First Time Wizard" from OpenLP.')
self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard',
'\n\nTo cancel the First Time Wizard completely (and not start OpenLP), '
'click the %s button now.') % \
2015-11-07 00:49:40 +00:00
clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton))
2013-05-11 17:41:26 +00:00
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'))
self.bibles_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.'))
self.themes_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes'))
self.themes_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.'))
self.defaults_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Default Settings'))
self.defaults_page.setSubTitle(translate('OpenLP.FirstTimeWizard',
2013-12-24 15:55:01 +00:00
'Set up default settings to be used by OpenLP.'))
2013-05-11 17:41:26 +00:00
self.display_label.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:'))
self.theme_label.setText(translate('OpenLP.FirstTimeWizard', 'Select default theme:'))
self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring'))
self.progress_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded '
'and OpenLP is configured.'))
2013-05-11 17:41:26 +00:00
self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...'))
2015-11-07 00:49:40 +00:00
first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish'))
first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel'))