This commit is contained in:
BasioMeusPuga
2017-11-17 10:33:34 +05:30
parent 5ed8cb6dde
commit bf8ddf4346
4 changed files with 47 additions and 16 deletions

View File

@@ -2,10 +2,13 @@
""" TODO """ TODO
Options: Options:
Automatic library management
Auto deletion
Recursive file addition
Add only one file type if multiple are present
Remember files
Check files (hashes) upon restart Check files (hashes) upon restart
Recursive file addition
Show what on startup Show what on startup
If cache large files
Library: Library:
✓ sqlite3 for cover images cache ✓ sqlite3 for cover images cache
✓ sqlite3 for storing metadata ✓ sqlite3 for storing metadata
@@ -24,6 +27,7 @@
Information dialog widget Information dialog widget
Context menu: Cache, Read, Edit database, delete, Mark read/unread Context menu: Cache, Read, Edit database, delete, Mark read/unread
Create separate thread for parser - Show progress in main window Create separate thread for parser - Show progress in main window
Set focus to newly added file
Reading: Reading:
✓ Drop down for TOC ✓ Drop down for TOC
✓ Override the keypress event of the textedit ✓ Override the keypress event of the textedit
@@ -40,13 +44,14 @@
Pagination Pagination
Set context menu for definitions and the like Set context menu for definitions and the like
Filetypes: Filetypes:
? Plugin system for parsers ✓ cbz, cbr support
? pdf support ✓ Keep font settings enabled but only for background color
Cache next and previous images
epub support epub support
mobi, azw support mobi, azw support
txt, doc, djvu support txt, doc, djvu, fb2 support
cbz, cbr support ? Plugin system for parsers
Keep font settings enabled but only for background color ? pdf support
Internet: Internet:
Goodreads API: Ratings, Read, Recommendations Goodreads API: Ratings, Read, Recommendations
Get ISBN using python-isbnlib Get ISBN using python-isbnlib
@@ -243,6 +248,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def tab_switch(self): def tab_switch(self):
if self.tabWidget.currentIndex() == 0: if self.tabWidget.currentIndex() == 0:
self.resizeEvent()
self.bookToolBar.hide() self.bookToolBar.hide()
self.libraryToolBar.show() self.libraryToolBar.show()
@@ -316,7 +322,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.viewModel.setData( self.viewModel.setData(
model_index, current_tab.metadata['position'], QtCore.Qt.UserRole + 7) model_index, current_tab.metadata['position'], QtCore.Qt.UserRole + 7)
current_tab.chapter_change() current_tab.change_chapter_tocBox()
def set_fullscreen(self): def set_fullscreen(self):
current_tab = self.tabWidget.currentIndex() current_tab = self.tabWidget.currentIndex()

View File

@@ -43,7 +43,7 @@ class Settings:
QtCore.QSize(1299, 748))) QtCore.QSize(1299, 748)))
self.parent_window.move(self.settings.value( self.parent_window.move(self.settings.value(
'windowPosition', 'windowPosition',
QtCore.QPoint(286, 141))) QtCore.QPoint(0, 0)))
self.settings.endGroup() self.settings.endGroup()
self.settings.beginGroup('runtimeVariables') self.settings.beginGroup('runtimeVariables')

View File

