Exemplo n.º 1
0
    def context_menu(self):
        popup_menu = HintedTextEdit.createStandardContextMenu(self)

        # Select the word under the cursor.
        cursor = self.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        spell_menu = None
        if self.textCursor().hasSelection():
            text = ustr(self.textCursor().selectedText())
            if not self.spellcheck.check(text):
                spell_menu = QMenu(N_('Spelling Suggestions'))
                for word in self.spellcheck.suggest(text):
                    action = SpellAction(word, spell_menu)
                    self.connect(action, SIGNAL('correct'), self.correct)
                    spell_menu.addAction(action)
                # Only add the spelling suggests to the menu if there are
                # suggestions.
                if len(spell_menu.actions()) > 0:
                    popup_menu.addSeparator()
                    popup_menu.addMenu(spell_menu)

        return popup_menu, spell_menu
Exemplo n.º 2
0
    def genesis(self):
        md = self.qaction.menu()
        cm = partial(self.create_menu_action, md)
        cm('individual', _('Edit metadata individually'), icon=self.qaction.icon(),
                triggered=partial(self.edit_metadata, False, bulk=False))
        md.addSeparator()
        cm('bulk', _('Edit metadata in bulk'),
                triggered=partial(self.edit_metadata, False, bulk=True))
        md.addSeparator()
        cm('download', _('Download metadata and covers'),
                triggered=partial(self.download_metadata, ids=None),
                shortcut='Ctrl+D')
        self.metadata_menu = md

        mb = QMenu()
        cm2 = partial(self.create_menu_action, mb)
        cm2('merge delete', _('Merge into first selected book - delete others'),
                triggered=self.merge_books)
        mb.addSeparator()
        cm2('merge keep', _('Merge into first selected book - keep others'),
                triggered=partial(self.merge_books, safe_merge=True),
                shortcut='Alt+M')
        mb.addSeparator()
        cm2('merge formats', _('Merge only formats into first selected book - delete others'),
                triggered=partial(self.merge_books, merge_only_formats=True),
                shortcut='Alt+Shift+M')
        self.merge_menu = mb
        md.addSeparator()
        self.action_merge = cm('merge', _('Merge book records'), icon='merge_books.png',
            shortcut=_('M'), triggered=self.merge_books)
        self.action_merge.setMenu(mb)

        self.qaction.triggered.connect(self.edit_metadata)
Exemplo n.º 3
0
 def showContextMenu(self, position):
     SuggestionContextMenu = self.ui.textEdit.createStandardContextMenu()
     cursor=self.ui.textEdit.textCursor()
     cursor.select(QTextCursor.WordUnderCursor)
     self.ui.textEdit.setTextCursor(cursor)
     if self.ui.textEdit.textCursor().hasSelection():
         a=self.ui.textEdit.textCursor().selectedText()
         if a[-1]==u'।':
             a=a.remove(u'।')
             cursor.movePosition(QTextCursor.Left,QTextCursor.KeepAnchor)
             self.ui.textEdit.setTextCursor(cursor)
         text = unicode(a).encode('utf-8')
         if not self.checker.spell(text):
             ignoreAction=QAction('Ignore',SuggestionContextMenu)
             ignoreAction.triggered.connect(self.ignoreSelection)
             addAction=QAction('Add to Dictionary',SuggestionContextMenu)
             addAction.triggered.connect(self.addWord)
             SuggestionContextMenu.insertSeparator(SuggestionContextMenu.actions()[0])
             SuggestionContextMenu.insertAction(SuggestionContextMenu.actions()[0], addAction)
             SuggestionContextMenu.insertAction(SuggestionContextMenu.actions()[0], ignoreAction)
             SuggestionMenu = QMenu('Spelling Suggestions')
             for word in self.checker.suggest(text):
                 word=word.decode('utf-8')
                 action = SuggestAction(word, SuggestionMenu)
                 action.correct.connect(self.replaceCorrect)
                 SuggestionMenu.addAction(action)
             if len(SuggestionMenu.actions()) != 0:
                SuggestionContextMenu.insertMenu(SuggestionContextMenu.actions()[0], SuggestionMenu)
     cursor.clearSelection()
     SuggestionContextMenu.exec_(self.ui.textEdit.mapToGlobal(position))
     self.ui.textEdit.setTextCursor(cursor)
Exemplo n.º 4
0
    def __init__(self):
        self.checked = QIcon(I('ok.png'))
        self.empty = QIcon(I('blank.png'))
        self.current_search_action = QAction(self.empty, _('*current search'), self)
        self.current_search_action.triggered.connect(partial(self.apply_virtual_library, library='*'))
        self.addAction(self.current_search_action)
        self.keyboard.register_shortcut(
            'vl-from-current-search', _('Virtual library from current search'), description=_(
                'Create a temporary Virtual library from the current search'), group=_('Miscellaneous'),
            default_keys=('Ctrl+*',), action=self.current_search_action)

        self.search_based_vl_name = None
        self.search_based_vl = None

        self.virtual_library_menu = QMenu()

        self.virtual_library.clicked.connect(self.virtual_library_clicked)
        self.clear_vl.clicked.connect(lambda x: (self.apply_virtual_library(), self.clear_additional_restriction()))

        self.virtual_library_tooltip = \
            _('Use a "virtual library" to show only a subset of the books present in this library')
        self.virtual_library.setToolTip(self.virtual_library_tooltip)

        self.search_restriction = ComboBoxWithHelp(self)
        self.search_restriction.setVisible(False)
        self.search_count.setText(_("(all books)"))
        self.ar_menu = QMenu(_('Additional restriction'))
        self.edit_menu = QMenu(_('Edit Virtual Library'))
        self.rm_menu = QMenu(_('Remove Virtual Library'))
