mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refactoring
This commit is contained in:
parent
4ef7f45530
commit
3b3b7bd815
@ -6,7 +6,7 @@ from functools import partial
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from PyQt4.Qt import (
|
from PyQt4.Qt import (
|
||||||
QApplication, Qt, QIcon, QTimer, QByteArray, QSize, QTime, QLabel,
|
QApplication, Qt, QIcon, QTimer, QByteArray, QSize, QTime,
|
||||||
QPropertyAnimation, QUrl, QInputDialog, QAction, QModelIndex)
|
QPropertyAnimation, QUrl, QInputDialog, QAction, QModelIndex)
|
||||||
|
|
||||||
from calibre.gui2.viewer.ui import Main as MainWindow
|
from calibre.gui2.viewer.ui import Main as MainWindow
|
||||||
@ -118,30 +118,6 @@ class EbookViewer(MainWindow):
|
|||||||
if pathtoebook is not None:
|
if pathtoebook is not None:
|
||||||
f = functools.partial(self.load_ebook, pathtoebook, open_at=open_at)
|
f = functools.partial(self.load_ebook, pathtoebook, open_at=open_at)
|
||||||
QTimer.singleShot(50, f)
|
QTimer.singleShot(50, f)
|
||||||
self.view.setMinimumSize(100, 100)
|
|
||||||
self.full_screen_label = QLabel('''
|
|
||||||
<center>
|
|
||||||
<h1>%s</h1>
|
|
||||||
<h3>%s</h3>
|
|
||||||
<h3>%s</h3>
|
|
||||||
<h3>%s</h3>
|
|
||||||
</center>
|
|
||||||
'''%(_('Full screen mode'),
|
|
||||||
_('Right click to show controls'),
|
|
||||||
_('Tap in the left or right page margin to turn pages'),
|
|
||||||
_('Press Esc to quit')),
|
|
||||||
self.centralWidget())
|
|
||||||
self.full_screen_label.setVisible(False)
|
|
||||||
self.full_screen_label.setStyleSheet('''
|
|
||||||
QLabel {
|
|
||||||
text-align: center;
|
|
||||||
background-color: white;
|
|
||||||
color: black;
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-radius: 20px;
|
|
||||||
}
|
|
||||||
''')
|
|
||||||
self.window_mode_changed = None
|
self.window_mode_changed = None
|
||||||
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
|
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
|
||||||
self.toggle_toolbar_action.setCheckable(True)
|
self.toggle_toolbar_action.setCheckable(True)
|
||||||
@ -150,24 +126,6 @@ class EbookViewer(MainWindow):
|
|||||||
self.addAction(self.toggle_toolbar_action)
|
self.addAction(self.toggle_toolbar_action)
|
||||||
self.full_screen_label_anim = QPropertyAnimation(
|
self.full_screen_label_anim = QPropertyAnimation(
|
||||||
self.full_screen_label, 'size')
|
self.full_screen_label, 'size')
|
||||||
self.clock_label = QLabel('99:99', self.centralWidget())
|
|
||||||
self.clock_label.setVisible(False)
|
|
||||||
self.clock_label.setFocusPolicy(Qt.NoFocus)
|
|
||||||
self.info_label_style = '''
|
|
||||||
QLabel {
|
|
||||||
text-align: center;
|
|
||||||
border-width: 1px;
|
|
||||||
border-style: solid;
|
|
||||||
border-radius: 8px;
|
|
||||||
background-color: %s;
|
|
||||||
color: %s;
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: larger;
|
|
||||||
padding: 5px;
|
|
||||||
}'''
|
|
||||||
self.pos_label = QLabel('2000/4000', self.centralWidget())
|
|
||||||
self.pos_label.setVisible(False)
|
|
||||||
self.pos_label.setFocusPolicy(Qt.NoFocus)
|
|
||||||
self.clock_timer = QTimer(self)
|
self.clock_timer = QTimer(self)
|
||||||
self.clock_timer.timeout.connect(self.update_clock)
|
self.clock_timer.timeout.connect(self.update_clock)
|
||||||
|
|
||||||
@ -338,7 +296,7 @@ class EbookViewer(MainWindow):
|
|||||||
|
|
||||||
def show_full_screen_label(self):
|
def show_full_screen_label(self):
|
||||||
f = self.full_screen_label
|
f = self.full_screen_label
|
||||||
height = f.final_height = 200
|
height = f.final_height
|
||||||
width = int(0.7*self.view.width())
|
width = int(0.7*self.view.width())
|
||||||
f.resize(width, height)
|
f.resize(width, height)
|
||||||
if self.view.document.show_fullscreen_help:
|
if self.view.document.show_fullscreen_help:
|
||||||
|
@ -12,7 +12,7 @@ from PyQt4.Qt import (
|
|||||||
QIcon, QWidget, Qt, QGridLayout, QScrollBar, QToolBar, QAction,
|
QIcon, QWidget, Qt, QGridLayout, QScrollBar, QToolBar, QAction,
|
||||||
QToolButton, QMenu, QDoubleSpinBox, pyqtSignal, QLineEdit,
|
QToolButton, QMenu, QDoubleSpinBox, pyqtSignal, QLineEdit,
|
||||||
QRegExpValidator, QRegExp, QPalette, QColor, QBrush, QPainter,
|
QRegExpValidator, QRegExp, QPalette, QColor, QBrush, QPainter,
|
||||||
QDockWidget, QSize)
|
QDockWidget, QSize, QLabel)
|
||||||
from PyQt4.QtWebKit import QWebView
|
from PyQt4.QtWebKit import QWebView
|
||||||
|
|
||||||
from calibre.gui2 import rating_font
|
from calibre.gui2 import rating_font
|
||||||
@ -170,6 +170,7 @@ class Main(MainWindow):
|
|||||||
c.setLayout(cl), cl.setContentsMargins(0, 0, 0, 0)
|
c.setLayout(cl), cl.setContentsMargins(0, 0, 0, 0)
|
||||||
|
|
||||||
self.view = v = DocumentView(self)
|
self.view = v = DocumentView(self)
|
||||||
|
v.setMinimumSize(100, 100)
|
||||||
self.view.initialize_view(debug_javascript)
|
self.view.initialize_view(debug_javascript)
|
||||||
v.setObjectName('view')
|
v.setObjectName('view')
|
||||||
cl.addWidget(v)
|
cl.addWidget(v)
|
||||||
@ -229,6 +230,50 @@ class Main(MainWindow):
|
|||||||
self.metadata = Metadata(self.centralwidget)
|
self.metadata = Metadata(self.centralwidget)
|
||||||
self.history = History(self.action_back, self.action_forward)
|
self.history = History(self.action_back, self.action_forward)
|
||||||
|
|
||||||
|
self.full_screen_label = QLabel('''
|
||||||
|
<center>
|
||||||
|
<h1>%s</h1>
|
||||||
|
<h3>%s</h3>
|
||||||
|
<h3>%s</h3>
|
||||||
|
<h3>%s</h3>
|
||||||
|
</center>
|
||||||
|
'''%(_('Full screen mode'),
|
||||||
|
_('Right click to show controls'),
|
||||||
|
_('Tap in the left or right page margin to turn pages'),
|
||||||
|
_('Press Esc to quit')),
|
||||||
|
self.centralWidget())
|
||||||
|
self.full_screen_label.setVisible(False)
|
||||||
|
self.full_screen_label.final_height = 200
|
||||||
|
self.full_screen_label.setFocusPolicy(Qt.NoFocus)
|
||||||
|
self.full_screen_label.setStyleSheet('''
|
||||||
|
QLabel {
|
||||||
|
text-align: center;
|
||||||
|
background-color: white;
|
||||||
|
color: black;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
''')
|
||||||
|
self.clock_label = QLabel('99:99', self.centralWidget())
|
||||||
|
self.clock_label.setVisible(False)
|
||||||
|
self.clock_label.setFocusPolicy(Qt.NoFocus)
|
||||||
|
self.info_label_style = '''
|
||||||
|
QLabel {
|
||||||
|
text-align: center;
|
||||||
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: %s;
|
||||||
|
color: %s;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: larger;
|
||||||
|
padding: 5px;
|
||||||
|
}'''
|
||||||
|
self.pos_label = QLabel('2000/4000', self.centralWidget())
|
||||||
|
self.pos_label.setVisible(False)
|
||||||
|
self.pos_label.setFocusPolicy(Qt.NoFocus)
|
||||||
|
|
||||||
self.resize(653, 746)
|
self.resize(653, 746)
|
||||||
|
|
||||||
def resizeEvent(self, ev):
|
def resizeEvent(self, ev):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user