Fix image caching
Move library background color chooser to toolbar
This commit is contained in:
10
__main__.py
10
__main__.py
@@ -92,15 +92,6 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
self.toolbarToggle.clicked.connect(self.toggle_toolbars)
|
||||
self.statusBar.addPermanentWidget(self.toolbarToggle)
|
||||
|
||||
# Statusbar - Library background
|
||||
self.libraryBackground = QtWidgets.QToolButton()
|
||||
self.libraryBackground.setIcon(QtGui.QIcon(':/images/color.svg'))
|
||||
self.libraryBackground.setObjectName('libraryBackground')
|
||||
self.libraryBackground.setToolTip('Change library background color')
|
||||
self.libraryBackground.setAutoRaise(True)
|
||||
self.libraryBackground.clicked.connect(self.get_color)
|
||||
self.statusBar.addPermanentWidget(self.libraryBackground)
|
||||
|
||||
# THIS IS TEMPORARY
|
||||
self.guiTest = QtWidgets.QToolButton()
|
||||
self.guiTest.setIcon(QtGui.QIcon.fromTheme('mail-thread-watch'))
|
||||
@@ -130,6 +121,7 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
|
||||
self.libraryToolBar.deleteButton.triggered.connect(self.delete_books)
|
||||
self.libraryToolBar.coverViewButton.triggered.connect(self.switch_library_view)
|
||||
self.libraryToolBar.tableViewButton.triggered.connect(self.switch_library_view)
|
||||
self.libraryToolBar.colorButton.triggered.connect(self.get_color)
|
||||
self.libraryToolBar.settingsButton.triggered.connect(self.show_settings)
|
||||
self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodels)
|
||||
self.libraryToolBar.sortingBox.activated.connect(self.lib_ref.update_proxymodels)
|
||||
|
@@ -325,6 +325,9 @@ class LibraryToolBar(QtWidgets.QToolBar):
|
||||
QtGui.QIcon.fromTheme('add'), 'Add book', self)
|
||||
self.deleteButton = QtWidgets.QAction(
|
||||
QtGui.QIcon.fromTheme('remove'), 'Delete book', self)
|
||||
self.colorButton = QtWidgets.QAction(
|
||||
QtGui.QIcon.fromTheme('color-picker'), 'Library background color', self)
|
||||
self.colorButton.setObjectName('libraryBackground')
|
||||
self.settingsButton = QtWidgets.QAction(
|
||||
QtGui.QIcon.fromTheme('settings'), 'Settings', self)
|
||||
self.settingsButton.setCheckable(True)
|
||||
@@ -356,6 +359,7 @@ class LibraryToolBar(QtWidgets.QToolBar):
|
||||
self.addSeparator()
|
||||
self.addWidget(self.libraryFilterButton)
|
||||
self.addSeparator()
|
||||
self.addAction(self.colorButton)
|
||||
self.addAction(self.settingsButton)
|
||||
|
||||
# Filter
|
||||
|
13
widgets.py
13
widgets.py
@@ -441,18 +441,14 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
||||
|
||||
def loadImage(self, current_image):
|
||||
# TODO
|
||||
# Cache 4 images
|
||||
# For single page view: 1 before, 2 after
|
||||
# For double page view: 1 before, 1 after
|
||||
# Move caching to new thread
|
||||
# Account for IndexErrors
|
||||
# Image panning with mouse
|
||||
|
||||
content = self.parent.metadata['content']
|
||||
image_paths = [i[1] for i in content.items()]
|
||||
|
||||
def generate_image_cache(current_image):
|
||||
print('Generator hit', self.image_cache, '\n')
|
||||
print('Building image cache')
|
||||
current_image_index = image_paths.index(current_image)
|
||||
|
||||
for i in (-1, 0, 1, 2):
|
||||
@@ -468,14 +464,15 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
||||
remove_index = self.image_cache.index(remove_value)
|
||||
refill_pixmap = QtGui.QPixmap()
|
||||
|
||||
if remove_index == 0:
|
||||
self.image_cache.pop(3)
|
||||
if remove_index == 1:
|
||||
first_path = self.image_cache[0][0]
|
||||
self.image_cache.pop(3)
|
||||
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)
|
||||
self.image_cache[0] = self.image_cache[1]
|
||||
self.image_cache.pop(1)
|
||||
try:
|
||||
last_path = self.image_cache[2][0]
|
||||
next_path = image_paths[image_paths.index(last_path) + 1]
|
||||
|
Reference in New Issue
Block a user