예제 #1
0
    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)))
예제 #2
0
    def setupUi(self, EbookViewer):
        EbookViewer.setObjectName(_fromUtf8("EbookViewer"))
        EbookViewer.resize(653, 672)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(I("viewer.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        EbookViewer.setWindowIcon(icon)
        self.centralwidget = QtGui.QWidget(EbookViewer)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.gridLayout_2 = QtGui.QGridLayout(self.centralwidget)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.splitter = QtGui.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.toc = TOCView(self.splitter)
        self.toc.setObjectName(_fromUtf8("toc"))
        self.frame = QtGui.QFrame(self.splitter)
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName(_fromUtf8("frame"))
        self.gridLayout = QtGui.QGridLayout(self.frame)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.vertical_scrollbar = QtGui.QScrollBar(self.frame)
        self.vertical_scrollbar.setOrientation(QtCore.Qt.Vertical)
        self.vertical_scrollbar.setObjectName(_fromUtf8("vertical_scrollbar"))
        self.gridLayout.addWidget(self.vertical_scrollbar, 1, 1, 1, 1)
        self.horizontal_scrollbar = QtGui.QScrollBar(self.frame)
        self.horizontal_scrollbar.setOrientation(QtCore.Qt.Horizontal)
        self.horizontal_scrollbar.setObjectName(_fromUtf8("horizontal_scrollbar"))
        self.gridLayout.addWidget(self.horizontal_scrollbar, 2, 0, 1, 1)
        self.dictionary_box = QtGui.QFrame(self.frame)
        self.dictionary_box.setFrameShape(QtGui.QFrame.StyledPanel)
        self.dictionary_box.setFrameShadow(QtGui.QFrame.Raised)
        self.dictionary_box.setObjectName(_fromUtf8("dictionary_box"))
        self.horizontalLayout = QtGui.QHBoxLayout(self.dictionary_box)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.dictionary_view = QtWebKit.QWebView(self.dictionary_box)
        self.dictionary_view.setMinimumSize(QtCore.QSize(0, 150))
        self.dictionary_view.setUrl(QtCore.QUrl(_fromUtf8("about:blank")))
        self.dictionary_view.setObjectName(_fromUtf8("dictionary_view"))
        self.horizontalLayout.addWidget(self.dictionary_view)
        self.close_dictionary_view = QtGui.QToolButton(self.dictionary_box)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8(I("window-close.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.close_dictionary_view.setIcon(icon1)
        self.close_dictionary_view.setObjectName(_fromUtf8("close_dictionary_view"))
        self.horizontalLayout.addWidget(self.close_dictionary_view)
        self.gridLayout.addWidget(self.dictionary_box, 3, 0, 1, 2)
        self.view = DocumentView(self.frame)
        self.view.setObjectName(_fromUtf8("view"))
        self.gridLayout.addWidget(self.view, 1, 0, 1, 1)
        self.gridLayout_2.addWidget(self.splitter, 0, 0, 1, 1)
        EbookViewer.setCentralWidget(self.centralwidget)
        self.tool_bar = QtGui.QToolBar(EbookViewer)
        self.tool_bar.setIconSize(QtCore.QSize(32, 32))
        self.tool_bar.setObjectName(_fromUtf8("tool_bar"))
        EbookViewer.addToolBar(QtCore.Qt.LeftToolBarArea, self.tool_bar)
        self.tool_bar2 = QtGui.QToolBar(EbookViewer)
        self.tool_bar2.setObjectName(_fromUtf8("tool_bar2"))
        EbookViewer.addToolBar(QtCore.Qt.TopToolBarArea, self.tool_bar2)
        self.action_back = QtGui.QAction(EbookViewer)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(_fromUtf8(I("back.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_back.setIcon(icon2)
        self.action_back.setObjectName(_fromUtf8("action_back"))
        self.action_forward = QtGui.QAction(EbookViewer)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(_fromUtf8(I("forward.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_forward.setIcon(icon3)
        self.action_forward.setObjectName(_fromUtf8("action_forward"))
        self.action_next_page = QtGui.QAction(EbookViewer)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(_fromUtf8(I("next.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_next_page.setIcon(icon4)
        self.action_next_page.setObjectName(_fromUtf8("action_next_page"))
        self.action_previous_page = QtGui.QAction(EbookViewer)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(_fromUtf8(I("previous.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_previous_page.setIcon(icon5)
        self.action_previous_page.setObjectName(_fromUtf8("action_previous_page"))
        self.action_font_size_larger = QtGui.QAction(EbookViewer)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(_fromUtf8(I("font_size_larger.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_font_size_larger.setIcon(icon6)
        self.action_font_size_larger.setObjectName(_fromUtf8("action_font_size_larger"))
        self.action_font_size_smaller = QtGui.QAction(EbookViewer)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(_fromUtf8(I("font_size_smaller.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_font_size_smaller.setIcon(icon7)
        self.action_font_size_smaller.setObjectName(_fromUtf8("action_font_size_smaller"))
        self.action_table_of_contents = QtGui.QAction(EbookViewer)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(_fromUtf8(I("highlight_only_on.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_table_of_contents.setIcon(icon8)
        self.action_table_of_contents.setObjectName(_fromUtf8("action_table_of_contents"))
        self.action_metadata = QtGui.QAction(EbookViewer)
        icon9 = QtGui.QIcon()
        icon9.addPixmap(QtGui.QPixmap(_fromUtf8(I("dialog_information.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_metadata.setIcon(icon9)
        self.action_metadata.setObjectName(_fromUtf8("action_metadata"))
        self.action_open_ebook = QtGui.QAction(EbookViewer)
        icon10 = QtGui.QIcon()
        icon10.addPixmap(QtGui.QPixmap(_fromUtf8(I("document_open.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_open_ebook.setIcon(icon10)
        self.action_open_ebook.setObjectName(_fromUtf8("action_open_ebook"))
        self.action_find_next = QtGui.QAction(EbookViewer)
        icon11 = QtGui.QIcon()
        icon11.addPixmap(QtGui.QPixmap(_fromUtf8(I("arrow-down.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_find_next.setIcon(icon11)
        self.action_find_next.setObjectName(_fromUtf8("action_find_next"))
        self.action_copy = QtGui.QAction(EbookViewer)
        icon12 = QtGui.QIcon()
        icon12.addPixmap(QtGui.QPixmap(_fromUtf8(I("edit-copy.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_copy.setIcon(icon12)
        self.action_copy.setObjectName(_fromUtf8("action_copy"))
        self.action_preferences = QtGui.QAction(EbookViewer)
        icon13 = QtGui.QIcon()
        icon13.addPixmap(QtGui.QPixmap(_fromUtf8(I("config.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_preferences.setIcon(icon13)
        self.action_preferences.setObjectName(_fromUtf8("action_preferences"))
        self.action_reference_mode = QtGui.QAction(EbookViewer)
        icon14 = QtGui.QIcon()
        icon14.addPixmap(QtGui.QPixmap(_fromUtf8(I("lookfeel.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_reference_mode.setIcon(icon14)
        self.action_reference_mode.setObjectName(_fromUtf8("action_reference_mode"))
        self.action_bookmark = QtGui.QAction(EbookViewer)
        icon15 = QtGui.QIcon()
        icon15.addPixmap(QtGui.QPixmap(_fromUtf8(I("bookmarks.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_bookmark.setIcon(icon15)
        self.action_bookmark.setObjectName(_fromUtf8("action_bookmark"))
        self.action_full_screen = QtGui.QAction(EbookViewer)
        icon16 = QtGui.QIcon()
        icon16.addPixmap(QtGui.QPixmap(_fromUtf8(I("page.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_full_screen.setIcon(icon16)
        self.action_full_screen.setObjectName(_fromUtf8("action_full_screen"))
        self.action_print = QtGui.QAction(EbookViewer)
        icon17 = QtGui.QIcon()
        icon17.addPixmap(QtGui.QPixmap(_fromUtf8(I("print.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_print.setIcon(icon17)
        self.action_print.setObjectName(_fromUtf8("action_print"))
        self.action_find_previous = QtGui.QAction(EbookViewer)
        icon18 = QtGui.QIcon()
        icon18.addPixmap(QtGui.QPixmap(_fromUtf8(I("arrow-up.png"))), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.action_find_previous.setIcon(icon18)
        self.action_find_previous.setObjectName(_fromUtf8("action_find_previous"))
        self.tool_bar.addAction(self.action_back)
        self.tool_bar.addAction(self.action_forward)
        self.tool_bar.addSeparator()
        self.tool_bar.addAction(self.action_open_ebook)
        self.tool_bar.addAction(self.action_copy)
        self.tool_bar.addAction(self.action_font_size_larger)
        self.tool_bar.addAction(self.action_font_size_smaller)
        self.tool_bar.addAction(self.action_table_of_contents)
        self.tool_bar.addAction(self.action_full_screen)
        self.tool_bar.addSeparator()
        self.tool_bar.addAction(self.action_previous_page)
        self.tool_bar.addAction(self.action_next_page)
        self.tool_bar.addSeparator()
        self.tool_bar.addAction(self.action_bookmark)
        self.tool_bar.addAction(self.action_reference_mode)
        self.tool_bar.addSeparator()
        self.tool_bar.addAction(self.action_preferences)
        self.tool_bar.addAction(self.action_metadata)
        self.tool_bar.addSeparator()
        self.tool_bar.addAction(self.action_print)
        self.tool_bar2.addAction(self.action_find_next)
        self.tool_bar2.addAction(self.action_find_previous)

        self.retranslateUi(EbookViewer)
        QtCore.QMetaObject.connectSlotsByName(EbookViewer)