def create_toolbars(self): def create(text, name): name += '-bar' b = self.addToolBar(text) b.setObjectName(name) # Needed for saveState setattr(self, name.replace('-', '_'), b) actions[name] = b.toggleViewAction() return b a = create(_('Book tool bar'), 'global').addAction for x in ('new_file', 'open_book', None, 'global_undo', 'global_redo', 'create_checkpoint', 'save', None, 'toc', 'check_book'): if x is None: self.global_bar.addSeparator() continue a(getattr(self, 'action_' + x)) self.donate_button = b = ThrobbingButton(self) b.clicked.connect(open_donate) b.setAutoRaise(True) self.donate_widget = w = create_donate_widget(b) if hasattr(w, 'filler'): w.filler.setVisible(False) b.set_normal_icon_size(self.global_bar.iconSize().width(), self.global_bar.iconSize().height()) b.setIcon(QIcon(I('donate.png'))) b.setToolTip(_('Donate to support calibre development')) QTimer.singleShot(10, b.start_animation) self.global_bar.addWidget(w) self.global_bar.addAction(self.action_insert_char) a(self.action_help) a = create(_('Polish book tool bar'), 'polish').addAction for x in ('embed_fonts', 'subset_fonts', 'smarten_punctuation', 'remove_unused_css'): a(getattr(self, 'action_' + x))
def create_toolbars(self): def create(text, name): name += '-bar' b = self.addToolBar(text) b.setObjectName(name) # Needed for saveState setattr(self, name.replace('-', '_'), b) actions[name] = b.toggleViewAction() return b a = create(_('Book tool bar'), 'global').addAction for x in ('new_file', 'open_book', None, 'global_undo', 'global_redo', 'create_checkpoint', 'save', None, 'toc', 'check_book', 'spell_check_book'): if x is None: self.global_bar.addSeparator() continue a(getattr(self, 'action_' + x)) self.donate_button = b = ThrobbingButton(self) b.clicked.connect(open_donate) b.setAutoRaise(True) self.donate_widget = w = create_donate_widget(b) if hasattr(w, 'filler'): w.filler.setVisible(False) b.set_normal_icon_size(self.global_bar.iconSize().width(), self.global_bar.iconSize().height()) b.setIcon(QIcon(I('donate.png'))) b.setToolTip(_('Donate to support calibre development')) QTimer.singleShot(10, b.start_animation) self.global_bar.addWidget(w) self.global_bar.addAction(self.action_insert_char) a(self.action_help) a = create(_('Polish book tool bar'), 'polish').addAction for x in ('embed_fonts', 'subset_fonts', 'smarten_punctuation', 'remove_unused_css'): a(getattr(self, 'action_' + x))
def init_bar(self, actions): self.showing_donate = False for ac in self.added_actions: m = ac.menu() if m is not None: m.setVisible(False) self.clear() self.added_actions = [] bar = self for what in actions: if what is None: bar.addSeparator() elif what == 'Location Manager': for ac in self.location_manager.all_actions: bar.addAction(ac) bar.added_actions.append(ac) bar.setup_tool_button(bar, ac, QToolButton.MenuButtonPopup) ac.setVisible(False) elif what == 'Donate': self.d_widget = create_donate_widget(self.donate_button) bar.addWidget(self.d_widget) self.showing_donate = True elif what in self.gui.iactions: action = self.gui.iactions[what] bar.addAction(action.qaction) self.added_actions.append(action.qaction) self.setup_tool_button(bar, action.qaction, action.popup_type) self.preferred_width = self.sizeHint().width()
def add(bar, ac): if ac is None: bar.addSeparator() elif ac == 'donate': self.donate_button = b = ThrobbingButton(self) b.clicked.connect(open_donate) b.setAutoRaise(True) self.donate_widget = w = create_donate_widget(b) if hasattr(w, 'filler'): w.filler.setVisible(False) b.set_normal_icon_size(self.global_bar.iconSize().width(), self.global_bar.iconSize().height()) b.setIcon(QIcon(I('donate.png'))) b.setToolTip(_('Donate to support calibre development')) if animate: QTimer.singleShot(10, b.start_animation) bar.addWidget(w) else: try: bar.addAction(actions[ac]) except KeyError: if DEBUG: prints('Unknown action for toolbar %r: %r' % (unicode(bar.objectName()), ac))