forked from openlp/openlp
moved recent files to a menu (bug #818794)
bzr-revno: 1708 Fixes: https://launchpad.net/bugs/818794
This commit is contained in:
commit
cb16463d99
@ -109,6 +109,8 @@ class Ui_MainWindow(object):
|
|||||||
self.menuBar.setObjectName(u'menuBar')
|
self.menuBar.setObjectName(u'menuBar')
|
||||||
self.fileMenu = QtGui.QMenu(self.menuBar)
|
self.fileMenu = QtGui.QMenu(self.menuBar)
|
||||||
self.fileMenu.setObjectName(u'fileMenu')
|
self.fileMenu.setObjectName(u'fileMenu')
|
||||||
|
self.recentFilesMenu = QtGui.QMenu(self.fileMenu)
|
||||||
|
self.recentFilesMenu.setObjectName(u'recentFilesMenu')
|
||||||
self.fileImportMenu = QtGui.QMenu(self.fileMenu)
|
self.fileImportMenu = QtGui.QMenu(self.fileMenu)
|
||||||
self.fileImportMenu.setObjectName(u'fileImportMenu')
|
self.fileImportMenu.setObjectName(u'fileImportMenu')
|
||||||
self.fileExportMenu = QtGui.QMenu(self.fileMenu)
|
self.fileExportMenu = QtGui.QMenu(self.fileMenu)
|
||||||
@ -302,10 +304,11 @@ class Ui_MainWindow(object):
|
|||||||
(self.importThemeItem, self.importLanguageItem))
|
(self.importThemeItem, self.importLanguageItem))
|
||||||
add_actions(self.fileExportMenu,
|
add_actions(self.fileExportMenu,
|
||||||
(self.exportThemeItem, self.exportLanguageItem))
|
(self.exportThemeItem, self.exportLanguageItem))
|
||||||
self.fileMenuActions = (self.fileNewItem, self.fileOpenItem,
|
add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem,
|
||||||
self.fileSaveItem, self.fileSaveAsItem, None,
|
self.fileSaveItem, self.fileSaveAsItem, None,
|
||||||
self.printServiceOrderItem, None, self.fileImportMenu.menuAction(),
|
self.recentFilesMenu.menuAction(), None, self.printServiceOrderItem,
|
||||||
self.fileExportMenu.menuAction(), self.fileExitItem)
|
None, self.fileImportMenu.menuAction(),
|
||||||
|
self.fileExportMenu.menuAction(), self.fileExitItem))
|
||||||
add_actions(self.viewModeMenu, (self.modeDefaultItem,
|
add_actions(self.viewModeMenu, (self.modeDefaultItem,
|
||||||
self.modeSetupItem, self.modeLiveItem))
|
self.modeSetupItem, self.modeLiveItem))
|
||||||
add_actions(self.viewMenu, (self.viewModeMenu.menuAction(),
|
add_actions(self.viewMenu, (self.viewModeMenu.menuAction(),
|
||||||
@ -346,7 +349,7 @@ class Ui_MainWindow(object):
|
|||||||
self.mediaToolBox.setCurrentIndex(0)
|
self.mediaToolBox.setCurrentIndex(0)
|
||||||
# Connect up some signals and slots
|
# Connect up some signals and slots
|
||||||
QtCore.QObject.connect(self.fileMenu,
|
QtCore.QObject.connect(self.fileMenu,
|
||||||
QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu)
|
QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu)
|
||||||
QtCore.QMetaObject.connectSlotsByName(mainWindow)
|
QtCore.QMetaObject.connectSlotsByName(mainWindow)
|
||||||
# Hide the entry, as it does not have any functionality yet.
|
# Hide the entry, as it does not have any functionality yet.
|
||||||
self.toolsAddToolItem.setVisible(False)
|
self.toolsAddToolItem.setVisible(False)
|
||||||
@ -363,6 +366,8 @@ class Ui_MainWindow(object):
|
|||||||
self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
|
self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
|
||||||
self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
|
self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
|
||||||
self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export'))
|
self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export'))
|
||||||
|
self.recentFilesMenu.setTitle(
|
||||||
|
translate('OpenLP.MainWindow', '&Recent Files'))
|
||||||
self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View'))
|
self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View'))
|
||||||
self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode'))
|
self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode'))
|
||||||
self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
|
self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
|
||||||
@ -534,8 +539,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Load settings after setupUi so default UI sizes are overwritten
|
# Load settings after setupUi so default UI sizes are overwritten
|
||||||
self.loadSettings()
|
self.loadSettings()
|
||||||
# Once settings are loaded update FileMenu with recentFiles
|
# Once settings are loaded update the menu with the recent files.
|
||||||
self.updateFileMenu()
|
self.updateRecentFilesMenu()
|
||||||
self.pluginForm = PluginForm(self)
|
self.pluginForm = PluginForm(self)
|
||||||
# Set up signals and slots
|
# Set up signals and slots
|
||||||
QtCore.QObject.connect(self.importThemeItem,
|
QtCore.QObject.connect(self.importThemeItem,
|
||||||
@ -1137,30 +1142,36 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
QtCore.QVariant(self.controlSplitter.saveState()))
|
QtCore.QVariant(self.controlSplitter.saveState()))
|
||||||
settings.endGroup()
|
settings.endGroup()
|
||||||
|
|
||||||
def updateFileMenu(self):
|
def updateRecentFilesMenu(self):
|
||||||
"""
|
"""
|
||||||
Updates the file menu with the latest list of service files accessed.
|
Updates the recent file menu with the latest list of service files
|
||||||
|
accessed.
|
||||||
"""
|
"""
|
||||||
recentFileCount = QtCore.QSettings().value(
|
recentFileCount = QtCore.QSettings().value(
|
||||||
u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0]
|
u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0]
|
||||||
self.fileMenu.clear()
|
|
||||||
add_actions(self.fileMenu, self.fileMenuActions[:-1])
|
|
||||||
existingRecentFiles = [recentFile for recentFile in self.recentFiles
|
existingRecentFiles = [recentFile for recentFile in self.recentFiles
|
||||||
if QtCore.QFile.exists(recentFile)]
|
if QtCore.QFile.exists(recentFile)]
|
||||||
recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
|
recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
|
||||||
if recentFilesToDisplay:
|
self.recentFilesMenu.clear()
|
||||||
self.fileMenu.addSeparator()
|
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()'),
|
self.serviceManagerContents.onRecentServiceClicked)
|
||||||
self.serviceManagerContents.onRecentServiceClicked)
|
self.recentFilesMenu.addAction(action)
|
||||||
self.fileMenu.addAction(action)
|
clearRecentFilesAction = base_action(self, u'')
|
||||||
self.fileMenu.addSeparator()
|
clearRecentFilesAction.setText(
|
||||||
self.fileMenu.addAction(self.fileMenuActions[-1])
|
translate('OpenLP.MainWindow', 'Clear List',
|
||||||
|
'Clear List of recent files'))
|
||||||
|
clearRecentFilesAction.setStatusTip(
|
||||||
|
translate('OpenLP.MainWindow', 'Clear the list of recent files.'))
|
||||||
|
add_actions(self.recentFilesMenu, (None, clearRecentFilesAction))
|
||||||
|
self.connect(clearRecentFilesAction, QtCore.SIGNAL(u'triggered()'),
|
||||||
|
self.recentFiles.clear)
|
||||||
|
clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty())
|
||||||
|
|
||||||
def addRecentFile(self, filename):
|
def addRecentFile(self, filename):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user