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

View File

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

View File

@@ -18,9 +18,8 @@ import database
# get_year()
# get_cover_image()
# get_isbn()
# get_contents() - Should return a tuple with 0: TOC 1: Deletable temp_directory
# Parsers for files containing only images need to return only
# the image path, and images_only = True
# get_contents() - Should return a tuple with 0: TOC 1: special_settings (dict)
# Parsers for files containing only images need to return only images_only = True
from parsers.epub import ParseEPUB
from parsers.cbz import ParseCBZ
@@ -99,7 +98,11 @@ class BookSorter:
}
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
# None values are accounted for here
@@ -117,6 +120,9 @@ class BookSorter:
# Different modes require different values
if self.mode == 'addition':
cover_image = book_ref.get_cover_image()
# TODO
# Consider sizing down the image in case
# it's too big
self.all_books[file_md5] = {
'title': title,
'author': author,

View File

@@ -353,6 +353,13 @@ class Tab(QtWidgets.QWidget):
self.prev_chapter.setObjectName('prevChapter')
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(
QtGui.QKeySequence('F11'), self.contentView)
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.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()
required_content = self.metadata['content'][chapter_name]
@@ -413,7 +428,8 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
self.image_pixmap = None
self.ignore_wheel_event = False
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):
self.image_pixmap = QtGui.QPixmap()
@@ -453,7 +469,8 @@ class PliantQTextBrowser(QtWidgets.QTextBrowser):
self.main_window = main_window
self.ignore_wheel_event = False
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):
self.common_functions.wheelEvent(event, False)
@@ -562,6 +579,8 @@ class LibraryDelegate(QtWidgets.QStyledItemDelegate):
elif current_chapter == 1:
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
else:
# TODO
# See if saving the svg to disk can be avoided
QtWidgets.QStyledItemDelegate.paint(self, painter, option, index)
pie_chart.GeneratePie(progress_percent, self.temp_dir).generate()
svg_path = os.path.join(self.temp_dir, 'lector_progress.svg')