Ejemplo n.º 1
0
    def do_search(self):
        query = str(self.search_text.text())
        if not query:
            d = error_dialog(
                self.gui, _('Match books'),
                _('You must enter a search expression into the search field'))
            d.exec()
            return
        try:
            self.search_button.setEnabled(False)
            QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
            books = self.library_db.data.search(query, return_matches=True)
            self.books_table.setRowCount(len(books))

            self.books_table.setSortingEnabled(False)
            for row, b in enumerate(books):
                mi = self.library_db.get_metadata(b,
                                                  index_is_id=True,
                                                  get_user_categories=False)
                a = TableItem(mi.title, mi.title_sort)
                a.setData(Qt.ItemDataRole.UserRole, b)
                self.books_table.setItem(row, 0, a)
                a = TableItem(' & '.join(mi.authors), mi.author_sort)
                self.books_table.setItem(row, 1, a)
                series = mi.format_field('series')[1]
                if series is None:
                    series = ''
                a = TableItem(series, mi.series, mi.series_index)
                self.books_table.setItem(row, 2, a)
                self.books_table.setRowHeight(row, self.books_table_row_height)

            self.books_table.setSortingEnabled(True)
        finally:
            self.search_button.setEnabled(True)
            QApplication.restoreOverrideCursor()
Ejemplo n.º 2
0
    def scrollbar_context_menu(self, x, y, frac):
        m = QMenu(self)
        amap = {}

        def a(text, name):
            m.addAction(text)
            amap[text] = name

        a(_('Scroll here'), 'here')
        m.addSeparator()
        a(_('Start of book'), 'start_of_book')
        a(_('End of book'), 'end_of_book')
        m.addSeparator()
        a(_('Previous section'), 'previous_section')
        a(_('Next section'), 'next_section')
        m.addSeparator()
        a(_('Start of current file'), 'start_of_file')
        a(_('End of current file'), 'end_of_file')
        m.addSeparator()
        a(_('Hide this scrollbar'), 'toggle_scrollbar')

        q = m.exec_(QCursor.pos())
        if not q:
            return
        q = amap[q.text()]
        if q == 'here':
            self.web_view.goto_frac(frac)
        else:
            self.web_view.trigger_shortcut(q)
Ejemplo n.º 3
0
    def show_context_menu(self, point):
        item = self.currentItem()

        def key(k):
            sc = str(QKeySequence(k | Qt.KeyboardModifier.ControlModifier).toString(QKeySequence.SequenceFormat.NativeText))
            return ' [%s]'%sc

        if item is not None:
            m = QMenu(self)
            m.addAction(QIcon(I('edit_input.png')), _('Change the location this entry points to'), self.edit_item)
            m.addAction(QIcon(I('modified.png')), _('Bulk rename all selected items'), self.bulk_rename)
            m.addAction(QIcon(I('trash.png')), _('Remove all selected items'), self.del_items)
            m.addSeparator()
            ci = str(item.data(0, Qt.ItemDataRole.DisplayRole) or '')
            p = item.parent() or self.invisibleRootItem()
            idx = p.indexOfChild(item)
            if idx > 0:
                m.addAction(QIcon(I('arrow-up.png')), (_('Move "%s" up')%ci)+key(Qt.Key.Key_Up), self.move_up)
            if idx + 1 < p.childCount():
                m.addAction(QIcon(I('arrow-down.png')), (_('Move "%s" down')%ci)+key(Qt.Key.Key_Down), self.move_down)
            if item.parent() is not None:
                m.addAction(QIcon(I('back.png')), (_('Unindent "%s"')%ci)+key(Qt.Key.Key_Left), self.move_left)
            if idx > 0:
                m.addAction(QIcon(I('forward.png')), (_('Indent "%s"')%ci)+key(Qt.Key.Key_Right), self.move_right)

            m.addSeparator()
            case_menu = QMenu(_('Change case'), m)
            case_menu.addAction(_('Upper case'), self.upper_case)
            case_menu.addAction(_('Lower case'), self.lower_case)
            case_menu.addAction(_('Swap case'), self.swap_case)
            case_menu.addAction(_('Title case'), self.title_case)
            case_menu.addAction(_('Capitalize'), self.capitalize)
            m.addMenu(case_menu)

            m.exec(QCursor.pos())
Ejemplo n.º 4
0
 def show_context_menu(self, point):
     idx = self.currentIndex()
     if idx and idx.isValid() and not idx.data(Qt.ItemDataRole.UserRole):
         m = QMenu(self)
         m.addAction(QIcon(I('view.png')), _('View this cover at full size'), self.show_cover)
         m.addAction(QIcon(I('edit-copy.png')), _('Copy this cover to clipboard'), self.copy_cover)
         m.exec_(QCursor.pos())
Ejemplo n.º 5
0
 def __enter__(self):
     self.stacks.setCurrentIndex(0)
     self.busy.setVisible(True)
     self.busy.pi.startAnimation()
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     QApplication.processEvents(
         QEventLoop.ProcessEventsFlag.ExcludeUserInputEvents
         | QEventLoop.ProcessEventsFlag.ExcludeSocketNotifiers)
Ejemplo n.º 6
0
 def start(self):
     self.setGeometry(0, 0, self.parent().width(), self.parent().height())
     self.setVisible(True)
     # Prevent any actions from being triggered by key presses
     self.parent().setEnabled(False)
     self.raise_()
     self.setFocus(Qt.FocusReason.OtherFocusReason)
     self.pi.startAnimation()
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
Ejemplo n.º 7
0
 def __enter__(self):
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
Ejemplo n.º 8
0
 def rehighlight(self):
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     super().rehighlight()
     QApplication.restoreOverrideCursor()
Ejemplo n.º 9
0
 def rehighlight(self):
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     QSyntaxHighlighter.rehighlight(self)
     QApplication.restoreOverrideCursor()