mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:Various miscellaneous fixes.
This commit is contained in:
parent
efddafa088
commit
bad5db6d57
@ -9,7 +9,7 @@ from PyQt4.QtGui import QFileDialog, QMessageBox, QPixmap, QFileIconProvider, \
|
|||||||
|
|
||||||
ORG_NAME = 'KovidsBrain'
|
ORG_NAME = 'KovidsBrain'
|
||||||
APP_UID = 'libprs500'
|
APP_UID = 'libprs500'
|
||||||
from calibre import islinux, iswindows
|
from calibre import islinux, iswindows, isosx
|
||||||
from calibre.startup import get_lang
|
from calibre.startup import get_lang
|
||||||
from calibre.utils.config import Config, ConfigProxy, dynamic
|
from calibre.utils.config import Config, ConfigProxy, dynamic
|
||||||
import calibre.resources as resources
|
import calibre.resources as resources
|
||||||
@ -110,7 +110,7 @@ class CopyButton(QPushButton):
|
|||||||
def copied(self):
|
def copied(self):
|
||||||
self.emit(SIGNAL('copy()'))
|
self.emit(SIGNAL('copy()'))
|
||||||
self.setDisabled(True)
|
self.setDisabled(True)
|
||||||
self.setText(_('Copied to clipboard'))
|
self.setText(_('Copied'))
|
||||||
|
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
@ -139,7 +139,7 @@ class MessageBox(QMessageBox):
|
|||||||
self.det_msg = det_msg
|
self.det_msg = det_msg
|
||||||
self.setDetailedText(det_msg)
|
self.setDetailedText(det_msg)
|
||||||
# Cannot set keyboard shortcut as the event is not easy to filter
|
# Cannot set keyboard shortcut as the event is not easy to filter
|
||||||
self.cb = CopyButton(_('Copy to Clipboard'))
|
self.cb = CopyButton(_('Copy') if isosx else _('Copy to Clipboard'))
|
||||||
self.connect(self.cb, SIGNAL('copy()'), self.copy_to_clipboard)
|
self.connect(self.cb, SIGNAL('copy()'), self.copy_to_clipboard)
|
||||||
self.addButton(self.cb, QMessageBox.ActionRole)
|
self.addButton(self.cb, QMessageBox.ActionRole)
|
||||||
default_button = self.button(self.Ok)
|
default_button = self.button(self.Ok)
|
||||||
@ -158,6 +158,7 @@ class MessageBox(QMessageBox):
|
|||||||
def warning_dialog(parent, title, msg, det_msg='', show=False):
|
def warning_dialog(parent, title, msg, det_msg='', show=False):
|
||||||
d = MessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
|
d = MessageBox(QMessageBox.Warning, 'WARNING: '+title, msg, QMessageBox.Ok,
|
||||||
parent, det_msg)
|
parent, det_msg)
|
||||||
|
d.setEscapeButton(QMessageBox.Ok)
|
||||||
d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
|
d.setIconPixmap(QPixmap(':/images/dialog_warning.svg'))
|
||||||
if show:
|
if show:
|
||||||
return d.exec_()
|
return d.exec_()
|
||||||
@ -167,6 +168,7 @@ def error_dialog(parent, title, msg, det_msg='', show=False):
|
|||||||
d = MessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok,
|
d = MessageBox(QMessageBox.Critical, 'ERROR: '+title, msg, QMessageBox.Ok,
|
||||||
parent, det_msg)
|
parent, det_msg)
|
||||||
d.setIconPixmap(QPixmap(':/images/dialog_error.svg'))
|
d.setIconPixmap(QPixmap(':/images/dialog_error.svg'))
|
||||||
|
d.setEscapeButton(QMessageBox.Ok)
|
||||||
if show:
|
if show:
|
||||||
return d.exec_()
|
return d.exec_()
|
||||||
return d
|
return d
|
||||||
@ -175,6 +177,7 @@ def question_dialog(parent, title, msg, det_msg=''):
|
|||||||
d = MessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No,
|
d = MessageBox(QMessageBox.Question, title, msg, QMessageBox.Yes|QMessageBox.No,
|
||||||
parent, det_msg)
|
parent, det_msg)
|
||||||
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
|
d.setIconPixmap(QPixmap(':/images/dialog_information.svg'))
|
||||||
|
d.setEscapeButton(QMessageBox.No)
|
||||||
return d.exec_() == QMessageBox.Yes
|
return d.exec_() == QMessageBox.Yes
|
||||||
|
|
||||||
def info_dialog(parent, title, msg, det_msg='', show=False):
|
def info_dialog(parent, title, msg, det_msg='', show=False):
|
||||||
|
@ -166,7 +166,8 @@ class PluginModel(QAbstractItemModel):
|
|||||||
if index.internalId() == 0:
|
if index.internalId() == 0:
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
category = self.categories[index.row()]
|
category = self.categories[index.row()]
|
||||||
return QVariant(category + _(' plugins'))
|
return QVariant(_("%(plugin_type)s %(plugins)s")%\
|
||||||
|
dict(plugin_type=category, plugins=_('plugins')))
|
||||||
else:
|
else:
|
||||||
plugin = self.index_to_plugin(index)
|
plugin = self.index_to_plugin(index)
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.DisplayRole:
|
||||||
|
@ -1788,7 +1788,7 @@ def init_qt(args):
|
|||||||
parser = option_parser()
|
parser = option_parser()
|
||||||
opts, args = parser.parse_args(args)
|
opts, args = parser.parse_args(args)
|
||||||
if opts.with_library is not None and os.path.isdir(opts.with_library):
|
if opts.with_library is not None and os.path.isdir(opts.with_library):
|
||||||
prefs.set('library_path', opts.with_library)
|
prefs.set('library_path', os.path.abspath(opts.with_library))
|
||||||
print 'Using library at', prefs['library_path']
|
print 'Using library at', prefs['library_path']
|
||||||
app = Application(args)
|
app = Application(args)
|
||||||
actions = tuple(Main.create_application_menubar())
|
actions = tuple(Main.create_application_menubar())
|
||||||
|
@ -14,6 +14,7 @@ from calibre.ptempfile import PersistentTemporaryFile
|
|||||||
|
|
||||||
if iswindows:
|
if iswindows:
|
||||||
import win32process
|
import win32process
|
||||||
|
_windows_null_file = open(os.devnull, 'wb')
|
||||||
|
|
||||||
class Worker(object):
|
class Worker(object):
|
||||||
'''
|
'''
|
||||||
@ -149,9 +150,20 @@ class Worker(object):
|
|||||||
self._file = PersistentTemporaryFile('_worker_redirect.log')
|
self._file = PersistentTemporaryFile('_worker_redirect.log')
|
||||||
args['stdout'] = self._file._fd
|
args['stdout'] = self._file._fd
|
||||||
args['stderr'] = subprocess.STDOUT
|
args['stderr'] = subprocess.STDOUT
|
||||||
|
if iswindows:
|
||||||
|
args['stdin'] = subprocess.PIPE
|
||||||
ret = self._file.name
|
ret = self._file.name
|
||||||
|
|
||||||
|
if iswindows and 'stdin' not in args:
|
||||||
|
# On windows when usingthepythonw interpreter,
|
||||||
|
# stdout, stderr and stdin may not be valid
|
||||||
|
args['stdin'] = subprocess.PIPE
|
||||||
|
args['stdout'] = _windows_null_file
|
||||||
|
args['stderr'] = subprocess.STDOUT
|
||||||
|
|
||||||
self.child = subprocess.Popen(cmd, **args)
|
self.child = subprocess.Popen(cmd, **args)
|
||||||
|
if 'stdin' in args:
|
||||||
|
self.child.stdin.close()
|
||||||
|
|
||||||
self.log_path = ret
|
self.log_path = ret
|
||||||
return ret
|
return ret
|
||||||
|
@ -78,7 +78,8 @@ class ConnectedWorker(Thread):
|
|||||||
self._returncode = r
|
self._returncode = r
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
class CriticalError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
class Server(Thread):
|
class Server(Thread):
|
||||||
|
|
||||||
@ -112,6 +113,8 @@ class Server(Thread):
|
|||||||
id = self.launched_worker_count
|
id = self.launched_worker_count
|
||||||
rfile = os.path.join(tempfile.gettempdir(),
|
rfile = os.path.join(tempfile.gettempdir(),
|
||||||
'calibre_ipc_result_%d_%d.pickle'%(self.id, id))
|
'calibre_ipc_result_%d_%d.pickle'%(self.id, id))
|
||||||
|
if redirect_output is None:
|
||||||
|
redirect_output = not gui
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
'CALIBRE_WORKER_ADDRESS' :
|
'CALIBRE_WORKER_ADDRESS' :
|
||||||
@ -126,14 +129,12 @@ class Server(Thread):
|
|||||||
if isinstance(cw, ConnectedWorker):
|
if isinstance(cw, ConnectedWorker):
|
||||||
break
|
break
|
||||||
if isinstance(cw, basestring):
|
if isinstance(cw, basestring):
|
||||||
raise Exception('Failed to launch worker process:\n'+cw)
|
raise CriticalError('Failed to launch worker process:\n'+cw)
|
||||||
return cw
|
return cw
|
||||||
|
|
||||||
def do_launch(self, env, gui, redirect_output, rfile):
|
def do_launch(self, env, gui, redirect_output, rfile):
|
||||||
w = Worker(env, gui=gui)
|
w = Worker(env, gui=gui)
|
||||||
|
|
||||||
if redirect_output is None:
|
|
||||||
redirect_output = not gui
|
|
||||||
try:
|
try:
|
||||||
w(redirect_output=redirect_output)
|
w(redirect_output=redirect_output)
|
||||||
conn = self.listener.accept()
|
conn = self.listener.accept()
|
||||||
@ -191,7 +192,9 @@ class Server(Thread):
|
|||||||
if len(self.pool) + len(self.workers) < self.pool_size:
|
if len(self.pool) + len(self.workers) < self.pool_size:
|
||||||
try:
|
try:
|
||||||
self.pool.append(self.launch_worker())
|
self.pool.append(self.launch_worker())
|
||||||
except Exception, err:
|
except CriticalError:
|
||||||
|
raise
|
||||||
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if len(self.pool) > 0 and len(self.waiting_jobs) > 0:
|
if len(self.pool) > 0 and len(self.waiting_jobs) > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user