mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
qt: merge ME edition into SE
(breaks PE temporarily) Adds a Standard/Music Application Mode button to SE and thus adds the ability to run ME scan types in SE. When in Music mode, the Music-specific results window, details panel and preferences panel will show up. All preferences except scan_type become shared between app modes (changing the pref in a mode changes it in the other mode). Results Window and Details Panel are now re-created at each scan operation because they could change their type between two runs. Preferences panel is instantiated on the fly and discarded after close. This is a very big merge operation and I'm trying to touch as little code as possible, sometimes at the cost of elegance. I try to minimize the breakage that this change brings.
This commit is contained in:
49
qt/se/app.py
49
qt/se/app.py
@@ -7,12 +7,16 @@
|
||||
from core_se import __appname__
|
||||
from core_se.app import DupeGuru as DupeGuruModel
|
||||
from core.directories import Directories as DirectoriesBase, DirectoryState
|
||||
from core.app import AppMode
|
||||
|
||||
from ..base.app import DupeGuru as DupeGuruBase
|
||||
from .details_dialog import DetailsDialog
|
||||
from .results_model import ResultsModel
|
||||
from .details_dialog import DetailsDialog as DetailsDialogStandard
|
||||
from ..me.details_dialog import DetailsDialog as DetailsDialogMusic
|
||||
from .results_model import ResultsModel as ResultsModelStandard
|
||||
from ..me.results_model import ResultsModel as ResultsModelMusic
|
||||
from .preferences import Preferences
|
||||
from .preferences_dialog import PreferencesDialog
|
||||
from .preferences_dialog import PreferencesDialog as PreferencesDialogStandard
|
||||
from ..me.preferences_dialog import PreferencesDialog as PreferencesDialogMusic
|
||||
|
||||
class Directories(DirectoriesBase):
|
||||
ROOT_PATH_TO_EXCLUDE = frozenset(['windows', 'program files'])
|
||||
@@ -30,10 +34,7 @@ class DupeGuru(DupeGuruBase):
|
||||
LOGO_NAME = 'logo_se'
|
||||
NAME = __appname__
|
||||
|
||||
DETAILS_DIALOG_CLASS = DetailsDialog
|
||||
RESULT_MODEL_CLASS = ResultsModel
|
||||
PREFERENCES_CLASS = Preferences
|
||||
PREFERENCES_DIALOG_CLASS = PreferencesDialog
|
||||
|
||||
def _setup(self):
|
||||
self.directories = Directories()
|
||||
@@ -42,9 +43,43 @@ class DupeGuru(DupeGuruBase):
|
||||
def _update_options(self):
|
||||
DupeGuruBase._update_options(self)
|
||||
self.model.options['min_match_percentage'] = self.prefs.filter_hardness
|
||||
self.model.options['scan_type'] = self.prefs.scan_type
|
||||
self.model.options['word_weighting'] = self.prefs.word_weighting
|
||||
self.model.options['match_similar_words'] = self.prefs.match_similar
|
||||
threshold = self.prefs.small_file_threshold if self.prefs.ignore_small_files else 0
|
||||
self.model.options['size_threshold'] = threshold * 1024 # threshold is in KB. the scanner wants bytes
|
||||
scanned_tags = set()
|
||||
if self.prefs.scan_tag_track:
|
||||
scanned_tags.add('track')
|
||||
if self.prefs.scan_tag_artist:
|
||||
scanned_tags.add('artist')
|
||||
if self.prefs.scan_tag_album:
|
||||
scanned_tags.add('album')
|
||||
if self.prefs.scan_tag_title:
|
||||
scanned_tags.add('title')
|
||||
if self.prefs.scan_tag_genre:
|
||||
scanned_tags.add('genre')
|
||||
if self.prefs.scan_tag_year:
|
||||
scanned_tags.add('year')
|
||||
self.model.options['scanned_tags'] = scanned_tags
|
||||
|
||||
@property
|
||||
def DETAILS_DIALOG_CLASS(self):
|
||||
if self.model.app_mode == AppMode.Music:
|
||||
return DetailsDialogMusic
|
||||
else:
|
||||
return DetailsDialogStandard
|
||||
|
||||
@property
|
||||
def RESULT_MODEL_CLASS(self):
|
||||
if self.model.app_mode == AppMode.Music:
|
||||
return ResultsModelMusic
|
||||
else:
|
||||
return ResultsModelStandard
|
||||
|
||||
@property
|
||||
def PREFERENCES_DIALOG_CLASS(self):
|
||||
if self.model.app_mode == AppMode.Music:
|
||||
return PreferencesDialogMusic
|
||||
else:
|
||||
return PreferencesDialogStandard
|
||||
|
||||
|
||||
@@ -4,19 +4,21 @@
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
from core.scanner import ScanType
|
||||
|
||||
from ..base.preferences import Preferences as PreferencesBase
|
||||
|
||||
class Preferences(PreferencesBase):
|
||||
DEFAULT_SCAN_TYPE = ScanType.Contents
|
||||
|
||||
def _load_specific(self, settings):
|
||||
get = self.get_value
|
||||
self.word_weighting = get('WordWeighting', self.word_weighting)
|
||||
self.match_similar = get('MatchSimilar', self.match_similar)
|
||||
self.ignore_small_files = get('IgnoreSmallFiles', self.ignore_small_files)
|
||||
self.small_file_threshold = get('SmallFileThreshold', self.small_file_threshold)
|
||||
self.scan_tag_track = get('ScanTagTrack', self.scan_tag_track)
|
||||
self.scan_tag_artist = get('ScanTagArtist', self.scan_tag_artist)
|
||||
self.scan_tag_album = get('ScanTagAlbum', self.scan_tag_album)
|
||||
self.scan_tag_title = get('ScanTagTitle', self.scan_tag_title)
|
||||
self.scan_tag_genre = get('ScanTagGenre', self.scan_tag_genre)
|
||||
self.scan_tag_year = get('ScanTagYear', self.scan_tag_year)
|
||||
|
||||
def _reset_specific(self):
|
||||
self.filter_hardness = 80
|
||||
@@ -24,6 +26,12 @@ class Preferences(PreferencesBase):
|
||||
self.match_similar = False
|
||||
self.ignore_small_files = True
|
||||
self.small_file_threshold = 10 # KB
|
||||
self.scan_tag_track = False
|
||||
self.scan_tag_artist = True
|
||||
self.scan_tag_album = True
|
||||
self.scan_tag_title = True
|
||||
self.scan_tag_genre = False
|
||||
self.scan_tag_year = False
|
||||
|
||||
def _save_specific(self, settings):
|
||||
set_ = self.set_value
|
||||
@@ -31,4 +39,10 @@ class Preferences(PreferencesBase):
|
||||
set_('MatchSimilar', self.match_similar)
|
||||
set_('IgnoreSmallFiles', self.ignore_small_files)
|
||||
set_('SmallFileThreshold', self.small_file_threshold)
|
||||
set_('ScanTagTrack', self.scan_tag_track)
|
||||
set_('ScanTagArtist', self.scan_tag_artist)
|
||||
set_('ScanTagAlbum', self.scan_tag_album)
|
||||
set_('ScanTagTitle', self.scan_tag_title)
|
||||
set_('ScanTagGenre', self.scan_tag_genre)
|
||||
set_('ScanTagYear', self.scan_tag_year)
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from hscommon.plat import ISWINDOWS, ISLINUX
|
||||
from hscommon.trans import trget
|
||||
from hscommon.util import tryint
|
||||
|
||||
from core.app import AppMode
|
||||
from core.scanner import ScanType
|
||||
|
||||
from ..base.preferences_dialog import PreferencesDialogBase
|
||||
@@ -81,7 +82,7 @@ class PreferencesDialog(PreferencesDialogBase):
|
||||
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
|
||||
|
||||
# Update UI state based on selected scan type
|
||||
scan_type = prefs.scan_type
|
||||
scan_type = prefs.get_scan_type(AppMode.Standard)
|
||||
word_based = scan_type == ScanType.Filename
|
||||
self.filterHardnessSlider.setEnabled(word_based)
|
||||
self.matchSimilarBox.setEnabled(word_based)
|
||||
|
||||
Reference in New Issue
Block a user