Exemplo n.º 5
0
    def setupMenu(self):
        self.menu = QMenu("New")
        self.standardDevices = self.menu.addMenu(_("Standard"))
        self.lvmDevices = self.menu.addMenu(_("LVM"))
        self.raidDevices = self.menu.addMenu(_("RAID"))

        self.createPartition = self.standardDevices.addAction(_("Partition"))
        self.createPartition.setWhatsThis(_("General purpose of partition creation"))
        self.createPartition.setVisible(False)
        self.createPhysicalVolume = self.lvmDevices.addAction(_("Physical Volume"))
        self.createPhysicalVolume.setWhatsThis(_("Create LVM formatted partition"))
        self.createPhysicalVolume.setVisible(False)
        self.createVolumeGroup = self.lvmDevices.addAction(_("Volume Group"))
        self.createVolumeGroup.setWhatsThis(_("Requires at least 1 free LVM formatted partition"))
        self.createVolumeGroup.setVisible(False)
        self.createLogicalVolume = self.lvmDevices.addAction(_("Logical Volume"))
        self.createLogicalVolume.setWhatsThis(_("Create Logical Volume on selected Volume Group"))
        self.createLogicalVolume.setVisible(False)
        self.createRaidMember = self.raidDevices.addAction(_("Member"))
        self.createRaidMember.setWhatsThis(_("Create Raid formatted partition"))
        self.createRaidMember.setVisible(False)
        self.createRaidArray= self.raidDevices.addAction(_("Array"))
        self.createRaidArray.setWhatsThis(_("Requires at least 2 free Raid formatted partition"))
        self.createRaidArray.setVisible(False)

        self.ui.newButton.setMenu(self.menu)
Exemplo n.º 6
0
 def show_context_menu(self, point):
     item = self.folders.itemAt(point)
     if item is None:
         return
     m = QMenu(self)
     m.addAction(QIcon(I('mimetypes/dir.png')), _('Create new folder'), partial(self.create_folder, item))
     m.popup(self.folders.mapToGlobal(point))
Exemplo n.º 7
0
    def show_context_menu(self, point):
        self.context_item = self.table.itemAt(point)
        case_menu = QMenu(_('Change Case'))
        action_upper_case = case_menu.addAction(_('Upper Case'))
        action_lower_case = case_menu.addAction(_('Lower Case'))
        action_swap_case = case_menu.addAction(_('Swap Case'))
        action_title_case = case_menu.addAction(_('Title Case'))
        action_capitalize = case_menu.addAction(_('Capitalize'))

        action_upper_case.triggered.connect(self.upper_case)
        action_lower_case.triggered.connect(self.lower_case)
        action_swap_case.triggered.connect(self.swap_case)
        action_title_case.triggered.connect(self.title_case)
        action_capitalize.triggered.connect(self.capitalize)

        m = self.au_context_menu = QMenu()
        ca = m.addAction(_('Copy'))
        ca.triggered.connect(self.copy_to_clipboard)
        ca = m.addAction(_('Paste'))
        ca.triggered.connect(self.paste_from_clipboard)
        m.addSeparator()

        if self.context_item is not None and self.context_item.column() == 0:
            ca = m.addAction(_('Copy to author sort'))
            ca.triggered.connect(self.copy_au_to_aus)
        else:
            ca = m.addAction(_('Copy to author'))
            ca.triggered.connect(self.copy_aus_to_au)
        m.addSeparator()
        m.addMenu(case_menu)
        m.exec_(self.table.mapToGlobal(point))
Exemplo n.º 8
0
    def contextMenuEvent(self, event):
        popup_menu = self.createStandardContextMenu()
 
        # Select the word under the cursor.
        cursor = self.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.setTextCursor(cursor)
 
        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        if self.textCursor().hasSelection() and self._active:
            text = unicode(self.textCursor().selectedText())
            if not self.dict.check(text):
                spell_menu = QMenu('Spelling Suggestions')
                for word in self.dict.suggest(text):
                    action = SpellAction(word, spell_menu)
                    action.correct.connect(self.correctWord)
                    spell_menu.addAction(action)
                # Only add the spelling suggests to the menu if there are
                # suggestions.
                if len(spell_menu.actions()) != 0:
                    popup_menu.insertSeparator(popup_menu.actions()[0])
                    popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
 
        popup_menu.exec_(event.globalPos())
Exemplo n.º 9
0
    def contextMenuEvent(self, event):  #pos):
        popup_menu = self.textEdit.createStandardContextMenu()  #pos)

        # Select the word under the cursor.
        cursor = self.textEdit.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.textEdit.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        if self.textEdit.textCursor().hasSelection():
            text = unicode(self.textEdit.textCursor().selectedText())
            if not self.dict.check(text):
                #print "o0mad to0 dict :D"
                spell_menu = QMenu(u'شاید منظورتان این بوده:')
                #print spell_menu
                for word in self.dict.suggest(text):
                    action = SpellAction(word, spell_menu)
                    action.correct.connect(self.correctWord)
                    spell_menu.addAction(action)
                    #print word
                # Only add the spelling suggests to the menu if there are
                # suggestions.
                print len(spell_menu.actions())
                #print spell_menu.actions()
                if len(spell_menu.actions()) != 0:
                    popup_menu.insertSeparator(popup_menu.actions()[0])
                    popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)

        popup_menu.exec_(
            QCursor.
            pos())  #self.textEdit.mapToGlobal(QPoint(0, 0)))#.globalPos())
Exemplo n.º 10
0
        def ac(name, text, icon, tooltip):
            icon = QIcon(I(icon))
            ac = self.location_actions.addAction(icon, text)
            setattr(self, 'location_'+name, ac)
            ac.setAutoRepeat(False)
            ac.setCheckable(True)
            receiver = partial(self._location_selected, name)
            ac.triggered.connect(receiver)
            self.tooltips[name] = tooltip

            m = QMenu(parent)
            self._mem.append(m)
            a = m.addAction(icon, tooltip)
            a.triggered.connect(receiver)
            if name != 'library':
                self._mem.append(a)
                a = m.addAction(QIcon(I('eject.png')), _('Eject this device'))
                a.triggered.connect(self._eject_requested)
                self._mem.append(a)
                a = m.addAction(QIcon(I('config.png')), _('Configure this device'))
                a.triggered.connect(self._configure_requested)
                self._mem.append(a)
                a = m.addAction(QIcon(I('sync.png')), _('Update cached metadata on device'))
                a.triggered.connect(lambda x : self.update_device_metadata.emit())
                self._mem.append(a)

            else:
                ac.setToolTip(tooltip)
            ac.setMenu(m)
            ac.calibre_name = name

            self.all_actions.append(ac)
            return ac
