2016-05-25 02:53:03 +00:00
|
|
|
# Copyright 2016 Hardcoded Software (http://www.hardcoded.net)
|
2014-10-13 19:08:59 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-13 19:08:59 +00:00
|
|
|
# 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.QtCore import QSize
|
2014-10-13 19:08:59 +00:00
|
|
|
from PyQt5.QtWidgets import (
|
2020-01-01 02:16:27 +00:00
|
|
|
QVBoxLayout,
|
|
|
|
QHBoxLayout,
|
|
|
|
QLabel,
|
|
|
|
QSizePolicy,
|
|
|
|
QSpacerItem,
|
|
|
|
QWidget,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon.trans import trget
|
2016-05-30 02:37:38 +00:00
|
|
|
from core.app import AppMode
|
2010-08-14 17:52:23 +00:00
|
|
|
from core.scanner import ScanType
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2016-06-01 01:59:31 +00:00
|
|
|
from ..preferences_dialog import PreferencesDialogBase
|
2009-06-01 09:55:11 +00:00
|
|
|
|
2020-01-01 02:16:27 +00:00
|
|
|
tr = trget("ui")
|
|
|
|
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2011-01-21 12:57:54 +00:00
|
|
|
class PreferencesDialog(PreferencesDialogBase):
|
|
|
|
def _setupPreferenceWidgets(self):
|
|
|
|
self._setupFilterHardnessBox()
|
|
|
|
self.widgetsVLayout.addLayout(self.filterHardnessHLayout)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.widget = QWidget(self)
|
|
|
|
self.widget.setMinimumSize(QSize(0, 40))
|
|
|
|
self.verticalLayout_4 = QVBoxLayout(self.widget)
|
|
|
|
self.verticalLayout_4.setSpacing(0)
|
2013-11-16 18:38:07 +00:00
|
|
|
self.verticalLayout_4.setContentsMargins(0, 0, 0, 0)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.label_6 = QLabel(self.widget)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.label_6.setText(tr("Tags to scan:"))
|
2010-10-04 13:29:00 +00:00
|
|
|
self.verticalLayout_4.addWidget(self.label_6)
|
|
|
|
self.horizontalLayout_2 = QHBoxLayout()
|
|
|
|
self.horizontalLayout_2.setSpacing(0)
|
2021-08-24 05:12:23 +00:00
|
|
|
spacer_item = QSpacerItem(15, 20, QSizePolicy.Fixed, QSizePolicy.Minimum)
|
|
|
|
self.horizontalLayout_2.addItem(spacer_item)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagTrackBox", tr("Track"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagTrackBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagArtistBox", tr("Artist"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagArtistBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagAlbumBox", tr("Album"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagAlbumBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagTitleBox", tr("Title"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagTitleBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagGenreBox", tr("Genre"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagGenreBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("tagYearBox", tr("Year"), self.widget)
|
2010-10-04 13:29:00 +00:00
|
|
|
self.horizontalLayout_2.addWidget(self.tagYearBox)
|
|
|
|
self.verticalLayout_4.addLayout(self.horizontalLayout_2)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.widget)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("wordWeightingBox", tr("Word weighting"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.wordWeightingBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("matchSimilarBox", tr("Match similar words"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.matchSimilarBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("mixFileKindBox", tr("Can mix file kind"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.mixFileKindBox)
|
2021-08-15 09:10:18 +00:00
|
|
|
self._setupAddCheckbox("useRegexpBox", tr("Use regular expressions when filtering"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.useRegexpBox)
|
2021-08-15 09:10:18 +00:00
|
|
|
self._setupAddCheckbox("removeEmptyFoldersBox", tr("Remove empty folders on delete or move"))
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.removeEmptyFoldersBox)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox(
|
|
|
|
"ignoreHardlinkMatches",
|
|
|
|
tr("Ignore duplicates hardlinking to the same file"),
|
|
|
|
)
|
2011-01-21 12:57:54 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.ignoreHardlinkMatches)
|
2020-01-01 02:16:27 +00:00
|
|
|
self._setupAddCheckbox("debugModeBox", tr("Debug mode (restart required)"))
|
2011-01-26 11:50:44 +00:00
|
|
|
self.widgetsVLayout.addWidget(self.debugModeBox)
|
2011-01-21 12:57:54 +00:00
|
|
|
self._setupBottomPart()
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2020-07-20 03:04:25 +00:00
|
|
|
def _load(self, prefs, setchecked, section):
|
2009-06-01 09:55:11 +00:00
|
|
|
setchecked(self.tagTrackBox, prefs.scan_tag_track)
|
|
|
|
setchecked(self.tagArtistBox, prefs.scan_tag_artist)
|
|
|
|
setchecked(self.tagAlbumBox, prefs.scan_tag_album)
|
|
|
|
setchecked(self.tagTitleBox, prefs.scan_tag_title)
|
|
|
|
setchecked(self.tagGenreBox, prefs.scan_tag_genre)
|
|
|
|
setchecked(self.tagYearBox, prefs.scan_tag_year)
|
|
|
|
setchecked(self.matchSimilarBox, prefs.match_similar)
|
|
|
|
setchecked(self.wordWeightingBox, prefs.word_weighting)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-29 01:54:25 +00:00
|
|
|
# Update UI state based on selected scan type
|
2021-08-21 23:02:02 +00:00
|
|
|
scan_type = prefs.get_scan_type(AppMode.MUSIC)
|
2014-10-13 19:08:59 +00:00
|
|
|
word_based = scan_type in (
|
2021-08-21 23:02:02 +00:00
|
|
|
ScanType.FILENAME,
|
|
|
|
ScanType.FIELDS,
|
|
|
|
ScanType.FIELDSNOORDER,
|
|
|
|
ScanType.TAG,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2021-08-21 23:02:02 +00:00
|
|
|
tag_based = scan_type == ScanType.TAG
|
2009-09-06 08:07:50 +00:00
|
|
|
self.filterHardnessSlider.setEnabled(word_based)
|
|
|
|
self.matchSimilarBox.setEnabled(word_based)
|
|
|
|
self.wordWeightingBox.setEnabled(word_based)
|
|
|
|
self.tagTrackBox.setEnabled(tag_based)
|
|
|
|
self.tagArtistBox.setEnabled(tag_based)
|
|
|
|
self.tagAlbumBox.setEnabled(tag_based)
|
|
|
|
self.tagTitleBox.setEnabled(tag_based)
|
|
|
|
self.tagGenreBox.setEnabled(tag_based)
|
|
|
|
self.tagYearBox.setEnabled(tag_based)
|
2014-10-13 19:08:59 +00:00
|
|
|
|
2016-05-29 01:54:25 +00:00
|
|
|
def _save(self, prefs, ischecked):
|
|
|
|
prefs.scan_tag_track = ischecked(self.tagTrackBox)
|
|
|
|
prefs.scan_tag_artist = ischecked(self.tagArtistBox)
|
|
|
|
prefs.scan_tag_album = ischecked(self.tagAlbumBox)
|
|
|
|
prefs.scan_tag_title = ischecked(self.tagTitleBox)
|
|
|
|
prefs.scan_tag_genre = ischecked(self.tagGenreBox)
|
|
|
|
prefs.scan_tag_year = ischecked(self.tagYearBox)
|
|
|
|
prefs.match_similar = ischecked(self.matchSimilarBox)
|
|
|
|
prefs.word_weighting = ischecked(self.wordWeightingBox)
|