diff --git a/__main__.py b/__main__.py index fab2b2c..b59465f 100755 --- a/__main__.py +++ b/__main__.py @@ -31,6 +31,7 @@ ✓ Substitute textedit for another widget ✓ Theming ✓ Keep fontsize and margins consistent - Let page increase in length + ✓ Fullscreening All ebooks should first be added to the database and then returned as HTML Pagination Set context menu for definitions and the like @@ -283,20 +284,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): current_tab_widget = self.tabWidget.widget(current_tab) self.current_contentView = current_tab_widget.findChildren(QtWidgets.QTextBrowser)[0] - self.exit_shortcut = QtWidgets.QShortcut( - QtGui.QKeySequence('Escape'), self.current_contentView) - self.exit_shortcut.activated.connect(self.set_normalsize) - self.current_contentView.setWindowFlags(QtCore.Qt.Window) self.current_contentView.setWindowState(QtCore.Qt.WindowFullScreen) + self.current_contentView.show() self.hide() - self.current_contentView.show() - - def set_normalsize(self): - self.current_contentView.setWindowState(QtCore.Qt.WindowNoState) - self.current_contentView.setWindowFlags(QtCore.Qt.Widget) - self.show() - self.current_contentView.show() def list_doubleclick(self, myindex): index = self.listView.model().index(myindex.row(), 0) @@ -418,9 +409,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): current_tab_widget = self.tabWidget.widget(current_tab) current_contentView = current_tab_widget.findChildren(QtWidgets.QTextBrowser)[0] + # This allows for the scrollbar to always be at the edge of the screen + current_contentView.setViewportMargins(padding, 0, padding, 0) + current_contentView.setStyleSheet( - "QTextEdit {{font-family: {0}; font-size: {1}px; padding-left: {2}; padding-right: {2}; color: {3}; background-color: {4}}}".format( - font, font_size, padding, foreground, background)) + "QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format( + font, font_size, foreground, background)) def closeEvent(self, event=None): # All tabs must be iterated upon here diff --git a/widgets.py b/widgets.py index e5f34d7..0c172c7 100644 --- a/widgets.py +++ b/widgets.py @@ -258,7 +258,6 @@ class Tab(QtWidgets.QWidget): def __init__(self, metadata, parent=None): # TODO # A horizontal slider to control flow - # Keyboard shortcuts # Take hint from a position function argument to open the book # at a specific page @@ -273,19 +272,33 @@ class Tab(QtWidgets.QWidget): self.contentView.setFrameShape(QtWidgets.QFrame.NoFrame) self.contentView.setObjectName("contentView") self.contentView.verticalScrollBar().setSingleStep(7) + self.contentView.setHorizontalScrollBarPolicy( + QtCore.Qt.ScrollBarAlwaysOff) title = self.metadata['title'] position = self.metadata['position'] + + # TODO + # Chapter position and vertical scrollbar position if not position: first_chapter_name = list(self.metadata['content'])[0] first_chapter_content = self.metadata['content'][first_chapter_name] self.contentView.setHtml(first_chapter_content) - self.contentView.setHorizontalScrollBarPolicy( - QtCore.Qt.ScrollBarAlwaysOff) self.gridLayout.addWidget(self.contentView, 0, 0, 1, 1) self.parent.addTab(self, title) + self.exit_fs = QtWidgets.QShortcut( + QtGui.QKeySequence('Escape'), self.contentView) + self.exit_fs.setContext(QtCore.Qt.ApplicationShortcut) + self.exit_fs.activated.connect(self.exit_fullscreen) + + def exit_fullscreen(self): + self.contentView.setWindowFlags(QtCore.Qt.Widget) + self.contentView.setWindowState(QtCore.Qt.WindowNoState) + self.contentView.show() + self.window().show() + class LibraryDelegate(QtWidgets.QStyledItemDelegate): def __init__(self, parent=None):