Push edition-specific scan option listing down to the core

... rather than have each UI layer repeat them.

Did qt, but not cocoa yet.
This commit is contained in:
Virgil Dupras 2016-05-24 22:53:03 -04:00
parent de9122c3cb
commit 2ed1b82ecf
9 changed files with 112 additions and 135 deletions

View File

@ -1,6 +1,4 @@
# Created By: Virgil Dupras # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# Created On: 2006/03/03
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# #
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file, # 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 # which should be included with this package. The terms are also available at
@ -9,6 +7,7 @@
import logging import logging
import re import re
import os.path as op import os.path as op
from collections import namedtuple
from hscommon.jobprogress import job from hscommon.jobprogress import job
from hscommon.util import dedupe, rem_file_ext, get_file_ext from hscommon.util import dedupe, rem_file_ext, get_file_ext
@ -34,6 +33,8 @@ class ScanType:
FuzzyBlock = 10 FuzzyBlock = 10
ExifTimestamp = 11 ExifTimestamp = 11
ScanOption = namedtuple('ScanOption', 'scan_type label')
SCANNABLE_TAGS = ['track', 'artist', 'album', 'title', 'genre', 'year'] SCANNABLE_TAGS = ['track', 'artist', 'album', 'title', 'genre', 'year']
RE_DIGIT_ENDING = re.compile(r'\d+|\(\d+\)|\[\d+\]|{\d+}') RE_DIGIT_ENDING = re.compile(r'\d+|\(\d+\)|\[\d+\]|{\d+}')
@ -125,6 +126,13 @@ class Scanner:
return True return True
return len(dupe.path) > len(ref.path) return len(dupe.path) > len(ref.path)
def get_scan_options(self):
"""Returns a list of scanning options for this scanner.
Returns a list of ``ScanOption``.
"""
raise NotImplementedError()
def get_dupe_groups(self, files, j=job.nulljob): def get_dupe_groups(self, files, j=job.nulljob):
j = j.start_subjob([8, 2]) j = j.start_subjob([8, 2])
for f in (f for f in files if not hasattr(f, 'is_ref')): for f in (f for f in files if not hasattr(f, 'is_ref')):

View File

@ -1,15 +1,26 @@
# Created By: Virgil Dupras # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# Created On: 2006/03/03 #
# 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
# 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 # http://www.gnu.org/licenses/gpl-3.0.html
from core.scanner import Scanner as ScannerBase from hscommon.trans import tr
from core.scanner import Scanner as ScannerBase, ScanOption, ScanType
class ScannerME(ScannerBase): class ScannerME(ScannerBase):
@staticmethod @staticmethod
def _key_func(dupe): def _key_func(dupe):
return (-dupe.bitrate, -dupe.size) return (-dupe.bitrate, -dupe.size)
def get_scan_options(self):
return [
ScanOption(ScanType.Filename, tr("Filename")),
ScanOption(ScanType.Fields, tr("Filename - Fields")),
ScanOption(ScanType.FieldsNoOrder, tr("Filename - Fields (No Order)")),
ScanOption(ScanType.Tag, tr("Tags")),
ScanOption(ScanType.Contents, tr("Contents")),
ScanOption(ScanType.ContentsAudio, tr("Audio Contents")),
]

View File

