示例#1
0
文件: ui.py 项目: aaaaarg/caaaaalibre
    def rebuild_menus(self):
        ''' Builds the UI menus '''
        print('Rebuilding menus')
        m = self.menu
        m.clear()
        self.actions_unique_map = {}

        if False and prefs['username']=='guest' and prefs['password']=='guest':
            foo = True
        else:
            self.add_new_menu_item = create_menu_action_unique(self, m, _('&Add to Casanova') + '...', None, shortcut=False, triggered=self.add_book)
            self.casanova_book_submenu = m.addMenu(get_icon('images/link.png'), 'Linked text')
            self.create_menu_item_ex(self.casanova_book_submenu, 'Refresh metadata',
                    'images/update.png', 'Gets any updates to the metadata for this text from the server',
                    triggered=self.refresh_metadata)
            self.create_menu_item_ex(self.casanova_book_submenu, 'Upload metadata',
                    'images/commit.png', 'Send your metadata changes for this text to the server',
                    triggered=self.upload_metadata)
            self.casanova_book_submenu.addSeparator()
            self.create_menu_item_ex(self.casanova_book_submenu, 'Download',
                    'images/download.png', 'Download a file format from the Casanova server',
                    triggered=self.download_format)
            m.addSeparator()
            self.casanova_issue_submenu = m.addMenu(get_icon('images/link.png'), 'Get metadata')
            self.create_menu_item_ex(self.casanova_issue_submenu, 'Update issues',
                    'images/refresh.png', 'Get updates to issues from the Casanova server',
                    triggered=self.update_issues)
            self.author_menu_item = self.create_menu_item_ex(self.casanova_issue_submenu, 'Get all by author',
                    'images/download.png', 'Get metadata for all texts by this author',
                    triggered=self.update_author)
            self.create_menu_item_ex(self.casanova_issue_submenu, 'Search',
                    'images/download.png', 'Search Casanova titles and authors',
                    triggered=self.search)

        m.addSeparator()
        create_menu_action_unique(self, m, _('&Settings') + '...', None, shortcut=False, triggered=self.show_configuration)
        # Before we finalize, make sure we delete any actions for menus that are no longer displayed
        for menu_id, unique_name in self.old_actions_unique_map.iteritems():
            if menu_id not in self.actions_unique_map:
                self.gui.keyboard.unregister_shortcut(unique_name)
        self.old_actions_unique_map = self.actions_unique_map
        self.gui.keyboard.finalize()

        from calibre.gui2 import gprefs
        
        if self.name not in gprefs['action-layout-context-menu']:
            gprefs['action-layout-context-menu'] += (self.name, )
        if self.name not in gprefs['action-layout-toolbar']:
            gprefs['action-layout-toolbar'] += (self.name, )
        
        #gprefs['action-layout-context-menu'] += ('AAAARG', )
        #gprefs['action-layout-toolbar'] += ('AAAARG', )
        #print(gprefs['action-layout-toolbar'])
        # force add our menu into the gui toolbar
        #print(self.gui.tags_view.context_menu)
        #print(gprefs['action-layout-context-menu'])
        for x in (self.gui.preferences_action, self.qaction):
            x.triggered.connect(self.show_configuration)
示例#2
0
文件: ui.py 项目: aaaaarg/caaaaalibre
    def genesis(self):
        # This method is called once per plugin, do initial setup here
        self.old_actions_unique_map = {}

        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.menu = QMenu(self.gui)
        self.qaction.setMenu(self.menu)
        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))

        self.qaction.setMenu(self.menu)
示例#3
0
 def _display_choices(self, choices):
     self.values_list.clear()
     for id, name in choices.items():
         item = QListWidgetItem(get_icon('images/books.png'), name, self.values_list)
         item.setData(1, (id,))
         self.values_list.addItem(item)