mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More work on the new viewer
This commit is contained in:
parent
200d38d2f5
commit
2c669bf853
@ -158,11 +158,13 @@ def main(args=sys.argv):
|
|||||||
app.setWindowIcon(QIcon(I('viewer.png')))
|
app.setWindowIcon(QIcon(I('viewer.png')))
|
||||||
main = EbookViewer()
|
main = EbookViewer()
|
||||||
main.set_exception_handler()
|
main.set_exception_handler()
|
||||||
|
if args:
|
||||||
|
acc.events.append(args[-1])
|
||||||
acc.got_file.connect(main.handle_commandline_arg)
|
acc.got_file.connect(main.handle_commandline_arg)
|
||||||
main.show()
|
main.show()
|
||||||
main.msg_from_anotherinstance.connect(main.another_instance_wants_to_talk, type=Qt.QueuedConnection)
|
main.msg_from_anotherinstance.connect(main.another_instance_wants_to_talk, type=Qt.QueuedConnection)
|
||||||
if listener is not None:
|
if listener is not None:
|
||||||
t = Thread(name='ListenSI', target=listen, args=(listener, main.msg_from_anotherinstance))
|
t = Thread(name='ConnListener', target=listen, args=(listener, main.msg_from_anotherinstance))
|
||||||
t.daemon = True
|
t.daemon = True
|
||||||
t.start()
|
t.start()
|
||||||
QTimer.singleShot(0, acc.flush)
|
QTimer.singleShot(0, acc.flush)
|
||||||
|
31
src/calibre/gui2/viewer2/ui.py
Normal file
31
src/calibre/gui2/viewer2/ui.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from PyQt5.Qt import pyqtSignal
|
||||||
|
|
||||||
|
from calibre.gui2.main_window import MainWindow
|
||||||
|
|
||||||
|
|
||||||
|
class EbookViewer(MainWindow):
|
||||||
|
|
||||||
|
msg_from_anotherinstance = pyqtSignal(object)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
MainWindow.__init__(self)
|
||||||
|
|
||||||
|
def handle_commandline_arg(self, arg):
|
||||||
|
if arg and os.path.isfile(arg) and os.access(arg, os.R_OK):
|
||||||
|
self.load_ebook(arg)
|
||||||
|
|
||||||
|
def another_instance_wants_to_talk(self, msg):
|
||||||
|
try:
|
||||||
|
path, open_at = msg
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
self.load_ebook(path, open_at=open_at)
|
||||||
|
self.raise_()
|
Loading…
x
Reference in New Issue
Block a user