Switch context menu TOC to combobox
Update translations
This commit is contained in:
@@ -711,16 +711,7 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
||||
self._translate('PliantQGraphicsView', 'Original size (O)'))
|
||||
|
||||
if not self.main_window.settings['show_bars']:
|
||||
tocSubMenu = contextMenu.addMenu(
|
||||
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)
|
||||
self.common_functions.generate_combo_box_action(contextMenu)
|
||||
|
||||
action = contextMenu.exec_(self.sender().mapToGlobal(position))
|
||||
|
||||
@@ -747,9 +738,6 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
||||
if action in view_action_dict:
|
||||
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):
|
||||
# In case the program is closed when a contentView is fullscreened
|
||||
self.main_window.closeEvent()
|
||||
@@ -841,16 +829,7 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
||||
self._translate('PliantQTextBrowser', 'Toggle distraction free mode'))
|
||||
|
||||
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)
|
||||
self.common_functions.generate_combo_box_action(contextMenu)
|
||||
|
||||
action = contextMenu.exec_(self.sender().mapToGlobal(position))
|
||||
|
||||
@@ -861,9 +840,6 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
|
||||
if action == toggleAction:
|
||||
self.main_window.toggle_distraction_free()
|
||||
|
||||
def set_chapter(self):
|
||||
self.common_functions.set_chapter(self.sender().data())
|
||||
|
||||
def closeEvent(self, *args):
|
||||
self.main_window.closeEvent()
|
||||
|
||||
@@ -939,9 +915,20 @@ class PliantWidgetsCommonFunctions():
|
||||
if not was_button_pressed:
|
||||
self.pw.ignore_wheel_event = True
|
||||
|
||||
def set_chapter(self, chapter_index):
|
||||
self.main_window.bookToolBar.tocBox.setCurrentIndex(
|
||||
chapter_index)
|
||||
def generate_combo_box_action(self, contextMenu):
|
||||
contextMenu.addSeparator()
|
||||
|
||||
toc_combobox = QtWidgets.QComboBox()
|
||||
toc_data = [i[0] for i in self.pw.parent.metadata['content']]
|
||||
toc_combobox.addItems(toc_data)
|
||||
toc_combobox.setCurrentIndex(
|
||||
self.pw.main_window.bookToolBar.tocBox.currentIndex())
|
||||
toc_combobox.currentIndexChanged.connect(
|
||||
self.pw.main_window.bookToolBar.tocBox.setCurrentIndex)
|
||||
|
||||
comboboxAction = QtWidgets.QWidgetAction(self.pw)
|
||||
comboboxAction.setDefaultWidget(toc_combobox)
|
||||
contextMenu.addAction(comboboxAction)
|
||||
|
||||
|
||||
class PliantDockWidget(QtWidgets.QDockWidget):
|
||||
|
Reference in New Issue
Block a user