mirror of
https://github.com/arsenetar/dupeguru.git
synced 2024-11-05 15:59:03 +00:00
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
# Created By: Virgil Dupras
|
|
# Created On: 2009-04-29
|
|
# Copyright 2010 Hardcoded Software (http://www.hardcoded.net)
|
|
#
|
|
# This software is licensed under the "HS" License as described in the "LICENSE" file,
|
|
# which should be included with this package. The terms are also available at
|
|
# http://www.hardcoded.net/licenses/hs_license
|
|
|
|
from PyQt4.QtCore import SIGNAL, Qt
|
|
from PyQt4.QtGui import QDialog, QDialogButtonBox
|
|
|
|
from preferences_dialog_ui import Ui_PreferencesDialog
|
|
import preferences
|
|
|
|
class PreferencesDialog(QDialog, Ui_PreferencesDialog):
|
|
def __init__(self, parent, app):
|
|
flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
|
|
QDialog.__init__(self, parent, flags)
|
|
self.app = app
|
|
self._setupUi()
|
|
|
|
self.connect(self.buttonBox, SIGNAL('clicked(QAbstractButton*)'), self.buttonClicked)
|
|
|
|
def _setupUi(self):
|
|
self.setupUi(self)
|
|
|
|
def load(self, prefs=None):
|
|
if prefs is None:
|
|
prefs = self.app.prefs
|
|
self.filterHardnessSlider.setValue(prefs.filter_hardness)
|
|
self.filterHardnessLabel.setNum(prefs.filter_hardness)
|
|
setchecked = lambda cb, b: cb.setCheckState(Qt.Checked if b else Qt.Unchecked)
|
|
setchecked(self.matchScaledBox, prefs.match_scaled)
|
|
setchecked(self.mixFileKindBox, prefs.mix_file_kind)
|
|
setchecked(self.useRegexpBox, prefs.use_regexp)
|
|
setchecked(self.removeEmptyFoldersBox, prefs.remove_empty_folders)
|
|
self.copyMoveDestinationComboBox.setCurrentIndex(prefs.destination_type)
|
|
self.customCommandEdit.setText(prefs.custom_command)
|
|
|
|
def save(self):
|
|
prefs = self.app.prefs
|
|
prefs.filter_hardness = self.filterHardnessSlider.value()
|
|
ischecked = lambda cb: cb.checkState() == Qt.Checked
|
|
prefs.match_scaled = ischecked(self.matchScaledBox)
|
|
prefs.mix_file_kind = ischecked(self.mixFileKindBox)
|
|
prefs.use_regexp = ischecked(self.useRegexpBox)
|
|
prefs.remove_empty_folders = ischecked(self.removeEmptyFoldersBox)
|
|
prefs.destination_type = self.copyMoveDestinationComboBox.currentIndex()
|
|
prefs.custom_command = str(self.customCommandEdit.text())
|
|
|
|
def resetToDefaults(self):
|
|
self.load(preferences.Preferences())
|
|
|
|
#--- Events
|
|
def buttonClicked(self, button):
|
|
role = self.buttonBox.buttonRole(button)
|
|
if role == QDialogButtonBox.ResetRole:
|
|
self.resetToDefaults()
|
|
|