From 91bde6272377d8c4bd91885f18d89d6507cc736f Mon Sep 17 00:00:00 2001 From: BasioMeusPuga Date: Sat, 3 Mar 2018 09:35:52 +0530 Subject: [PATCH] Small fixes --- __main__.py | 63 ++++++++++++++++++++++++++--------------------------- library.py | 2 +- widgets.py | 5 ++++- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/__main__.py b/__main__.py index cc8b9d1..602aa21 100755 --- a/__main__.py +++ b/__main__.py @@ -261,30 +261,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): if self.settings['scan_library']: self.settingsDialog.start_library_scan() - def generate_library_context_menu(self, position): - # TODO - # The library might have multiple items selected - # Make sure the context menu actions are carried out on each - - index = self.sender().indexAt(position) - if not index.isValid(): - return - - context_menu = QtWidgets.QMenu() - - openAction = context_menu.addAction( - QtGui.QIcon.fromTheme('view-readermode'), 'Start reading') - editAction = context_menu.addAction( - QtGui.QIcon.fromTheme('edit-rename'), 'Edit') - deleteAction = context_menu.addAction( - QtGui.QIcon.fromTheme('trash-empty'), 'Delete') - readAction = context_menu.addAction( - QtGui.QIcon.fromTheme('vcs-normal'), 'Mark read') - unreadAction = context_menu.addAction( - QtGui.QIcon.fromTheme('emblem-unavailable'), 'Mark unread') - - action = context_menu.exec_(self.sender().mapToGlobal(position)) - def open_books_at_startup(self): # Last open books and command line books aren't being opened together # so that command line books are processed last and therefore retain focus @@ -956,13 +932,31 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): else: self.settingsDialog.hide() - def generate_library_filter_menu(self, directory_list=None): + def generate_library_context_menu(self, position): # TODO - # Connect this to filtering @ the level of the library - # Remember state of the checkboxes on library update and application restart - # Behavior for clicking on All - # Don't show anything for less than 2 library folders + # The library might have multiple items selected + # Make sure the context menu actions are carried out on each + index = self.sender().indexAt(position) + if not index.isValid(): + return + + context_menu = QtWidgets.QMenu() + + openAction = context_menu.addAction( + QtGui.QIcon.fromTheme('view-readermode'), 'Start reading') + editAction = context_menu.addAction( + QtGui.QIcon.fromTheme('edit-rename'), 'Edit') + deleteAction = context_menu.addAction( + QtGui.QIcon.fromTheme('trash-empty'), 'Delete') + readAction = context_menu.addAction( + QtGui.QIcon.fromTheme('vcs-normal'), 'Mark read') + unreadAction = context_menu.addAction( + QtGui.QIcon.fromTheme('emblem-unavailable'), 'Mark unread') + + action = context_menu.exec_(self.sender().mapToGlobal(position)) + + def generate_library_filter_menu(self, directory_list=None): self.libraryFilterMenu.clear() def generate_name(path_data): @@ -1026,20 +1020,25 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow): not self.bookToolBar.isVisible()) def closeEvent(self, event=None): - # All tabs must be iterated upon here + if event: + event.ignore() + self.hide() self.settingsDialog.hide() self.temp_dir.remove() self.settings['last_open_books'] = [] - if self.tabWidget.count() > 1 and self.settings['remember_files']: + if self.tabWidget.count() > 1: + # All tabs must be iterated upon here all_metadata = [] for i in range(1, self.tabWidget.count()): tab_metadata = self.tabWidget.widget(i).metadata - self.settings['last_open_books'].append(tab_metadata['path']) all_metadata.append(tab_metadata) + if self.settings['remember_files']: + self.settings['last_open_books'].append(tab_metadata['path']) + Settings(self).save_settings() self.thread = BackGroundTabUpdate(self.database_path, all_metadata) self.thread.finished.connect(QtWidgets.qApp.exit) diff --git a/library.py b/library.py index 20ade74..162c6f4 100644 --- a/library.py +++ b/library.py @@ -19,7 +19,7 @@ import os import pickle import pathlib -from PyQt5 import QtGui, QtCore, QtWidgets +from PyQt5 import QtGui, QtCore import database from models import TableProxyModel, ItemProxyModel diff --git a/widgets.py b/widgets.py index 561e115..3676aab 100644 --- a/widgets.py +++ b/widgets.py @@ -53,7 +53,7 @@ class Tab(QtWidgets.QWidget): chapter_name = list(self.metadata['content'])[current_chapter - 1] chapter_content = self.metadata['content'][chapter_name] - # The content display widget is, by default a QTextBrowser + # The content display widget is, by default a QTextBrowser. # In case the incoming data is only images # such as in the case of comic book files, # we want a QGraphicsView widget doing all the heavy lifting @@ -147,6 +147,7 @@ class Tab(QtWidgets.QWidget): # TODO # Bookmark navigation does not work in case 2 entries in the same # chapter are clicked successively + # It plain refuses to work other times if self.sender().objectName() == 'tabWidget': return @@ -702,6 +703,8 @@ class BookmarkDelegate(QtWidgets.QStyledItemDelegate): chapter_index = index.data(QtCore.Qt.UserRole) chapter_name = self.parent.window().bookToolBar.tocBox.itemText(chapter_index - 1) + if len(chapter_name) > 25: + chapter_name = chapter_name[:25] + '...' QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) painter.drawText(