Exemplo n.º 11
0
    def context_menu(self):
        popup_menu = HintedTextEdit.createStandardContextMenu(self)

        # Select the word under the cursor.
        cursor = self.textCursor()
        cursor.select(QTextCursor.WordUnderCursor)
        self.setTextCursor(cursor)

        # Check if the selected word is misspelled and offer spelling
        # suggestions if it is.
        spell_menu = None
        if self.textCursor().hasSelection():
            text = unicode(self.textCursor().selectedText())
            if not self.spellcheck.check(text):
                spell_menu = QMenu(N_('Spelling Suggestions'))
                for word in self.spellcheck.suggest(text):
                    action = SpellAction(word, spell_menu)
                    self.connect(action, SIGNAL('correct'), self.correct)
                    spell_menu.addAction(action)
                # Only add the spelling suggests to the menu if there are
                # suggestions.
                if len(spell_menu.actions()) > 0:
                    popup_menu.addSeparator()
                    popup_menu.addMenu(spell_menu)

        return popup_menu, spell_menu
Exemplo n.º 12
0
 def create_toolbars(self):
     self.action_bar = b = self.addToolBar(_('File actions tool bar'))
     b.setObjectName('action_bar')  # Needed for saveState
     for x in ('undo', 'redo'):
         b.addAction(actions['editor-%s' % x])
     self.edit_bar = b = self.addToolBar(_('Edit actions tool bar'))
     for x in ('cut', 'copy', 'paste'):
         b.addAction(actions['editor-%s' % x])
     self.tools_bar = b = self.addToolBar(_('Editor tools'))
     if self.syntax == 'html':
         b.addAction(actions['fix-html-current'])
     if self.syntax in {'xml', 'html', 'css'}:
         b.addAction(actions['pretty-current'])
     if self.syntax in {'html', 'css'}:
         b.addAction(actions['insert-image'])
     if self.syntax == 'html':
         self.format_bar = b = self.addToolBar(_('Format text'))
         for x in ('bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'color', 'background-color'):
             b.addAction(actions['format-text-%s' % x])
         ac = b.addAction(QIcon(I('format-text-heading.png')), _('Change paragraph to heading'))
         m = QMenu()
         ac.setMenu(m)
         b.widgetForAction(ac).setPopupMode(QToolButton.InstantPopup)
         for name in tuple('h%d' % d for d in range(1, 7)) + ('p',):
             m.addAction(actions['rename-block-tag-%s' % name])
Exemplo n.º 13
0
 def showContextMenu(self, position):
     SuggestionContextMenu = self.ui.textEdit.createStandardContextMenu()
     cursor = self.ui.textEdit.textCursor()
     cursor.select(QTextCursor.WordUnderCursor)
     self.ui.textEdit.setTextCursor(cursor)
     if self.ui.textEdit.textCursor().hasSelection():
         a = self.ui.textEdit.textCursor().selectedText()
         if a[-1] == u'।':
             a = a.remove(u'।')
             cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor)
             self.ui.textEdit.setTextCursor(cursor)
         text = unicode(a).encode('utf-8')
         if not self.checker.spell(text):
             ignoreAction = QAction('Ignore', SuggestionContextMenu)
             ignoreAction.triggered.connect(self.ignoreSelection)
             addAction = QAction('Add to Dictionary', SuggestionContextMenu)
             addAction.triggered.connect(self.addWord)
             SuggestionContextMenu.insertSeparator(
                 SuggestionContextMenu.actions()[0])
             SuggestionContextMenu.insertAction(
                 SuggestionContextMenu.actions()[0], addAction)
             SuggestionContextMenu.insertAction(
                 SuggestionContextMenu.actions()[0], ignoreAction)
             SuggestionMenu = QMenu('Spelling Suggestions')
             for word in self.checker.suggest(text):
                 word = word.decode('utf-8')
                 action = SuggestAction(word, SuggestionMenu)
                 action.correct.connect(self.replaceCorrect)
                 SuggestionMenu.addAction(action)
             if len(SuggestionMenu.actions()) != 0:
                 SuggestionContextMenu.insertMenu(
                     SuggestionContextMenu.actions()[0], SuggestionMenu)
     cursor.clearSelection()
     SuggestionContextMenu.exec_(self.ui.textEdit.mapToGlobal(position))
     self.ui.textEdit.setTextCursor(cursor)
Exemplo n.º 14
0
    def __init__(self, parent, db):
        QObject.__init__(self, parent)
        self.internet_connection_failed = False
        self._parent = parent
        self.no_internet_msg = _('Cannot download news as no internet connection '
                'is active')
        self.no_internet_dialog = d = error_dialog(self._parent,
                self.no_internet_msg, _('No internet connection'),
                show_copy_button=False)
        d.setModal(False)

        self.recipe_model = RecipeModel()
        self.db = db
        self.lock = QMutex(QMutex.Recursive)
        self.download_queue = set([])

        self.news_menu = QMenu()
        self.news_icon = QIcon(I('news.png'))
        self.scheduler_action = QAction(QIcon(I('scheduler.png')), _('Schedule news download'), self)
        self.news_menu.addAction(self.scheduler_action)
        self.scheduler_action.triggered[bool].connect(self.show_dialog)
        self.cac = QAction(QIcon(I('user_profile.png')), _('Add a custom news source'), self)
        self.cac.triggered[bool].connect(self.customize_feeds)
        self.news_menu.addAction(self.cac)
        self.news_menu.addSeparator()
        self.all_action = self.news_menu.addAction(
                _('Download all scheduled news sources'),
                self.download_all_scheduled)

        self.timer = QTimer(self)
        self.timer.start(int(self.INTERVAL * 60 * 1000))
        self.timer.timeout.connect(self.check)
        self.oldest = gconf['oldest_news']
        QTimer.singleShot(5 * 1000, self.oldest_check)
Exemplo n.º 15
0
 def build_menu(self, action):
     m = action.menu()
     ac = MenuAction(action, self)
     if m is None:
         m = QMenu()
         m.addAction(action)
     ac.setMenu(m)
     return ac
