Esempio 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()
Esempio n. 2
0
 def stop(self):
     QApplication.restoreOverrideCursor()
     self.pi.stopAnimation()
     self.setVisible(False)
     self.parent().setEnabled(True)
     # The following line is needed on OS X, because of this bug:
     # https://bugreports.qt-project.org/browse/QTBUG-34371 it causes
     # keyboard events to no longer work
     self.parent().setFocus(Qt.FocusReason.OtherFocusReason)
Esempio n. 3
0
 def ans(self, *args, **kwargs):
     if self.original_image_data is None:
         return error_dialog(self, _('No image'), _('No image loaded'), show=True)
     if not self.is_valid:
         return error_dialog(self, _('Invalid image'), _('The current image is not valid'), show=True)
     QApplication.setOverrideCursor(Qt.CursorShape.BusyCursor)
     try:
         return func(self, *args, **kwargs)
     finally:
         QApplication.restoreOverrideCursor()
Esempio n. 4
0
 def __exit__(self, *args):
     QApplication.restoreOverrideCursor()
Esempio n. 5
0
 def rehighlight(self):
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     super().rehighlight()
     QApplication.restoreOverrideCursor()
Esempio n. 6
0
 def rehighlight(self):
     QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
     QSyntaxHighlighter.rehighlight(self)
     QApplication.restoreOverrideCursor()
Esempio n. 7
0
 def __exit__(self, *args):
     self.busy.pi.stopAnimation()
     self.stacks.setCurrentIndex(1)
     QApplication.restoreOverrideCursor()