@ -1,12 +1,12 @@
# Created By: Virgil Dupras # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# Created On: 2009-10-18 #
# 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
# 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 # http://www.gnu.org/licenses/gpl-3.0.html
from core.scanner import Scanner, ScanType from hscommon.trans import tr
from core.scanner import Scanner, ScanType, ScanOption
from . import matchblock, matchexif from . import matchblock, matchexif
from .cache import Cache from .cache import Cache
@ -15,7 +15,13 @@ class ScannerPE(Scanner):
cache_path = None cache_path = None
match_scaled = False match_scaled = False
threshold = 75 threshold = 75
def get_scan_options(self):
return [
ScanOption(ScanType.FuzzyBlock, tr("Contents")),
ScanOption(ScanType.ExifTimestamp, tr("EXIF Timestamp")),
]
def _getmatches(self, files, j): def _getmatches(self, files, j):
if self.scan_type == ScanType.FuzzyBlock: if self.scan_type == ScanType.FuzzyBlock:
return matchblock.getmatches(files, self.cache_path, self.threshold, self.match_scaled, j) return matchblock.getmatches(files, self.cache_path, self.threshold, self.match_scaled, j)
@ -23,9 +29,9 @@ class ScannerPE(Scanner):
return matchexif.getmatches(files, self.match_scaled, j) return matchexif.getmatches(files, self.match_scaled, j)
else: else:
raise Exception("Invalid scan type") raise Exception("Invalid scan type")
def clear_picture_cache(self): def clear_picture_cache(self):
cache = Cache(self.cache_path) cache = Cache(self.cache_path)
cache.clear() cache.clear()
cache.close() cache.close()

View File

@ -1,27 +1,27 @@
# Created On: 2011/09/20 # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net) #
# # This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# 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
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
from core.app import DupeGuru as DupeGuruBase from core.app import DupeGuru as DupeGuruBase
from core import prioritize from core import prioritize
from . import __appname__, fs from . import __appname__, fs, scanner
from .result_table import ResultTable from .result_table import ResultTable
class DupeGuru(DupeGuruBase): class DupeGuru(DupeGuruBase):
NAME = __appname__ NAME = __appname__
METADATA_TO_READ = ['size', 'mtime'] METADATA_TO_READ = ['size', 'mtime']
SCANNER_CLASS = scanner.ScannerSE
def __init__(self, view): def __init__(self, view):
DupeGuruBase.__init__(self, view) DupeGuruBase.__init__(self, view)
self.directories.fileclasses = [fs.File] self.directories.fileclasses = [fs.File]
self.directories.folderclass = fs.Folder self.directories.folderclass = fs.Folder
def _prioritization_categories(self): def _prioritization_categories(self):
return prioritize.all_categories() return prioritize.all_categories()
def _create_result_table(self): def _create_result_table(self):
return ResultTable(self) return ResultTable(self)

18
core_se/scanner.py Normal file
View File

@ -0,0 +1,18 @@
# 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 hscommon.trans import tr
from core.scanner import Scanner as ScannerBase, ScanOption, ScanType
class ScannerSE(ScannerBase):
def get_scan_options(self):
return [
ScanOption(ScanType.Filename, tr("Filename")),
ScanOption(ScanType.Contents, tr("Contents")),
ScanOption(ScanType.Folders, tr("Folders")),
]

View File

@ -37,18 +37,17 @@ class PreferencesDialogBase(QDialog):
self.buttonBox.accepted.connect(self.accept) self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
def _setupScanTypeBox(self, labels): def _setupScanTypeBox(self):
self.scanTypeHLayout = QHBoxLayout() hl = QHBoxLayout()
self.scanTypeLabel = QLabel(self) label = QLabel(tr("Scan Type:"), self)
self.scanTypeLabel.setText(tr("Scan Type:")) label.setMinimumSize(QSize(100, 0))
self.scanTypeLabel.setMinimumSize(QSize(100, 0)) label.setMaximumSize(QSize(100, 16777215))
self.scanTypeLabel.setMaximumSize(QSize(100, 16777215)) hl.addWidget(label)
self.scanTypeHLayout.addWidget(self.scanTypeLabel)
self.scanTypeComboBox = QComboBox(self) self.scanTypeComboBox = QComboBox(self)
for label in labels: for scan_option in self.app.model.scanner.get_scan_options():
self.scanTypeComboBox.addItem(label) self.scanTypeComboBox.addItem(scan_option.label)
self.scanTypeHLayout.addWidget(self.scanTypeComboBox) hl.addWidget(self.scanTypeComboBox)
self.widgetsVLayout.addLayout(self.scanTypeHLayout) self.widgetsVLayout.addLayout(hl)
def _setupFilterHardnessBox(self): def _setupFilterHardnessBox(self):
self.filterHardnessHLayout = QHBoxLayout() self.filterHardnessHLayout = QHBoxLayout()
@ -141,10 +140,19 @@ class PreferencesDialogBase(QDialog):
self.mainVLayout.removeWidget(self.ignoreHardlinkMatches) self.mainVLayout.removeWidget(self.ignoreHardlinkMatches)
self.ignoreHardlinkMatches.setHidden(True) self.ignoreHardlinkMatches.setHidden(True)
def _load_scan_type(self, prefs):
SCAN_TYPE_ORDER = [so.scan_type for so in self.app.model.scanner.get_scan_options()]
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
def _load(self, prefs, setchecked): def _load(self, prefs, setchecked):
# Edition-specific # Edition-specific
pass pass
def _save_scan_type(self, prefs):
scan_options = self.app.model.scanner.get_scan_options()
prefs.scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
def _save(self, prefs, ischecked): def _save(self, prefs, ischecked):
# Edition-specific # Edition-specific
pass pass

