openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #08414
[Merge] lp:~trb143/openlp/b1 into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/b1 into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~trb143/openlp/b1/+merge/59459
Add ProgressBar on the Mainwindow and hide / Show correctly.
Use it for Service Loads and Saves
Use it for Image Imports
Use it for Presentation Imports
--
https://code.launchpad.net/~trb143/openlp/b1/+merge/59459
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/b1 into lp:openlp.
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2011-04-26 18:52:46 +0000
+++ openlp/core/ui/mainwindow.py 2011-04-29 07:18:44 +0000
@@ -38,7 +38,7 @@
ThemeManager, SlideController, PluginForm, MediaDockManager, \
ShortcutListForm, DisplayTagForm
from openlp.core.utils import AppLocation, add_actions, LanguageManager, \
- get_application_version
+ get_application_version, LoadSleepThread
from openlp.core.utils.actions import ActionList, CategoryOrder
log = logging.getLogger(__name__)
@@ -122,12 +122,17 @@
self.HelpMenu = QtGui.QMenu(self.MenuBar)
self.HelpMenu.setObjectName(u'HelpMenu')
mainWindow.setMenuBar(self.MenuBar)
- self.StatusBar = QtGui.QStatusBar(mainWindow)
- self.StatusBar.setObjectName(u'StatusBar')
- mainWindow.setStatusBar(self.StatusBar)
- self.DefaultThemeLabel = QtGui.QLabel(self.StatusBar)
- self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel')
- self.StatusBar.addPermanentWidget(self.DefaultThemeLabel)
+ self.statusBar = QtGui.QStatusBar(mainWindow)
+ self.statusBar.setObjectName(u'statusBar')
+ mainWindow.setStatusBar(self.statusBar)
+ self.loadProgressBar = QtGui.QProgressBar(self.statusBar)
+ self.loadProgressBar.setObjectName(u'loadProgressBar')
+ self.statusBar.addPermanentWidget(self.loadProgressBar)
+ self.statusBar.removeWidget(self.loadProgressBar)
+ self.loadProgressBar.setValue(0)
+ self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
+ self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
+ self.statusBar.addPermanentWidget(self.defaultThemeLabel)
# Create the MediaManager
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
u'mediaManagerDock', u':/system/system_mediamanager.png')
@@ -544,6 +549,9 @@
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'openlp_information_message'),
self.onInformationMessage)
+ QtCore.QObject.connect(Receiver.get_receiver(),
+ QtCore.SIGNAL(u'mainwindow_remove_progress'),
+ self.removeProgressBar)
# warning cyclic dependency
# renderer needs to call ThemeManager and
# ThemeManager needs to call Renderer
@@ -880,10 +888,10 @@
self.setWindowTitle(title)
def showStatusMessage(self, message):
- self.StatusBar.showMessage(message)
+ self.statusBar.showMessage(message)
def defaultThemeChanged(self, theme):
- self.DefaultThemeLabel.setText(
+ self.defaultThemeLabel.setText(
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
theme)
@@ -979,7 +987,7 @@
for fileId, filename in enumerate(recentFilesToDisplay):
log.debug('Recent file name: %s', filename)
action = base_action(self, u'')
- action.setText(u'&%d %s' %
+ action.setText(u'&%d %s' %
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
action.setData(QtCore.QVariant(filename))
self.connect(action, QtCore.SIGNAL(u'triggered()'),
@@ -1008,3 +1016,33 @@
while self.recentFiles.count() > maxRecentFiles:
# Don't care what API says takeLast works, removeLast doesn't!
self.recentFiles.takeLast()
+
+ def displayProgressBar(self, size):
+ """
+ Make Progress bar visible and set size
+ """
+ self.statusBar.addWidget(self.loadProgressBar)
+ self.loadProgressBar.show()
+ self.loadProgressBar.setMaximum(size)
+ self.loadProgressBar.setValue(0)
+ Receiver.send_message(u'openlp_process_events')
+
+ def incrementProgressBar(self):
+ """
+ Increase the Progress Bar Value by 1
+ """
+ self.loadProgressBar.setValue(self.loadProgressBar.value() + 1)
+ Receiver.send_message(u'openlp_process_events')
+
+ def finishedProgressBar(self):
+ """
+ Trigger it's removal after 1 second
+ """
+ LoadSleepThread(self).start()
+
+ def removeProgressBar(self):
+ """
+ Remove the Progress bar from view.
+ """
+ self.statusBar.removeWidget(self.loadProgressBar)
+ Receiver.send_message(u'openlp_process_events')
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2011-04-26 18:52:46 +0000
+++ openlp/core/ui/servicemanager.py 2011-04-29 07:18:44 +0000
@@ -460,7 +460,11 @@
service = []
write_list = []
total_size = 0
+ Receiver.send_message(u'cursor_busy')
+ # Number if items + 1 to zip it
+ self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
for item in self.serviceItems:
+ self.mainwindow.incrementProgressBar()
service.append({u'serviceitem':
item[u'service_item'].get_service_repr()})
if not item[u'service_item'].uses_file():
@@ -501,6 +505,7 @@
log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
zip = None
success = True
+ self.mainwindow.incrementProgressBar()
try:
zip = zipfile.ZipFile(path_file_name, 'w', zipfile.ZIP_STORED,
allow_zip_64)
@@ -516,6 +521,8 @@
finally:
if zip:
zip.close()
+ self.mainwindow.finishedProgressBar()
+ Receiver.send_message(u'cursor_normal')
if success:
self.mainwindow.addRecentFile(path_file_name)
self.setModified(False)
@@ -576,7 +583,9 @@
items = cPickle.load(fileTo)
fileTo.close()
self.newFile()
+ self.mainwindow.displayProgressBar(len(items))
for item in items:
+ self.mainwindow.incrementProgressBar()
serviceItem = ServiceItem()
serviceItem.from_service = True
serviceItem.renderer = self.mainwindow.renderer
@@ -592,6 +601,7 @@
self.setModified(False)
QtCore.QSettings().setValue(
'service/last file', QtCore.QVariant(fileName))
+ self.mainwindow.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
else:
critical_error_message_box(
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2011-03-29 16:44:36 +0000
+++ openlp/core/utils/__init__.py 2011-04-29 07:18:44 +0000
@@ -100,6 +100,19 @@
remote_version[u'revision'] > local_version[u'revision']:
Receiver.send_message(u'openlp_version_check', u'%s' % version)
+class LoadSleepThread(QtCore.QThread):
+ """
+ A special Qt thread class sleep then remove the load progress bar
+ """
+ def __init__(self, parent):
+ QtCore.QThread.__init__(self, parent)
+
+ def run(self):
+ """
+ Run the thread.
+ """
+ time.sleep(1)
+ Receiver.send_message(u'mainwindow_remove_progress')
class AppLocation(object):
"""
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2011-04-15 21:43:59 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2011-04-29 07:18:44 +0000
@@ -108,7 +108,10 @@
self.settingsSection, self.getFileList())
def loadList(self, list):
+ Receiver.send_message(u'cursor_busy')
+ self.parent.formparent.displayProgressBar(len(list))
for imageFile in list:
+ self.parent.formparent.incrementProgressBar()
filename = os.path.split(unicode(imageFile))[1]
thumb = os.path.join(self.servicePath, filename)
if os.path.exists(thumb):
@@ -122,6 +125,8 @@
item_name.setIcon(icon)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
self.listView.addItem(item_name)
+ Receiver.send_message(u'cursor_normal')
+ self.parent.formparent.finishedProgressBar()
def generateSlideData(self, service_item, item=None, xmlVersion=False):
items = self.listView.selectedIndexes()
@@ -201,4 +206,4 @@
critical_error_message_box(UiStrings().LiveBGError,
unicode(translate('ImagePlugin.MediaItem',
'There was a problem replacing your background, '
- 'the image file "%s" no longer exists.')) % filename)
\ No newline at end of file
+ 'the image file "%s" no longer exists.')) % filename)
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2011-04-15 21:43:59 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2011-04-29 07:18:44 +0000
@@ -158,7 +158,10 @@
titles = []
for file in currlist:
titles.append(os.path.split(file)[1])
+ Receiver.send_message(u'cursor_busy')
+ self.parent.formparent.displayProgressBar(len(list))
for file in list:
+ self.parent.formparent.incrementProgressBar()
if currlist.count(file) > 0:
continue
filename = os.path.split(unicode(file))[1]
@@ -198,6 +201,8 @@
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
item_name.setIcon(icon)
self.listView.addItem(item_name)
+ Receiver.send_message(u'cursor_normal')
+ self.parent.formparent.finishedProgressBar()
def onDeleteClick(self):
"""
@@ -296,4 +301,4 @@
if self.controllers[controller].enabled():
if filetype in self.controllers[controller].alsosupports:
return controller
- return None
\ No newline at end of file
+ return None
Follow ups