@@ -18,9 +18,8 @@ import database
# get_year() # get_year()
# get_cover_image() # get_cover_image()
# get_isbn() # get_isbn()
# get_contents() - Should return a tuple with 0: TOC 1: Deletable temp_directory # get_contents() - Should return a tuple with 0: TOC 1: special_settings (dict)
# Parsers for files containing only images need to return only # Parsers for files containing only images need to return only images_only = True
# the image path, and images_only = True
from parsers.epub import ParseEPUB from parsers.epub import ParseEPUB
from parsers.cbz import ParseCBZ from parsers.cbz import ParseCBZ
@@ -99,7 +98,11 @@ class BookSorter:
} }
file_extension = os.path.splitext(filename)[1][1:] file_extension = os.path.splitext(filename)[1][1:]
book_ref = sorter[file_extension](filename, self.temp_dir, file_md5) try:
book_ref = sorter[file_extension](filename, self.temp_dir, file_md5)
except KeyError:
print(filename + ' has an unsupported extension')
return
# Everything following this is standard # Everything following this is standard
# None values are accounted for here # None values are accounted for here
@@ -117,6 +120,9 @@ class BookSorter:
# Different modes require different values # Different modes require different values
if self.mode == 'addition': if self.mode == 'addition':
cover_image = book_ref.get_cover_image() cover_image = book_ref.get_cover_image()
# TODO
# Consider sizing down the image in case
# it's too big
self.all_books[file_md5] = { self.all_books[file_md5] = {
'title': title, 'title': title,
'author': author, 'author': author,

View File

@@ -353,6 +353,13 @@ class Tab(QtWidgets.QWidget):
self.prev_chapter.setObjectName('prevChapter') self.prev_chapter.setObjectName('prevChapter')
self.prev_chapter.activated.connect(self.sneaky_change) self.prev_chapter.activated.connect(self.sneaky_change)
# TODO
# Get this working
self.space_press = QtWidgets.QShortcut(
QtGui.QKeySequence('Spacebar'), self.contentView)
self.space_press.setObjectName('spacePress')
self.space_press.activated.connect(self.spacebar_pressed)
self.go_fs = QtWidgets.QShortcut( self.go_fs = QtWidgets.QShortcut(
QtGui.QKeySequence('F11'), self.contentView) QtGui.QKeySequence('F11'), self.contentView)
self.go_fs.activated.connect(self.window().set_fullscreen) self.go_fs.activated.connect(self.window().set_fullscreen)
@@ -372,7 +379,15 @@ class Tab(QtWidgets.QWidget):
self.contentView.setWindowState(QtCore.Qt.WindowNoState) self.contentView.setWindowState(QtCore.Qt.WindowNoState)
self.contentView.show() self.contentView.show()
def chapter_change(self): def spacebar_pressed(self):
vertical = self.verticalScrollBar().value()
maximum = self.verticalScrollBar().maximum()
if vertical == maximum:
self.contentView.common_functions.change_chapter(
1, True)
def change_chapter_tocBox(self):
chapter_name = self.window().bookToolBar.tocBox.currentText() chapter_name = self.window().bookToolBar.tocBox.currentText()
required_content = self.metadata['content'][chapter_name] required_content = self.metadata['content'][chapter_name]
@@ -413,7 +428,8 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.image_pixmap = None self.image_pixmap = None
self.ignore_wheel_event = False self.ignore_wheel_event = False
self.ignore_wheel_event_number = 0 self.ignore_wheel_event_number = 0
self.common_functions = PliantWidgetsCommonFunctions(self, self.main_window) self.common_functions = PliantWidgetsCommonFunctions(
self, self.main_window)
def loadImage(self, image_path): def loadImage(self, image_path):
self.image_pixmap = QtGui.QPixmap() self.image_pixmap = QtGui.QPixmap()
@@ -453,7 +469,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.main_window = main_window self.main_window = main_window
self.ignore_wheel_event = False self.ignore_wheel_event = False
self.ignore_wheel_event_number = 0 self.ignore_wheel_event_number = 0
self.common_functions = PliantWidgetsCommonFunctions(self, self.main_window) self.common_functions = PliantWidgetsCommonFunctions(
self, self.main_window)
def wheelEvent(self, event): def wheelEvent(self, event):
self.common_functions.wheelEvent(event, False) self.common_functions.wheelEvent(event, False)
@@ -562,6 +579,8 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
elif current_chapter == 1: elif current_chapter == 1:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
else: else:
# TODO
# See if saving the svg to disk can be avoided
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index) QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
pie_chart.GeneratePie(progress_percent, self.temp_dir).generate() pie_chart.GeneratePie(progress_percent, self.temp_dir).generate()
svg_path = os.path.join(self.temp_dir, 'lector_progress.svg') svg_path = os.path.join(self.temp_dir, 'lector_progress.svg')