Image caching mostly functional
This commit is contained in:
5
TODO
5
TODO
@@ -25,7 +25,6 @@ TODO
|
|||||||
✓ Information dialog widget
|
✓ Information dialog widget
|
||||||
✓ Allow editing of database data through the UI + for Bookmarks
|
✓ Allow editing of database data through the UI + for Bookmarks
|
||||||
Set focus to newly added file
|
Set focus to newly added file
|
||||||
Change focus rectangle dimensions
|
|
||||||
Reading:
|
Reading:
|
||||||
✓ Drop down for TOC
|
✓ Drop down for TOC
|
||||||
✓ Override the keypress event of the textedit
|
✓ Override the keypress event of the textedit
|
||||||
@@ -54,10 +53,10 @@ TODO
|
|||||||
Comic view modes
|
Comic view modes
|
||||||
Continuous paging
|
Continuous paging
|
||||||
Double pages
|
Double pages
|
||||||
|
Cache next and previous images
|
||||||
Filetypes:
|
Filetypes:
|
||||||
✓ cbz, cbr support
|
✓ cbz, cbr support
|
||||||
✓ Keep font settings enabled but only for background color
|
✓ Keep font settings enabled but only for background color
|
||||||
Cache next and previous images
|
|
||||||
epub support
|
epub support
|
||||||
mobi, azw support
|
mobi, azw support
|
||||||
Other:
|
Other:
|
||||||
@@ -65,10 +64,12 @@ TODO
|
|||||||
Bugs:
|
Bugs:
|
||||||
If there are files open and the database is deleted, TypeErrors result
|
If there are files open and the database is deleted, TypeErrors result
|
||||||
Cover culling does not occur if some other tab has initial focus
|
Cover culling does not occur if some other tab has initial focus
|
||||||
|
Exiting with Ctrl + Q does not save the cursor position INITIALLY
|
||||||
|
|
||||||
Secondary:
|
Secondary:
|
||||||
Annotations
|
Annotations
|
||||||
Graphical themes
|
Graphical themes
|
||||||
|
Change focus rectangle dimensions
|
||||||
Tab reordering
|
Tab reordering
|
||||||
Allow tabs to detach and form their own windows
|
Allow tabs to detach and form their own windows
|
||||||
Goodreads API: Ratings, Read, Recommendations
|
Goodreads API: Ratings, Read, Recommendations
|
||||||
|
@@ -229,7 +229,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# Maybe use this for readjusting the border of the focus rectangle
|
# Maybe use this for readjusting the border of the focus rectangle
|
||||||
# in the listView
|
# in the listView. Maybe this is a job for QML?
|
||||||
|
|
||||||
# self.listView.setStyleSheet(
|
# self.listView.setStyleSheet(
|
||||||
# "QListView::item:selected { border-color:blue; border-style:outset;"
|
# "QListView::item:selected { border-color:blue; border-style:outset;"
|
||||||
@@ -1165,7 +1165,8 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
|||||||
self.settings['last_open_books'].append(tab_metadata['path'])
|
self.settings['last_open_books'].append(tab_metadata['path'])
|
||||||
|
|
||||||
Settings(self).save_settings()
|
Settings(self).save_settings()
|
||||||
self.thread = BackGroundTabUpdate(self.database_path, all_metadata)
|
self.thread = BackGroundTabUpdate(
|
||||||
|
self.database_path, all_metadata)
|
||||||
self.thread.finished.connect(self.database_care)
|
self.thread.finished.connect(self.database_care)
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
|
||||||
|
61
widgets.py
61
widgets.py
@@ -225,7 +225,7 @@ class Tab(QtWidgets.QWidget):
|
|||||||
self.exit_fs.activated.connect(self.exit_fullscreen)
|
self.exit_fs.activated.connect(self.exit_fullscreen)
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# See why Ctrl + Q stop working on a non fullscreened contentView
|
# See why Ctrl + Q won't work on a non fullscreened contentView
|
||||||
# widget in case the following is in code
|
# widget in case the following is in code
|
||||||
|
|
||||||
# self.exit_all = QtWidgets.QShortcut(
|
# self.exit_all = QtWidgets.QShortcut(
|
||||||
@@ -437,16 +437,69 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
self.common_functions = PliantWidgetsCommonFunctions(
|
self.common_functions = PliantWidgetsCommonFunctions(
|
||||||
self, self.main_window)
|
self, self.main_window)
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
|
self.image_cache = [None for _ in range(4)]
|
||||||
|
|
||||||
def loadImage(self, image_path):
|
def loadImage(self, current_image):
|
||||||
# TODO
|
# TODO
|
||||||
# Cache 4 images
|
# Cache 4 images
|
||||||
# For single page view: 1 before, 2 after
|
# For single page view: 1 before, 2 after
|
||||||
# For double page view: 1 before, 1 after
|
# For double page view: 1 before, 1 after
|
||||||
|
# Move caching to new thread
|
||||||
|
# Account for IndexErrors
|
||||||
# Image panning with mouse
|
# Image panning with mouse
|
||||||
|
|
||||||
self.image_pixmap = QtGui.QPixmap()
|
content = self.parent.metadata['content']
|
||||||
self.image_pixmap.load(image_path)
|
image_paths = [i[1] for i in content.items()]
|
||||||
|
|
||||||
|
def generate_image_cache(current_image):
|
||||||
|
print('Generator hit', self.image_cache, '\n')
|
||||||
|
current_image_index = image_paths.index(current_image)
|
||||||
|
|
||||||
|
for i in (-1, 0, 1, 2):
|
||||||
|
try:
|
||||||
|
this_path = image_paths[current_image_index + i]
|
||||||
|
this_pixmap = QtGui.QPixmap()
|
||||||
|
this_pixmap.load(this_path)
|
||||||
|
self.image_cache[i + 1] = (this_path, this_pixmap)
|
||||||
|
except IndexError:
|
||||||
|
self.image_cache[i + 1] = None
|
||||||
|
|
||||||
|
def refill_cache(remove_value):
|
||||||
|
remove_index = self.image_cache.index(remove_value)
|
||||||
|
refill_pixmap = QtGui.QPixmap()
|
||||||
|
|
||||||
|
if remove_index == 0:
|
||||||
|
self.image_cache.pop(3)
|
||||||
|
first_path = self.image_cache[0][0]
|
||||||
|
previous_path = image_paths[image_paths.index(first_path) - 1]
|
||||||
|
refill_pixmap.load(previous_path)
|
||||||
|
self.image_cache.insert(0, (previous_path, refill_pixmap))
|
||||||
|
else:
|
||||||
|
self.image_cache.remove(remove_value)
|
||||||
|
try:
|
||||||
|
last_path = self.image_cache[2][0]
|
||||||
|
next_path = image_paths[image_paths.index(last_path) + 1]
|
||||||
|
refill_pixmap.load(next_path)
|
||||||
|
self.image_cache.append((next_path, refill_pixmap))
|
||||||
|
except (IndexError, TypeError):
|
||||||
|
self.image_cache.append(None)
|
||||||
|
|
||||||
|
def check_cache(current_image):
|
||||||
|
for i in self.image_cache:
|
||||||
|
if i:
|
||||||
|
if i[0] == current_image:
|
||||||
|
return_pixmap = i[1]
|
||||||
|
refill_cache(i)
|
||||||
|
return return_pixmap
|
||||||
|
|
||||||
|
# No return happened so the image isn't in the cache
|
||||||
|
generate_image_cache(current_image)
|
||||||
|
|
||||||
|
return_pixmap = None
|
||||||
|
while not return_pixmap:
|
||||||
|
return_pixmap = check_cache(current_image)
|
||||||
|
|
||||||
|
self.image_pixmap = return_pixmap
|
||||||
self.resizeEvent()
|
self.resizeEvent()
|
||||||
|
|
||||||
def resizeEvent(self, *args):
|
def resizeEvent(self, *args):
|
||||||
|
Reference in New Issue
Block a user