Merge lp:~googol-deactivatedaccount/openlp/bug-818794 into lp:openlp

Proposed by Andreas Preikschat
Status: Merged
Approved by: Raoul Snyman
Approved revision: 1707
Merged at revision: 1708
Proposed branch: lp:~googol-deactivatedaccount/openlp/bug-818794
Merge into: lp:openlp
Diff against target: 110 lines (+34/-23)
1 file modified
openlp/core/ui/mainwindow.py (+34/-23)
To merge this branch: bzr merge lp:~googol-deactivatedaccount/openlp/bug-818794
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+71169@code.launchpad.net

Commit message

moved recent files to a menu (bug #818794)

Description of the change

Hello,

I have moved the "recent files" in the main menu to its own menu. (bug #818794) You can delete the list of recent files by clicking "Clear List" which is the last entry in the menu.

New stings:
&Recent Files (menu name)
Clear List (menu entry)
Clear the list of recent files. (status tooltip)

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/mainwindow.py'
2--- openlp/core/ui/mainwindow.py 2011-08-05 05:52:44 +0000
3+++ openlp/core/ui/mainwindow.py 2011-08-11 09:26:56 +0000
4@@ -109,6 +109,8 @@
5 self.menuBar.setObjectName(u'menuBar')
6 self.fileMenu = QtGui.QMenu(self.menuBar)
7 self.fileMenu.setObjectName(u'fileMenu')
8+ self.recentFilesMenu = QtGui.QMenu(self.fileMenu)
9+ self.recentFilesMenu.setObjectName(u'recentFilesMenu')
10 self.fileImportMenu = QtGui.QMenu(self.fileMenu)
11 self.fileImportMenu.setObjectName(u'fileImportMenu')
12 self.fileExportMenu = QtGui.QMenu(self.fileMenu)
13@@ -302,10 +304,11 @@
14 (self.importThemeItem, self.importLanguageItem))
15 add_actions(self.fileExportMenu,
16 (self.exportThemeItem, self.exportLanguageItem))
17- self.fileMenuActions = (self.fileNewItem, self.fileOpenItem,
18+ add_actions(self.fileMenu, (self.fileNewItem, self.fileOpenItem,
19 self.fileSaveItem, self.fileSaveAsItem, None,
20- self.printServiceOrderItem, None, self.fileImportMenu.menuAction(),
21- self.fileExportMenu.menuAction(), self.fileExitItem)
22+ self.recentFilesMenu.menuAction(), None, self.printServiceOrderItem,
23+ None, self.fileImportMenu.menuAction(),
24+ self.fileExportMenu.menuAction(), self.fileExitItem))
25 add_actions(self.viewModeMenu, (self.modeDefaultItem,
26 self.modeSetupItem, self.modeLiveItem))
27 add_actions(self.viewMenu, (self.viewModeMenu.menuAction(),
28@@ -346,7 +349,7 @@
29 self.mediaToolBox.setCurrentIndex(0)
30 # Connect up some signals and slots
31 QtCore.QObject.connect(self.fileMenu,
32- QtCore.SIGNAL(u'aboutToShow()'), self.updateFileMenu)
33+ QtCore.SIGNAL(u'aboutToShow()'), self.updateRecentFilesMenu)
34 QtCore.QMetaObject.connectSlotsByName(mainWindow)
35 # Hide the entry, as it does not have any functionality yet.
36 self.toolsAddToolItem.setVisible(False)
37@@ -363,6 +366,8 @@
38 self.fileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
39 self.fileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))
40 self.fileExportMenu.setTitle(translate('OpenLP.MainWindow', '&Export'))
41+ self.recentFilesMenu.setTitle(
42+ translate('OpenLP.MainWindow', '&Recent Files'))
43 self.viewMenu.setTitle(translate('OpenLP.MainWindow', '&View'))
44 self.viewModeMenu.setTitle(translate('OpenLP.MainWindow', 'M&ode'))
45 self.toolsMenu.setTitle(translate('OpenLP.MainWindow', '&Tools'))
46@@ -534,8 +539,8 @@
47 self.setupUi(self)
48 # Load settings after setupUi so default UI sizes are overwritten
49 self.loadSettings()
50- # Once settings are loaded update FileMenu with recentFiles
51- self.updateFileMenu()
52+ # Once settings are loaded update the menu with the recent files.
53+ self.updateRecentFilesMenu()
54 self.pluginForm = PluginForm(self)
55 # Set up signals and slots
56 QtCore.QObject.connect(self.importThemeItem,
57@@ -1137,30 +1142,36 @@
58 QtCore.QVariant(self.controlSplitter.saveState()))
59 settings.endGroup()
60
61- def updateFileMenu(self):
62+ def updateRecentFilesMenu(self):
63 """
64- Updates the file menu with the latest list of service files accessed.
65+ Updates the recent file menu with the latest list of service files
66+ accessed.
67 """
68 recentFileCount = QtCore.QSettings().value(
69 u'advanced/recent file count', QtCore.QVariant(4)).toInt()[0]
70- self.fileMenu.clear()
71- add_actions(self.fileMenu, self.fileMenuActions[:-1])
72 existingRecentFiles = [recentFile for recentFile in self.recentFiles
73 if QtCore.QFile.exists(recentFile)]
74 recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
75- if recentFilesToDisplay:
76- self.fileMenu.addSeparator()
77- for fileId, filename in enumerate(recentFilesToDisplay):
78- log.debug('Recent file name: %s', filename)
79- action = base_action(self, u'')
80- action.setText(u'&%d %s' %
81- (fileId + 1, QtCore.QFileInfo(filename).fileName()))
82- action.setData(QtCore.QVariant(filename))
83- self.connect(action, QtCore.SIGNAL(u'triggered()'),
84- self.serviceManagerContents.onRecentServiceClicked)
85- self.fileMenu.addAction(action)
86- self.fileMenu.addSeparator()
87- self.fileMenu.addAction(self.fileMenuActions[-1])
88+ self.recentFilesMenu.clear()
89+ for fileId, filename in enumerate(recentFilesToDisplay):
90+ log.debug('Recent file name: %s', filename)
91+ action = base_action(self, u'')
92+ action.setText(u'&%d %s' %
93+ (fileId + 1, QtCore.QFileInfo(filename).fileName()))
94+ action.setData(QtCore.QVariant(filename))
95+ self.connect(action, QtCore.SIGNAL(u'triggered()'),
96+ self.serviceManagerContents.onRecentServiceClicked)
97+ self.recentFilesMenu.addAction(action)
98+ clearRecentFilesAction = base_action(self, u'')
99+ clearRecentFilesAction.setText(
100+ translate('OpenLP.MainWindow', 'Clear List',
101+ 'Clear List of recent files'))
102+ clearRecentFilesAction.setStatusTip(
103+ translate('OpenLP.MainWindow', 'Clear the list of recent files.'))
104+ add_actions(self.recentFilesMenu, (None, clearRecentFilesAction))
105+ self.connect(clearRecentFilesAction, QtCore.SIGNAL(u'triggered()'),
106+ self.recentFiles.clear)
107+ clearRecentFilesAction.setEnabled(not self.recentFiles.isEmpty())
108
109 def addRecentFile(self, filename):
110 """