def manage_bookmarks(self): bmm = BookmarkManager(self, self.iterator.bookmarks) if bmm.exec_() != BookmarkManager.Accepted: return bookmarks = bmm.get_bookmarks() if bookmarks != self.iterator.bookmarks: self.iterator.set_bookmarks(bookmarks) self.iterator.save_bookmarks() self.set_bookmarks(bookmarks)
def __init__(self, debug_javascript): MainWindow.__init__(self, None) self.setWindowTitle(_('E-book viewer')) self.base_window_title = unicode(self.windowTitle()) self.setObjectName('EbookViewer') self.setWindowIcon(QIcon(I('viewer.png'))) self.setDockOptions(self.AnimatedDocks | self.AllowTabbedDocks) self.centralwidget = c = QWidget(self) c.setObjectName('centralwidget') self.setCentralWidget(c) self.central_layout = cl = QGridLayout(c) cl.setSpacing(0) 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) self.vertical_scrollbar = vs = QScrollBar(c) vs.setOrientation(Qt.Vertical), vs.setObjectName("vertical_scrollbar") cl.addWidget(vs, 0, 1, 2, 1) self.horizontal_scrollbar = hs = QScrollBar(c) hs.setOrientation(Qt.Vertical), hs.setObjectName("horizontal_scrollbar") cl.addWidget(hs, 1, 0, 1, 1) self.tool_bar = tb = QToolBar(self) tb.setObjectName('tool_bar'), tb.setIconSize(QSize(32, 32)) self.addToolBar(Qt.LeftToolBarArea, tb) self.tool_bar2 = tb2 = QToolBar(self) tb2.setObjectName('tool_bar2') self.addToolBar(Qt.TopToolBarArea, tb2) self.tool_bar.setContextMenuPolicy(Qt.PreventContextMenu) self.tool_bar2.setContextMenuPolicy(Qt.PreventContextMenu) self.pos = DoubleSpinBox() self.pos.setDecimals(1) self.pos.setSuffix('/'+_('Unknown')+' ') self.pos.setMinimum(1.) self.tool_bar2.addWidget(self.pos) self.tool_bar2.addSeparator() self.reference = Reference() self.tool_bar2.addWidget(self.reference) self.tool_bar2.addSeparator() self.search = SearchBox2(self) self.search.setMinimumContentsLength(20) self.search.initialize('viewer_search_history') self.search.setToolTip(_('Search for text in book')) self.search.setMinimumWidth(200) self.tool_bar2.addWidget(self.search) self.toc_dock = d = QDockWidget(_('Table of Contents'), self) self.toc = TOCView(self) d.setObjectName('toc-dock') d.setWidget(self.toc) d.close() # starts out hidden self.addDockWidget(Qt.LeftDockWidgetArea, d) d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.bookmarks_dock = d = QDockWidget(_('Bookmarks'), self) self.bookmarks = BookmarkManager(self) d.setObjectName('bookmarks-dock') d.setWidget(self.bookmarks) d.close() # starts out hidden self.addDockWidget(Qt.RightDockWidgetArea, d) d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.create_actions() self.metadata = Metadata(self.centralwidget) 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) if workaround_broken_under_mouse is not None: for bar in (self.tool_bar, self.tool_bar2): for ac in bar.actions(): m = ac.menu() if m is not None: m.aboutToHide.connect(partial(workaround_broken_under_mouse, bar.widgetForAction(ac)))