View File

@ -1,16 +1,14 @@
# Created By: Virgil Dupras # Created By: Virgil Dupras
# Created On: 2009-04-29 # Created On: 2009-04-29
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net) # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# #
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file, # 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 # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
import sys
from PyQt5.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget,
QApplication
) )
from hscommon.trans import trget from hscommon.trans import trget
@ -21,15 +19,6 @@ from . import preferences
tr = trget('ui') tr = trget('ui')
SCAN_TYPE_ORDER = [
ScanType.Filename,
ScanType.Fields,
ScanType.FieldsNoOrder,
ScanType.Tag,
ScanType.Contents,
ScanType.ContentsAudio,
]
class PreferencesDialog(PreferencesDialogBase): class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app): def __init__(self, parent, app):
PreferencesDialogBase.__init__(self, parent, app) PreferencesDialogBase.__init__(self, parent, app)
@ -37,15 +26,7 @@ class PreferencesDialog(PreferencesDialogBase):
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged) self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self): def _setupPreferenceWidgets(self):
scanTypeLabels = [ self._setupScanTypeBox()
tr("Filename"),
tr("Filename - Fields"),
tr("Filename - Fields (No Order)"),
tr("Tags"),
tr("Contents"),
tr("Audio Contents"),
]
self._setupScanTypeBox(scanTypeLabels)
self._setupFilterHardnessBox() self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout) self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self) self.widget = QWidget(self)
@ -91,8 +72,7 @@ class PreferencesDialog(PreferencesDialogBase):
self._setupBottomPart() self._setupBottomPart()
def _load(self, prefs, setchecked): def _load(self, prefs, setchecked):
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type) self._load_scan_type(prefs)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
setchecked(self.tagTrackBox, prefs.scan_tag_track) setchecked(self.tagTrackBox, prefs.scan_tag_track)
setchecked(self.tagArtistBox, prefs.scan_tag_artist) setchecked(self.tagArtistBox, prefs.scan_tag_artist)
setchecked(self.tagAlbumBox, prefs.scan_tag_album) setchecked(self.tagAlbumBox, prefs.scan_tag_album)
@ -103,7 +83,7 @@ class PreferencesDialog(PreferencesDialogBase):
setchecked(self.wordWeightingBox, prefs.word_weighting) setchecked(self.wordWeightingBox, prefs.word_weighting)
def _save(self, prefs, ischecked): def _save(self, prefs, ischecked):
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] self._save_scan_type(prefs)
prefs.scan_tag_track = ischecked(self.tagTrackBox) prefs.scan_tag_track = ischecked(self.tagTrackBox)
prefs.scan_tag_artist = ischecked(self.tagArtistBox) prefs.scan_tag_artist = ischecked(self.tagArtistBox)
prefs.scan_tag_album = ischecked(self.tagAlbumBox) prefs.scan_tag_album = ischecked(self.tagAlbumBox)
@ -118,7 +98,8 @@ class PreferencesDialog(PreferencesDialogBase):
#--- Events #--- Events
def scanTypeChanged(self, index): def scanTypeChanged(self, index):
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] scan_options = self.app.model.scanner.get_scan_options()
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
word_based = scan_type in ( word_based = scan_type in (
ScanType.Filename, ScanType.Fields, ScanType.FieldsNoOrder, ScanType.Filename, ScanType.Fields, ScanType.FieldsNoOrder,
ScanType.Tag ScanType.Tag
@ -134,12 +115,3 @@ class PreferencesDialog(PreferencesDialogBase):
self.tagGenreBox.setEnabled(tag_based) self.tagGenreBox.setEnabled(tag_based)
self.tagYearBox.setEnabled(tag_based) self.tagYearBox.setEnabled(tag_based)
if __name__ == '__main__':
from ..testapp import TestApp
app = QApplication([])
dgapp = TestApp()
dialog = PreferencesDialog(None, dgapp)
dialog.show()
sys.exit(app.exec_())

View File

@ -1,14 +1,9 @@
# Created By: Virgil Dupras # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# Created On: 2009-04-29
# Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
# #
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file, # 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 # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
import sys
from PyQt5.QtWidgets import QApplication
from hscommon.trans import trget from hscommon.trans import trget
from core.scanner import ScanType from core.scanner import ScanType
@ -17,11 +12,6 @@ from . import preferences
tr = trget('ui') tr = trget('ui')
SCAN_TYPE_ORDER = [
ScanType.FuzzyBlock,
ScanType.ExifTimestamp,
]
class PreferencesDialog(PreferencesDialogBase): class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app): def __init__(self, parent, app):
PreferencesDialogBase.__init__(self, parent, app) PreferencesDialogBase.__init__(self, parent, app)
@ -29,11 +19,7 @@ class PreferencesDialog(PreferencesDialogBase):
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged) self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self): def _setupPreferenceWidgets(self):
scanTypeLabels = [ self._setupScanTypeBox()
tr("Contents"),
tr("EXIF Timestamp"),
]
self._setupScanTypeBox(scanTypeLabels)
self._setupFilterHardnessBox() self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout) self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self._setupAddCheckbox('matchScaledBox', tr("Match pictures of different dimensions")) self._setupAddCheckbox('matchScaledBox', tr("Match pictures of different dimensions"))
@ -51,12 +37,11 @@ class PreferencesDialog(PreferencesDialogBase):
self._setupBottomPart() self._setupBottomPart()
def _load(self, prefs, setchecked): def _load(self, prefs, setchecked):
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type) self._load_scan_type(prefs)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
setchecked(self.matchScaledBox, prefs.match_scaled) setchecked(self.matchScaledBox, prefs.match_scaled)
def _save(self, prefs, ischecked): def _save(self, prefs, ischecked):
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] self._save_scan_type(prefs)
prefs.match_scaled = ischecked(self.matchScaledBox) prefs.match_scaled = ischecked(self.matchScaledBox)
def resetToDefaults(self): def resetToDefaults(self):
@ -64,16 +49,8 @@ class PreferencesDialog(PreferencesDialogBase):
#--- Events #--- Events
def scanTypeChanged(self, index): def scanTypeChanged(self, index):
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] scan_options = self.app.model.scanner.get_scan_options()
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
fuzzy_scan = scan_type == ScanType.FuzzyBlock fuzzy_scan = scan_type == ScanType.FuzzyBlock
self.filterHardnessSlider.setEnabled(fuzzy_scan) self.filterHardnessSlider.setEnabled(fuzzy_scan)
if __name__ == '__main__':
from ..testapp import TestApp
app = QApplication([])
dgapp = TestApp()
dialog = PreferencesDialog(None, dgapp)
dialog.show()
sys.exit(app.exec_())