Exemplo n.º 16
0
    def genesis(self):
        self.count_changed(0)
        self.action_choose = self.menuless_qaction

        self.stats = LibraryUsageStats()
        self.popup_type = QToolButton.InstantPopup if len(self.stats.stats) > 1 else QToolButton.MenuButtonPopup
        if len(self.stats.stats) > 1:
            self.action_choose.triggered.connect(self.choose_library)
        else:
            self.qaction.triggered.connect(self.choose_library)

        self.choose_menu = self.qaction.menu()

        ac = self.create_action(spec=(_("Pick a random book"), "random.png", None, None), attr="action_pick_random")
        ac.triggered.connect(self.pick_random)

        if not os.environ.get("CALIBRE_OVERRIDE_DATABASE_PATH", None):
            self.choose_menu.addAction(self.action_choose)

            self.quick_menu = QMenu(_("Quick switch"))
            self.quick_menu_action = self.choose_menu.addMenu(self.quick_menu)
            self.rename_menu = QMenu(_("Rename library"))
            self.rename_menu_action = self.choose_menu.addMenu(self.rename_menu)
            self.choose_menu.addAction(ac)
            self.delete_menu = QMenu(_("Remove library"))
            self.delete_menu_action = self.choose_menu.addMenu(self.delete_menu)
        else:
            self.choose_menu.addAction(ac)

        self.rename_separator = self.choose_menu.addSeparator()

        self.switch_actions = []
        for i in range(5):
            ac = self.create_action(spec=("", None, None, None), attr="switch_action%d" % i)
            self.switch_actions.append(ac)
            ac.setVisible(False)
            ac.triggered.connect(partial(self.qs_requested, i), type=Qt.QueuedConnection)
            self.choose_menu.addAction(ac)

        self.rename_separator = self.choose_menu.addSeparator()

        self.maintenance_menu = QMenu(_("Library Maintenance"))
        ac = self.create_action(
            spec=(_("Library metadata backup status"), "lt.png", None, None), attr="action_backup_status"
        )
        ac.triggered.connect(self.backup_status, type=Qt.QueuedConnection)
        self.maintenance_menu.addAction(ac)
        ac = self.create_action(spec=(_("Check library"), "lt.png", None, None), attr="action_check_library")
        ac.triggered.connect(self.check_library, type=Qt.QueuedConnection)
        self.maintenance_menu.addAction(ac)
        ac = self.create_action(spec=(_("Restore database"), "lt.png", None, None), attr="action_restore_database")
        ac.triggered.connect(self.restore_database, type=Qt.QueuedConnection)
        self.maintenance_menu.addAction(ac)

        self.choose_menu.addMenu(self.maintenance_menu)
        self.view_state_map = {}
        self.restore_view_state.connect(self._restore_view_state, type=Qt.QueuedConnection)
Exemplo n.º 17
0
 def contextMenuEvent(self, ev):
     menu = QMenu(self)
     ca = self.pageAction(QWebPage.Copy)
     if ca.isEnabled():
         menu.addAction(ca)
     menu.addAction(actions['reload-preview'])
     menu.addAction(QIcon(I('debug.png')), _('Inspect element'),
                    self.inspect)
     menu.exec_(ev.globalPos())
Exemplo n.º 18
0
 def contextMenuEvent(self, ev):
     cm = QMenu(self)
     paste = cm.addAction(_("Paste Cover"))
     copy = cm.addAction(_("Copy Cover"))
     if not QApplication.instance().clipboard().mimeData().hasImage():
         paste.setEnabled(False)
     copy.triggered.connect(self.copy_to_clipboard)
     paste.triggered.connect(self.paste_from_clipboard)
     cm.exec_(ev.globalPos())
Exemplo n.º 19
0
 def build_context_menu(self):
     cm = QMenu(self)
     paste = cm.addAction(_('Paste Cover'))
     copy = cm.addAction(_('Copy Cover'))
     if not QApplication.instance().clipboard().mimeData().hasImage():
         paste.setEnabled(False)
     copy.triggered.connect(self.copy_to_clipboard)
     paste.triggered.connect(self.paste_from_clipboard)
     return cm
