Fix manual zoom padding, Speed up hashing

This commit is contained in:
BasioMeusPuga
2017-11-19 17:36:42 +05:30
parent bc8a533bb8
commit 6ca94924cf
4 changed files with 23 additions and 7 deletions

View File

@@ -18,6 +18,7 @@
✓ Search bar in toolbar
✓ Shift focus to the tab that has the book open
✓ Tie file deletion and tab closing to model updates
✓ Create separate thread for parser - Show progress in main window
? Create emblem per filetype
Look into how you might group icons
Ignore a / the / numbers for sorting purposes
@@ -26,8 +27,8 @@
Mass tagging
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
Better way to thread than subprocess QThread
Reading:
✓ Drop down for TOC
✓ Override the keypress event of the textedit
@@ -494,12 +495,16 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
if signal_sender == 'zoomOut':
self.comic_profile['zoom_mode'] = 'manualZoom'
self.comic_profile['padding'] += 50
# This prevents infinite zoom out
if self.comic_profile['padding'] * 2 > current_tab.contentView.viewport().width():
self.comic_profile['padding'] -= 50
if signal_sender == 'zoomIn':
self.comic_profile['zoom_mode'] = 'manualZoom'
self.comic_profile['padding'] -= 50
# This prevents infinite zoom in
if self.comic_profile['padding'] < 0:
self.comic_profile['padding'] = 0
@@ -508,6 +513,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.comic_profile['padding'] = 0
self.bookToolBar.fitWidth.setChecked(True)
# Padding in the following cases is decided by
# the image pixmap loaded by the widget
if signal_sender == 'bestFit':
self.comic_profile['zoom_mode'] = 'bestFit'
self.bookToolBar.bestFit.setChecked(True)
@@ -615,7 +622,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
QtWidgets.qApp.exit()
def main():
app = QtWidgets.QApplication(sys.argv)
app.setApplicationName('Lector') # This is needed for QStandardPaths

View File

@@ -46,4 +46,3 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
QtWidgets.QFileDialog.ShowDirsOnly)
# Directories will NOT be added recursively

View File

@@ -1,7 +1,6 @@
#!/usr/bin/env python3
# TODO
# See if tags can be generated from book content
# See if you want to include a hash of the book's name and author
import os
@@ -87,10 +86,13 @@ class BookSorter:
# full path of the ebook file
with open(filename, 'rb') as current_book:
file_md5 = hashlib.md5(current_book.read()).hexdigest()
# This should speed up addition for larger files
# without compromising the integrity of the process
first_bytes = current_book.read(1024 * 32) # First 32KB of the file
salt = filename.encode()
first_bytes += salt
file_md5 = hashlib.md5(first_bytes).hexdigest()
# TODO
# Make use of this
self.statistics[0] += 1
self.progressbar.setValue(self.statistics[0])

View File

@@ -512,6 +512,12 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
elif zoom_mode == 'originalSize':
image_pixmap = self.image_pixmap
new_padding = (self.viewport().width() - image_pixmap.width()) // 2
if new_padding < 0: # The image is larger than the viewport
self.main_window.comic_profile['padding'] = 0
else:
self.main_window.comic_profile['padding'] = new_padding
elif zoom_mode == 'bestFit':
available_width = self.viewport().width()
available_height = self.viewport().height()
@@ -520,6 +526,9 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
available_width, available_height,
QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation)
self.main_window.comic_profile['padding'] = (
self.viewport().width() - image_pixmap.width()) // 2
elif zoom_mode == 'manualZoom':
available_width = self.viewport().width() - 2 * padding
image_pixmap = self.image_pixmap.scaledToWidth(