fixed recent file menu

This commit is contained in:
Andreas Preikschat 2012-05-17 21:49:06 +02:00
parent 06e49d4b97
commit 3fa5422d7d
2 changed files with 10 additions and 12 deletions

View File

@ -1334,8 +1334,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
log.debug(u'Saving QSettings') log.debug(u'Saving QSettings')
settings = Settings() settings = Settings()
settings.beginGroup(self.generalSettingsSection) settings.beginGroup(self.generalSettingsSection)
recentFiles = self.recentFiles if self.recentFiles else u'' settings.setValue(
settings.setValue(u'recent files', recentFiles) u'recent files', self.recentFiles if self.recentFiles else list())
settings.endGroup() settings.endGroup()
settings.beginGroup(self.uiSettingsSection) settings.beginGroup(self.uiSettingsSection)
settings.setValue(u'main window position', self.pos()) settings.setValue(u'main window position', self.pos())
@ -1359,6 +1359,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
if os.path.isfile(unicode(recentFile))] if os.path.isfile(unicode(recentFile))]
recentFilesToDisplay = existingRecentFiles[0:recentFileCount] recentFilesToDisplay = existingRecentFiles[0:recentFileCount]
self.clearRecentFileMenu() self.clearRecentFileMenu()
self.recentFilesMenu.clear()
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 = create_action(self, u'', action = create_action(self, u'',
@ -1394,13 +1395,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
# in the given filename which then causes duplication. # in the given filename which then causes duplication.
if filename[1:3] == ':\\': if filename[1:3] == ':\\':
filename = filename[0].upper() + filename[1:] filename = filename[0].upper() + filename[1:]
position = self.recentFiles.indexOf(filename) if filename in self.recentFiles:
if position != -1: self.recentFiles.remove(filename)
self.recentFiles.removeAt(position)
self.recentFiles.insert(0, filename) self.recentFiles.insert(0, filename)
while self.recentFiles.count() > maxRecentFiles: while len(self.recentFiles) > maxRecentFiles:
# Don't care what API says takeLast works, removeLast doesn't! self.recentFiles.pop()
self.recentFiles.takeLast()
def clearRecentFileMenu(self): def clearRecentFileMenu(self):
""" """

View File

@ -593,15 +593,14 @@ class ServiceManager(QtGui.QWidget):
default_service_enabled = Settings().value( default_service_enabled = Settings().value(
u'advanced/default service enabled', True) u'advanced/default service enabled', True)
if default_service_enabled: if default_service_enabled:
service_day = Settings().value( service_day = Settings().value(u'advanced/default service day', 7)
u'advanced/default service day', 7).toInt()[0]
if service_day == 7: if service_day == 7:
time = datetime.now() time = datetime.now()
else: else:
service_hour = Settings().value( service_hour = Settings().value(
u'advanced/default service hour', 11).toInt()[0] u'advanced/default service hour', 11)
service_minute = Settings().value( service_minute = Settings().value(
u'advanced/default service minute', 0).toInt()[0] u'advanced/default service minute', 0)
now = datetime.now() now = datetime.now()
day_delta = service_day - now.weekday() day_delta = service_day - now.weekday()
if day_delta < 0: if day_delta < 0: