Add toggle for image caching

Remove PyQt5 reference from setup.py
This commit is contained in:
BasioMeusPuga
2018-03-17 10:44:02 +05:30
parent 50089cb57a
commit 89a32bfeda
6 changed files with 30 additions and 18 deletions

View File

@@ -99,6 +99,9 @@ class Settings:
'performCulling', 'True').capitalize())
self.parent.settings['dictionary_language'] = self.settings.value(
'dictionaryLanguage', 'en')
self.parent.settings['caching_enabled'] = literal_eval(self.settings.value(
'cachingEnabled', 'True').capitalize())
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')
@@ -167,6 +170,7 @@ class Settings:
self.settings.setValue('scanLibraryAtStart', current_settings['scan_library'])
self.settings.setValue('performCulling', current_settings['perform_culling'])
self.settings.setValue('dictionaryLanguage', current_settings['dictionary_language'])
self.settings.setValue('cachingEnabled', current_settings['caching_enabled'])
self.settings.endGroup()
self.settings.beginGroup('dialogSettings')

View File

@@ -83,15 +83,14 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
self.refreshLibrary.setChecked(self.parent.settings['scan_library'])
self.fileRemember.setChecked(self.parent.settings['remember_files'])
self.performCulling.setChecked(self.parent.settings['perform_culling'])
self.cachingEnabled.setChecked(self.parent.settings['caching_enabled'])
self.autoTags.clicked.connect(self.manage_checkboxes)
self.coverShadows.clicked.connect(self.manage_checkboxes)
self.refreshLibrary.clicked.connect(self.manage_checkboxes)
self.fileRemember.clicked.connect(self.manage_checkboxes)
self.performCulling.clicked.connect(self.manage_checkboxes)
self.comicsRemain.setEnabled(False)
self.comicsRemain.setToolTip('Not implemented yet')
self.cachingEnabled.clicked.connect(self.manage_checkboxes)
# Generate the filesystem treeView
self.generate_tree()
@@ -278,7 +277,8 @@ class SettingsUI(QtWidgets.QDialog, settingswindow.Ui_Dialog):
'autoTags': 'auto_tags',
'refreshLibrary': 'scan_library',
'fileRemember': 'remember_files',
'performCulling': 'perform_culling'}
'performCulling': 'perform_culling',
'cachingEnabled': 'caching_enabled',}
self.parent.settings[sender_dict[sender]] = not self.parent.settings[sender_dict[sender]]

View File

@@ -27,7 +27,11 @@ import uuid
import zipfile
from PyQt5 import QtWidgets, QtGui, QtCore
import popplerqt5
try:
import popplerqt5
except ImportError:
pass
from rarfile import rarfile
from lector.models import BookmarkProxyModel
@@ -513,8 +517,6 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
def loadImage(self, current_page):
# TODO
# Threaded caching will still work here
# Look at a commit where it's not been deleted
# For double page view: 1 before, 1 after
all_pages = [i[1] for i in self.parent.metadata['content']]
@@ -565,9 +567,12 @@ class PliantQGraphicsView(QtWidgets.QGraphicsView):
# No return happened so the image isn't in the cache
generate_image_cache(current_page)
return_pixmap = None
while not return_pixmap:
return_pixmap = check_cache(current_page)
if self.window().settings['caching_enabled']:
return_pixmap = None
while not return_pixmap:
return_pixmap = check_cache(current_page)
else:
return_pixmap = load_page(current_page)
self.image_pixmap = return_pixmap
self.resizeEvent()

View File

@@ -116,9 +116,12 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="comicsRemain">
<widget class="QCheckBox" name="cachingEnabled">
<property name="toolTip">
<string>Greatly reduces page transition time at the cost of more memory</string>
</property>
<property name="text">
<string>Leave comics on disc</string>
<string>Cache comic / pdf pages</string>
</property>
</widget>
</item>

View File

@@ -71,9 +71,9 @@ class Ui_Dialog(object):
self.performCulling = QtWidgets.QCheckBox(self.groupBox)
self.performCulling.setObjectName("performCulling")
self.horizontalLayout.addWidget(self.performCulling)
self.comicsRemain = QtWidgets.QCheckBox(self.groupBox)
self.comicsRemain.setObjectName("comicsRemain")
self.horizontalLayout.addWidget(self.comicsRemain)
self.cachingEnabled = QtWidgets.QCheckBox(self.groupBox)
self.cachingEnabled.setObjectName("cachingEnabled")
self.horizontalLayout.addWidget(self.cachingEnabled)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.label = QtWidgets.QLabel(self.groupBox)
@@ -118,7 +118,8 @@ class Ui_Dialog(object):
self.coverShadows.setText(_translate("Dialog", "Cover shadows"))
self.performCulling.setToolTip(_translate("Dialog", "Enabling reduces startup time and memory usage"))
self.performCulling.setText(_translate("Dialog", "Load covers only when needed"))
self.comicsRemain.setText(_translate("Dialog", "Leave comics on disc"))
self.cachingEnabled.setToolTip(_translate("Dialog", "Greatly reduces page transition time at the cost of more memory"))
self.cachingEnabled.setText(_translate("Dialog", "Cache comic / pdf pages"))
self.label.setToolTip(_translate("Dialog", "Restart to see changes"))
self.label.setText(_translate("Dialog", "Icon theme: "))
self.darkIconsRadio.setToolTip(_translate("Dialog", "Restart to see changes"))

View File

@@ -13,8 +13,7 @@ VERSION = "{}.{}.{}".format(MAJOR_VERSION, MINOR_VERSION, MICRO_VERSION)
with codecs.open(path.join(HERE, 'README.md'), encoding='utf-8') as f:
LONG_DESC = f.read()
INSTALL_DEPS = ['PyQt5',
'requests',
INSTALL_DEPS = ['requests',
'beautifulsoup4']
TEST_DEPS = ['pytest',
'unittest2']