~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/gui2/tweak_book/ui.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    QVBoxLayout, QStackedWidget, QTabWidget, QImage, QPixmap, pyqtSignal,
17
17
    QMenu, QHBoxLayout, QTimer, QUrl)
18
18
 
19
 
from calibre.constants import __appname__, get_version
 
19
from calibre.constants import __appname__, get_version, isosx
20
20
from calibre.gui2 import elided_text, open_url
21
21
from calibre.gui2.keyboard import Manager as KeyboardManager
22
22
from calibre.gui2.main_window import MainWindow
270
270
        group = _('Global Actions')
271
271
 
272
272
        def reg(icon, text, target, sid, keys, description):
273
 
            ac = actions[sid] = QAction(QIcon(I(icon)), text, self) if icon else QAction(text, self)
 
273
            if not isinstance(icon, QIcon):
 
274
                icon = QIcon(I(icon))
 
275
            ac = actions[sid] = QAction(icon, text, self) if icon else QAction(text, self)
274
276
            ac.setObjectName('action-' + sid)
275
277
            if target is not None:
276
278
                ac.triggered.connect(target)
285
287
                                   'new-file', (), _('Create a new file in the current book'))
286
288
        self.action_import_files = reg(None, _('&Import files into book'), self.boss.add_files, 'new-files', (), _('Import files into book'))
287
289
        self.action_open_book = reg('document_open.png', _('Open &book'), self.boss.open_book, 'open-book', 'Ctrl+O', _('Open a new book'))
288
 
        self.action_global_undo = reg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', 'Ctrl+Left',
 
290
        # Qt does not generate shortcut overrides for cmd+arrow on os x which
 
291
        # means these shortcuts interfere with editing
 
292
        self.action_global_undo = reg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if isosx else 'Ctrl+Left',
289
293
                                      _('Revert book to before the last action (Undo)'))
290
 
        self.action_global_redo = reg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', 'Ctrl+Right',
 
294
        self.action_global_redo = reg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', () if isosx else 'Ctrl+Right',
291
295
                                      _('Revert book state to after the next action (Redo)'))
292
296
        self.action_save = reg('save.png', _('&Save'), self.boss.save_book, 'save-book', 'Ctrl+S', _('Save book'))
293
297
        self.action_save.setEnabled(False)
315
319
 
316
320
        def ereg(icon, text, target, sid, keys, description):
317
321
            return reg(icon, text, partial(self.boss.editor_action, target), sid, keys, description)
318
 
        register_text_editor_actions(ereg)
 
322
        register_text_editor_actions(ereg, self.palette())
319
323
 
320
324
        # Tool actions
321
325
        group = _('Tools')
322
326
        self.action_toc = reg('toc.png', _('&Edit Table of Contents'), self.boss.edit_toc, 'edit-toc', (), _('Edit Table of Contents'))
 
327
        self.action_inline_toc = reg('chapters.png', _('&Insert inline Table of Contents'),
 
328
                                     self.boss.insert_inline_toc, 'insert-inline-toc', (), _('Insert inline Table of Contents'))
323
329
        self.action_fix_html_current = reg('html-fix.png', _('&Fix HTML'), partial(self.boss.fix_html, True), 'fix-html-current', (),
324
330
                                           _('Fix HTML in the current file'))
325
331
        self.action_fix_html_all = reg('html-fix.png', _('&Fix HTML - all files'), partial(self.boss.fix_html, False), 'fix-html-all', (),
326
332
                                       _('Fix HTML in all files'))
327
 
        self.action_pretty_current = reg('format-justify-fill.png', _('&Beautify current file'), partial(self.boss.pretty_print, True), 'pretty-current', (),
 
333
        self.action_pretty_current = reg('beautify.png', _('&Beautify current file'), partial(self.boss.pretty_print, True), 'pretty-current', (),
328
334
                                           _('Beautify current file'))
329
 
        self.action_pretty_all = reg('format-justify-fill.png', _('&Beautify all files'), partial(self.boss.pretty_print, False), 'pretty-all', (),
 
335
        self.action_pretty_all = reg('beautify.png', _('&Beautify all files'), partial(self.boss.pretty_print, False), 'pretty-all', (),
330
336
                                       _('Beautify all files'))
331
337
        self.action_insert_char = reg('character-set.png', _('&Insert special character'), self.boss.insert_character, 'insert-character', (),
332
338
                                      _('Insert special character'))
448
454
        e.addAction(self.action_preferences)
449
455
 
450
456
        e = b.addMenu(_('&Tools'))
451
 
        e.addAction(self.action_toc)
 
457
        tm = e.addMenu(_('Table of Contents'))
 
458
        tm.addAction(self.action_toc)
 
459
        tm.addAction(self.action_inline_toc)
452
460
        e.addAction(self.action_embed_fonts)
453
461
        e.addAction(self.action_subset_fonts)
454
462
        e.addAction(self.action_smarten_punctuation)