mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
d11fec7c9d
commit
edb8e805b2
@ -9,7 +9,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from qt.core import QAction, QIcon, Qt, pyqtSignal, QDialog
|
from qt.core import QAction, QIcon, Qt, pyqtSignal, QDialog, QApplication, QCursor
|
||||||
|
|
||||||
from calibre.constants import ismacos, iswindows
|
from calibre.constants import ismacos, iswindows
|
||||||
from calibre.gui2 import (
|
from calibre.gui2 import (
|
||||||
@ -23,6 +23,15 @@ from calibre.utils.config import prefs, tweaks
|
|||||||
from polyglot.builtins import as_bytes
|
from polyglot.builtins import as_bytes
|
||||||
|
|
||||||
|
|
||||||
|
class BusyCursor:
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
|
|
||||||
def preferred_format(formats):
|
def preferred_format(formats):
|
||||||
formats = tuple(x.upper() for x in formats if x)
|
formats = tuple(x.upper() for x in formats if x)
|
||||||
fmt = formats[0]
|
fmt = formats[0]
|
||||||
@ -159,8 +168,7 @@ class ViewAction(InterfaceAction):
|
|||||||
self._view_file(job.result)
|
self._view_file(job.result)
|
||||||
|
|
||||||
def _launch_viewer(self, name=None, viewer='ebook-viewer', internal=True, calibre_book_data=None, open_at=None):
|
def _launch_viewer(self, name=None, viewer='ebook-viewer', internal=True, calibre_book_data=None, open_at=None):
|
||||||
self.gui.setCursor(Qt.CursorShape.BusyCursor)
|
with BusyCursor():
|
||||||
try:
|
|
||||||
if internal:
|
if internal:
|
||||||
args = [viewer]
|
args = [viewer]
|
||||||
if ismacos and 'ebook' in viewer:
|
if ismacos and 'ebook' in viewer:
|
||||||
@ -198,8 +206,6 @@ class ViewAction(InterfaceAction):
|
|||||||
|
|
||||||
open_local_file(name)
|
open_local_file(name)
|
||||||
time.sleep(2) # User feedback
|
time.sleep(2) # User feedback
|
||||||
finally:
|
|
||||||
self.gui.unsetCursor()
|
|
||||||
|
|
||||||
def _view_file(self, name, calibre_book_data=None, open_at=None):
|
def _view_file(self, name, calibre_book_data=None, open_at=None):
|
||||||
ext = os.path.splitext(name)[1].upper().replace('.',
|
ext = os.path.splitext(name)[1].upper().replace('.',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user