2009-06-01 09:55:11 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2009-04-29
|
2011-04-12 08:04:01 +00:00
|
|
|
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
2009-08-05 08:59:46 +00:00
|
|
|
#
|
2010-09-30 10:17:41 +00:00
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2009-08-05 08:59:46 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-09-25 10:28:34 +00:00
|
|
|
import sys
|
2011-01-21 12:57:54 +00:00
|
|
|
from PyQt4.QtGui import QLabel, QApplication
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
from hscommon.trans import tr
|
2011-04-21 15:17:19 +00:00
|
|
|
from core.scanner import ScanType
|
2011-01-21 12:57:54 +00:00
|
|
|
|
|
|
|
from ..base.preferences_dialog import PreferencesDialogBase
|
2010-10-04 13:29:00 +00:00
|
|
|
from . import preferences
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-04-21 15:17:19 +00:00
|
|
|
|
|
|
|
SCAN_TYPE_ORDER = [
|
|
|
|
ScanType.FuzzyBlock,
|
|
|
|
ScanType.ExifTimestamp,
|
|
|
|
]
|
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
class PreferencesDialog(PreferencesDialogBase):
|
2011-04-21 15:17:19 +00:00
|
|
|
def __init__(self, parent, app):
|
|
|
|
PreferencesDialogBase.__init__(self, parent, app)
|
|
|
|
|
|
|
|
self.scanTypeComboBox.currentIndexChanged[int].connect(self.scanTypeChanged)
|
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _setupPreferenceWidgets(self):
|
2011-04-21 15:17:19 +00:00
|
|
|
scanTypeLabels = [tr(s) for s in ["Contents", "EXIF Timestamp"]]
|
|
|
|
self._setupScanTypeBox(scanTypeLabels)
|
2011-01-21 12:57:54 +00:00
|
|
|
self._setupFilterHardnessBox()
|
|
|
|
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
|
2011-06-15 14:13:03 +00:00
|
|
|
self._setupAddCheckbox('matchScaledBox', tr("Match pictures of different dimensions"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.matchScaledBox)
|
|
|
|
self._setupAddCheckbox('mixFileKindBox', tr("Can mix file kind"))
|
|
|
|
self.widgetsVLayout.addWidget(self.mixFileKindBox)
|
|
|
|
self._setupAddCheckbox('useRegexpBox', tr("Use regular expressions when filtering"))
|
|
|
|
self.widgetsVLayout.addWidget(self.useRegexpBox)
|
|
|
|
self._setupAddCheckbox('removeEmptyFoldersBox', tr("Remove empty folders on delete or move"))
|
|
|
|
self.widgetsVLayout.addWidget(self.removeEmptyFoldersBox)
|
|
|
|
self._setupAddCheckbox('ignoreHardlinkMatches', tr("Ignore duplicates hardlinking to the same file"))
|
|
|
|
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
|
2011-01-26 11:50:44 +00:00
|
|
|
self._setupAddCheckbox('debugModeBox', tr(tr("Debug mode (restart required)")))
|
|
|
|
self.widgetsVLayout.addWidget(self.debugModeBox)
|
2011-01-21 12:57:54 +00:00
|
|
|
self._setupBottomPart()
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _load(self, prefs, setchecked):
|
2011-04-21 15:17:19 +00:00
|
|
|
scan_type_index = SCAN_TYPE_ORDER.index(prefs.scan_type)
|
|
|
|
self.scanTypeComboBox.setCurrentIndex(scan_type_index)
|
2009-06-01 09:55:11 +00:00
|
|
|
setchecked(self.matchScaledBox, prefs.match_scaled)
|
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
def _save(self, prefs, ischecked):
|
2011-04-21 15:17:19 +00:00
|
|
|
prefs.scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
|
2009-06-01 09:55:11 +00:00
|
|
|
prefs.match_scaled = ischecked(self.matchScaledBox)
|
|
|
|
|
|
|
|
def resetToDefaults(self):
|
|
|
|
self.load(preferences.Preferences())
|
|
|
|
|
2011-04-21 15:17:19 +00:00
|
|
|
#--- Events
|
|
|
|
def scanTypeChanged(self, index):
|
|
|
|
scan_type = SCAN_TYPE_ORDER[self.scanTypeComboBox.currentIndex()]
|
|
|
|
fuzzy_scan = scan_type == ScanType.FuzzyBlock
|
|
|
|
self.filterHardnessSlider.setEnabled(fuzzy_scan)
|
|
|
|
|
2010-10-04 13:29:00 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from ..testapp import TestApp
|
|
|
|
app = QApplication([])
|
|
|
|
dgapp = TestApp()
|
|
|
|
dialog = PreferencesDialog(None, dgapp)
|
|
|
|
dialog.show()
|
|
|
|
sys.exit(app.exec_())
|