1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

qt: move scan_type preference to main window

It leads to better discoverability of dupeguru's options and will make
more sense after the big merge of all editions.
This commit is contained in:
Virgil Dupras
2016-05-28 21:54:25 -04:00
parent 09d5243648
commit 197acbf5b3
10 changed files with 111 additions and 154 deletions

View File

@@ -1,9 +1,7 @@
# Created By: Virgil Dupras
# Created On: 2009-05-24
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# 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
@@ -11,27 +9,26 @@ 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.scan_type = get('ScanType', self.scan_type)
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)
def _reset_specific(self):
self.filter_hardness = 80
self.scan_type = ScanType.Contents
self.word_weighting = True
self.match_similar = False
self.ignore_small_files = True
self.small_file_threshold = 10 # KB
def _save_specific(self, settings):
set_ = self.set_value
set_('ScanType', self.scan_type)
set_('WordWeighting', self.word_weighting)
set_('MatchSimilar', self.match_similar)
set_('IgnoreSmallFiles', self.ignore_small_files)
set_('SmallFileThreshold', self.small_file_threshold)

View File

@@ -21,13 +21,7 @@ from . import preferences
tr = trget('ui')
class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app, **kwargs):
super().__init__(parent, app, **kwargs)
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self):
self._setupScanTypeBox()
self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self)
@@ -81,14 +75,19 @@ class PreferencesDialog(PreferencesDialogBase):
self.resize(self.width(), 440)
def _load(self, prefs, setchecked):
self._load_scan_type(prefs)
setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting)
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
# Update UI state based on selected scan type
scan_type = prefs.scan_type
word_based = scan_type == ScanType.Filename
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)
def _save(self, prefs, ischecked):
self._save_scan_type(prefs)
prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox)
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
@@ -97,12 +96,3 @@ class PreferencesDialog(PreferencesDialogBase):
def resetToDefaults(self):
self.load(preferences.Preferences())
#--- Events
def scanTypeChanged(self, index):
scan_options = self.app.model.scanner.get_scan_options()
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
word_based = scan_type == ScanType.Filename
self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based)