diff --git a/TODO b/TODO index a2dad3d..a0efc61 100644 --- a/TODO +++ b/TODO @@ -50,6 +50,7 @@ TODO Continuous paging Double pages Record progress + Bookmarks Pagination Set context menu for definitions and the like Scrolling: Smooth / By Line diff --git a/__main__.py b/__main__.py index 988982c..2a586db 100755 --- a/__main__.py +++ b/__main__.py @@ -35,7 +35,6 @@ from settings import Settings from settingsdialog import SettingsUI - class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): def __init__(self): super(MainUI, self).__init__() @@ -558,6 +557,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): # Go on to change the value of the Table of Contents box current_tab.change_chapter_tocBox() + self.format_contentView() def set_fullscreen(self): current_tab = self.tabWidget.currentIndex() @@ -637,6 +637,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): self.tabWidget.setCurrentIndex(self.tabWidget.count() - 1) finishing_touches() + + # TODO + # def dropEvent def get_color(self): signal_sender = self.sender().objectName() @@ -697,9 +700,9 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): current_profile['font_size'] = old_size if signal_sender == 'lineSpacingUp' and current_profile['line_spacing'] < 200: - current_profile['line_spacing'] += 10 + current_profile['line_spacing'] += 5 if signal_sender == 'lineSpacingDown' and current_profile['line_spacing'] > 100: - current_profile['line_spacing'] -= 10 + current_profile['line_spacing'] -= 5 if signal_sender == 'paddingUp': current_profile['padding'] += 5 @@ -753,7 +756,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): def format_contentView(self): # TODO - # Implement line spacing # See what happens if a font isn't installed current_tab = self.tabWidget.widget(self.tabWidget.currentIndex()) diff --git a/models.py b/models.py index de7eac8..fd10e0f 100644 --- a/models.py +++ b/models.py @@ -44,7 +44,7 @@ class ItemProxyModel(QtCore.QSortFilterProxyModel): directory_tags = model.data(this_index, QtCore.Qt.UserRole + 11) if self.active_library_filters: - if directory_name not in self.active_library_filters: + if directory_name.lower() not in [i.lower() for i in self.active_library_filters]: return False else: return False @@ -188,8 +188,8 @@ class TableProxyModel(QtCore.QSortFilterProxyModel): # Filter out all books not in the active library filters if self.active_library_filters: - current_library_name = valid_data[-2] - if current_library_name not in self.active_library_filters: + current_library_name = valid_data[-2].lower() + if current_library_name not in [i.lower() for i in self.active_library_filters]: return False else: return False @@ -198,7 +198,6 @@ class TableProxyModel(QtCore.QSortFilterProxyModel): if i: if self.filter_string in i: return True - return False diff --git a/widgets.py b/widgets.py index 445d43b..d9cd1ce 100644 --- a/widgets.py +++ b/widgets.py @@ -420,13 +420,35 @@ class Tab(QtWidgets.QWidget): relative_paths.append(os.path.join(relative_path_root, i[0])) self.contentView.setSearchPaths(relative_paths) - self.contentView.setOpenLinks(False) # Change this when HTML navigation works + self.contentView.setOpenLinks(False) # TODO Change this when HTML navigation works self.contentView.setHtml(chapter_content) + def set_scroll_value(): + # self.window().tabWidget.blockSignals(True) + previous_widget = self.window().tabWidget.currentWidget() + self.window().tabWidget.setCurrentWidget(self) + + scroll_position = int( + self.metadata['position']['scroll_value'] * + self.contentView.verticalScrollBar().maximum()) + + # print(self.contentView.verticalScrollBar().maximum(), scroll_position) + # print(self.metadata['position']) + + self.contentView.verticalScrollBar().setValue(scroll_position) + + self.window().tabWidget.setCurrentWidget(previous_widget) + # self.window().tabWidget.blockSignals(False) + + temp_hidden_button = QtWidgets.QToolButton(self) + temp_hidden_button.setVisible(False) + temp_hidden_button.clicked.connect(set_scroll_value) + temp_hidden_button.animateClick(100) + # The following are common to both the text browser and # the graphics view self.contentView.setFrameShape(QtWidgets.QFrame.NoFrame) - self.contentView.setObjectName("contentView") + self.contentView.setObjectName('contentView') self.contentView.verticalScrollBar().setSingleStep(7) self.contentView.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) @@ -454,7 +476,7 @@ class Tab(QtWidgets.QWidget): self.mouse_hide_timer.timeout.connect(self.hide_mouse) self.contentView.setFocus() - + def generate_position(self): total_chapters = len(self.metadata['content'].keys()) # TODO @@ -463,8 +485,7 @@ class Tab(QtWidgets.QWidget): 'current_chapter': 1, 'current_line': 0, 'total_chapters': total_chapters, - 'read_lines': 0, - 'total_lines': 0} + 'scroll_value': 0} def generate_keyboard_shortcuts(self): self.next_chapter = QtWidgets.QShortcut( @@ -527,7 +548,6 @@ class Tab(QtWidgets.QWidget): self.contentView.resizeEvent() else: - self.contentView.setStyleSheet( "QTextEdit {{font-family: {0}; font-size: {1}px; color: {2}; background-color: {3}}}".format( font, font_size, foreground.name(), background.name())) @@ -677,6 +697,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser): self.setMouseTracking(True) def wheelEvent(self, event): + self.parent.metadata['position']['scroll_value'] = ( + self.verticalScrollBar().value() / self.verticalScrollBar().maximum()) self.common_functions.wheelEvent(event, False) def keyPressEvent(self, event): @@ -684,6 +706,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser): vertical = self.verticalScrollBar().value() maximum = self.verticalScrollBar().maximum() + self.parent.metadata['position']['scroll_value'] = (vertical / maximum) + if vertical == maximum: self.common_functions.change_chapter(1, True) else: @@ -760,7 +784,7 @@ class PliantWidgetsCommonFunctions(): if not was_button_pressed: self.pw.ignore_wheel_event = True - + class LibraryDelegate(QtWidgets.QStyledItemDelegate): def __init__(self, temp_dir, parent=None):