From 3b3b7bd81567e36a2f3fd0b7104b5be00b96b610 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Aug 2014 22:38:05 +0530 Subject: [PATCH] Refactoring --- src/calibre/gui2/viewer/main.py | 46 ++------------------------------ src/calibre/gui2/viewer/ui.py | 47 ++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index 40955e79d3..4a73461de6 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -6,7 +6,7 @@ from functools import partial from threading import Thread from PyQt4.Qt import ( - QApplication, Qt, QIcon, QTimer, QByteArray, QSize, QTime, QLabel, + QApplication, Qt, QIcon, QTimer, QByteArray, QSize, QTime, QPropertyAnimation, QUrl, QInputDialog, QAction, QModelIndex) from calibre.gui2.viewer.ui import Main as MainWindow @@ -118,30 +118,6 @@ class EbookViewer(MainWindow): if pathtoebook is not None: f = functools.partial(self.load_ebook, pathtoebook, open_at=open_at) QTimer.singleShot(50, f) - self.view.setMinimumSize(100, 100) - self.full_screen_label = QLabel(''' -
-

%s

-

%s

-

%s

-

%s

-
- '''%(_('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.toggle_toolbar_action = QAction(_('Show/hide controls'), self) self.toggle_toolbar_action.setCheckable(True) @@ -150,24 +126,6 @@ class EbookViewer(MainWindow): self.addAction(self.toggle_toolbar_action) self.full_screen_label_anim = QPropertyAnimation( 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.timeout.connect(self.update_clock) @@ -338,7 +296,7 @@ class EbookViewer(MainWindow): def show_full_screen_label(self): f = self.full_screen_label - height = f.final_height = 200 + height = f.final_height width = int(0.7*self.view.width()) f.resize(width, height) if self.view.document.show_fullscreen_help: diff --git a/src/calibre/gui2/viewer/ui.py b/src/calibre/gui2/viewer/ui.py index 3ccb592e08..b233a1e04a 100644 --- a/src/calibre/gui2/viewer/ui.py +++ b/src/calibre/gui2/viewer/ui.py @@ -12,7 +12,7 @@ from PyQt4.Qt import ( QIcon, QWidget, Qt, QGridLayout, QScrollBar, QToolBar, QAction, QToolButton, QMenu, QDoubleSpinBox, pyqtSignal, QLineEdit, QRegExpValidator, QRegExp, QPalette, QColor, QBrush, QPainter, - QDockWidget, QSize) + QDockWidget, QSize, QLabel) from PyQt4.QtWebKit import QWebView from calibre.gui2 import rating_font @@ -170,6 +170,7 @@ class Main(MainWindow): c.setLayout(cl), cl.setContentsMargins(0, 0, 0, 0) self.view = v = DocumentView(self) + v.setMinimumSize(100, 100) self.view.initialize_view(debug_javascript) v.setObjectName('view') cl.addWidget(v) @@ -229,6 +230,50 @@ class Main(MainWindow): self.metadata = Metadata(self.centralwidget) self.history = History(self.action_back, self.action_forward) + self.full_screen_label = QLabel(''' +
+

%s

+

%s

+

%s

+

%s

+
+ '''%(_('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) def resizeEvent(self, ev):