Exemplo n.º 20
0
    def __init__(self, shortcuts, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

        for x in ('text', 'background'):
            getattr(self, 'change_%s_color_button' % x).clicked.connect(
                partial(self.change_color, x, reset=False))
            getattr(self, 'reset_%s_color_button' % x).clicked.connect(
                partial(self.change_color, x, reset=True))
        self.css.setToolTip(
            _('Set the user CSS stylesheet. This can be used to customize the look of all books.'
              ))

        self.shortcuts = shortcuts
        self.shortcut_config = ShortcutConfig(shortcuts, parent=self)
        bb = self.buttonBox
        bb.button(bb.RestoreDefaults).clicked.connect(self.restore_defaults)

        with zipfile.ZipFile(
                P('viewer/hyphenate/patterns.zip', allow_user_override=False),
                'r') as zf:
            pats = [x.split('.')[0].replace('-', '_') for x in zf.namelist()]
        names = list(map(get_language, pats))
        pmap = {}
        for i in range(len(pats)):
            pmap[names[i]] = pats[i]
        for x in sorted(names):
            self.hyphenate_default_lang.addItem(x, QVariant(pmap[x]))
        self.hyphenate_pats = pats
        self.hyphenate_names = names
        p = self.tabs.widget(1)
        p.layout().addWidget(self.shortcut_config)

        if isxp:
            self.hyphenate.setVisible(False)
            self.hyphenate_default_lang.setVisible(False)
            self.hyphenate_label.setVisible(False)

        self.themes = load_themes()
        self.save_theme_button.clicked.connect(self.save_theme)
        self.load_theme_button.m = m = QMenu()
        self.load_theme_button.setMenu(m)
        m.triggered.connect(self.load_theme)
        self.delete_theme_button.m = m = QMenu()
        self.delete_theme_button.setMenu(m)
        m.triggered.connect(self.delete_theme)

        opts = config().parse()
        self.load_options(opts)
        self.init_load_themes()

        self.clear_search_history_button.clicked.connect(
            self.clear_search_history)
        self.resize(self.width(),
                    min(self.height(), max(575,
                                           min_available_height() - 25)))
Exemplo n.º 21
0
 def build_email_entries(self, sync_menu):
     from calibre.gui2.device import DeviceAction
     for ac in self.email_actions:
         self.removeAction(ac)
     self.email_actions = []
     self.memory = []
     opts = email_config().parse()
     if opts.accounts:
         self.email_to_menu = QMenu(_('Email to') + '...', self)
         ac = self.addMenu(self.email_to_menu)
         self.email_actions.append(ac)
         self.email_to_and_delete_menu = QMenu(
             _('Email to and delete from library') + '...', self)
         keys = sorted(opts.accounts.keys())
         for account in keys:
             formats, auto, default = opts.accounts[account]
             subject = opts.subjects.get(account, '')
             alias = opts.aliases.get(account, '')
             dest = 'mail:' + account + ';' + formats + ';' + subject
             action1 = DeviceAction(dest, False, False, I('mail.png'), alias
                                    or account)
             action2 = DeviceAction(dest, True, False, I('mail.png'),
                                    (alias or account) + ' ' +
                                    _('(delete from library)'))
             self.email_to_menu.addAction(action1)
             self.email_to_and_delete_menu.addAction(action2)
             map(self.memory.append, (action1, action2))
             if default:
                 ac = DeviceAction(dest, False, False, I('mail.png'),
                                   _('Email to') + ' ' + (alias or account))
                 self.addAction(ac)
                 self.email_actions.append(ac)
                 ac.a_s.connect(sync_menu.action_triggered)
             action1.a_s.connect(sync_menu.action_triggered)
             action2.a_s.connect(sync_menu.action_triggered)
         action1 = DeviceAction('choosemail:', False, False, I('mail.png'),
                                _('Select recipients'))
         action2 = DeviceAction(
             'choosemail:', True, False, I('mail.png'),
             _('Select recipients') + ' ' + _('(delete from library)'))
         self.email_to_menu.addAction(action1)
         self.email_to_and_delete_menu.addAction(action2)
         map(self.memory.append, (action1, action2))
         tac1 = DeviceAction('choosemail:', False, False, I('mail.png'),
                             _('Email to selected recipients...'))
         self.addAction(tac1)
         tac1.a_s.connect(sync_menu.action_triggered)
         self.memory.append(tac1)
         ac = self.addMenu(self.email_to_and_delete_menu)
         self.email_actions.append(ac)
         action1.a_s.connect(sync_menu.action_triggered)
         action2.a_s.connect(sync_menu.action_triggered)
     else:
         ac = self.addAction(_('Setup email based sharing of books'))
         self.email_actions.append(ac)
         ac.triggered.connect(self.setup_email)
Exemplo n.º 22
0
 def create_application_menubar(cls):
     mb = QMenuBar(None)
     menu = QMenu()
     for action in cls.get_menubar_actions():
         menu.addAction(action)
         cls.__actions.append(action)
         yield action
     mb.addMenu(menu)
     cls.___menu_bar = mb
     cls.___menu = menu
Exemplo n.º 23
0
 def create_application_menubar(cls):
     mb = QMenuBar(None)
     menu = QMenu()
     for action in cls.get_menubar_actions():
         menu.addAction(action)
         cls.__actions.append(action)
         yield action
     mb.addMenu(menu)
     cls.___menu_bar = mb
     cls.___menu = menu
Exemplo n.º 24
0
 def build_email_entries(self, sync_menu):
     from calibre.gui2.device import DeviceAction
     for ac in self.email_actions:
         self.removeAction(ac)
     self.email_actions = []
     self.memory = []
     opts = email_config().parse()
     if opts.accounts:
         self.email_to_menu = QMenu(_('Email to')+'...', self)
         ac = self.addMenu(self.email_to_menu)
         self.email_actions.append(ac)
         self.email_to_and_delete_menu = QMenu(
                 _('Email to and delete from library')+'...', self)
         keys = sorted(opts.accounts.keys())
         for account in keys:
             formats, auto, default = opts.accounts[account]
             subject = opts.subjects.get(account, '')
             alias = opts.aliases.get(account, '')
             dest = 'mail:'+account+';'+formats+';'+subject
             action1 = DeviceAction(dest, False, False, I('mail.png'),
                     alias or account)
             action2 = DeviceAction(dest, True, False, I('mail.png'),
                     (alias or account) + ' ' + _('(delete from library)'))
             self.email_to_menu.addAction(action1)
             self.email_to_and_delete_menu.addAction(action2)
             map(self.memory.append, (action1, action2))
             if default:
                 ac = DeviceAction(dest, False, False,
                         I('mail.png'), _('Email to') + ' ' +(alias or
                             account))
                 self.addAction(ac)
                 self.email_actions.append(ac)
                 ac.a_s.connect(sync_menu.action_triggered)
             action1.a_s.connect(sync_menu.action_triggered)
             action2.a_s.connect(sync_menu.action_triggered)
         action1 = DeviceAction('choosemail:', False, False, I('mail.png'),
                 _('Select recipients'))
         action2 = DeviceAction('choosemail:', True, False, I('mail.png'),
                 _('Select recipients') + ' ' + _('(delete from library)'))
         self.email_to_menu.addAction(action1)
         self.email_to_and_delete_menu.addAction(action2)
         map(self.memory.append, (action1, action2))
         tac1 = DeviceAction('choosemail:', False, False, I('mail.png'),
                 _('Email to selected recipients...'))
         self.addAction(tac1)
         tac1.a_s.connect(sync_menu.action_triggered)
         self.memory.append(tac1)
         ac = self.addMenu(self.email_to_and_delete_menu)
         self.email_actions.append(ac)
         action1.a_s.connect(sync_menu.action_triggered)
         action2.a_s.connect(sync_menu.action_triggered)
     else:
         ac = self.addAction(_('Setup email based sharing of books'))
         self.email_actions.append(ac)
         ac.triggered.connect(self.setup_email)
Exemplo n.º 25
0
class MenuBar(QMenuBar): # {{{

    def __init__(self, location_manager, parent):
        QMenuBar.__init__(self, parent)
        self.gui = parent
        self.setNativeMenuBar(True)

        self.location_manager = location_manager
        self.added_actions = []

        self.donate_action = QAction(_('Donate'), self)
        self.donate_menu = QMenu()
        self.donate_menu.addAction(self.gui.donate_action)
        self.donate_action.setMenu(self.donate_menu)

    def update_lm_actions(self):
        for ac in self.added_actions:
            clone = getattr(ac, 'clone', None)
            if clone is not None and clone in self.location_manager.all_actions:
                ac.setVisible(clone in self.location_manager.available_actions)

    def init_bar(self, actions):
        for ac in self.added_actions:
            m = ac.menu()
            if m is not None:
                m.setVisible(False)

        self.clear()
        self.added_actions = []

        for what in actions:
            if what is None:
                continue
            elif what == 'Location Manager':
                for ac in self.location_manager.all_actions:
                    ac = self.build_menu(ac)
                    self.addAction(ac)
                    self.added_actions.append(ac)
                    ac.setVisible(False)
            elif what == 'Donate':
                self.addAction(self.donate_action)
            elif what in self.gui.iactions:
                action = self.gui.iactions[what]
                ac = self.build_menu(action.qaction)
                self.addAction(ac)
                self.added_actions.append(ac)

    def build_menu(self, action):
        m = action.menu()
        ac = MenuAction(action, self)
        if m is None:
            m = QMenu()
            m.addAction(action)
        ac.setMenu(m)
        return ac
Exemplo n.º 26
0
class MenuBar(QMenuBar):  # {{{

    def __init__(self, location_manager, parent):
        QMenuBar.__init__(self, parent)
        self.gui = parent
        self.setNativeMenuBar(True)

        self.location_manager = location_manager
        self.added_actions = []

        self.donate_action = QAction(_('Donate'), self)
        self.donate_menu = QMenu()
        self.donate_menu.addAction(self.gui.donate_action)
        self.donate_action.setMenu(self.donate_menu)

    def update_lm_actions(self):
        for ac in self.added_actions:
            clone = getattr(ac, 'clone', None)
            if clone is not None and clone in self.location_manager.all_actions:
                ac.setVisible(clone in self.location_manager.available_actions)

    def init_bar(self, actions):
        for ac in self.added_actions:
            m = ac.menu()
            if m is not None:
                m.setVisible(False)

        self.clear()
        self.added_actions = []

        for what in actions:
            if what is None:
                continue
            elif what == 'Location Manager':
                for ac in self.location_manager.all_actions:
                    ac = self.build_menu(ac)
                    self.addAction(ac)
                    self.added_actions.append(ac)
                    ac.setVisible(False)
            elif what == 'Donate':
                self.addAction(self.donate_action)
            elif what in self.gui.iactions:
                action = self.gui.iactions[what]
                ac = self.build_menu(action.qaction)
                self.addAction(ac)
                self.added_actions.append(ac)

    def build_menu(self, action):
        m = action.menu()
        ac = MenuAction(action, self)
        if m is None:
            m = QMenu()
            m.addAction(action)
        ac.setMenu(m)
        return ac
Exemplo n.º 27
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        mitem = self.addAction(QIcon(I('devices/folder.png')),
                               _('Connect to folder'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem
        mitem = self.addAction(QIcon(I('devices/itunes.png')),
                               _('Connect to iTunes'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_itunes.emit())
        self.connect_to_itunes_action = mitem
        if not (iswindows or isosx):
            mitem.setVisible(False)
        mitem = self.addAction(QIcon(I('devices/bambook.png')),
                               _('Connect to Bambook'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_bambook.emit())
        self.connect_to_bambook_action = mitem
        bambook_visible = False
        if not is_disabled(BAMBOOK):
            device_ip = BAMBOOK.settings().extra_customization
            if device_ip:
                bambook_visible = True
        self.connect_to_bambook_action.setVisible(bambook_visible)

        self.addSeparator()
        self.toggle_server_action = \
            self.addAction(QIcon(I('network-server.png')),
            _('Start Content Server'))
        self.toggle_server_action.triggered.connect(
            lambda x: self.toggle_server.emit())
        self.control_smartdevice_action = \
            self.addAction(QIcon(I('dot_red.png')),
            self.DEVICE_MSGS[0])
        self.control_smartdevice_action.triggered.connect(
            lambda x: self.control_smartdevice.emit())
        self.addSeparator()

        self.email_actions = []

        if hasattr(parent, 'keyboard'):
            r = parent.keyboard.register_shortcut
            prefix = 'Share/Connect Menu '
            gr = ConnectShareAction.action_spec[0]
            for attr in ('folder', 'bambook', 'itunes'):
                if not (iswindows or isosx) and attr == 'itunes':
                    continue
                ac = getattr(self, 'connect_to_%s_action' % attr)
                r(prefix + attr, unicode(ac.text()), action=ac, group=gr)
            r(prefix + ' content server',
              _('Start/stop content server'),
              action=self.toggle_server_action,
              group=gr)
   def showOrdContextMenu(self):
      menu = QMenu(self.segOrdListBox)
      if len(self.segOrdListBox.selectedItems())==0:
         return

      item = self.segOrdListBox.currentItem()
      deleteOrdMenuItem = menu.addAction("Delete Ordering")
      action = menu.exec_(QCursor.pos())
      
      if action == deleteOrdMenuItem:
         self.deleteOrdItem(item)
Exemplo n.º 29
0
 def displayContextMenu(self, pos):
     """
     type pos: int
     """
     menu = QMenu()
     removeAction = menu.addAction("Remove")
     action = menu.exec_(self.mapToGlobal(pos))
     if action == removeAction:
         while self.filterTable.rowCount() > self.row + 1:
             self.filterTable.removeRow(self.filterTable.rowCount() - 1)
         self.filterTable.removeCellWidget(self.row, self.filtTableConnectCol)
   def showSegContextMenu(self):
      menu = QMenu(self.segDefTableView)
      if len(self.segDefTableView.selectedIndexes())==0:
         return

      row = self.segDefTableView.selectedIndexes()[0].row()
      deleteSegMenuItem = menu.addAction("Delete Segment")
      action = menu.exec_(QCursor.pos())
      
      if action == deleteSegMenuItem:
         self.deleteSegRow(row)
Exemplo n.º 31
0
 def contextMenuEvent(self, ev):
     menu = QMenu(self)
     ca = self.pageAction(QWebPage.Copy)
     if ca.isEnabled():
         menu.addAction(ca)
     menu.addAction(actions['reload-preview'])
     menu.addAction(QIcon(I('debug.png')), _('Inspect element'), self.inspect)
     menu.exec_(ev.globalPos())
Exemplo n.º 32
0
    def create_action(self, spec=None, attr='qaction', shortcut_name=None):
        if spec is None:
            spec = self.action_spec
        text, icon, tooltip, shortcut = spec
        if icon is not None:
            action = QAction(QIcon(I(icon)), text, self.gui)
        else:
            action = QAction(text, self.gui)
        if attr == 'qaction':
            mt = (action.text() if self.action_menu_clone_qaction is True else
                    unicode(self.action_menu_clone_qaction))
            self.menuless_qaction = ma = QAction(action.icon(), mt, self.gui)
            ma.triggered.connect(action.trigger)
        for a in ((action, ma) if attr == 'qaction' else (action,)):
            a.setAutoRepeat(self.auto_repeat)
            text = tooltip if tooltip else text
            a.setToolTip(text)
            a.setStatusTip(text)
            a.setWhatsThis(text)
        shortcut_action = action
        desc = tooltip if tooltip else None
        if attr == 'qaction':
            shortcut_action = ma
        if shortcut is not None:
            keys = ((shortcut,) if isinstance(shortcut, basestring) else
                    tuple(shortcut))
            if shortcut_name is None and spec[0]:
                shortcut_name = unicode(spec[0])

            if shortcut_name and self.action_spec[0] and not (
                    attr == 'qaction' and self.popup_type == QToolButton.InstantPopup):
                try:
                    self.gui.keyboard.register_shortcut(self.unique_name + ' - ' + attr,
                        shortcut_name, default_keys=keys,
                        action=shortcut_action, description=desc,
                        group=self.action_spec[0])
                except NameConflict as e:
                    try:
                        prints(unicode(e))
                    except:
                        pass
                    shortcut_action.setShortcuts([QKeySequence(key,
                        QKeySequence.PortableText) for key in keys])


        if attr is not None:
            setattr(self, attr, action)
        if attr == 'qaction' and self.action_add_menu:
            menu = QMenu()
            action.setMenu(menu)
            if self.action_menu_clone_qaction:
                menu.addAction(self.menuless_qaction)
        return action
Exemplo n.º 33
0
 def contextMenuEvent(self, event):
     index = self.indexAt(event.pos())
     
     if not index.isValid():
         return
     
     plugin = self.model().get_plugin(index)
     
     menu = QMenu()
     ca = menu.addAction(_('Configure...'), partial(self.configure_plugin, plugin))
     if not plugin.is_customizable():
         ca.setEnabled(False)
     menu.exec_(event.globalPos())
Exemplo n.º 34
0
 def context_menu(self, pos):
     index = self.indexAt(pos)
     if index.isValid():
         char_code, ok = self.model().data(index, Qt.UserRole).toInt()
         if ok:
             m = QMenu(self)
             m.addAction(QIcon(I('edit-copy.png')), _('Copy %s to clipboard') % chr(char_code), partial(self.copy_to_clipboard, char_code))
             m.addAction(QIcon(I('rating.png')),
                         (_('Remove %s from favorites') if self.showing_favorites else _('Add %s to favorites')) % chr(char_code),
                         partial(self.remove_from_favorites, char_code))
             if self.showing_favorites:
                 m.addAction(_('Restore favorites to defaults'), self.restore_defaults)
             m.exec_(self.mapToGlobal(pos))
Exemplo n.º 35
0
 def show_context_menu(self, point):
     idx = self.tweaks_view.currentIndex()
     if not idx.isValid():
         return True
     tweak = self.tweaks.data(idx, Qt.UserRole)
     self.context_menu = QMenu(self)
     self.context_menu.addAction(
         self.copy_icon, _('Copy to clipboard'),
         partial(self.copy_item_to_clipboard,
                 val=u"%s (%s: %s)" %
                 (tweak.name, _('ID'), tweak.var_names[0])))
     self.context_menu.popup(self.mapToGlobal(point))
     return True
Exemplo n.º 36
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        mitem = self.addAction(QIcon(I('devices/folder.png')), _('Connect to folder'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem
        mitem = self.addAction(QIcon(I('devices/itunes.png')),
                _('Connect to iTunes'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_itunes.emit())
        self.connect_to_itunes_action = mitem
        if not (iswindows or isosx):
            mitem.setVisible(False)
        mitem = self.addAction(QIcon(I('devices/bambook.png')), _('Connect to Bambook'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_bambook.emit())
        self.connect_to_bambook_action = mitem
        bambook_visible = False
        if not is_disabled(BAMBOOK):
            device_ip = BAMBOOK.settings().extra_customization
            if device_ip:
                bambook_visible = True
        self.connect_to_bambook_action.setVisible(bambook_visible)

        self.addSeparator()
        self.toggle_server_action = \
            self.addAction(QIcon(I('network-server.png')),
            _('Start Content Server'))
        self.toggle_server_action.triggered.connect(lambda x:
                self.toggle_server.emit())
        self.control_smartdevice_action = \
            self.addAction(QIcon(I('dot_red.png')),
            self.DEVICE_MSGS[0])
        self.control_smartdevice_action.triggered.connect(lambda x:
                self.control_smartdevice.emit())
        self.addSeparator()

        self.email_actions = []

        if hasattr(parent, 'keyboard'):
            r = parent.keyboard.register_shortcut
            prefix = 'Share/Connect Menu '
            gr = ConnectShareAction.action_spec[0]
            for attr in ('folder', 'bambook', 'itunes'):
                if not (iswindows or isosx) and attr == 'itunes':
                    continue
                ac = getattr(self, 'connect_to_%s_action'%attr)
                r(prefix + attr, unicode(ac.text()), action=ac,
                        group=gr)
            r(prefix+' content server', _('Start/stop content server'),
                    action=self.toggle_server_action, group=gr)
Exemplo n.º 37
0
 def contextMenuEvent(self, ev):
     m = QMenu(self)
     m.addAction(_('Sort alphabetically'), self.sort_alphabetically)
     hidden = self.current_db.prefs['virt_libs_hidden']
     if hidden:
         s = m._s = m.addMenu(_('Restore hidden tabs'))
         for x in hidden:
             s.addAction(x, partial(self.restore, x))
     m.addAction(_('Hide virtual library tabs'), self.disable_bar)
     m.exec_(ev.globalPos())
Exemplo n.º 38
0
 def openMenu(self, position):
     """
     Method that handles actions from context menu.
     Parameters:
     position - Position of the action on screen (right click).
     """
     menu = QMenu()
     copyChannels = menu.addAction("Copy channels to all time series")
     clearChannels = menu.addAction("Clear")
     action = menu.exec_(self.ui.listWidgetChannels.mapToGlobal(position))
     if action == copyChannels:
         self.channelCopy.emit(self.index)
     elif action == clearChannels:
         self.ui.listWidgetChannels.clear()
Exemplo n.º 39
0
 def _setFindOptionsToolButtonMenu(self):
     """
     Sets the menu for the findOptionstoolbutton that appears a small
     menu button next to the findLineEdit.
     """
     self.findOptionsMenu = QMenu(self.findOptionsToolButton)
     self.caseSensitiveFindAction = QAction(self.findOptionsToolButton)
     self.caseSensitiveFindAction.setText('Match Case')
     self.caseSensitiveFindAction.setCheckable(True)
     self.caseSensitiveFindAction.setChecked(False)
     self.findOptionsMenu.addAction(self.caseSensitiveFindAction)
     self.findOptionsMenu.addSeparator()
     self.findOptionsToolButton.setMenu(self.findOptionsMenu)
     return
Exemplo n.º 40
0
    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.setWindowTitle(_('Create ToC from XPath'))
        self.l = l = QVBoxLayout()
        self.setLayout(l)
        self.la = la = QLabel(
            _('Specify a series of XPath expressions for the different levels of'
              ' the Table of Contents. You can use the wizard buttons to help'
              ' you create XPath expressions.'))
        la.setWordWrap(True)
        l.addWidget(la)
        self.widgets = []
        for i in xrange(5):
            la = _('Level %s ToC:') % ('&%d' % (i + 1))
            xp = XPathEdit(self)
            xp.set_msg(la)
            self.widgets.append(xp)
            l.addWidget(xp)

        self.bb = bb = QDialogButtonBox(QDialogButtonBox.Ok
                                        | QDialogButtonBox.Cancel)
        bb.accepted.connect(self.accept)
        bb.rejected.connect(self.reject)
        self.ssb = b = bb.addButton(_('&Save settings'), bb.ActionRole)
        b.clicked.connect(self.save_settings)
        self.load_button = b = bb.addButton(_('&Load settings'), bb.ActionRole)
        self.load_menu = QMenu(b)
        b.setMenu(self.load_menu)
        self.setup_load_button()
        l.addStretch()
        l.addWidget(bb)
        self.resize(self.sizeHint() + QSize(50, 75))
Exemplo n.º 41
0
    def __init__(self, parent, db):
        QObject.__init__(self, parent)
        self.internet_connection_failed = False
        self._parent = parent
        self.no_internet_msg = _('Cannot download news as no internet connection '
                'is active')
        self.no_internet_dialog = d = error_dialog(self._parent,
                self.no_internet_msg, _('No internet connection'),
                show_copy_button=False)
        d.setModal(False)

        self.recipe_model = RecipeModel()
        self.db = db
        self.lock = QMutex(QMutex.Recursive)
        self.download_queue = set([])

        self.news_menu = QMenu()
        self.news_icon = QIcon(I('news.png'))
        self.scheduler_action = QAction(QIcon(I('scheduler.png')), _('Schedule news download'), self)
        self.news_menu.addAction(self.scheduler_action)
        self.scheduler_action.triggered[bool].connect(self.show_dialog)
        self.cac = QAction(QIcon(I('user_profile.png')), _('Add a custom news source'), self)
        self.cac.triggered[bool].connect(self.customize_feeds)
        self.news_menu.addAction(self.cac)
        self.news_menu.addSeparator()
        self.all_action = self.news_menu.addAction(
                _('Download all scheduled news sources'),
                self.download_all_scheduled)

        self.timer = QTimer(self)
        self.timer.start(int(self.INTERVAL * 60 * 1000))
        self.timer.timeout.connect(self.check)
        self.oldest = gconf['oldest_news']
        QTimer.singleShot(5 * 1000, self.oldest_check)
Exemplo n.º 42
0
 def context_menu(self, pos):
     index = self.indexAt(pos)
     if index.isValid():
         char_code, ok = self.model().data(index, Qt.UserRole).toInt()
         if ok:
             m = QMenu(self)
             m.addAction(QIcon(I('edit-copy.png')), _('Copy %s to clipboard') % chr(char_code), partial(self.copy_to_clipboard, char_code))
             m.addAction(QIcon(I('rating.png')),
                         (_('Remove %s from favorites') if self.showing_favorites else _('Add %s to favorites')) % chr(char_code),
                         partial(self.remove_from_favorites, char_code))
             if self.showing_favorites:
                 m.addAction(_('Restore favorites to defaults'), self.restore_defaults)
             m.exec_(self.mapToGlobal(pos))
Exemplo n.º 43
0
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}
        self.us = UnitedStates()

        res = self.load_resources(PORTABLE_RESOURCES)

        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/css'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/js'))
        os.makedirs(os.path.join(self.us.portable_directory,
                                 'portable/bootstrap/fonts'))

        for resource in res.keys():
            if resource == "portable/libraries.js":
                lib_lines = res[resource].split(os.linesep)
                lib_lines.insert(4, "var PORTABLE = true;{}".format(os.linesep))
                with open(os.path.join(self.us.portable_directory,
                                       'portable/libraries.js'), "w") as lib:
                    lib.writelines(os.linesep.join(lib_lines))
            else:
                with open(os.path.join(self.us.portable_directory,
                                       resource), 'wb') as portable:
                    portable.write(res[resource])

        self.popup_type = QToolButton.InstantPopup
        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        self.d = LetsShareBooksDialog(self.gui,
                                      self.qaction.icon(),
                                      do_user_config,
                                      self.qaction, self.us)
        m = QMenu(self.gui)
        self.qaction.setMenu(m)
        a = QWidgetAction(m)
        a.setDefaultWidget(self.d)
        m.addAction(a)
Exemplo n.º 44
0
 def __init__(self, parent):
     QMenu.__init__(self, _('Choose theme (needs restart)'))
     parent.addMenu(self)
     self.group = QActionGroup(self)
     current = prefs['theme']
     alls = list(sorted(get_all_styles()))
     if current not in alls:
         current = prefs['theme'] = 'default'
     self.actions = []
     for style in alls:
         ac = self.group.addAction(style)
         ac.setCheckable(True)
         if current == style:
             ac.setChecked(True)
         self.actions.append(ac)
         ac.triggered.connect(partial(self.set_theme, style))
         self.addAction(ac)
Exemplo n.º 45
0
 def contextMenuEvent(self, ev):
     m = QMenu(self)
     m.addAction(_('Sort alphabetically'), self.sort_alphabetically)
     hidden = self.current_db.prefs['virt_libs_hidden']
     if hidden:
         s = m._s = m.addMenu(_('Restore hidden tabs'))
         for x in hidden:
             s.addAction(x, partial(self.restore, x))
     m.addAction(_('Hide virtual library tabs'), self.disable_bar)
     m.exec_(ev.globalPos())