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

7
TODO
View File

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

View File

@@ -698,7 +698,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
# The set_content method is universal
# It's going to do position tracking
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):
sender = self.sender().objectName()
@@ -993,7 +993,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def start_culling_timer(self):
if self.settings['perform_culling']:
self.culling_timer.start(30)
self.culling_timer.start(90)
def resizeEvent(self, event=None):
if event:

View File

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

View File

@@ -72,6 +72,7 @@ class PliantDockWidget(QtWidgets.QDockWidget):
else:
dock_width = desktop_size.width() // 5
dock_x = viewport_topRight.x() - dock_width + 1
self.parent.navBar.hide()
self.main_window.active_docks.append(self)
self.setGeometry(dock_x, dock_y, dock_width, dock_height)
@@ -534,51 +535,72 @@ class PliantNavBarWidget(QtWidgets.QDockWidget):
self.contentView = contentView
self.parent = parent
self.setWindowTitle('Navigation')
# Animate appearance
self.animation = QtCore.QPropertyAnimation(self, b'windowOpacity')
self.animation.setDuration(200)
self.animation.setStartValue(0)
self.animation.setEndValue(1)
self.animation.setEndValue(.9)
background = self.main_window.settings['dialog_background']
self.setStyleSheet(
"QDockWidget {{background-color: {0}}}".format(background.name()))
self.backButton = QtWidgets.QPushButton('Previous')
self.nextButton = QtWidgets.QPushButton('Next')
self.tocBox = QtWidgets.QComboBox()
self.backButton = QtWidgets.QPushButton()
self.backButton.setFlat(True)
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.addWidget(self.backButton)
self.navLayout.addWidget(self.tocBox)
self.navLayout.addWidget(self.tocComboBox)
self.navLayout.addWidget(self.nextButton)
self.navWidget = QtWidgets.QWidget()
self.navWidget.setLayout(self.navLayout)
self.setWidget(self.navWidget)
def showEvent(self, event):
def showEvent(self, event=None):
# TODO
# See what happens when the size of the viewport is smaller
# than the size of the dock
viewport_bottomLeft = self.contentView.mapToGlobal(
self.contentView.viewport().rect().bottomLeft())
viewport_width = self.contentView.viewport().width()
viewport_bottomRight = self.contentView.mapToGlobal(
self.contentView.viewport().rect().bottomRight())
# Dock dimensions
desktop_size = QtWidgets.QDesktopWidget().screenGeometry()
dock_width = desktop_size.width() // 4
dock_height = 60
dock_width = desktop_size.width() // 4.5
dock_height = 30
dock_x = viewport_bottomLeft.x() + (viewport_width - dock_width) // 2
dock_y = viewport_bottomLeft.y() - 100
dock_x = viewport_bottomRight.x() - dock_width - 30
dock_y = viewport_bottomRight.y() - 70
self.main_window.active_docks.append(self)
self.setGeometry(dock_x, dock_y, dock_width, dock_height)
# Rounded
radius = 15
radius = 20
path = QtGui.QPainterPath()
path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius)
try:
@@ -588,3 +610,53 @@ class PliantNavBarWidget(QtWidgets.QDockWidget):
pass
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-original.svg</file>
<file>LightIcons/zoom-out.svg</file>
<file>next.png</file>
<file>previous.png</file>
<file>QMPlay2.svg</file>
<file>color.svg</file>
<file>blank.png</file>

View File

@@ -196,7 +196,7 @@
<item>
<widget class="QCheckBox" name="navBarVisible">
<property name="text">
<string>Show NavBar</string>
<string>Show navigation bar</string>
</property>
</widget>
</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.autoTags.setText(_translate("Dialog", "Generate tags from files"))
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.setText(_translate("Dialog", "Download missing covers"))
self.groupBox_2.setTitle(_translate("Dialog", "Reading"))

View File

@@ -513,7 +513,10 @@ class FixedComboBox(QtWidgets.QComboBox):
def sizeHint(self):
# 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):
# Disable mouse wheel scrolling in the ComboBox
@@ -526,7 +529,10 @@ class FixedLineEdit(QtWidgets.QLineEdit):
self.adjusted_size = screen_width // 4.5
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):
if event.key() == QtCore.Qt.Key_Escape:

View File

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