View File

@ -1,16 +1,12 @@
# Created By: Virgil Dupras # Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
# 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, # 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 # which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html # http://www.gnu.org/licenses/gpl-3.0.html
import sys
from PyQt5.QtCore import QSize from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import ( from PyQt5.QtWidgets import (
QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, QVBoxLayout, QHBoxLayout, QLabel, QSizePolicy, QSpacerItem, QWidget, QLineEdit
QLineEdit, QApplication
) )
from hscommon.plat import ISWINDOWS, ISLINUX from hscommon.plat import ISWINDOWS, ISLINUX
@ -24,12 +20,6 @@ from . import preferences
tr = trget('ui') tr = trget('ui')
SCAN_TYPE_ORDER = [
ScanType.Filename,
ScanType.Contents,
ScanType.Folders,
]
class PreferencesDialog(PreferencesDialogBase): class PreferencesDialog(PreferencesDialogBase):
def __init__(self, parent, app, **kwargs): def __init__(self, parent, app, **kwargs):
super().__init__(parent, app, **kwargs) super().__init__(parent, app, **kwargs)
@ -37,12 +27,7 @@ class PreferencesDialog(PreferencesDialogBase):
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged) self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
def _setupPreferenceWidgets(self): def _setupPreferenceWidgets(self):
scanTypeLabels = [ self._setupScanTypeBox()
tr("Filename"),
tr("Contents"),
tr("Folders"),
]
self._setupScanTypeBox(scanTypeLabels)
self._setupFilterHardnessBox() self._setupFilterHardnessBox()
self.widgetsVLayout.addLayout(self.filterHardnessHLayout) self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
self.widget = QWidget(self) self.widget = QWidget(self)
@ -96,15 +81,14 @@ class PreferencesDialog(PreferencesDialogBase):
self.resize(self.width(), 440) self.resize(self.width(), 440)
def _load(self, prefs, setchecked): def _load(self, prefs, setchecked):
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type) self._load_scan_type(prefs)
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
setchecked(self.matchSimilarBox, prefs.match_similar) setchecked(self.matchSimilarBox, prefs.match_similar)
setchecked(self.wordWeightingBox, prefs.word_weighting) setchecked(self.wordWeightingBox, prefs.word_weighting)
setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files) setchecked(self.ignoreSmallFilesBox, prefs.ignore_small_files)
self.sizeThresholdEdit.setText(str(prefs.small_file_threshold)) self.sizeThresholdEdit.setText(str(prefs.small_file_threshold))
def _save(self, prefs, ischecked): def _save(self, prefs, ischecked):
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] self._save_scan_type(prefs)
prefs.match_similar = ischecked(self.matchSimilarBox) prefs.match_similar = ischecked(self.matchSimilarBox)
prefs.word_weighting = ischecked(self.wordWeightingBox) prefs.word_weighting = ischecked(self.wordWeightingBox)
prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox) prefs.ignore_small_files = ischecked(self.ignoreSmallFilesBox)
@ -115,17 +99,10 @@ class PreferencesDialog(PreferencesDialogBase):
#--- Events #--- Events
def scanTypeChanged(self, index): def scanTypeChanged(self, index):
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()] scan_options = self.app.model.scanner.get_scan_options()
scan_type = scan_options[self.scanTypeComboBox.currentIndex()].scan_type
word_based = scan_type == ScanType.Filename word_based = scan_type == ScanType.Filename
self.filterHardnessSlider.setEnabled(word_based) self.filterHardnessSlider.setEnabled(word_based)
self.matchSimilarBox.setEnabled(word_based) self.matchSimilarBox.setEnabled(word_based)
self.wordWeightingBox.setEnabled(word_based) self.wordWeightingBox.setEnabled(word_based)
if __name__ == '__main__':
from ..testapp import TestApp
app = QApplication([])
dgapp = TestApp()
dialog = PreferencesDialog(None, dgapp)
dialog.show()
sys.exit(app.exec_())