UI elements for page modes

This commit is contained in:
BasioMeusPuga
2018-10-29 23:08:34 +05:30
parent ee18f157f1
commit b5349315be
12 changed files with 7459 additions and 7243 deletions

2
TODO
View File

@@ -87,8 +87,10 @@ TODO
Clean up 'switch' page layout
Colors aren't loaded properly for annotation previews
Cover page shouldn't be scolled midway
Last line in QTextBrowser should never be cut off
Secondary:
Double page view for books
Graphical themes
Change focus rectangle dimensions
Tab reordering

View File

@@ -177,6 +177,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.bookToolBar.distractionFreeButton.triggered.connect(self.toggle_distraction_free)
self.bookToolBar.fullscreenButton.triggered.connect(self.set_fullscreen)
self.bookToolBar.singlePageButton.triggered.connect(self.change_page_view)
self.bookToolBar.doublePageButton.triggered.connect(self.change_page_view)
for count, i in enumerate(self.display_profiles):
self.bookToolBar.profileBox.setItemData(count, i, QtCore.Qt.UserRole)
self.bookToolBar.profileBox.currentIndexChanged.connect(
@@ -761,6 +764,10 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
#____________________________________________
def change_page_view(self):
self.settings['page_view_button'] = self.sender().objectName()
print(self.sender().objectName())
def search_book(self, search_text):
current_tab = self.tabWidget.currentIndex()
if not (current_tab != 0 and not self.tabWidget.widget(

View File

@@ -74,7 +74,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
def loadImage(self, current_page):
# TODO
# For double page view: 1 before, 1 after
# For double page view: 2 before, 2 after
all_pages = [i[1] for i in self.parent.metadata['content']]
def load_page(current_page):
@@ -93,7 +93,14 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
print('Building image cache')
current_page_index = all_pages.index(current_page)
for i in (-1, 0, 1, 2):
# Image caching for single and double page views
if self.main_window.settings['page_view_button'] == 'singlePageButton':
page_indices = (-1, 0, 1, 2)
else:
# 2 page view
page_indices = (-2, -1, 0, 1, 2, 3)
for i in page_indices:
try:
this_page = all_pages[current_page_index + i]
this_pixmap = load_page(this_page)
@@ -171,10 +178,10 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
image_pixmap = self.image_pixmap.scaledToWidth(
available_width, QtCore.Qt.SmoothTransformation)
graphics_scene = QtWidgets.QGraphicsScene()
graphics_scene.addPixmap(image_pixmap)
graphicsScene = QtWidgets.QGraphicsScene()
graphicsScene.addPixmap(image_pixmap)
self.setScene(graphics_scene)
self.setScene(graphicsScene)
self.show()
def wheelEvent(self, event):
@@ -751,14 +758,14 @@ class PliantWidgetsCommonFunctions:
def generate_combo_box_action(self, contextMenu):
contextMenu.addSeparator()
toc_combobox = QtWidgets.QComboBox()
tocCombobox = QtWidgets.QComboBox()
toc_data = [i[0] for i in self.pw.parent.metadata['content']]
toc_combobox.addItems(toc_data)
toc_combobox.setCurrentIndex(
tocCombobox.addItems(toc_data)
tocCombobox.setCurrentIndex(
self.pw.main_window.bookToolBar.tocBox.currentIndex())
toc_combobox.currentIndexChanged.connect(
tocCombobox.currentIndexChanged.connect(
self.pw.main_window.bookToolBar.tocBox.setCurrentIndex)
comboboxAction = QtWidgets.QWidgetAction(self.pw)
comboboxAction.setDefaultWidget(toc_combobox)
comboboxAction.setDefaultWidget(tocCombobox)
contextMenu.addAction(comboboxAction)

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<defs>
<style id="current-color-scheme" type="text/css">
.ColorScheme-Text { color:#5c616c; } .ColorScheme-Highlight { color:#5294e2; }
</style>
</defs>
<path style="fill:currentColor" class="ColorScheme-Text" d="M 2 1 L 2 15 L 14 15 L 14 1 L 2 1 z M 4 3 L 12 3 L 12 13 L 4 13 L 4 3 z" transform="translate(4 4)"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<defs>
<style id="current-color-scheme" type="text/css">
.ColorScheme-Text { color:#5c616c; } .ColorScheme-Highlight { color:#5294e2; }
</style>
</defs>
<path style="fill:currentColor" class="ColorScheme-Text" d="M 1 1 L 1 15 L 15 15 L 15 1 L 1 1 z M 3 3 L 7 3 L 7 13 L 3 13 L 3 3 z M 9 3 L 13 3 L 13 13 L 9 13 L 9 3 z" transform="translate(4 4)"/>
</svg>

After

Width:  |  Height:  |  Size: 450 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<defs>
<style id="current-color-scheme" type="text/css">
.ColorScheme-Text { color:#d3dae3; } .ColorScheme-Highlight { color:#5294e2; }
</style>
</defs>
<path style="fill:currentColor" class="ColorScheme-Text" d="M 1 1 L 1 15 L 15 15 L 15 1 L 1 1 z M 3 3 L 7 3 L 7 13 L 3 13 L 3 3 z M 9 3 L 13 3 L 13 13 L 9 13 L 9 3 z" transform="translate(4 4)"/>
</svg>

After

Width:  |  Height:  |  Size: 450 B

View File

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<defs>
<style id="current-color-scheme" type="text/css">
.ColorScheme-Text { color:#d3dae3; } .ColorScheme-Highlight { color:#5294e2; }
</style>
</defs>
<path style="fill:currentColor" class="ColorScheme-Text" d="M 2 1 L 2 15 L 14 15 L 14 1 L 2 1 z M 4 3 L 12 3 L 12 13 L 4 13 L 4 3 z" transform="translate(4 4)"/>
</svg>

After

Width:  |  Height:  |  Size: 416 B

View File

@@ -1,5 +1,9 @@
<RCC>
<qresource prefix="images">
<file>DarkIcons/page-single.svg</file>
<file>DarkIcons/page-double.svg</file>
<file>LightIcons/page-single.svg</file>
<file>LightIcons/page-double.svg</file>
<file>DarkIcons/about.svg</file>
<file>DarkIcons/switches.svg</file>
<file>LightIcons/about.svg</file>

File diff suppressed because it is too large Load Diff

View File

@@ -125,6 +125,8 @@ class Settings:
self.parent.settings['consider_read_at'] = int(self.settings.value('considerReadAt', 95))
self.parent.settings['attenuate_titles'] = literal_eval(self.settings.value(
'attenuateTitles', 'False').capitalize())
self.parent.settings['page_view_button'] = self.settings.value(
'pageViewButton', 'singlePageButton')
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')
@@ -206,6 +208,7 @@ class Settings:
self.settings.setValue('tocWithBookmarks', str(current_settings['toc_with_bookmarks']))
self.settings.setValue('scrollSpeed', current_settings['scroll_speed'])
self.settings.setValue('considerReadAt', current_settings['consider_read_at'])
self.settings.setValue('pageViewButton', current_settings['page_view_button'])
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')

View File

@@ -148,7 +148,7 @@ class BackGroundCacheRefill(QtCore.QThread):
image_pixmap.loadFromData(page_data)
elif self.filetype == 'pdf':
page_data = self.book.page(current_page)
page_qimage = page_data.renderToImage(350, 350)
page_qimage = page_data.renderToImage(400, 400) # TODO Readjust
image_pixmap.convertFromImage(page_qimage)
return image_pixmap

View File

@@ -68,6 +68,26 @@ class BookToolBar(QtWidgets.QToolBar):
self._translate('BookToolBar', 'Reset profile'),
self)
# Single and double page view buttons
self.singlePageButton = QtWidgets.QAction(
image_factory.get_image('page-single'),
self._translate('BookToolBar', 'View as single page'),
self)
self.singlePageButton.setObjectName('singlePageButton')
self.singlePageButton.setCheckable(True)
self.doublePageButton = QtWidgets.QAction(
image_factory.get_image('page-double'),
self._translate('BookToolBar', 'View as double page'),
self)
self.doublePageButton.setObjectName('doublePageButton')
self.doublePageButton.setCheckable(True)
self.pageViewButtons = QtWidgets.QActionGroup(self)
self.pageViewButtons.setExclusive(True)
self.pageViewButtons.addAction(self.singlePageButton)
self.pageViewButtons.addAction(self.doublePageButton)
# Add buttons
self.addAction(self.fontButton)
self.fontButton.setCheckable(True)
@@ -80,6 +100,9 @@ class BookToolBar(QtWidgets.QToolBar):
self.addAction(self.bookmarkButton)
self.bookmarkButton.setCheckable(True)
self.addSeparator()
self.addAction(self.singlePageButton)
self.addAction(self.doublePageButton)
self.addSeparator()
self.addAction(self.distractionFreeButton)
self.addAction(self.fullscreenButton)