forked from openlp/openlp
Add Progressbar
bzr-revno: 1501
This commit is contained in:
commit
1eeebeda1c
@ -554,4 +554,4 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
item_id = remoteItem
|
item_id = remoteItem
|
||||||
else:
|
else:
|
||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
return item_id
|
return item_id
|
||||||
|
@ -122,12 +122,17 @@ class Ui_MainWindow(object):
|
|||||||
self.HelpMenu = QtGui.QMenu(self.MenuBar)
|
self.HelpMenu = QtGui.QMenu(self.MenuBar)
|
||||||
self.HelpMenu.setObjectName(u'HelpMenu')
|
self.HelpMenu.setObjectName(u'HelpMenu')
|
||||||
mainWindow.setMenuBar(self.MenuBar)
|
mainWindow.setMenuBar(self.MenuBar)
|
||||||
self.StatusBar = QtGui.QStatusBar(mainWindow)
|
self.statusBar = QtGui.QStatusBar(mainWindow)
|
||||||
self.StatusBar.setObjectName(u'StatusBar')
|
self.statusBar.setObjectName(u'statusBar')
|
||||||
mainWindow.setStatusBar(self.StatusBar)
|
mainWindow.setStatusBar(self.statusBar)
|
||||||
self.DefaultThemeLabel = QtGui.QLabel(self.StatusBar)
|
self.loadProgressBar = QtGui.QProgressBar(self.statusBar)
|
||||||
self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel')
|
self.loadProgressBar.setObjectName(u'loadProgressBar')
|
||||||
self.StatusBar.addPermanentWidget(self.DefaultThemeLabel)
|
self.statusBar.addPermanentWidget(self.loadProgressBar)
|
||||||
|
self.loadProgressBar.hide()
|
||||||
|
self.loadProgressBar.setValue(0)
|
||||||
|
self.defaultThemeLabel = QtGui.QLabel(self.statusBar)
|
||||||
|
self.defaultThemeLabel.setObjectName(u'defaultThemeLabel')
|
||||||
|
self.statusBar.addPermanentWidget(self.defaultThemeLabel)
|
||||||
# Create the MediaManager
|
# Create the MediaManager
|
||||||
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
|
self.mediaManagerDock = OpenLPDockWidget(mainWindow,
|
||||||
u'mediaManagerDock', u':/system/system_mediamanager.png')
|
u'mediaManagerDock', u':/system/system_mediamanager.png')
|
||||||
@ -880,10 +885,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.setWindowTitle(title)
|
self.setWindowTitle(title)
|
||||||
|
|
||||||
def showStatusMessage(self, message):
|
def showStatusMessage(self, message):
|
||||||
self.StatusBar.showMessage(message)
|
self.statusBar.showMessage(message)
|
||||||
|
|
||||||
def defaultThemeChanged(self, theme):
|
def defaultThemeChanged(self, theme):
|
||||||
self.DefaultThemeLabel.setText(
|
self.defaultThemeLabel.setText(
|
||||||
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
|
unicode(translate('OpenLP.MainWindow', 'Default Theme: %s')) %
|
||||||
theme)
|
theme)
|
||||||
|
|
||||||
@ -979,7 +984,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
for fileId, filename in enumerate(recentFilesToDisplay):
|
for fileId, filename in enumerate(recentFilesToDisplay):
|
||||||
log.debug('Recent file name: %s', filename)
|
log.debug('Recent file name: %s', filename)
|
||||||
action = base_action(self, u'')
|
action = base_action(self, u'')
|
||||||
action.setText(u'&%d %s' %
|
action.setText(u'&%d %s' %
|
||||||
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
|
(fileId + 1, QtCore.QFileInfo(filename).fileName()))
|
||||||
action.setData(QtCore.QVariant(filename))
|
action.setData(QtCore.QVariant(filename))
|
||||||
self.connect(action, QtCore.SIGNAL(u'triggered()'),
|
self.connect(action, QtCore.SIGNAL(u'triggered()'),
|
||||||
@ -1008,3 +1013,34 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
while self.recentFiles.count() > maxRecentFiles:
|
while self.recentFiles.count() > maxRecentFiles:
|
||||||
# Don't care what API says takeLast works, removeLast doesn't!
|
# Don't care what API says takeLast works, removeLast doesn't!
|
||||||
self.recentFiles.takeLast()
|
self.recentFiles.takeLast()
|
||||||
|
|
||||||
|
def displayProgressBar(self, size):
|
||||||
|
"""
|
||||||
|
Make Progress bar visible and set size
|
||||||
|
"""
|
||||||
|
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 2.5 second
|
||||||
|
"""
|
||||||
|
self.timer_id = self.startTimer(2500)
|
||||||
|
|
||||||
|
def timerEvent(self, event):
|
||||||
|
"""
|
||||||
|
Remove the Progress bar from view.
|
||||||
|
"""
|
||||||
|
if event.timerId() == self.timer_id:
|
||||||
|
self.timer_id = 0
|
||||||
|
self.loadProgressBar.hide()
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
|
@ -460,7 +460,11 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
service = []
|
service = []
|
||||||
write_list = []
|
write_list = []
|
||||||
total_size = 0
|
total_size = 0
|
||||||
|
Receiver.send_message(u'cursor_busy')
|
||||||
|
# Number of items + 1 to zip it
|
||||||
|
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
||||||
for item in self.serviceItems:
|
for item in self.serviceItems:
|
||||||
|
self.mainwindow.incrementProgressBar()
|
||||||
service.append({u'serviceitem':
|
service.append({u'serviceitem':
|
||||||
item[u'service_item'].get_service_repr()})
|
item[u'service_item'].get_service_repr()})
|
||||||
if not item[u'service_item'].uses_file():
|
if not item[u'service_item'].uses_file():
|
||||||
@ -501,6 +505,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
|
log.debug(u'ServiceManager.saveFile - allowZip64 is %s' % allow_zip_64)
|
||||||
zip = None
|
zip = None
|
||||||
success = True
|
success = True
|
||||||
|
self.mainwindow.incrementProgressBar()
|
||||||
try:
|
try:
|
||||||
zip = zipfile.ZipFile(path_file_name, 'w', zipfile.ZIP_STORED,
|
zip = zipfile.ZipFile(path_file_name, 'w', zipfile.ZIP_STORED,
|
||||||
allow_zip_64)
|
allow_zip_64)
|
||||||
@ -516,6 +521,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
finally:
|
finally:
|
||||||
if zip:
|
if zip:
|
||||||
zip.close()
|
zip.close()
|
||||||
|
self.mainwindow.finishedProgressBar()
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
if success:
|
if success:
|
||||||
self.mainwindow.addRecentFile(path_file_name)
|
self.mainwindow.addRecentFile(path_file_name)
|
||||||
self.setModified(False)
|
self.setModified(False)
|
||||||
@ -576,13 +583,15 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
items = cPickle.load(fileTo)
|
items = cPickle.load(fileTo)
|
||||||
fileTo.close()
|
fileTo.close()
|
||||||
self.newFile()
|
self.newFile()
|
||||||
|
self.mainwindow.displayProgressBar(len(items))
|
||||||
for item in items:
|
for item in items:
|
||||||
|
self.mainwindow.incrementProgressBar()
|
||||||
serviceItem = ServiceItem()
|
serviceItem = ServiceItem()
|
||||||
serviceItem.from_service = True
|
serviceItem.from_service = True
|
||||||
serviceItem.renderer = self.mainwindow.renderer
|
serviceItem.renderer = self.mainwindow.renderer
|
||||||
serviceItem.set_from_service(item, self.servicePath)
|
serviceItem.set_from_service(item, self.servicePath)
|
||||||
self.validateItem(serviceItem)
|
self.validateItem(serviceItem)
|
||||||
self.addServiceItem(serviceItem)
|
self.addServiceItem(serviceItem, repaint=False)
|
||||||
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
|
if serviceItem.is_capable(ItemCapabilities.OnLoadUpdate):
|
||||||
Receiver.send_message(u'%s_service_load' %
|
Receiver.send_message(u'%s_service_load' %
|
||||||
serviceItem.name.lower(), serviceItem)
|
serviceItem.name.lower(), serviceItem)
|
||||||
@ -592,7 +601,6 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.setModified(False)
|
self.setModified(False)
|
||||||
QtCore.QSettings().setValue(
|
QtCore.QSettings().setValue(
|
||||||
'service/last file', QtCore.QVariant(fileName))
|
'service/last file', QtCore.QVariant(fileName))
|
||||||
Receiver.send_message(u'cursor_normal')
|
|
||||||
else:
|
else:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
message=translate('OpenLP.ServiceManager',
|
message=translate('OpenLP.ServiceManager',
|
||||||
@ -623,6 +631,9 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
fileTo.close()
|
fileTo.close()
|
||||||
if zip:
|
if zip:
|
||||||
zip.close()
|
zip.close()
|
||||||
|
self.mainwindow.finishedProgressBar()
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
self.repaintServiceList(-1, -1)
|
||||||
|
|
||||||
def loadLastFile(self):
|
def loadLastFile(self):
|
||||||
"""
|
"""
|
||||||
@ -1056,7 +1067,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
newItem)
|
newItem)
|
||||||
self.setModified()
|
self.setModified()
|
||||||
|
|
||||||
def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
|
def addServiceItem(self, item, rebuild=False, expand=None, replace=False,
|
||||||
|
repaint=True):
|
||||||
"""
|
"""
|
||||||
Add a Service item to the list
|
Add a Service item to the list
|
||||||
|
|
||||||
@ -1089,7 +1101,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.serviceItems.append({u'service_item': item,
|
self.serviceItems.append({u'service_item': item,
|
||||||
u'order': len(self.serviceItems) + 1,
|
u'order': len(self.serviceItems) + 1,
|
||||||
u'expanded': expand})
|
u'expanded': expand})
|
||||||
self.repaintServiceList(len(self.serviceItems) - 1, -1)
|
if repaint:
|
||||||
|
self.repaintServiceList(len(self.serviceItems) - 1, -1)
|
||||||
else:
|
else:
|
||||||
self.serviceItems.insert(self.dropPosition,
|
self.serviceItems.insert(self.dropPosition,
|
||||||
{u'service_item': item, u'order': self.dropPosition,
|
{u'service_item': item, u'order': self.dropPosition,
|
||||||
|
@ -77,7 +77,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
u'thumbnails')
|
u'thumbnails')
|
||||||
check_directory_exists(self.servicePath)
|
check_directory_exists(self.servicePath)
|
||||||
self.loadList(SettingsManager.load_list(
|
self.loadList(SettingsManager.load_list(
|
||||||
self.settingsSection, self.settingsSection))
|
self.settingsSection, self.settingsSection), True)
|
||||||
|
|
||||||
def addListViewToToolBar(self):
|
def addListViewToToolBar(self):
|
||||||
MediaManagerItem.addListViewToToolBar(self)
|
MediaManagerItem.addListViewToToolBar(self)
|
||||||
@ -107,8 +107,13 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
SettingsManager.set_list(self.settingsSection,
|
SettingsManager.set_list(self.settingsSection,
|
||||||
self.settingsSection, self.getFileList())
|
self.settingsSection, self.getFileList())
|
||||||
|
|
||||||
def loadList(self, list):
|
def loadList(self, list, initialLoad=False):
|
||||||
|
Receiver.send_message(u'cursor_busy')
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.displayProgressBar(len(list))
|
||||||
for imageFile in list:
|
for imageFile in list:
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.incrementProgressBar()
|
||||||
filename = os.path.split(unicode(imageFile))[1]
|
filename = os.path.split(unicode(imageFile))[1]
|
||||||
thumb = os.path.join(self.servicePath, filename)
|
thumb = os.path.join(self.servicePath, filename)
|
||||||
if os.path.exists(thumb):
|
if os.path.exists(thumb):
|
||||||
@ -122,6 +127,9 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
item_name.setIcon(icon)
|
item_name.setIcon(icon)
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
|
||||||
self.listView.addItem(item_name)
|
self.listView.addItem(item_name)
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.finishedProgressBar()
|
||||||
|
|
||||||
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
||||||
items = self.listView.selectedIndexes()
|
items = self.listView.selectedIndexes()
|
||||||
@ -201,4 +209,4 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
critical_error_message_box(UiStrings().LiveBGError,
|
critical_error_message_box(UiStrings().LiveBGError,
|
||||||
unicode(translate('ImagePlugin.MediaItem',
|
unicode(translate('ImagePlugin.MediaItem',
|
||||||
'There was a problem replacing your background, '
|
'There was a problem replacing your background, '
|
||||||
'the image file "%s" no longer exists.')) % filename)
|
'the image file "%s" no longer exists.')) % filename)
|
||||||
|
@ -158,7 +158,12 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
titles = []
|
titles = []
|
||||||
for file in currlist:
|
for file in currlist:
|
||||||
titles.append(os.path.split(file)[1])
|
titles.append(os.path.split(file)[1])
|
||||||
|
Receiver.send_message(u'cursor_busy')
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.displayProgressBar(len(list))
|
||||||
for file in list:
|
for file in list:
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.incrementProgressBar()
|
||||||
if currlist.count(file) > 0:
|
if currlist.count(file) > 0:
|
||||||
continue
|
continue
|
||||||
filename = os.path.split(unicode(file))[1]
|
filename = os.path.split(unicode(file))[1]
|
||||||
@ -198,6 +203,9 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
item_name.setIcon(icon)
|
item_name.setIcon(icon)
|
||||||
self.listView.addItem(item_name)
|
self.listView.addItem(item_name)
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
if not initialLoad:
|
||||||
|
self.parent.formparent.finishedProgressBar()
|
||||||
|
|
||||||
def onDeleteClick(self):
|
def onDeleteClick(self):
|
||||||
"""
|
"""
|
||||||
@ -296,4 +304,4 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
if self.controllers[controller].enabled():
|
if self.controllers[controller].enabled():
|
||||||
if filetype in self.controllers[controller].alsosupports:
|
if filetype in self.controllers[controller].alsosupports:
|
||||||
return controller
|
return controller
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user