Add TOC to context menu in distraction free mode
This commit is contained in:
@@ -556,6 +556,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.lib_ref.update_proxymodels()
|
self.lib_ref.update_proxymodels()
|
||||||
self.lib_ref.generate_library_tags()
|
self.lib_ref.generate_library_tags()
|
||||||
|
|
||||||
|
self.statusMessage.setText(
|
||||||
|
str(self.lib_ref.item_proxy_model.rowCount()) + ' books')
|
||||||
|
|
||||||
if not self.settings['perform_culling']:
|
if not self.settings['perform_culling']:
|
||||||
self.load_all_covers()
|
self.load_all_covers()
|
||||||
|
|
||||||
|
@@ -678,11 +678,17 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
|
|
||||||
def generate_graphicsview_context_menu(self, position):
|
def generate_graphicsview_context_menu(self, position):
|
||||||
contextMenu = QtWidgets.QMenu()
|
contextMenu = QtWidgets.QMenu()
|
||||||
viewSubMenu = contextMenu.addMenu('View')
|
|
||||||
|
|
||||||
saveAction = contextMenu.addAction(
|
saveAction = contextMenu.addAction(
|
||||||
self.main_window.QImageFactory.get_image('filesaveas'),
|
self.main_window.QImageFactory.get_image('filesaveas'),
|
||||||
self._translate('PliantQGraphicsView', 'Save page as...'))
|
self._translate('PliantQGraphicsView', 'Save page as...'))
|
||||||
|
toggleAction = contextMenu.addAction(
|
||||||
|
self.main_window.QImageFactory.get_image('visibility'),
|
||||||
|
self._translate('PliantQGraphicsView', 'Toggle distraction free mode'))
|
||||||
|
|
||||||
|
viewSubMenu = contextMenu.addMenu('View')
|
||||||
|
viewSubMenu.setIcon(
|
||||||
|
self.main_window.QImageFactory.get_image('mail-thread-watch'))
|
||||||
|
|
||||||
zoominAction = viewSubMenu.addAction(
|
zoominAction = viewSubMenu.addAction(
|
||||||
self.main_window.QImageFactory.get_image('zoom-in'),
|
self.main_window.QImageFactory.get_image('zoom-in'),
|
||||||
@@ -704,9 +710,17 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
self.main_window.QImageFactory.get_image('zoom-original'),
|
self.main_window.QImageFactory.get_image('zoom-original'),
|
||||||
self._translate('PliantQGraphicsView', 'Original size (O)'))
|
self._translate('PliantQGraphicsView', 'Original size (O)'))
|
||||||
|
|
||||||
toggleAction = contextMenu.addAction(
|
if not self.main_window.settings['show_bars']:
|
||||||
self.main_window.QImageFactory.get_image('visibility'),
|
tocSubMenu = contextMenu.addMenu(
|
||||||
self._translate('PliantQGraphicsView', 'Toggle distraction free mode'))
|
self._translate('PliantQGraphicsView', 'Table of Contents'))
|
||||||
|
tocSubMenu.setIcon(
|
||||||
|
self.main_window.QImageFactory.get_image('tableofcontents'))
|
||||||
|
|
||||||
|
current_toc = [i[0] for i in self.parent.metadata['content']]
|
||||||
|
for count, i in enumerate(current_toc):
|
||||||
|
this_action = tocSubMenu.addAction(i)
|
||||||
|
this_action.setData(count)
|
||||||
|
this_action.triggered.connect(self.set_chapter)
|
||||||
|
|
||||||
action = contextMenu.exec_(self.sender().mapToGlobal(position))
|
action = contextMenu.exec_(self.sender().mapToGlobal(position))
|
||||||
|
|
||||||
@@ -733,6 +747,9 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
if action in view_action_dict:
|
if action in view_action_dict:
|
||||||
self.main_window.modify_comic_view(view_action_dict[action])
|
self.main_window.modify_comic_view(view_action_dict[action])
|
||||||
|
|
||||||
|
def set_chapter(self):
|
||||||
|
self.common_functions.set_chapter(self.sender().data())
|
||||||
|
|
||||||
def closeEvent(self, *args):
|
def closeEvent(self, *args):
|
||||||
# In case the program is closed when a contentView is fullscreened
|
# In case the program is closed when a contentView is fullscreened
|
||||||
self.main_window.closeEvent()
|
self.main_window.closeEvent()
|
||||||
@@ -805,25 +822,37 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
selected_word = self.textCursor().selection()
|
selected_word = self.textCursor().selection()
|
||||||
selected_word = selected_word.toPlainText()
|
selected_word = selected_word.toPlainText()
|
||||||
|
|
||||||
context_menu = QtWidgets.QMenu()
|
contextMenu = QtWidgets.QMenu()
|
||||||
|
|
||||||
defineAction = 'Caesar si viveret, ad remum dareris'
|
defineAction = 'Caesar si viveret, ad remum dareris'
|
||||||
if selected_word and selected_word != '':
|
if selected_word and selected_word != '':
|
||||||
selected_word = selected_word.split()[0]
|
selected_word = selected_word.split()[0]
|
||||||
define_string = self._translate('PliantQTextBrowser', 'Define')
|
define_string = self._translate('PliantQTextBrowser', 'Define')
|
||||||
defineAction = context_menu.addAction(
|
defineAction = contextMenu.addAction(
|
||||||
self.main_window.QImageFactory.get_image('view-readermode'),
|
self.main_window.QImageFactory.get_image('view-readermode'),
|
||||||
f'{define_string} "{selected_word}"')
|
f'{define_string} "{selected_word}"')
|
||||||
|
|
||||||
searchAction = context_menu.addAction(
|
searchAction = contextMenu.addAction(
|
||||||
self.main_window.QImageFactory.get_image('search'),
|
self.main_window.QImageFactory.get_image('search'),
|
||||||
self._translate('PliantQTextBrowser', 'Search'))
|
self._translate('PliantQTextBrowser', 'Search'))
|
||||||
|
|
||||||
toggleAction = context_menu.addAction(
|
toggleAction = contextMenu.addAction(
|
||||||
self.main_window.QImageFactory.get_image('visibility'),
|
self.main_window.QImageFactory.get_image('visibility'),
|
||||||
self._translate('PliantQTextBrowser', 'Toggle distraction free mode'))
|
self._translate('PliantQTextBrowser', 'Toggle distraction free mode'))
|
||||||
|
|
||||||
action = context_menu.exec_(self.sender().mapToGlobal(position))
|
if not self.main_window.settings['show_bars']:
|
||||||
|
tocSubMenu = contextMenu.addMenu(
|
||||||
|
self._translate('PliantQTextBrowser', 'Table of Contents'))
|
||||||
|
tocSubMenu.setIcon(
|
||||||
|
self.main_window.QImageFactory.get_image('tableofcontents'))
|
||||||
|
|
||||||
|
current_toc = [i[0] for i in self.parent.metadata['content']]
|
||||||
|
for count, i in enumerate(current_toc):
|
||||||
|
this_action = tocSubMenu.addAction(i)
|
||||||
|
this_action.setData(count)
|
||||||
|
this_action.triggered.connect(self.set_chapter)
|
||||||
|
|
||||||
|
action = contextMenu.exec_(self.sender().mapToGlobal(position))
|
||||||
|
|
||||||
if action == defineAction:
|
if action == defineAction:
|
||||||
self.main_window.definitionDialog.find_definition(selected_word)
|
self.main_window.definitionDialog.find_definition(selected_word)
|
||||||
@@ -832,6 +861,9 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
|||||||
if action == toggleAction:
|
if action == toggleAction:
|
||||||
self.main_window.toggle_distraction_free()
|
self.main_window.toggle_distraction_free()
|
||||||
|
|
||||||
|
def set_chapter(self):
|
||||||
|
self.common_functions.set_chapter(self.sender().data())
|
||||||
|
|
||||||
def closeEvent(self, *args):
|
def closeEvent(self, *args):
|
||||||
self.main_window.closeEvent()
|
self.main_window.closeEvent()
|
||||||
|
|
||||||
@@ -907,6 +939,10 @@ class PliantWidgetsCommonFunctions():
|
|||||||
if not was_button_pressed:
|
if not was_button_pressed:
|
||||||
self.pw.ignore_wheel_event = True
|
self.pw.ignore_wheel_event = True
|
||||||
|
|
||||||
|
def set_chapter(self, chapter_index):
|
||||||
|
self.main_window.bookToolBar.tocBox.setCurrentIndex(
|
||||||
|
chapter_index)
|
||||||
|
|
||||||
|
|
||||||
class PliantDockWidget(QtWidgets.QDockWidget):
|
class PliantDockWidget(QtWidgets.QDockWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="images">
|
<qresource prefix="images">
|
||||||
|
<file>DarkIcons/tableofcontents.svg</file>
|
||||||
|
<file>LightIcons/tableofcontents.svg</file>
|
||||||
<file>DarkIcons/filesaveas.svg</file>
|
<file>DarkIcons/filesaveas.svg</file>
|
||||||
<file>LightIcons/filesaveas.svg</file>
|
<file>LightIcons/filesaveas.svg</file>
|
||||||
<file>DarkIcons/search.svg</file>
|
<file>DarkIcons/search.svg</file>
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user