Fix bug when trying to set keyboard shortcuts for the viewer with a translated calibre interface. Also possible workarounf for cover flow related crash on OS X

This commit is contained in:
Kovid Goyal 2010-01-04 19:28:12 -07:00
parent c7ac9a5bdd
commit 60b290caed
3 changed files with 10 additions and 7 deletions

View File

@ -57,7 +57,13 @@ if pictureflow is not None:
return self.model.count() return self.model.count()
def caption(self, index): def caption(self, index):
return self.model.title(index) try:
ans = self.model.title(index)
if not ans:
ans = ''
except:
ans = ''
return ans
def reset(self): def reset(self):
self.emit(SIGNAL('dataChanged()')) self.emit(SIGNAL('dataChanged()'))

View File

@ -152,9 +152,9 @@ class Delegate(QStyledItemDelegate):
class Shortcuts(QAbstractListModel): class Shortcuts(QAbstractListModel):
TEMPLATE = ''' TEMPLATE = u'''
<p><b>{0}</b><br> <p><b>{0}</b><br>
Keys: <code>{1}</code></p> {2}: <code>{1}</code></p>
''' '''
def __init__(self, shortcuts, config_file_base_name, parent=None): def __init__(self, shortcuts, config_file_base_name, parent=None):
@ -212,7 +212,7 @@ class Shortcuts(QAbstractListModel):
key = self.order[row] key = self.order[row]
if role == Qt.DisplayRole: if role == Qt.DisplayRole:
return QVariant(self.TEMPLATE.format(self.descriptions[key], return QVariant(self.TEMPLATE.format(self.descriptions[key],
_(' or ').join(self.get_shortcuts(key)))) _(' or ').join(self.get_shortcuts(key)), _('Keys')))
if role == Qt.ToolTipRole: if role == Qt.ToolTipRole:
return QVariant(_('Double click to change')) return QVariant(_('Double click to change'))
if role == DEFAULTS: if role == DEFAULTS:

View File

@ -533,8 +533,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
if not config['separate_cover_flow']: if not config['separate_cover_flow']:
self.library.layout().addWidget(self.cover_flow) self.library.layout().addWidget(self.cover_flow)
self.cover_flow.currentChanged.connect(self.sync_listview_to_cf) self.cover_flow.currentChanged.connect(self.sync_listview_to_cf)
#self.connect(self.cover_flow, SIGNAL('itemActivated(int)'),
# self.show_book_info)
self.connect(self.status_bar.cover_flow_button, self.connect(self.status_bar.cover_flow_button,
SIGNAL('toggled(bool)'), self.toggle_cover_flow) SIGNAL('toggled(bool)'), self.toggle_cover_flow)
self.connect(self.cover_flow, SIGNAL('stop()'), self.connect(self.cover_flow, SIGNAL('stop()'),
@ -758,7 +756,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
sm.select(index, sm.ClearAndSelect|sm.Rows) sm.select(index, sm.ClearAndSelect|sm.Rows)
self.library_view.setCurrentIndex(index) self.library_view.setCurrentIndex(index)
except: except:
#raise
pass pass