forked from openlp/openlp
Add first time language dialog
This commit is contained in:
parent
df3a3cc133
commit
a10ad04254
@ -37,6 +37,7 @@ from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import Receiver, check_directory_exists
|
||||
from openlp.core.resources import qInitResources
|
||||
from openlp.core.ui.mainwindow import MainWindow
|
||||
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm
|
||||
from openlp.core.ui.firsttimeform import FirstTimeForm
|
||||
from openlp.core.ui.exceptionform import ExceptionForm
|
||||
from openlp.core.ui import SplashScreen, ScreenList
|
||||
@ -275,14 +276,18 @@ def main():
|
||||
# First time checks in settings
|
||||
if QtCore.QSettings().value(
|
||||
u'general/first time', QtCore.QVariant(True)).toBool():
|
||||
FirstTimeForm().exec_()
|
||||
FirstTimeLanguageForm().exec_()
|
||||
# i18n Set Language
|
||||
language = LanguageManager.get_language()
|
||||
appTranslator = LanguageManager.get_translator(language)
|
||||
app.installTranslator(appTranslator)
|
||||
# First time checks in settings
|
||||
if QtCore.QSettings().value(
|
||||
u'general/first time', QtCore.QVariant(True)).toBool():
|
||||
FirstTimeForm().exec_()
|
||||
if not options.no_error_form:
|
||||
sys.excepthook = app.hookException
|
||||
sys.exit(app.run())
|
||||
sys.exit()#(app.run())
|
||||
|
||||
if __name__ == u'__main__':
|
||||
"""
|
||||
|
@ -52,6 +52,7 @@ class HideMode(object):
|
||||
Screen = 3
|
||||
|
||||
from firsttimeform import FirstTimeForm
|
||||
from firsttimelanguageform import FirstTimeLanguageForm
|
||||
from themeform import ThemeForm
|
||||
from filerenameform import FileRenameForm
|
||||
from starttimeform import StartTimeForm
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
from firsttimewizard import Ui_FirstTimeWizard
|
||||
|
||||
from openlp.core.lib import translate, PluginStatus
|
||||
from openlp.core.utils import get_web_page, LanguageManager
|
||||
from openlp.core.utils import get_web_page
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -54,9 +54,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self.bibles = bibles.read()
|
||||
QtGui.QWizard.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
QtCore.QObject.connect(self.autoLanguageCheckBox,
|
||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||
self.onAutoLanguageClicked)
|
||||
#self.registerFields()
|
||||
|
||||
def exec_(self, edit=False):
|
||||
@ -79,11 +76,6 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self.internetGroupBox.setVisible(False)
|
||||
self.noInternetLabel.setVisible(True)
|
||||
# Sort out Language settings
|
||||
self.autoLanguageCheckBox.setChecked(True)
|
||||
self.LanguageComboBox.setEnabled(False)
|
||||
self.qmList = LanguageManager.get_qm_list()
|
||||
for key in sorted(self.qmList.keys()):
|
||||
self.LanguageComboBox.addItem(key)
|
||||
treewidgetitem = QtGui.QTreeWidgetItem(self.selectionTreeWidget)
|
||||
treewidgetitem.setText(0, u'Songs')
|
||||
self.__loadChild(treewidgetitem, self.songs)
|
||||
@ -115,22 +107,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard):
|
||||
self.__pluginStatus(self.customCheckBox, u'custom/status')
|
||||
self.__pluginStatus(self.songUsageCheckBox, u'songusage/status')
|
||||
self.__pluginStatus(self.alertCheckBox, u'alerts/status')
|
||||
if self.autoLanguageCheckBox.checkState() == QtCore.Qt.Checked:
|
||||
LanguageManager.auto_language = True
|
||||
LanguageManager.set_language(False, False)
|
||||
else:
|
||||
LanguageManager.auto_language = False
|
||||
action = QtGui.QAction(None)
|
||||
action.setObjectName(unicode(self.LanguageComboBox.currentText()))
|
||||
LanguageManager.set_language(action, False)
|
||||
return QtGui.QWizard.accept(self)
|
||||
|
||||
def onAutoLanguageClicked(self, state):
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.LanguageComboBox.setEnabled(False)
|
||||
else:
|
||||
self.LanguageComboBox.setEnabled(True)
|
||||
|
||||
def __pluginStatus(self, field, tag):
|
||||
status = PluginStatus.Active if field.checkState() \
|
||||
== QtCore.Qt.Checked else PluginStatus.Inactive
|
||||
|
55
openlp/core/ui/firsttimelanguagedialog.py
Normal file
55
openlp/core/ui/firsttimelanguagedialog.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, #
|
||||
# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon #
|
||||
# Tibble, Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.lib.ui import create_accept_reject_button_box
|
||||
|
||||
class Ui_FirstTimeLanguageDialog(object):
|
||||
def setupUi(self, firstTimeLanguageDialog):
|
||||
firstTimeLanguageDialog.setObjectName(u'firstTimeLanguageDialog')
|
||||
firstTimeLanguageDialog.resize(300, 10)
|
||||
self.dialogLayout = QtGui.QGridLayout(firstTimeLanguageDialog)
|
||||
self.dialogLayout.setObjectName(u'dialogLayout')
|
||||
self.fileNameLabel = QtGui.QLabel(firstTimeLanguageDialog)
|
||||
self.fileNameLabel.setObjectName(u'fileNameLabel')
|
||||
self.dialogLayout.addWidget(self.fileNameLabel, 0, 0)
|
||||
self.LanguageComboBox = QtGui.QComboBox(firstTimeLanguageDialog)
|
||||
self.LanguageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.LanguageComboBox.setObjectName("LanguageComboBox")
|
||||
self.dialogLayout.addWidget(self.LanguageComboBox, 0, 1)
|
||||
self.buttonBox = create_accept_reject_button_box(firstTimeLanguageDialog, True)
|
||||
self.dialogLayout.addWidget(self.buttonBox, 1, 0, 1, 2)
|
||||
self.retranslateUi(firstTimeLanguageDialog)
|
||||
self.setMaximumHeight(self.sizeHint().height())
|
||||
QtCore.QMetaObject.connectSlotsByName(firstTimeLanguageDialog)
|
||||
|
||||
def retranslateUi(self, firstTimeLanguageDialog):
|
||||
self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm',
|
||||
'Initial Set up Language'))
|
||||
self.fileNameLabel.setText(translate('OpenLP.FirstTimeLanguageForm',
|
||||
'Initial Language:'))
|
67
openlp/core/ui/firsttimelanguageform.py
Normal file
67
openlp/core/ui/firsttimelanguageform.py
Normal file
@ -0,0 +1,67 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2011 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, #
|
||||
# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon #
|
||||
# Tibble, Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from firsttimelanguagedialog import Ui_FirstTimeLanguageDialog
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.utils import LanguageManager
|
||||
|
||||
class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
|
||||
"""
|
||||
The exception dialog
|
||||
"""
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.qmList = LanguageManager.get_qm_list()
|
||||
for key in sorted(self.qmList.keys()):
|
||||
self.LanguageComboBox.addItem(key)
|
||||
|
||||
def exec_(self):
|
||||
"""
|
||||
Run the Dialog with correct heading.
|
||||
"""
|
||||
return QtGui.QDialog.exec_(self)
|
||||
|
||||
def accept(self):
|
||||
print "Accept"
|
||||
# if self.autoLanguageCheckBox.checkState() == QtCore.Qt.Checked:
|
||||
# LanguageManager.auto_language = True
|
||||
# LanguageManager.set_language(False, False)
|
||||
# else:
|
||||
# LanguageManager.auto_language = False
|
||||
# action = QtGui.QAction(None)
|
||||
# action.setObjectName(unicode(self.LanguageComboBox.currentText()))
|
||||
# LanguageManager.set_language(action, False)
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
def reject(self):
|
||||
print "Reject"
|
||||
LanguageManager.auto_language = True
|
||||
LanguageManager.set_language(False, False)
|
||||
return QtGui.QDialog.reject(self)
|
@ -142,17 +142,6 @@ class Ui_FirstTimeWizard(object):
|
||||
self.themeSelectionComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.themeSelectionComboBox.setObjectName(_fromUtf8("themeSelectionComboBox"))
|
||||
self.gridLayout.addWidget(self.themeSelectionComboBox, 1, 1, 1, 1)
|
||||
self.languageLabel = QtGui.QLabel(self.layoutWidget)
|
||||
self.languageLabel.setObjectName(_fromUtf8("languageLabel"))
|
||||
self.gridLayout.addWidget(self.languageLabel, 3, 0, 1, 1)
|
||||
self.LanguageComboBox = QtGui.QComboBox(self.layoutWidget)
|
||||
self.LanguageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
||||
self.LanguageComboBox.setObjectName(_fromUtf8("LanguageComboBox"))
|
||||
self.gridLayout.addWidget(self.LanguageComboBox, 3, 1, 1, 1)
|
||||
self.autoLanguageCheckBox = QtGui.QCheckBox(self.layoutWidget)
|
||||
self.autoLanguageCheckBox.setChecked(True)
|
||||
self.autoLanguageCheckBox.setObjectName(_fromUtf8("autoLanguageCheckBox"))
|
||||
self.gridLayout.addWidget(self.autoLanguageCheckBox, 2, 0, 1, 1)
|
||||
self.label = QtGui.QLabel(self.DefaultsPage)
|
||||
self.label.setGeometry(QtCore.QRect(40, 190, 471, 17))
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
@ -188,7 +177,5 @@ class Ui_FirstTimeWizard(object):
|
||||
self.DefaultsPage.setSubTitle(QtGui.QApplication.translate("FirstTimeWizard", "Set up default values to be used by OpenLP", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.displaySelectionLabel.setText(QtGui.QApplication.translate("FirstTimeWizard", "Default output display", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.themeSelectionLabel.setText(QtGui.QApplication.translate("FirstTimeWizard", "Select the default Theme", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.languageLabel.setText(QtGui.QApplication.translate("FirstTimeWizard", "Select default language", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.autoLanguageCheckBox.setText(QtGui.QApplication.translate("FirstTimeWizard", "Auto Language", None, QtGui.QApplication.UnicodeUTF8))
|
||||
self.label.setText(QtGui.QApplication.translate("FirstTimeWizard", "Press Finish to apply all you changes and start OpenLP", None, QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user