Improve navigation bar

This commit is contained in:
BasioMeusPuga
2019-03-16 19:38:50 -04:00
parent 56f15528c2
commit 8fd6a0d432
13 changed files with 11391 additions and 9890 deletions

View File

@@ -10,6 +10,7 @@ Currently supports:
* mobi * mobi
* azw / azw3 / azw4 * azw / azw3 / azw4
* cbr / cbz * cbr / cbz
* md
## Contribute ## Contribute
[Paypal](https://www.paypal.me/supportlector) [Paypal](https://www.paypal.me/supportlector)
@@ -31,6 +32,7 @@ Bitcoin: 17jaxj26vFJNqQ2hEVerbBV5fpTusfqFro
| --- | --- | --- | | --- | --- | --- |
| python-pymupdf | 1.14.5 | PDF support | | python-pymupdf | 1.14.5 | PDF support |
| python-djvulibre | 0.8.4 | DjVu support | | python-djvulibre | 0.8.4 | DjVu support |
| python-markdown | 3.0.1 | Markdown support |
## Support ## Support
When reporting issues: When reporting issues:

7
TODO
View File

@@ -37,6 +37,7 @@ TODO
✓ Create covers for books without them - VERY SLOW ✓ Create covers for books without them - VERY SLOW
Set focus to newly added file Set focus to newly added file
Reading: Reading:
✓ Navbar
✓ Drop down for TOC ✓ Drop down for TOC
✓ Treeview navigation for TOC ✓ Treeview navigation for TOC
✓ Override the keypress event of the textedit ✓ Override the keypress event of the textedit
@@ -64,6 +65,7 @@ TODO
✓ Paragraph indentation ✓ Paragraph indentation
✓ Comic view keyboard shortcuts ✓ Comic view keyboard shortcuts
✓ Comic view context menu ✓ Comic view context menu
✓ Image rotation
✓ Make the bookmark dock float over the reading area ✓ Make the bookmark dock float over the reading area
✓ Spacebar should not cut off lines at the top ✓ Spacebar should not cut off lines at the top
✓ Track open bookmark windows so they can be closed quickly at exit ✓ Track open bookmark windows so they can be closed quickly at exit
@@ -90,6 +92,7 @@ TODO
✓ fb2 support ✓ fb2 support
✓ Images need to show up in their placeholders ✓ Images need to show up in their placeholders
✓ djvu support ✓ djvu support
✓ markdown support
Other: Other:
✓ Define every widget in code ✓ Define every widget in code
Bugs: Bugs:
@@ -104,7 +107,6 @@ TODO
Drag and drop is acting out Drag and drop is acting out
Secondary: Secondary:
Navbar
Text to speech Text to speech
Definitions dialog needs to respond to escape Definitions dialog needs to respond to escape
Zoom slider for comics Zoom slider for comics
@@ -122,11 +124,10 @@ TODO
Goodreads API: Ratings, Read, Recommendations Goodreads API: Ratings, Read, Recommendations
Get ISBN using python-isbnlib Get ISBN using python-isbnlib
Use embedded fonts + CSS Use embedded fonts + CSS
txt, doc, chm, markdown support txt, doc, chm support
Include icons for filetype emblems Include icons for filetype emblems
Comic view modes Comic view modes
Continuous paging Continuous paging
Image rotation
Ignore a / the / numbers for sorting purposes Ignore a / the / numbers for sorting purposes
? Add only one file type if multiple are present ? Add only one file type if multiple are present
? Create emblem per filetype ? Create emblem per filetype

View File

@@ -698,7 +698,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# The set_content method is universal # The set_content method is universal
# It's going to do position tracking # It's going to do position tracking
current_tab = self.tabWidget.currentWidget() current_tab = self.tabWidget.currentWidget()
current_tab.set_content(required_position, False, True) current_tab.set_content(required_position, True, True)
def library_doubleclick(self, index): def library_doubleclick(self, index):
sender = self.sender().objectName() sender = self.sender().objectName()
@@ -993,7 +993,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def start_culling_timer(self): def start_culling_timer(self):
if self.settings['perform_culling']: if self.settings['perform_culling']:
self.culling_timer.start(30) self.culling_timer.start(90)
def resizeEvent(self, event=None): def resizeEvent(self, event=None):
if event: if event:

View File

@@ -323,7 +323,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
return return
current_position = event.pos() current_position = event.pos()
if current_position == self.mousePosition: if current_position == self.mousePosition or self.parent.sideDock.isVisible():
return return
else: else:
self.mousePosition = event.pos() self.mousePosition = event.pos()
@@ -333,7 +333,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.viewport().setCursor(QtCore.Qt.OpenHandCursor) self.viewport().setCursor(QtCore.Qt.OpenHandCursor)
else: else:
self.viewport().setCursor(QtCore.Qt.ClosedHandCursor) self.viewport().setCursor(QtCore.Qt.ClosedHandCursor)
self.parent.mouse_hide_timer.start(2000) self.parent.mouseHideTimer.start(2000)
def generate_graphicsview_context_menu(self, position): def generate_graphicsview_context_menu(self, position):
contextMenu = QtWidgets.QMenu() contextMenu = QtWidgets.QMenu()
@@ -762,7 +762,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
return return
current_position = event.pos() current_position = event.pos()
if current_position == self.mousePosition: if current_position == self.mousePosition or self.parent.sideDock.isVisible():
return return
else: else:
self.mousePosition = event.pos() self.mousePosition = event.pos()
@@ -772,7 +772,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.viewport().setCursor(QtCore.Qt.IBeamCursor) self.viewport().setCursor(QtCore.Qt.IBeamCursor)
else: else:
self.viewport().setCursor(QtCore.Qt.ArrowCursor) self.viewport().setCursor(QtCore.Qt.ArrowCursor)
self.parent.mouse_hide_timer.start(2000) self.parent.mouseHideTimer.start(2000)
class PliantWidgetsCommonFunctions: class PliantWidgetsCommonFunctions:

View File

@@ -72,6 +72,7 @@ class PliantDockWidget(QtWidgets.QDockWidget):
else: else:
dock_width = desktop_size.width() // 5 dock_width = desktop_size.width() // 5
dock_x = viewport_topRight.x() - dock_width + 1 dock_x = viewport_topRight.x() - dock_width + 1
self.parent.navBar.hide()
self.main_window.active_docks.append(self) self.main_window.active_docks.append(self)
self.setGeometry(dock_x, dock_y, dock_width, dock_height) self.setGeometry(dock_x, dock_y, dock_width, dock_height)
@@ -534,51 +535,72 @@ class PliantNavBarWidget(QtWidgets.QDockWidget):
self.contentView = contentView self.contentView = contentView
self.parent = parent self.parent = parent
self.setWindowTitle('Navigation')
# Animate appearance # Animate appearance
self.animation = QtCore.QPropertyAnimation(self, b'windowOpacity') self.animation = QtCore.QPropertyAnimation(self, b'windowOpacity')
self.animation.setDuration(200) self.animation.setDuration(200)
self.animation.setStartValue(0) self.animation.setStartValue(0)
self.animation.setEndValue(1) self.animation.setEndValue(.9)
background = self.main_window.settings['dialog_background'] background = self.main_window.settings['dialog_background']
self.setStyleSheet( self.setStyleSheet(
"QDockWidget {{background-color: {0}}}".format(background.name())) "QDockWidget {{background-color: {0}}}".format(background.name()))
self.backButton = QtWidgets.QPushButton('Previous') self.backButton = QtWidgets.QPushButton()
self.nextButton = QtWidgets.QPushButton('Next') self.backButton.setFlat(True)
self.tocBox = QtWidgets.QComboBox() icon = QtGui.QIcon()
icon.addPixmap(
QtGui.QPixmap(":/images/previous.png"),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.backButton.setIcon(icon)
self.backButton.setIconSize(QtCore.QSize(24, 24))
self.nextButton = QtWidgets.QPushButton()
self.nextButton.setFlat(True)
icon = QtGui.QIcon()
icon.addPixmap(
QtGui.QPixmap(":/images/next.png"),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.nextButton.setIcon(icon)
self.nextButton.setIconSize(QtCore.QSize(24, 24))
self.backButton.clicked.connect(lambda: self.button_click(-1))
self.nextButton.clicked.connect(lambda: self.button_click(1))
self.tocComboBox = FixedComboBox(self)
self.populate_combo_box()
self.navLayout = QtWidgets.QHBoxLayout() self.navLayout = QtWidgets.QHBoxLayout()
self.navLayout.addWidget(self.backButton) self.navLayout.addWidget(self.backButton)
self.navLayout.addWidget(self.tocBox) self.navLayout.addWidget(self.tocComboBox)
self.navLayout.addWidget(self.nextButton) self.navLayout.addWidget(self.nextButton)
self.navWidget = QtWidgets.QWidget() self.navWidget = QtWidgets.QWidget()
self.navWidget.setLayout(self.navLayout) self.navWidget.setLayout(self.navLayout)
self.setWidget(self.navWidget) self.setWidget(self.navWidget)
def showEvent(self, event): def showEvent(self, event=None):
# TODO # TODO
# See what happens when the size of the viewport is smaller # See what happens when the size of the viewport is smaller
# than the size of the dock # than the size of the dock
viewport_bottomLeft = self.contentView.mapToGlobal( viewport_bottomRight = self.contentView.mapToGlobal(
self.contentView.viewport().rect().bottomLeft()) self.contentView.viewport().rect().bottomRight())
viewport_width = self.contentView.viewport().width()
# Dock dimensions # Dock dimensions
desktop_size = QtWidgets.QDesktopWidget().screenGeometry() desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
dock_width = desktop_size.width() // 4 dock_width = desktop_size.width() // 4.5
dock_height = 60 dock_height = 30
dock_x = viewport_bottomLeft.x() + (viewport_width - dock_width) // 2 dock_x = viewport_bottomRight.x() - dock_width - 30
dock_y = viewport_bottomLeft.y() - 100 dock_y = viewport_bottomRight.y() - 70
self.main_window.active_docks.append(self) self.main_window.active_docks.append(self)
self.setGeometry(dock_x, dock_y, dock_width, dock_height) self.setGeometry(dock_x, dock_y, dock_width, dock_height)
# Rounded # Rounded
radius = 15 radius = 20
path = QtGui.QPainterPath() path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius) path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try: try:
@@ -588,3 +610,53 @@ class PliantNavBarWidget(QtWidgets.QDockWidget):
pass pass
self.animation.start() self.animation.start()
def populate_combo_box(self):
def set_toc_position(tocTree):
currentIndex = tocTree.currentIndex()
required_position = currentIndex.data(QtCore.Qt.UserRole)
self.return_focus()
self.parent.set_content(required_position, True, True)
# Create the Combobox / Treeview combination
tocTree = QtWidgets.QTreeView()
self.tocComboBox.setView(tocTree)
self.tocComboBox.setModel(self.parent.tocModel)
tocTree.setRootIsDecorated(False)
tocTree.setItemsExpandable(False)
tocTree.expandAll()
# Set the position of the QComboBox
self.parent.set_tocBox_index(None, self.tocComboBox)
# Make clicking do something
self.tocComboBox.currentIndexChanged.connect(
lambda: set_toc_position(tocTree))
def button_click(self, change):
self.contentView.common_functions.change_chapter(change)
self.return_focus()
def return_focus(self):
# The NavBar needs to be hidden after clicking
self.parent.activateWindow()
self.parent.contentView.setFocus()
self.parent.mouseHideTimer.start()
class FixedComboBox(QtWidgets.QComboBox):
def __init__(self, parent=None):
super(FixedComboBox, self).__init__(parent)
screen_width = QtWidgets.QDesktopWidget().screenGeometry().width()
self.adjusted_size = screen_width // 6
def sizeHint(self):
# This and the one below should adjust to screen size
return self.minimumSizeHint()
def minimumSizeHint(self):
return QtCore.QSize(self.adjusted_size, 32)
def wheelEvent(self, QWheelEvent):
# Disable mouse wheel scrolling in the ComboBox
return

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@@ -96,6 +96,8 @@
<file>LightIcons/zoom-in.svg</file> <file>LightIcons/zoom-in.svg</file>
<file>LightIcons/zoom-original.svg</file> <file>LightIcons/zoom-original.svg</file>
<file>LightIcons/zoom-out.svg</file> <file>LightIcons/zoom-out.svg</file>
<file>next.png</file>
<file>previous.png</file>
<file>QMPlay2.svg</file> <file>QMPlay2.svg</file>
<file>color.svg</file> <file>color.svg</file>
<file>blank.png</file> <file>blank.png</file>

View File

@@ -196,7 +196,7 @@
<item> <item>
<widget class="QCheckBox" name="navBarVisible"> <widget class="QCheckBox" name="navBarVisible">
<property name="text"> <property name="text">
<string>Show NavBar</string> <string>Show navigation bar</string>
</property> </property>
</widget> </widget>
</item> </item>

File diff suppressed because it is too large Load Diff

View File

@@ -390,7 +390,7 @@ class Ui_Dialog(object):
self.performCulling.setText(_translate("Dialog", "Load covers only when needed")) self.performCulling.setText(_translate("Dialog", "Load covers only when needed"))
self.autoTags.setText(_translate("Dialog", "Generate tags from files")) self.autoTags.setText(_translate("Dialog", "Generate tags from files"))
self.attenuateTitles.setText(_translate("Dialog", "Shrink long book titles")) self.attenuateTitles.setText(_translate("Dialog", "Shrink long book titles"))
self.navBarVisible.setText(_translate("Dialog", "Show NavBar")) self.navBarVisible.setText(_translate("Dialog", "Show navigation bar"))
self.autoCover.setToolTip(_translate("Dialog", "<html><head/><body><p>Attempt to download missing book covers from Google books - SLOW</p></body></html>")) self.autoCover.setToolTip(_translate("Dialog", "<html><head/><body><p>Attempt to download missing book covers from Google books - SLOW</p></body></html>"))
self.autoCover.setText(_translate("Dialog", "Download missing covers")) self.autoCover.setText(_translate("Dialog", "Download missing covers"))
self.groupBox_2.setTitle(_translate("Dialog", "Reading")) self.groupBox_2.setTitle(_translate("Dialog", "Reading"))

View File

@@ -513,7 +513,10 @@ class FixedComboBox(QtWidgets.QComboBox):
def sizeHint(self): def sizeHint(self):
# This and the one below should adjust to screen size # This and the one below should adjust to screen size
return QtCore.QSize(self.adjusted_size, 22) return self.minimumSizeHint()
def minimumSizeHint(self):
return QtCore.QSize(self.adjusted_size, 32)
def wheelEvent(self, QWheelEvent): def wheelEvent(self, QWheelEvent):
# Disable mouse wheel scrolling in the ComboBox # Disable mouse wheel scrolling in the ComboBox
@@ -526,7 +529,10 @@ class FixedLineEdit(QtWidgets.QLineEdit):
self.adjusted_size = screen_width // 4.5 self.adjusted_size = screen_width // 4.5
def sizeHint(self): def sizeHint(self):
return QtCore.QSize(self.adjusted_size, 22) return self.minimumSizeHint()
def minimumSizeHint(self):
return QtCore.QSize(self.adjusted_size, 32)
def keyReleaseEvent(self, event): def keyReleaseEvent(self, event):
if event.key() == QtCore.Qt.Key_Escape: if event.key() == QtCore.Qt.Key_Escape:

View File

@@ -192,9 +192,9 @@ class Tab(QtWidgets.QWidget):
this_tab_index, QtGui.QIcon(cover_icon)) this_tab_index, QtGui.QIcon(cover_icon))
# Hide mouse cursor timer # Hide mouse cursor timer
self.mouse_hide_timer = QtCore.QTimer() self.mouseHideTimer = QtCore.QTimer()
self.mouse_hide_timer.setSingleShot(True) self.mouseHideTimer.setSingleShot(True)
self.mouse_hide_timer.timeout.connect(self.hide_mouse) self.mouseHideTimer.timeout.connect(self.hide_mouse)
# Hide the tab bar in case distraction free mode is active # Hide the tab bar in case distraction free mode is active
if not self.main_window.settings['show_bars']: if not self.main_window.settings['show_bars']:
@@ -403,7 +403,7 @@ class Tab(QtWidgets.QWidget):
if not self.are_we_doing_images_only: if not self.are_we_doing_images_only:
self.hiddenButton.animateClick(50) self.hiddenButton.animateClick(50)
self.mouse_hide_timer.start(2000) self.mouseHideTimer.start(2000)
self.is_fullscreen = True self.is_fullscreen = True
def exit_fullscreen(self): def exit_fullscreen(self):
@@ -436,7 +436,8 @@ class Tab(QtWidgets.QWidget):
if not self.main_window.settings['show_bars']: if not self.main_window.settings['show_bars']:
self.main_window.toggle_distraction_free() self.main_window.toggle_distraction_free()
self.mouse_hide_timer.start(2000) self.navBar.hide()
self.mouseHideTimer.start(2000)
self.contentView.setFocus() self.contentView.setFocus()
def set_content(self, required_position, tocBox_readjust=False, record_position=False): def set_content(self, required_position, tocBox_readjust=False, record_position=False):
@@ -473,6 +474,13 @@ class Tab(QtWidgets.QWidget):
if tocBox_readjust: if tocBox_readjust:
self.set_tocBox_index(required_position, None) self.set_tocBox_index(required_position, None)
# The NavBar doesn't get declared until later
try:
self.set_tocBox_index(
required_position, self.navBar.tocComboBox)
except AttributeError:
pass
self.contentView.setFocus() self.contentView.setFocus()
def set_tocBox_index(self, current_position=None, tocBox=None): def set_tocBox_index(self, current_position=None, tocBox=None):
@@ -583,7 +591,9 @@ class Tab(QtWidgets.QWidget):
def hide_mouse(self): def hide_mouse(self):
self.contentView.viewport().setCursor(QtCore.Qt.BlankCursor) self.contentView.viewport().setCursor(QtCore.Qt.BlankCursor)
self.navBar.hide()
if self.contentView.hasFocus():
self.navBar.hide()
def sneaky_change(self): def sneaky_change(self):
direction = -1 direction = -1