mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
Add UI preference to picture cache type under Qt
This commit is contained in:
parent
e4b6e12d4c
commit
76cc2000ab
10
core/app.py
10
core/app.py
@ -135,13 +135,12 @@ class DupeGuru(Broadcaster):
|
||||
# In addition to "app-level" options, this dictionary also holds options that will be
|
||||
# sent to the scanner. They don't have default values because those defaults values are
|
||||
# defined in the scanner class.
|
||||
picture_cache_name = 'cached_pictures.shelve' if self.PICTURE_CACHE_TYPE == 'shelve' else 'cached_pictures.db'
|
||||
self.options = {
|
||||
'escape_filter_regexp': True,
|
||||
'clean_empty_dirs': False,
|
||||
'ignore_hardlink_matches': False,
|
||||
'copymove_dest_type': DestType.Relative,
|
||||
'cache_path': op.join(self.appdata, picture_cache_name),
|
||||
'picture_cache_type': self.PICTURE_CACHE_TYPE
|
||||
}
|
||||
self.selected_dupes = []
|
||||
self.details_panel = DetailsPanel(self)
|
||||
@ -169,6 +168,11 @@ class DupeGuru(Broadcaster):
|
||||
self.result_table.connect()
|
||||
self.view.create_results_window()
|
||||
|
||||
def _get_picture_cache_path(self):
|
||||
cache_type = self.options['picture_cache_type']
|
||||
cache_name = 'cached_pictures.shelve' if cache_type == 'shelve' else 'cached_pictures.db'
|
||||
return op.join(self.appdata, cache_name)
|
||||
|
||||
def _get_dupe_sort_key(self, dupe, get_group, key, delta):
|
||||
if self.app_mode in (AppMode.Music, AppMode.Picture):
|
||||
if key == 'folder_path':
|
||||
@ -758,6 +762,8 @@ class DupeGuru(Broadcaster):
|
||||
for k, v in self.options.items():
|
||||
if hasattr(scanner, k):
|
||||
setattr(scanner, k, v)
|
||||
if self.app_mode == AppMode.Picture:
|
||||
scanner.cache_path = self._get_picture_cache_path()
|
||||
self.results.groups = []
|
||||
self._recreate_result_table()
|
||||
self._results_changed()
|
||||
|
@ -115,6 +115,7 @@ class DupeGuru(QObject):
|
||||
scanned_tags.add('year')
|
||||
self.model.options['scanned_tags'] = scanned_tags
|
||||
self.model.options['match_scaled'] = self.prefs.match_scaled
|
||||
self.model.options['picture_cache_type'] = self.prefs.picture_cache_type
|
||||
|
||||
#--- Private
|
||||
def _get_details_dialog_class(self):
|
||||
|
@ -4,7 +4,9 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from PyQt5.QtWidgets import QLabel
|
||||
from hscommon.trans import trget
|
||||
from qtlib.radio_box import RadioBox
|
||||
from core.scanner import ScanType
|
||||
from core.app import AppMode
|
||||
|
||||
@ -28,10 +30,14 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
|
||||
self._setupAddCheckbox('debugModeBox', tr("Debug mode (restart required)"))
|
||||
self.widgetsVLayout.addWidget(self.debugModeBox)
|
||||
self.widgetsVLayout.addWidget(QLabel(tr("Picture cache mode:")))
|
||||
self.cacheTypeRadio = RadioBox(self, items=["Sqlite", "Shelve"], spread=False)
|
||||
self.widgetsVLayout.addWidget(self.cacheTypeRadio)
|
||||
self._setupBottomPart()
|
||||
|
||||
def _load(self, prefs, setchecked):
|
||||
setchecked(self.matchScaledBox, prefs.match_scaled)
|
||||
self.cacheTypeRadio.selected_index = 1 if prefs.picture_cache_type == 'shelve' else 0
|
||||
|
||||
# Update UI state based on selected scan type
|
||||
scan_type = prefs.get_scan_type(AppMode.Picture)
|
||||
@ -40,4 +46,5 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
|
||||
def _save(self, prefs, ischecked):
|
||||
prefs.match_scaled = ischecked(self.matchScaledBox)
|
||||
prefs.picture_cache_type = 'shelve' if self.cacheTypeRadio.selected_index == 1 else 'sqlite'
|
||||
|
||||
|
@ -44,6 +44,7 @@ class Preferences(PreferencesBase):
|
||||
self.scan_tag_genre = get('ScanTagGenre', self.scan_tag_genre)
|
||||
self.scan_tag_year = get('ScanTagYear', self.scan_tag_year)
|
||||
self.match_scaled = get('MatchScaled', self.match_scaled)
|
||||
self.picture_cache_type = get('PictureCacheType', self.picture_cache_type)
|
||||
|
||||
def reset(self):
|
||||
self.filter_hardness = 95
|
||||
@ -74,6 +75,7 @@ class Preferences(PreferencesBase):
|
||||
self.scan_tag_genre = False
|
||||
self.scan_tag_year = False
|
||||
self.match_scaled = False
|
||||
self.picture_cache_type = 'sqlite'
|
||||
|
||||
def _save_values(self, settings):
|
||||
set_ = self.set_value
|
||||
@ -105,6 +107,7 @@ class Preferences(PreferencesBase):
|
||||
set_('ScanTagGenre', self.scan_tag_genre)
|
||||
set_('ScanTagYear', self.scan_tag_year)
|
||||
set_('MatchScaled', self.match_scaled)
|
||||
set_('PictureCacheType', self.picture_cache_type)
|
||||
|
||||
# scan_type is special because we save it immediately when we set it.
|
||||
def get_scan_type(self, app_mode):
|
||||
|
Loading…
x
Reference in New Issue
Block a user