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.toolbarToggle.clicked.connect(self.toggle_toolbars)
|
||||||
self.statusBar.addPermanentWidget(self.toolbarToggle)
|
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
|
# THIS IS TEMPORARY
|
||||||
self.guiTest = QtWidgets.QToolButton()
|
self.guiTest = QtWidgets.QToolButton()
|
||||||
self.guiTest.setIcon(QtGui.QIcon.fromTheme('mail-thread-watch'))
|
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.deleteButton.triggered.connect(self.delete_books)
|
||||||
self.libraryToolBar.coverViewButton.triggered.connect(self.switch_library_view)
|
self.libraryToolBar.coverViewButton.triggered.connect(self.switch_library_view)
|
||||||
self.libraryToolBar.tableViewButton.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.settingsButton.triggered.connect(self.show_settings)
|
||||||
self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodels)
|
self.libraryToolBar.searchBar.textChanged.connect(self.lib_ref.update_proxymodels)
|
||||||
self.libraryToolBar.sortingBox.activated.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)
|
QtGui.QIcon.fromTheme('add'), 'Add book', self)
|
||||||
self.deleteButton = QtWidgets.QAction(
|
self.deleteButton = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('remove'), 'Delete book', self)
|
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(
|
self.settingsButton = QtWidgets.QAction(
|
||||||
QtGui.QIcon.fromTheme('settings'), 'Settings', self)
|
QtGui.QIcon.fromTheme('settings'), 'Settings', self)
|
||||||
self.settingsButton.setCheckable(True)
|
self.settingsButton.setCheckable(True)
|
||||||
@@ -356,6 +359,7 @@ class LibraryToolBar(QtWidgets.QToolBar):
|
|||||||
self.addSeparator()
|
self.addSeparator()
|
||||||
self.addWidget(self.libraryFilterButton)
|
self.addWidget(self.libraryFilterButton)
|
||||||
self.addSeparator()
|
self.addSeparator()
|
||||||
|
self.addAction(self.colorButton)
|
||||||
self.addAction(self.settingsButton)
|
self.addAction(self.settingsButton)
|
||||||
|
|
||||||
# Filter
|
# Filter
|
||||||
|
13
widgets.py
13
widgets.py
@@ -441,18 +441,14 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
|
|
||||||
def loadImage(self, current_image):
|
def loadImage(self, current_image):
|
||||||
# TODO
|
# TODO
|
||||||
# Cache 4 images
|
|
||||||
# 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
|
||||||
|
|
||||||
content = self.parent.metadata['content']
|
content = self.parent.metadata['content']
|
||||||
image_paths = [i[1] for i in content.items()]
|
image_paths = [i[1] for i in content.items()]
|
||||||
|
|
||||||
def generate_image_cache(current_image):
|
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)
|
current_image_index = image_paths.index(current_image)
|
||||||
|
|
||||||
for i in (-1, 0, 1, 2):
|
for i in (-1, 0, 1, 2):
|
||||||
@@ -468,14 +464,15 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
|
|||||||
remove_index = self.image_cache.index(remove_value)
|
remove_index = self.image_cache.index(remove_value)
|
||||||
refill_pixmap = QtGui.QPixmap()
|
refill_pixmap = QtGui.QPixmap()
|
||||||
|
|
||||||
if remove_index == 0:
|
if remove_index == 1:
|
||||||
self.image_cache.pop(3)
|
|
||||||
first_path = self.image_cache[0][0]
|
first_path = self.image_cache[0][0]
|
||||||
|
self.image_cache.pop(3)
|
||||||
previous_path = image_paths[image_paths.index(first_path) - 1]
|
previous_path = image_paths[image_paths.index(first_path) - 1]
|
||||||
refill_pixmap.load(previous_path)
|
refill_pixmap.load(previous_path)
|
||||||
self.image_cache.insert(0, (previous_path, refill_pixmap))
|
self.image_cache.insert(0, (previous_path, refill_pixmap))
|
||||||
else:
|
else:
|
||||||
self.image_cache.remove(remove_value)
|
self.image_cache[0] = self.image_cache[1]
|
||||||
|
self.image_cache.pop(1)
|
||||||
try:
|
try:
|
||||||
last_path = self.image_cache[2][0]
|
last_path = self.image_cache[2][0]
|
||||||
next_path = image_paths[image_paths.index(last_path) + 1]
|
next_path = image_paths[image_paths.index(last_path) + 1]
|
||||||
|
Reference in New Issue
Block a user