2016-05-29 01:54:25 +00:00
|
|
|
# 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
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2013-10-20 19:15:09 +00:00
|
|
|
from PyQt5.QtWidgets import QApplication
|
2011-09-23 14:29:25 +00:00
|
|
|
|
2012-01-03 20:03:10 +00:00
|
|
|
from hscommon import trans
|
2016-05-30 02:37:38 +00:00
|
|
|
from core.app import AppMode
|
|
|
|
from core.scanner import ScanType
|
2010-01-13 14:25:15 +00:00
|
|
|
from qtlib.preferences import Preferences as PreferencesBase
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2010-01-13 14:25:15 +00:00
|
|
|
class Preferences(PreferencesBase):
|
2010-08-15 10:27:15 +00:00
|
|
|
def _load_values(self, settings):
|
|
|
|
get = self.get_value
|
2009-06-01 09:55:11 +00:00
|
|
|
self.filter_hardness = get('FilterHardness', self.filter_hardness)
|
|
|
|
self.mix_file_kind = get('MixFileKind', self.mix_file_kind)
|
2010-09-25 10:28:34 +00:00
|
|
|
self.ignore_hardlink_matches = get('IgnoreHardlinkMatches', self.ignore_hardlink_matches)
|
2009-06-01 09:55:11 +00:00
|
|
|
self.use_regexp = get('UseRegexp', self.use_regexp)
|
|
|
|
self.remove_empty_folders = get('RemoveEmptyFolders', self.remove_empty_folders)
|
2011-01-26 11:50:44 +00:00
|
|
|
self.debug_mode = get('DebugMode', self.debug_mode)
|
2009-06-01 09:55:11 +00:00
|
|
|
self.destination_type = get('DestinationType', self.destination_type)
|
2010-04-13 08:02:09 +00:00
|
|
|
self.custom_command = get('CustomCommand', self.custom_command)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.language = get('Language', self.language)
|
2012-01-03 20:03:10 +00:00
|
|
|
if not self.language and trans.installed_lang:
|
|
|
|
self.language = trans.installed_lang
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2011-09-23 14:29:25 +00:00
|
|
|
self.tableFontSize = get('TableFontSize', self.tableFontSize)
|
2011-01-15 15:29:35 +00:00
|
|
|
self.resultWindowIsMaximized = get('ResultWindowIsMaximized', self.resultWindowIsMaximized)
|
|
|
|
self.resultWindowRect = self.get_rect('ResultWindowRect', self.resultWindowRect)
|
2010-08-15 10:27:15 +00:00
|
|
|
self.directoriesWindowRect = self.get_rect('DirectoriesWindowRect', self.directoriesWindowRect)
|
2011-01-13 15:20:03 +00:00
|
|
|
self.recentResults = get('RecentResults', self.recentResults)
|
2011-01-17 16:15:16 +00:00
|
|
|
self.recentFolders = get('RecentFolders', self.recentFolders)
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2016-06-01 01:22:50 +00:00
|
|
|
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)
|
|
|
|
self.match_scaled = get('MatchScaled', self.match_scaled)
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2009-06-01 09:55:11 +00:00
|
|
|
def reset(self):
|
|
|
|
self.filter_hardness = 95
|
|
|
|
self.mix_file_kind = True
|
|
|
|
self.use_regexp = False
|
2010-09-25 10:28:34 +00:00
|
|
|
self.ignore_hardlink_matches = False
|
2009-06-01 09:55:11 +00:00
|
|
|
self.remove_empty_folders = False
|
2011-01-26 11:50:44 +00:00
|
|
|
self.debug_mode = False
|
2009-06-01 09:55:11 +00:00
|
|
|
self.destination_type = 1
|
2010-04-13 08:02:09 +00:00
|
|
|
self.custom_command = ''
|
2012-01-03 20:03:10 +00:00
|
|
|
self.language = trans.installed_lang if trans.installed_lang else ''
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2011-09-23 14:29:25 +00:00
|
|
|
self.tableFontSize = QApplication.font().pointSize()
|
2011-01-15 15:29:35 +00:00
|
|
|
self.resultWindowIsMaximized = False
|
|
|
|
self.resultWindowRect = None
|
2010-08-15 10:27:15 +00:00
|
|
|
self.directoriesWindowRect = None
|
2011-01-13 15:20:03 +00:00
|
|
|
self.recentResults = []
|
2011-01-17 16:15:16 +00:00
|
|
|
self.recentFolders = []
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2016-06-01 01:22:50 +00:00
|
|
|
self.word_weighting = True
|
|
|
|
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
|
|
|
|
self.match_scaled = False
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2010-08-15 10:27:15 +00:00
|
|
|
def _save_values(self, settings):
|
|
|
|
set_ = self.set_value
|
2009-06-01 09:55:11 +00:00
|
|
|
set_('FilterHardness', self.filter_hardness)
|
|
|
|
set_('MixFileKind', self.mix_file_kind)
|
2010-09-25 10:28:34 +00:00
|
|
|
set_('IgnoreHardlinkMatches', self.ignore_hardlink_matches)
|
2009-06-01 09:55:11 +00:00
|
|
|
set_('UseRegexp', self.use_regexp)
|
|
|
|
set_('RemoveEmptyFolders', self.remove_empty_folders)
|
2011-01-26 11:50:44 +00:00
|
|
|
set_('DebugMode', self.debug_mode)
|
2009-06-01 09:55:11 +00:00
|
|
|
set_('DestinationType', self.destination_type)
|
2010-04-13 08:02:09 +00:00
|
|
|
set_('CustomCommand', self.custom_command)
|
2011-01-21 12:57:54 +00:00
|
|
|
set_('Language', self.language)
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2011-09-23 14:29:25 +00:00
|
|
|
set_('TableFontSize', self.tableFontSize)
|
2011-01-15 15:29:35 +00:00
|
|
|
set_('ResultWindowIsMaximized', self.resultWindowIsMaximized)
|
|
|
|
self.set_rect('ResultWindowRect', self.resultWindowRect)
|
2010-08-15 10:27:15 +00:00
|
|
|
self.set_rect('DirectoriesWindowRect', self.directoriesWindowRect)
|
2011-01-13 15:20:03 +00:00
|
|
|
set_('RecentResults', self.recentResults)
|
2011-01-17 16:15:16 +00:00
|
|
|
set_('RecentFolders', self.recentFolders)
|
2016-05-29 01:54:25 +00:00
|
|
|
|
2016-06-01 01:22:50 +00:00
|
|
|
set_('WordWeighting', self.word_weighting)
|
|
|
|
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)
|
|
|
|
set_('MatchScaled', self.match_scaled)
|
2016-05-29 01:54:25 +00:00
|
|
|
|
|
|
|
# scan_type is special because we save it immediately when we set it.
|
2016-05-30 02:37:38 +00:00
|
|
|
def get_scan_type(self, app_mode):
|
2016-05-31 02:27:59 +00:00
|
|
|
if app_mode == AppMode.Picture:
|
|
|
|
return self.get_value('ScanTypePicture', ScanType.FuzzyBlock)
|
|
|
|
elif app_mode == AppMode.Music:
|
2016-05-30 02:37:38 +00:00
|
|
|
return self.get_value('ScanTypeMusic', ScanType.Tag)
|
|
|
|
else:
|
|
|
|
return self.get_value('ScanTypeStandard', ScanType.Contents)
|
|
|
|
|
|
|
|
def set_scan_type(self, app_mode, value):
|
2016-05-31 02:27:59 +00:00
|
|
|
if app_mode == AppMode.Picture:
|
|
|
|
self.set_value('ScanTypePicture', value)
|
|
|
|
elif app_mode == AppMode.Music:
|
2016-05-30 02:37:38 +00:00
|
|
|
self.set_value('ScanTypeMusic', value)
|
|
|
|
else:
|
|
|
|
self.set_value('ScanTypeStandard', value)
|