id
int64
0
458k
file_name
stringlengths
4
119
file_path
stringlengths
14
227
content
stringlengths
24
9.96M
size
int64
24
9.96M
language
stringclasses
1 value
extension
stringclasses
14 values
total_lines
int64
1
219k
avg_line_length
float64
2.52
4.63M
max_line_length
int64
5
9.91M
alphanum_fraction
float64
0
1
repo_name
stringlengths
7
101
repo_stars
int64
100
139k
repo_forks
int64
0
26.4k
repo_open_issues
int64
0
2.27k
repo_license
stringclasses
12 values
repo_extraction_date
stringclasses
433 values
11,000
moveable_list_view.py
metabrainz_picard/picard/ui/moveable_list_view.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2018 Sambhav Kothari # Copyright (C) 2018, 2020-2024 Laurent Monin # Copyright (C) 2022 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import ( QtCore, QtWidgets, ) class MoveableListView: def __init__(self, list_widget, up_button, down_button, callback=None): self.list_widget = list_widget self.up_button = up_button self.down_button = down_button self.update_callback = callback self.up_button.clicked.connect(partial(self.move_item, 1)) self.down_button.clicked.connect(partial(self.move_item, -1)) self.list_widget.currentRowChanged.connect(self.update_buttons) self.list_widget.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.DragDrop) self.list_widget.setDefaultDropAction(QtCore.Qt.DropAction.MoveAction) def move_item(self, offset): current_index = self.list_widget.currentRow() offset_index = current_index - offset offset_item = self.list_widget.item(offset_index) if offset_item: current_item = self.list_widget.takeItem(current_index) self.list_widget.insertItem(offset_index, current_item) self.list_widget.setCurrentItem(current_item) self.update_buttons() def update_buttons(self): current_row = self.list_widget.currentRow() self.up_button.setEnabled(current_row > 0) self.down_button.setEnabled(current_row < self.list_widget.count() - 1) if self.update_callback: self.update_callback()
2,347
Python
.py
52
39.826923
91
0.722781
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,001
scriptsmenu.py
metabrainz_picard/picard/ui/scriptsmenu.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2018 Yvan Rivière # Copyright (C) 2018, 2020-2021, 2024 Laurent Monin # Copyright (C) 2018, 2020-2022 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import QtWidgets from picard import log from picard.album import Album from picard.cluster import ( Cluster, ClusterList, ) from picard.i18n import N_ from picard.script import ( ScriptError, ScriptParser, ) from picard.track import Track from picard.util import iter_unique class ScriptsMenu(QtWidgets.QMenu): def __init__(self, scripts, title, parent=None): super().__init__(title, parent=parent) for script in scripts: action = self.addAction(script.name) action.triggered.connect(partial(self._run_script, script)) def _run_script(self, script): parser = ScriptParser() for obj in self._iter_unique_metadata_objects(): try: parser.eval(script.content, obj.metadata) obj.update() except ScriptError as e: log.exception('Error running tagger script "%s" on object %r', script.name, obj) msg = N_('Script error in "%(script)s": %(message)s') mparms = { 'script': script.name, 'message': str(e), } self.tagger.window.set_statusbar_message(msg, mparms) def _iter_unique_metadata_objects(self): return iter_unique(self._iter_metadata_objects(self.tagger.window.selected_objects)) def _iter_metadata_objects(self, objs): for obj in objs: if hasattr(obj, 'metadata') and not getattr(obj, 'special', False): yield obj if isinstance(obj, Cluster) or isinstance(obj, Track): yield from self._iter_metadata_objects(obj.iterfiles()) elif isinstance(obj, ClusterList): yield from self._iter_metadata_objects(obj) elif isinstance(obj, Album): yield from self._iter_metadata_objects(obj.tracks) yield from self._iter_metadata_objects(obj.unmatched_files.iterfiles())
2,934
Python
.py
69
35.434783
96
0.670522
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,002
ratingwidget.py
metabrainz_picard/picard/ui/ratingwidget.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2008, 2018-2022 Philipp Wolfer # Copyright (C) 2011, 2013 Michael Wiencek # Copyright (C) 2013, 2018, 2020-2024 Laurent Monin # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2018 Vishal Choudhary # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import log from picard.config import get_config from picard.i18n import N_ class RatingWidget(QtWidgets.QWidget): def __init__(self, track, parent=None): super().__init__(parent=parent) self._track = track config = get_config() self._maximum = config.setting['rating_steps'] - 1 try: self._rating = int(track.metadata['~rating'] or 0) except ValueError: self._rating = 0 self._highlight = 0 self._star_pixmap = QtGui.QPixmap(":/images/star.png") self._star_gray_pixmap = QtGui.QPixmap(":/images/star-gray.png") self._star_size = 16 self._star_spacing = 2 self._offset = 16 self._width = self._maximum * (self._star_size + self._star_spacing) + self._offset self._height = self._star_size + 6 self.setMaximumSize(self._width, self._height) self.setMinimumSize(self._width, self._height) self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed)) self.setMouseTracking(True) def sizeHint(self): return QtCore.QSize(self._width, self._height) def _setHighlight(self, highlight): assert 0 <= highlight <= self._maximum if highlight != self._highlight: self._highlight = highlight self.update() def mousePressEvent(self, event): if event.button() == QtCore.Qt.MouseButton.LeftButton: x = event.pos().x() if x < self._offset: return rating = self._getRatingFromPosition(x) if self._rating == rating: rating = 0 self._rating = rating self._update_track() self.update() event.accept() def mouseMoveEvent(self, event): self._setHighlight(self._getRatingFromPosition(event.pos().x())) event.accept() def leaveEvent(self, event): self._setHighlight(0) event.accept() def _getRatingFromPosition(self, position): rating = int((position - self._offset) / (self._star_size + self._star_spacing)) + 1 if rating > self._maximum: rating = self._maximum return rating def _submitted(self, document, http, error): if error: self.tagger.window.set_statusbar_message( N_("Failed to submit rating for track '%(track_title)s' due to server error %(error)d"), {'track_title': self._track.metadata['title'], 'error': error}, echo=None, ) log.error("Failed to submit rating for %s (server HTTP error %d)", self._track, error) def _update_track(self): track = self._track rating = str(self._rating) track.metadata['~rating'] = rating for file in track.files: file.metadata['~rating'] = rating config = get_config() if config.setting['submit_ratings']: ratings = {('recording', track.id): self._rating} try: self.tagger.mb_api.submit_ratings(ratings, self._submitted) except ValueError: # This should never happen as self._rating is always an integer log.error("Failed to submit rating for recording %s", track.id, exc_info=True) def paintEvent(self, event=None): painter = QtGui.QPainter(self) offset = self._offset for i in range(1, self._maximum + 1): if i <= self._rating or i <= self._highlight: pixmap = self._star_pixmap else: pixmap = self._star_gray_pixmap painter.drawPixmap(offset, 3, pixmap) offset += self._star_size + self._star_spacing
4,855
Python
.py
114
34.473684
121
0.632459
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,003
tristatesortheaderview.py
metabrainz_picard/picard/ui/widgets/tristatesortheaderview.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2020, 2022 Philipp Wolfer # Copyright (C) 2020-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtWidgets, ) from picard.i18n import gettext as _ class TristateSortHeaderView(QtWidgets.QHeaderView): """A QHeaderView implementation supporting tristate sorting. A column can either be sorted ascending, descending or not sorted. The view toggles through these states by clicking on a section header. """ STATE_NONE = 0 STATE_SECTION_MOVED_OR_RESIZED = 1 def __init__(self, orientation, parent=None): super().__init__(orientation, parent=parent) self.prelock_state = None # Remember if resize / move event just happened self._section_moved_or_resized = False self.lock(False) def update_state(i, o, n): self._section_moved_or_resized = True self.sectionResized.connect(update_state) self.sectionMoved.connect(update_state) def mouseReleaseEvent(self, event): if self.is_locked: tooltip = _( "The table is locked. To enable sorting and column resizing\n" "unlock the table in the table header's context menu.") QtWidgets.QToolTip.showText(event.globalPosition().toPoint(), tooltip, self) return if event.button() == QtCore.Qt.MouseButton.LeftButton: index = self.logicalIndexAt(event.pos()) if (index != -1 and index == self.sortIndicatorSection() and self.sortIndicatorOrder() == QtCore.Qt.SortOrder.DescendingOrder): # After a column was sorted descending we want to reset it # to no sorting state. But we need to call the parent # implementation of mouseReleaseEvent in order to handle # other events, such as column move and resize. # Disable clickable sections temporarily so the parent # implementation will not do the normal click behavior. self.setSectionsClickable(False) self._section_moved_or_resized = False super().mouseReleaseEvent(event) self.setSectionsClickable(True) # Only treat this as an actual click if no move # or resize event occurred. if not self._section_moved_or_resized: self.setSortIndicator(-1, self.sortIndicatorOrder()) return # Normal handling of events super().mouseReleaseEvent(event) def lock(self, is_locked): self.is_locked = is_locked if is_locked: self.prelock_state = self.saveState() self.setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Fixed) else: if self.prelock_state is not None: self.restoreState(self.prelock_state) self.prelock_state = None self.setSectionsClickable(not is_locked) self.setSectionsMovable(not is_locked)
3,804
Python
.py
81
38.234568
88
0.666217
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,004
scriptlistwidget.py
metabrainz_picard/picard/ui/widgets/scriptlistwidget.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2023 Philipp Wolfer # Copyright (C) 2020-2024 Laurent Monin # Copyright (C) 2021 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial import threading from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.const.defaults import DEFAULT_SCRIPT_NAME from picard.i18n import ( gettext as _, gettext_constants, ) from picard.script import TaggingScriptSetting from picard.util import unique_numbered_title from picard.ui import HashableListWidgetItem class ScriptListWidget(QtWidgets.QListWidget): signal_reset_selected_item = QtCore.pyqtSignal() def __init__(self, parent=None): super().__init__(parent=parent) self.itemChanged.connect(self.item_changed) self.currentItemChanged.connect(self.current_item_changed) self.old_row = -1 self.bad_row = -1 def contextMenuEvent(self, event): item = self.itemAt(event.x(), event.y()) if item: menu = QtWidgets.QMenu(self) rename_action = QtGui.QAction(_("Rename script"), self) rename_action.triggered.connect(partial(self.editItem, item)) menu.addAction(rename_action) remove_action = QtGui.QAction(_("Remove script"), self) remove_action.triggered.connect(partial(self.remove_script, item)) menu.addAction(remove_action) menu.exec(event.globalPos()) def keyPressEvent(self, event): if event.matches(QtGui.QKeySequence.StandardKey.Delete): self.remove_selected_script() elif event.key() == QtCore.Qt.Key.Key_Insert: self.add_script() else: super().keyPressEvent(event) def unique_script_name(self): existing_titles = [self.item(i).name for i in range(self.count())] return unique_numbered_title(gettext_constants(DEFAULT_SCRIPT_NAME), existing_titles) def add_script(self): numbered_name = self.unique_script_name() list_item = ScriptListWidgetItem(TaggingScriptSetting(name=numbered_name, enabled=True)) list_item.setCheckState(QtCore.Qt.CheckState.Checked) self.addItem(list_item) self.setCurrentItem(list_item, QtCore.QItemSelectionModel.SelectionFlag.Clear | QtCore.QItemSelectionModel.SelectionFlag.SelectCurrent) def remove_selected_script(self): items = self.selectedItems() if items: self.remove_script(items[0]) def remove_script(self, item): row = self.row(item) msg = _("Are you sure you want to remove this script?") reply = QtWidgets.QMessageBox.question(self, _('Confirm Remove'), msg, QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No) if item and reply == QtWidgets.QMessageBox.StandardButton.Yes: item = self.takeItem(row) del item def item_changed(self, item): if not item.name.strip(): # Replace empty script name with unique numbered name. item.setText(self.unique_script_name()) def current_item_changed(self, new_item, old_item): if old_item and old_item.has_error: self.bad_row = self.old_row # Use a new thread to force the reset of the selected item outside of the current_item_changed event. threading.Thread(target=self.signal_reset_selected_item.emit).start() else: self.old_row = self.currentRow() class ScriptListWidgetItem(HashableListWidgetItem): """Holds a script's list and text widget properties""" def __init__(self, script): assert isinstance(script, TaggingScriptSetting) super().__init__(script.name) self.setFlags(self.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEditable) if not script.name: script.name = gettext_constants(DEFAULT_SCRIPT_NAME) self.setText(script.name) self.setCheckState(QtCore.Qt.CheckState.Checked if script.enabled else QtCore.Qt.CheckState.Unchecked) self._script = script self.has_error = False @property def pos(self): return self.listWidget().row(self) @property def name(self): return self.text() @property def enabled(self): return self.checkState() == QtCore.Qt.CheckState.Checked @property def script(self): return self._script def get_script(self): self._script.pos = self.pos self._script.name = self.name self._script.enabled = self.enabled return self._script
5,377
Python
.py
124
36.387097
113
0.690895
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,005
checkbox_list_item.py
metabrainz_picard/picard/ui/widgets/checkbox_list_item.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2018 Sambhav Kothari # Copyright (C) 2018, 2020-2024 Laurent Monin # Copyright (C) 2022, 2024 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtWidgets, ) class CheckboxListItem(QtWidgets.QListWidgetItem): def __init__(self, text='', checked=False, parent=None): super().__init__(text, parent=parent) self.setFlags(self.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable) self.setCheckState(QtCore.Qt.CheckState.Checked if checked else QtCore.Qt.CheckState.Unchecked) @property def checked(self): return self.checkState() == QtCore.Qt.CheckState.Checked
1,405
Python
.py
33
39.818182
103
0.752562
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,006
profilelistwidget.py
metabrainz_picard/picard/ui/widgets/profilelistwidget.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2021 Bob Swift # Copyright (C) 2022-2023 Philipp Wolfer # Copyright (C) 2022-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial import uuid from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.const.defaults import DEFAULT_PROFILE_NAME from picard.i18n import ( gettext as _, gettext_constants, ) from picard.util import unique_numbered_title from picard.ui import HashableListWidgetItem class ProfileListWidget(QtWidgets.QListWidget): def contextMenuEvent(self, event): item = self.itemAt(event.x(), event.y()) if item: menu = QtWidgets.QMenu(self) rename_action = QtGui.QAction(_("Rename profile"), self) rename_action.triggered.connect(partial(self.editItem, item)) menu.addAction(rename_action) remove_action = QtGui.QAction(_("Remove profile"), self) remove_action.triggered.connect(partial(self.remove_profile, item)) menu.addAction(remove_action) menu.exec(event.globalPos()) def keyPressEvent(self, event): if event.matches(QtGui.QKeySequence.StandardKey.Delete): self.remove_selected_profile() elif event.key() == QtCore.Qt.Key.Key_Insert: self.add_profile() else: super().keyPressEvent(event) def unique_profile_name(self, base_name=None): if base_name is None: base_name = gettext_constants(DEFAULT_PROFILE_NAME) existing_titles = [self.item(i).name for i in range(self.count())] return unique_numbered_title(base_name, existing_titles) def add_profile(self, name=None, profile_id=""): if name is None: name = self.unique_profile_name() list_item = ProfileListWidgetItem(name=name, profile_id=profile_id) list_item.setCheckState(QtCore.Qt.CheckState.Checked) self.insertItem(0, list_item) self.setCurrentItem(list_item, QtCore.QItemSelectionModel.SelectionFlag.Clear | QtCore.QItemSelectionModel.SelectionFlag.SelectCurrent) def remove_selected_profile(self): items = self.selectedItems() if items: self.remove_profile(items[0]) def remove_profile(self, item): row = self.row(item) msg = _("Are you sure you want to remove this profile?") reply = QtWidgets.QMessageBox.question(self, _('Confirm Remove'), msg, QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No) if item and reply == QtWidgets.QMessageBox.StandardButton.Yes: item = self.takeItem(row) del item class ProfileListWidgetItem(HashableListWidgetItem): """Holds a profile's list and text widget properties""" def __init__(self, name=None, enabled=True, profile_id=""): super().__init__(name) self.setFlags(self.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEditable) if name is None: name = gettext_constants(DEFAULT_PROFILE_NAME) self.setText(name) self.setCheckState(QtCore.Qt.CheckState.Checked if enabled else QtCore.Qt.CheckState.Unchecked) if not profile_id: profile_id = str(uuid.uuid4()) self.profile_id = profile_id @property def pos(self): return self.listWidget().row(self) @property def name(self): return self.text() @property def enabled(self): return self.checkState() == QtCore.Qt.CheckState.Checked def get_all(self): # tuples used to get pickle dump of settings to work return (self.pos, self.name, self.enabled, self.profile_id) def get_dict(self): return { 'position': self.pos, 'title': self.name, 'enabled': self.enabled, 'id': self.profile_id, }
4,663
Python
.py
110
35.418182
112
0.68248
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,007
taglisteditor.py
metabrainz_picard/picard/ui/widgets/taglisteditor.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2020, 2022 Philipp Wolfer # Copyright (C) 2020-2021, 2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import QtWidgets from picard.util.tags import TAG_NAMES from picard.ui.forms.ui_widget_taglisteditor import Ui_TagListEditor from picard.ui.widgets.editablelistview import ( AutocompleteItemDelegate, EditableListModel, ) class TagListEditor(QtWidgets.QWidget): def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagListEditor() self.ui.setupUi(self) list_view = self.ui.tag_list_view model = EditableListModel() model.user_sortable_changed.connect(self.on_user_sortable_changed) self.ui.sort_buttons.setVisible(model.user_sortable) list_view.setModel(model) list_view.setItemDelegate(AutocompleteItemDelegate( sorted(TAG_NAMES.keys()))) selection = list_view.selectionModel() selection.selectionChanged.connect(self.on_selection_changed) self.on_selection_changed([], []) def on_selection_changed(self, selected, deselected): indexes = self.ui.tag_list_view.selectedIndexes() last_row = self.ui.tag_list_view.model().rowCount() - 1 buttons_enabled = len(indexes) > 0 move_up_enabled = buttons_enabled and all(i.row() != 0 for i in indexes) move_down_enabled = buttons_enabled and all(i.row() != last_row for i in indexes) self.ui.tags_remove_btn.setEnabled(buttons_enabled) self.ui.tags_move_up_btn.setEnabled(move_up_enabled) self.ui.tags_move_down_btn.setEnabled(move_down_enabled) def clear(self): self.ui.tag_list_view.update([]) def update(self, tags): self.ui.tag_list_view.update(tags) @property def tags(self): return self.ui.tag_list_view.items def on_user_sortable_changed(self, user_sortable): self.ui.sort_buttons.setVisible(user_sortable) def set_user_sortable(self, user_sortable): self.ui.tag_list_view.model().user_sortable = user_sortable
2,836
Python
.py
62
40.467742
89
0.71858
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,008
scripttextedit.py
metabrainz_picard/picard/ui/widgets/scripttextedit.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007, 2009 Lukáš Lalinský # Copyright (C) 2014 m42i # Copyright (C) 2020-2024 Philipp Wolfer # Copyright (C) 2020-2024 Laurent Monin # Copyright (C) 2021-2022 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import re import unicodedata from PyQt6 import ( QtCore, QtGui, ) from PyQt6.QtCore import Qt from PyQt6.QtGui import ( QAction, QCursor, QKeySequence, QTextCursor, ) from PyQt6.QtWidgets import ( QCompleter, QTextEdit, QToolTip, ) from picard.config import get_config from picard.const.sys import IS_MACOS from picard.i18n import gettext as _ from picard.script import ( ScriptFunctionDocError, ScriptFunctionDocUnknownFunctionError, script_function_documentation, script_function_names, ) from picard.util.tags import ( PRESERVED_TAGS, TAG_NAMES, display_tag_name, ) from picard.ui import FONT_FAMILY_MONOSPACE from picard.ui.colors import interface_colors EXTRA_VARIABLES = ( '~absolutetracknumber', '~albumartists_sort', '~albumartists', '~artists_sort', '~datatrack', '~discpregap', '~multiartist', '~musicbrainz_discids', '~musicbrainz_tracknumber', '~performance_attributes', '~pregap', '~primaryreleasetype', '~rating', '~recording_firstreleasedate', '~recordingcomment', '~recordingtitle', '~releasecomment', '~releasecountries', '~releasegroup_firstreleasedate', '~releasegroup', '~releasegroupcomment', '~releaselanguage', '~secondaryreleasetype', '~silence', '~totalalbumtracks', '~video', ) def find_regex_index(regex, text, start=0): m = regex.search(text[start:]) if m: return start + m.start() else: return -1 class HighlightRule: def __init__(self, fmtname, regex, start_offset=0, end_offset=0): self.fmtname = fmtname self.regex = re.compile(regex) self.start_offset = start_offset self.end_offset = end_offset class HighlightFormat(QtGui.QTextCharFormat): def __init__(self, fg_color=None, italic=False, bold=False): super().__init__() if fg_color is not None: self.setForeground(interface_colors.get_qcolor(fg_color)) if italic: self.setFontItalic(True) if bold: self.setFontWeight(QtGui.QFont.Weight.Bold) class TaggerScriptSyntaxHighlighter(QtGui.QSyntaxHighlighter): def __init__(self, document): super().__init__(document) self.textcharformats = { 'escape': HighlightFormat(fg_color='syntax_hl_escape'), 'func': HighlightFormat(fg_color='syntax_hl_func', bold=True), 'noop': HighlightFormat(fg_color='syntax_hl_noop', bold=True, italic=True), 'special': HighlightFormat(fg_color='syntax_hl_special'), 'unicode': HighlightFormat(fg_color='syntax_hl_unicode'), 'unknown_func': HighlightFormat(fg_color='syntax_hl_error', italic=True), 'var': HighlightFormat(fg_color='syntax_hl_var'), } self.rules = list(self.func_rules()) self.rules.extend(( HighlightRule('unknown_func', r"\$(?!noop)[_a-zA-Z0-9]*\(", end_offset=-1), HighlightRule('var', r"%[_a-zA-Z0-9:]*%"), HighlightRule('unicode', r"\\u[a-fA-F0-9]{4}"), HighlightRule('escape', r"\\[^u]"), HighlightRule('special', r"(?<!\\)[(),]"), )) def func_rules(self): for func_name in script_function_names(): if func_name != 'noop': pattern = re.escape("$" + func_name + "(") yield HighlightRule('func', pattern, end_offset=-1) def highlightBlock(self, text): self.setCurrentBlockState(0) already_matched = set() for rule in self.rules: for m in rule.regex.finditer(text): index = m.start() + rule.start_offset length = m.end() - m.start() + rule.end_offset if (index, length) not in already_matched: already_matched.add((index, length)) fmt = self.textcharformats[rule.fmtname] self.setFormat(index, length, fmt) noop_re = re.compile(r"\$noop\(") noop_fmt = self.textcharformats['noop'] # Ignore everything if we're already in a noop function index = find_regex_index(noop_re, text) if self.previousBlockState() <= 0 else 0 open_brackets = self.previousBlockState() if self.previousBlockState() > 0 else 0 text_length = len(text) bracket_re = re.compile(r"[()]") while index >= 0: next_index = find_regex_index(bracket_re, text, index) # Skip escaped brackets if next_index > 0 and text[next_index - 1] == '\\': next_index += 1 # Reached end of text? if next_index >= text_length: self.setFormat(index, text_length - index, noop_fmt) break if next_index > -1 and text[next_index] == '(': open_brackets += 1 elif next_index > -1 and text[next_index] == ')': open_brackets -= 1 if next_index > -1: self.setFormat(index, next_index - index + 1, noop_fmt) elif next_index == -1 and open_brackets > 0: self.setFormat(index, text_length - index, noop_fmt) # Check for next noop operation, necessary for multiple noops in one line if open_brackets == 0: next_index = find_regex_index(noop_re, text, next_index) index = next_index + 1 if next_index > -1 and next_index < text_length else -1 self.setCurrentBlockState(open_brackets) class ScriptCompleter(QCompleter): def __init__(self, parent=None): super().__init__(sorted(self.choices), parent) self.setCompletionMode(QCompleter.CompletionMode.UnfilteredPopupCompletion) self.highlighted.connect(self.set_highlighted) self.last_selected = '' @property def choices(self): yield from {'$' + name for name in script_function_names()} yield from {'%' + name.replace('~', '_') + '%' for name in self.all_tags} @property def all_tags(self): yield from TAG_NAMES.keys() yield from PRESERVED_TAGS yield from EXTRA_VARIABLES def set_highlighted(self, text): self.last_selected = text def get_selected(self): return self.last_selected class DocumentedScriptToken: allowed_chars = re.compile('[A-Za-z0-9_]') def __init__(self, doc, cursor_position): self._doc = doc self._cursor_position = cursor_position def is_start_char(self, char): return False def is_allowed_char(self, char, position): return self.allowed_chars.match(char) def get_tooltip(self, position): return None def _read_text(self, position, count): text = '' while count: char = self._doc.characterAt(position) if not char: break text += char count -= 1 position += 1 return text def _read_allowed_chars(self, position): doc = self._doc text = '' while True: char = doc.characterAt(position) if not self.allowed_chars.match(char): break text += char position += 1 return text class FunctionScriptToken(DocumentedScriptToken): def is_start_char(self, char): return char == '$' def get_tooltip(self, position): if self._doc.characterAt(position) != '$': return None function = self._read_allowed_chars(position + 1) try: return script_function_documentation(function, 'html') except ScriptFunctionDocUnknownFunctionError: return _( '<em>Function <code>$%s</code> does not exist.<br>' '<br>' 'Are you missing a plugin?' '</em>') % function except ScriptFunctionDocError: return None class VariableScriptToken(DocumentedScriptToken): allowed_chars = re.compile('[A-Za-z0-9_:]') def is_start_char(self, char): return char == '%' def get_tooltip(self, position): if self._doc.characterAt(position) != '%': return None tag = self._read_allowed_chars(position + 1) return display_tag_name(tag) class UnicodeEscapeScriptToken(DocumentedScriptToken): allowed_chars = re.compile('[uA-Fa-f0-9]') unicode_escape_sequence = re.compile('^\\\\u[a-fA-F0-9]{4}$') def is_start_char(self, char): return char == '\\' def is_allowed_char(self, char, position): return self.allowed_chars.match(char) and self._cursor_position - position < 6 def get_tooltip(self, position): text = self._read_text(position, 6) if self.unicode_escape_sequence.match(text): codepoint = int(text[2:], 16) char = chr(codepoint) try: tooltip = unicodedata.name(char) except ValueError: tooltip = f'U+{text[2:].upper()}' if unicodedata.category(char)[0] != "C": tooltip += f': "{char}"' return tooltip return None def _clean_text(text): return "".join(_replace_control_chars(text)) def _replace_control_chars(text): simple_ctrl_chars = {'\n', '\r', '\t'} for ch in text: if ch not in simple_ctrl_chars and unicodedata.category(ch)[0] == "C": yield '\\u' + hex(ord(ch))[2:].rjust(4, '0') else: yield ch class ScriptTextEdit(QTextEdit): autocomplete_trigger_chars = re.compile('[$%A-Za-z0-9_]') def __init__(self, parent): super().__init__(parent) config = get_config() self.highlighter = TaggerScriptSyntaxHighlighter(self.document()) self.enable_completer() self.setFontFamily(FONT_FAMILY_MONOSPACE) self.setMouseTracking(True) self.setAcceptRichText(False) self.wordwrap_action = QAction(_("&Word wrap script"), self) self.wordwrap_action.setToolTip(_("Word wrap long lines in the editor")) self.wordwrap_action.triggered.connect(self.update_wordwrap) self.wordwrap_action.setShortcut(QKeySequence(_("Ctrl+Shift+W"))) self.wordwrap_action.setCheckable(True) self.wordwrap_action.setChecked(config.persist['script_editor_wordwrap']) self.update_wordwrap() self.addAction(self.wordwrap_action) self._show_tooltips = config.persist['script_editor_tooltips'] self.show_tooltips_action = QAction(_("Show help &tooltips"), self) self.show_tooltips_action.setToolTip(_("Show tooltips for script elements")) self.show_tooltips_action.triggered.connect(self.update_show_tooltips) self.show_tooltips_action.setShortcut(QKeySequence(_("Ctrl+Shift+T"))) self.show_tooltips_action.setCheckable(True) self.show_tooltips_action.setChecked(self._show_tooltips) self.addAction(self.show_tooltips_action) self.textChanged.connect(self.update_tooltip) def contextMenuEvent(self, event): menu = self.createStandardContextMenu() menu.addSeparator() menu.addAction(self.wordwrap_action) menu.addAction(self.show_tooltips_action) menu.exec(event.globalPos()) def mouseMoveEvent(self, event): if self._show_tooltips: tooltip = self.get_tooltip_at_mouse_position(event.pos()) if not tooltip: QToolTip.hideText() self.setToolTip(tooltip) return super().mouseMoveEvent(event) def update_tooltip(self): if self.underMouse() and self.toolTip(): position = self.mapFromGlobal(QCursor.pos()) tooltip = self.get_tooltip_at_mouse_position(position) if tooltip != self.toolTip(): # Hide tooltip if the entity causing this tooltip # was moved away from the mouse position QToolTip.hideText() self.setToolTip(tooltip) def get_tooltip_at_mouse_position(self, position): cursor = self.cursorForPosition(position) return self.get_tooltip_at_cursor(cursor) def get_tooltip_at_cursor(self, cursor): position = cursor.position() doc = self.document() documented_tokens = { FunctionScriptToken(doc, position), VariableScriptToken(doc, position), UnicodeEscapeScriptToken(doc, position) } while position >= 0 and documented_tokens: char = doc.characterAt(position) for token in list(documented_tokens): if token.is_start_char(char): return token.get_tooltip(position) elif not token.is_allowed_char(char, position): documented_tokens.remove(token) position -= 1 return None def insertFromMimeData(self, source): text = _clean_text(source.text()) # Create a new data object, as modifying the existing one does not # work on Windows if copying from outside the Qt app. source = QtCore.QMimeData() source.setText(text) return super().insertFromMimeData(source) def setPlainText(self, text): super().setPlainText(text) self.update_wordwrap() def update_wordwrap(self): """Toggles wordwrap in the script editor """ wordwrap = self.wordwrap_action.isChecked() config = get_config() config.persist['script_editor_wordwrap'] = wordwrap if wordwrap: self.setLineWrapMode(QTextEdit.LineWrapMode.WidgetWidth) else: self.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap) def update_show_tooltips(self): """Toggles wordwrap in the script editor """ self._show_tooltips = self.show_tooltips_action.isChecked() config = get_config() config.persist['script_editor_tooltips'] = self._show_tooltips if not self._show_tooltips: QToolTip.hideText() self.setToolTip('') def enable_completer(self): self.completer = ScriptCompleter() self.completer.setWidget(self) self.completer.activated.connect(self.insert_completion) self.popup_shown = False def insert_completion(self, completion): if not completion: return tc = self.cursor_select_word() if completion.startswith('$'): completion += '(' tc.insertText(completion) # Peek at the next character to include it in the replacement if not tc.atEnd(): pos = tc.position() tc = self.textCursor() tc.setPosition(pos + 1, QTextCursor.MoveMode.KeepAnchor) first_char = completion[0] next_char = tc.selectedText() if (first_char == '$' and next_char == '(') or (first_char == '%' and next_char == '%'): tc.removeSelectedText() else: tc.setPosition(pos) # Reset position self.setTextCursor(tc) self.popup_hide() def popup_hide(self): self.completer.popup().hide() def cursor_select_word(self, full_word=True): tc = self.textCursor() current_position = tc.position() tc.select(QTextCursor.SelectionType.WordUnderCursor) selected_text = tc.selectedText() # Check for start of function or end of variable if current_position > 0 and selected_text and selected_text[0] in {'(', '%'}: current_position -= 1 tc.setPosition(current_position) tc.select(QTextCursor.SelectionType.WordUnderCursor) selected_text = tc.selectedText() start = tc.selectionStart() end = tc.selectionEnd() if current_position < start or current_position > end: # If the cursor is between words WordUnderCursor will select the # previous word. Reset the selection if the new selection is # outside the old cursor position. tc.setPosition(current_position) selected_text = tc.selectedText() if not selected_text.startswith('$') and not selected_text.startswith('%'): # Update selection to include the character before the # selected word to include the $ or %. tc.setPosition(start - 1 if start > 0 else 0) tc.setPosition(end, QTextCursor.MoveMode.KeepAnchor) selected_text = tc.selectedText() # No match, reset position (otherwise we could replace an additional character) if not selected_text.startswith('$') and not selected_text.startswith('%'): tc.setPosition(start) tc.setPosition(end, QTextCursor.MoveMode.KeepAnchor) if not full_word: tc.setPosition(current_position, QTextCursor.MoveMode.KeepAnchor) return tc def keyPressEvent(self, event): if self.completer.popup().isVisible(): if event.key() in {Qt.Key.Key_Tab, Qt.Key.Key_Return, Qt.Key.Key_Enter}: self.completer.activated.emit(self.completer.get_selected()) return super().keyPressEvent(event) self.handle_autocomplete(event) def handle_autocomplete(self, event): # Only trigger autocomplete on actual text input or if the user explicitly # requested auto completion with Ctrl+Space (Control+Space on macOS) modifier = QtCore.Qt.KeyboardModifier.MetaModifier if IS_MACOS else QtCore.Qt.KeyboardModifier.ControlModifier force_completion_popup = event.key() == QtCore.Qt.Key.Key_Space and event.modifiers() & modifier if not (force_completion_popup or event.key() in {Qt.Key.Key_Backspace, Qt.Key.Key_Delete} or self.autocomplete_trigger_chars.match(event.text())): self.popup_hide() return tc = self.cursor_select_word(full_word=False) selected_text = tc.selectedText() if force_completion_popup or (selected_text and selected_text[0] in {'$', '%'}): self.completer.setCompletionPrefix(selected_text) popup = self.completer.popup() popup.setCurrentIndex(self.completer.currentIndex()) cr = self.cursorRect() cr.setWidth( popup.sizeHintForColumn(0) + popup.verticalScrollBar().sizeHint().width() ) self.completer.complete(cr) else: self.popup_hide()
19,629
Python
.py
464
33.170259
118
0.625636
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,009
__init__.py
metabrainz_picard/picard/ui/widgets/__init__.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2019-2020, 2022-2023 Philipp Wolfer # Copyright (C) 2020-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) class ElidedLabel(QtWidgets.QLabel): """A QLabel that elides the displayed text with ellipsis when resized.""" def __init__(self, parent=None): self._full_label = "" super().__init__(parent=parent) def setText(self, text): self._full_label = text self._update_text() def resizeEvent(self, event): self._update_text() def _update_text(self): metrics = QtGui.QFontMetrics(self.font()) # Elide the text. On some setups, e.g. using the Breeze theme, the # text does not properly fit into width(), as a workaround subtract # 2 pixels from the available width. elided_label = metrics.elidedText(self._full_label, QtCore.Qt.TextElideMode.ElideRight, self.width() - 2) super().setText(elided_label) if self._full_label and elided_label != self._full_label: self.setToolTip(self._full_label) else: self.setToolTip("") class ActiveLabel(QtWidgets.QLabel): """Clickable QLabel.""" clicked = QtCore.pyqtSignal() def __init__(self, active=True, parent=None): super().__init__(parent=parent) self.setActive(active) def setActive(self, active): self.active = active if self.active: self.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor)) else: self.setCursor(QtGui.QCursor()) def mouseReleaseEvent(self, event): if self.active and event.button() == QtCore.Qt.MouseButton.LeftButton: self.clicked.emit() class ClickableSlider(QtWidgets.QSlider): """A slider implementation where the user can select any slider position by clicking.""" def mousePressEvent(self, event): self._set_position_from_mouse_event(event) def mouseMoveEvent(self, event): self._set_position_from_mouse_event(event) def _set_position_from_mouse_event(self, event): value = QtWidgets.QStyle.sliderValueFromPosition( self.minimum(), self.maximum(), event.pos().x(), self.width()) self.setValue(value) class Popover(QtWidgets.QFrame): """A generic popover implementation. The popover opens relative to its parent, either above or below the parent. Subclass this widget and add child widgets for a custom popover. """ def __init__(self, position='bottom', parent=None): super().__init__(parent=parent) self.setWindowFlags(QtCore.Qt.WindowType.Popup | QtCore.Qt.WindowType.FramelessWindowHint) self.position = position app = QtCore.QCoreApplication.instance() self._is_wayland = app.is_wayland self._main_window = app.window def show(self): super().show() # show so that the geometry gets known self.update_position() # on Wayland position updates only work if widget gets shown if self._is_wayland: super().hide() super().show() def update_position(self): parent = self.parent() x = -(self.width() - parent.width()) / 2 if self.position == 'top': y = -self.height() else: # bottom y = parent.height() pos = QtCore.QPoint(int(x), int(y)) pos = parent.mapToGlobal(pos) if not self._is_wayland: # Attempt to keep the popover fully visible on screen. min_pos = QtCore.QPoint(0, 0) screen = self._main_window.screen() screen_size = screen.size() else: # The full screen size is not known on Wayland, but we can ensure # the popover stays inside the app window boundary. min_pos = self._main_window.pos() window_size = self._main_window.size() screen_size = QtCore.QSize( min_pos.x() + window_size.width(), min_pos.y() + window_size.height(), ) if pos.x() < min_pos.x(): pos.setX(min_pos.x()) if pos.x() + self.width() > screen_size.width(): pos.setX(screen_size.width() - self.width()) if pos.y() < min_pos.y(): pos.setY(min_pos.y()) if pos.y() + self.height() > screen_size.height(): pos.setY(screen_size.height() - self.height()) self.move(pos) class SliderPopover(Popover): """A popover containing a single slider.""" value_changed = QtCore.pyqtSignal(int) def __init__(self, parent, position, label, value): super().__init__(position=position, parent=parent) vbox = QtWidgets.QVBoxLayout(self) self.label = QtWidgets.QLabel(label, self) self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) vbox.addWidget(self.label) self.slider = ClickableSlider(parent=self) self.slider.setOrientation(QtCore.Qt.Orientation.Horizontal) self.slider.setValue(int(value)) self.slider.valueChanged.connect(self.value_changed) vbox.addWidget(self.slider)
6,065
Python
.py
139
35.489209
98
0.641778
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,010
editablelistview.py
metabrainz_picard/picard/ui/widgets/editablelistview.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2022 Philipp Wolfer # Copyright (C) 2020-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) class EditableListView(QtWidgets.QListView): def __init__(self, parent=None): super().__init__(parent=parent) self.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) def keyPressEvent(self, event): if event.matches(QtGui.QKeySequence.StandardKey.Delete): self.remove_selected_rows() elif event.key() == QtCore.Qt.Key.Key_Insert: self.add_empty_row() else: super().keyPressEvent(event) def mouseDoubleClickEvent(self, event): pos = event.pos() index = self.indexAt(QtCore.QPoint(pos.x(), pos.y())) if index.isValid(): super().mouseDoubleClickEvent(event) else: self.add_empty_row() def closeEditor(self, editor, hint): model = self.model() index = self.currentIndex() if not editor.text(): row = index.row() model.removeRow(row) self.select_row(row) editor.parent().setFocus() else: super().closeEditor(editor, hint) if not model.user_sortable: data = index.data(QtCore.Qt.ItemDataRole.EditRole) model.sort(0) self.select_key(data) def add_item(self, value=""): model = self.model() row = model.rowCount() model.insertRow(row) index = model.createIndex(row, 0) model.setData(index, value) return index def clear(self): self.model().update([]) def update(self, values): self.model().update(values) @property def items(self): return self.model().items def add_empty_row(self): # Setting the focus causes any open editor to getting closed self.setFocus(QtCore.Qt.FocusReason.OtherFocusReason) index = self.add_item() self.setCurrentIndex(index) self.edit(index) def remove_selected_rows(self): rows = self.get_selected_rows() if not rows: return model = self.model() for row in sorted(rows, reverse=True): model.removeRow(row) first_selected_row = rows[0] self.select_row(first_selected_row) def move_selected_rows_up(self): rows = self.get_selected_rows() if not rows: return first_selected_row = min(rows) if first_selected_row > 0: self._move_rows_relative(rows, -1) def move_selected_rows_down(self): rows = self.get_selected_rows() if not rows: return last_selected_row = max(rows) if last_selected_row < self.model().rowCount() - 1: self._move_rows_relative(rows, 1) def select_row(self, row): index = self.model().index(row, 0) self.setCurrentIndex(index) def select_key(self, value): model = self.model() for row in range(0, model.rowCount()): index = model.createIndex(row, 0) if value == index.data(QtCore.Qt.ItemDataRole.EditRole): self.setCurrentIndex(index) break def get_selected_rows(self): return [index.row() for index in self.selectedIndexes()] def _move_rows_relative(self, rows, direction): model = self.model() current_index = self.currentIndex() selection = self.selectionModel() for row in sorted(rows, reverse=direction > 0): new_index = model.index(row + direction, 0) model.move_row(row, new_index.row()) selection.select(new_index, QtCore.QItemSelectionModel.SelectionFlag.Select) if row == current_index.row(): selection.setCurrentIndex(new_index, QtCore.QItemSelectionModel.SelectionFlag.Current) class UniqueEditableListView(EditableListView): def __init__(self, parent=None): super().__init__(parent) self._is_drag_drop = False def setModel(self, model): current_model = self.model() if current_model: current_model.dataChanged.disconnect(self.on_data_changed) super().setModel(model) model.dataChanged.connect(self.on_data_changed) def dropEvent(self, event): self._is_drag_drop = True super().dropEvent(event) self._is_drag_drop = False def on_data_changed(self, top_left, bottom_right, roles): # Do not drop duplicates during drag and drop as there is always # a duplicate in the list for a short time in this case. if self._is_drag_drop: return model = self.model() if QtCore.Qt.ItemDataRole.EditRole in roles: value = model.data(top_left, QtCore.Qt.ItemDataRole.EditRole) if not value: return # Remove duplicate entries from the model changed_row = top_left.row() row = 0 for item in model.items: if item == value and row != changed_row: model.removeRow(row) row -= 1 if changed_row > row: changed_row -= 1 row += 1 self.select_row(changed_row) class EditableListModel(QtCore.QAbstractListModel): user_sortable_changed = QtCore.pyqtSignal(bool) def __init__(self, items=None, parent=None): super().__init__(parent) self._items = [(item, self.get_display_name(item)) for item in items or []] self._user_sortable = True @property def user_sortable(self): return self._user_sortable @user_sortable.setter def user_sortable(self, user_sortable): self._user_sortable = user_sortable if not user_sortable: self.sort(0) self.user_sortable_changed.emit(user_sortable) def sort(self, column, order=QtCore.Qt.SortOrder.AscendingOrder): self.beginResetModel() self._items.sort(key=lambda t: t[1], reverse=(order == QtCore.Qt.SortOrder.DescendingOrder)) self.endResetModel() def get_display_name(self, item): # pylint: disable=no-self-use return item def rowCount(self, parent=QtCore.QModelIndex()): return len(self._items) def data(self, index, role=QtCore.Qt.ItemDataRole.DisplayRole): if not index.isValid() or role not in {QtCore.Qt.ItemDataRole.DisplayRole, QtCore.Qt.ItemDataRole.EditRole}: return None field = 1 if role == QtCore.Qt.ItemDataRole.DisplayRole else 0 try: return self._items[index.row()][field] except IndexError: return None def setData(self, index, value, role=QtCore.Qt.ItemDataRole.EditRole): if not index.isValid() or role not in {QtCore.Qt.ItemDataRole.DisplayRole, QtCore.Qt.ItemDataRole.EditRole}: return False i = index.row() try: if role == QtCore.Qt.ItemDataRole.EditRole: display_name = self.get_display_name(value) if value else value self._items[i] = (value, display_name) elif role == QtCore.Qt.ItemDataRole.DisplayRole: current = self._items[i] self._items[i] = (current[0], value) self.dataChanged.emit(index, index, [role]) return True except IndexError: return False def flags(self, index): if index.isValid(): flags = (QtCore.Qt.ItemFlag.ItemIsSelectable | QtCore.Qt.ItemFlag.ItemIsEditable | QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemNeverHasChildren) if self.user_sortable: flags |= QtCore.Qt.ItemFlag.ItemIsDragEnabled return flags elif self.user_sortable: return QtCore.Qt.ItemFlag.ItemIsDropEnabled else: return QtCore.Qt.ItemFlag.NoItemFlags def insertRows(self, row, count, parent=QtCore.QModelIndex()): super().beginInsertRows(parent, row, row + count - 1) for i in range(count): self._items.insert(row, ("", "")) super().endInsertRows() return True def removeRows(self, row, count, parent=QtCore.QModelIndex()): super().beginRemoveRows(parent, row, row + count - 1) self._items = self._items[:row] + self._items[row + count:] super().endRemoveRows() return True @staticmethod def supportedDragActions(): return QtCore.Qt.DropAction.MoveAction @staticmethod def supportedDropActions(): return QtCore.Qt.DropAction.MoveAction def update(self, items): self.beginResetModel() self._items = [(item, self.get_display_name(item)) for item in items] self.endResetModel() def move_row(self, row, new_row): item = self._items[row] self.removeRow(row) self.insertRow(new_row) index = self.index(new_row, 0) self.setData(index, item[0], QtCore.Qt.ItemDataRole.EditRole) self.setData(index, item[1], QtCore.Qt.ItemDataRole.DisplayRole) @property def items(self): return (t[0] for t in self._items) class AutocompleteItemDelegate(QtWidgets.QItemDelegate): def __init__(self, completions, parent=None): super().__init__(parent=parent) self._completions = completions def createEditor(self, parent, option, index): if not index.isValid(): return None def complete(text): parent.setFocus() editor = super().createEditor(parent, option, index) completer = QtWidgets.QCompleter(self._completions, parent) completer.setCompletionMode(QtWidgets.QCompleter.CompletionMode.UnfilteredPopupCompletion) completer.setCaseSensitivity(QtCore.Qt.CaseSensitivity.CaseInsensitive) completer.activated.connect(complete) editor.setCompleter(completer) return editor
10,982
Python
.py
264
32.465909
116
0.633399
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,011
scriptdocumentation.py
metabrainz_picard/picard/ui/widgets/scriptdocumentation.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2021 Bob Swift # Copyright (C) 2021-2022 Philipp Wolfer # Copyright (C) 2021-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtWidgets, ) from picard.const import PICARD_URLS from picard.i18n import gettext as _ from picard.script import script_function_documentation_all from picard.ui import FONT_FAMILY_MONOSPACE from picard.ui.colors import interface_colors DOCUMENTATION_HTML_TEMPLATE = ''' <!DOCTYPE html> <html> <head> <style> dt { color: %(script_function_fg)s } dd { /* Qt does not support margin-inline-start, use margin-left/margin-right instead */ margin-%(inline_start)s: 50px; margin-bottom: 50px; } code { font-family: %(monospace_font)s; } </style> </head> <body dir="%(dir)s"> %(html)s </body> </html> ''' class ScriptingDocumentationWidget(QtWidgets.QWidget): """Custom widget to display the scripting documentation. """ def __init__(self, include_link=True, parent=None): """Custom widget to display the scripting documentation. Args: include_link (bool): Indicates whether the web link should be included parent (QWidget): Parent screen to check layoutDirection() """ super().__init__(parent=parent) if self.layoutDirection() == QtCore.Qt.LayoutDirection.RightToLeft: text_direction = 'rtl' else: text_direction = 'ltr' def process_html(html, function): if not html: html = '' template = '<dt>%s%s</dt><dd>%s</dd>' if function.module is not None and function.module != 'picard.script.functions': module = ' [' + function.module + ']' else: module = '' try: firstline, remaining = html.split("\n", 1) return template % (firstline, module, remaining) except ValueError: return template % ("<code>$%s()</code>" % function.name, module, html) funcdoc = script_function_documentation_all( fmt='html', postprocessor=process_html, ) html = DOCUMENTATION_HTML_TEMPLATE % { 'html': "<dl>%s</dl>" % funcdoc, 'script_function_fg': interface_colors.get_qcolor('syntax_hl_func').name(), 'monospace_font': FONT_FAMILY_MONOSPACE, 'dir': text_direction, 'inline_start': 'right' if text_direction == 'rtl' else 'left' } # Scripting code is always left-to-right. Qt does not support the dir # attribute on inline tags, insert explicit left-right-marks instead. if text_direction == 'rtl': html = html.replace('<code>', '<code>&#8206;') link = '<a href="' + PICARD_URLS['doc_scripting'] + '">' + _('Open Scripting Documentation in your browser') + '</a>' self.verticalLayout = QtWidgets.QVBoxLayout(self) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName('docs_verticalLayout') self.textBrowser = QtWidgets.QTextBrowser(self) self.textBrowser.setEnabled(True) self.textBrowser.setMinimumSize(QtCore.QSize(0, 0)) self.textBrowser.setObjectName('docs_textBrowser') self.textBrowser.setHtml(html) self.textBrowser.show() self.verticalLayout.addWidget(self.textBrowser) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout.setObjectName('docs_horizontalLayout') self.scripting_doc_link = QtWidgets.QLabel(self) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scripting_doc_link.sizePolicy().hasHeightForWidth()) if include_link: self.scripting_doc_link.setSizePolicy(sizePolicy) self.scripting_doc_link.setMinimumSize(QtCore.QSize(0, 20)) self.scripting_doc_link.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.scripting_doc_link.setWordWrap(True) self.scripting_doc_link.setOpenExternalLinks(True) self.scripting_doc_link.setObjectName('docs_scripting_doc_link') self.scripting_doc_link.setText(link) self.scripting_doc_link.show() self.horizontalLayout.addWidget(self.scripting_doc_link) self.verticalLayout.addLayout(self.horizontalLayout)
5,382
Python
.py
125
35.984
125
0.672835
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,012
ui_infodialog.py
metabrainz_picard/picard/ui/forms/ui_infodialog.py
# Form implementation generated from reading ui file 'ui/infodialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InfoDialog(object): def setupUi(self, InfoDialog): InfoDialog.setObjectName("InfoDialog") InfoDialog.resize(665, 436) self.verticalLayout = QtWidgets.QVBoxLayout(InfoDialog) self.verticalLayout.setObjectName("verticalLayout") self.tabWidget = QtWidgets.QTabWidget(parent=InfoDialog) self.tabWidget.setObjectName("tabWidget") self.info_tab = QtWidgets.QWidget() self.info_tab.setObjectName("info_tab") self.vboxlayout = QtWidgets.QVBoxLayout(self.info_tab) self.vboxlayout.setObjectName("vboxlayout") self.info_scroll = QtWidgets.QScrollArea(parent=self.info_tab) self.info_scroll.setWidgetResizable(True) self.info_scroll.setObjectName("info_scroll") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setEnabled(True) self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 623, 361)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayoutLabel = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayoutLabel.setObjectName("verticalLayoutLabel") self.info = QtWidgets.QLabel(parent=self.scrollAreaWidgetContents) self.info.setText("") self.info.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.info.setWordWrap(True) self.info.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByKeyboard|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse) self.info.setObjectName("info") self.verticalLayoutLabel.addWidget(self.info) self.info_scroll.setWidget(self.scrollAreaWidgetContents) self.vboxlayout.addWidget(self.info_scroll) self.tabWidget.addTab(self.info_tab, "") self.error_tab = QtWidgets.QWidget() self.error_tab.setObjectName("error_tab") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.error_tab) self.vboxlayout1.setObjectName("vboxlayout1") self.scrollArea = QtWidgets.QScrollArea(parent=self.error_tab) self.scrollArea.setWidgetResizable(True) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents_3 = QtWidgets.QWidget() self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 623, 361)) self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_3) self.verticalLayout_2.setObjectName("verticalLayout_2") self.error = QtWidgets.QLabel(parent=self.scrollAreaWidgetContents_3) self.error.setText("") self.error.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.error.setWordWrap(True) self.error.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByKeyboard|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse) self.error.setObjectName("error") self.verticalLayout_2.addWidget(self.error) self.scrollArea.setWidget(self.scrollAreaWidgetContents_3) self.vboxlayout1.addWidget(self.scrollArea) self.tabWidget.addTab(self.error_tab, "") self.artwork_tab = QtWidgets.QWidget() self.artwork_tab.setObjectName("artwork_tab") self.vboxlayout2 = QtWidgets.QVBoxLayout(self.artwork_tab) self.vboxlayout2.setObjectName("vboxlayout2") self.tabWidget.addTab(self.artwork_tab, "") self.verticalLayout.addWidget(self.tabWidget) self.buttonBox = QtWidgets.QDialogButtonBox(parent=InfoDialog) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.NoButton) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(InfoDialog) self.tabWidget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(InfoDialog) InfoDialog.setTabOrder(self.tabWidget, self.buttonBox) def retranslateUi(self, InfoDialog): self.tabWidget.setTabText(self.tabWidget.indexOf(self.info_tab), _("&Info")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.error_tab), _("&Error")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.artwork_tab), _("A&rtwork"))
4,871
Python
.py
83
50.819277
203
0.751568
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,013
ui_options_interface_toolbar.py
metabrainz_picard/picard/ui/forms/ui_options_interface_toolbar.py
# Form implementation generated from reading ui file 'ui/options_interface_toolbar.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InterfaceToolbarOptionsPage(object): def setupUi(self, InterfaceToolbarOptionsPage): InterfaceToolbarOptionsPage.setObjectName("InterfaceToolbarOptionsPage") InterfaceToolbarOptionsPage.resize(466, 317) self.vboxlayout = QtWidgets.QVBoxLayout(InterfaceToolbarOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.customize_toolbar_box = QtWidgets.QGroupBox(parent=InterfaceToolbarOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.customize_toolbar_box.sizePolicy().hasHeightForWidth()) self.customize_toolbar_box.setSizePolicy(sizePolicy) self.customize_toolbar_box.setObjectName("customize_toolbar_box") self.verticalLayout = QtWidgets.QVBoxLayout(self.customize_toolbar_box) self.verticalLayout.setObjectName("verticalLayout") self.toolbar_layout_list = QtWidgets.QListWidget(parent=self.customize_toolbar_box) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.toolbar_layout_list.sizePolicy().hasHeightForWidth()) self.toolbar_layout_list.setSizePolicy(sizePolicy) self.toolbar_layout_list.setObjectName("toolbar_layout_list") self.verticalLayout.addWidget(self.toolbar_layout_list) self.edit_button_box = QtWidgets.QWidget(parent=self.customize_toolbar_box) self.edit_button_box.setObjectName("edit_button_box") self.edit_box_layout = QtWidgets.QHBoxLayout(self.edit_button_box) self.edit_box_layout.setContentsMargins(0, 0, 0, 0) self.edit_box_layout.setObjectName("edit_box_layout") self.add_button = QtWidgets.QToolButton(parent=self.edit_button_box) self.add_button.setObjectName("add_button") self.edit_box_layout.addWidget(self.add_button) self.insert_separator_button = QtWidgets.QToolButton(parent=self.edit_button_box) self.insert_separator_button.setObjectName("insert_separator_button") self.edit_box_layout.addWidget(self.insert_separator_button) spacerItem = QtWidgets.QSpacerItem(50, 20, QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Minimum) self.edit_box_layout.addItem(spacerItem) self.up_button = QtWidgets.QToolButton(parent=self.edit_button_box) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.up_button.setIcon(icon) self.up_button.setObjectName("up_button") self.edit_box_layout.addWidget(self.up_button) self.down_button = QtWidgets.QToolButton(parent=self.edit_button_box) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.down_button.setIcon(icon) self.down_button.setObjectName("down_button") self.edit_box_layout.addWidget(self.down_button) self.remove_button = QtWidgets.QToolButton(parent=self.edit_button_box) self.remove_button.setObjectName("remove_button") self.edit_box_layout.addWidget(self.remove_button) self.verticalLayout.addWidget(self.edit_button_box) self.vboxlayout.addWidget(self.customize_toolbar_box) self.retranslateUi(InterfaceToolbarOptionsPage) QtCore.QMetaObject.connectSlotsByName(InterfaceToolbarOptionsPage) InterfaceToolbarOptionsPage.setTabOrder(self.toolbar_layout_list, self.add_button) InterfaceToolbarOptionsPage.setTabOrder(self.add_button, self.insert_separator_button) InterfaceToolbarOptionsPage.setTabOrder(self.insert_separator_button, self.up_button) InterfaceToolbarOptionsPage.setTabOrder(self.up_button, self.down_button) InterfaceToolbarOptionsPage.setTabOrder(self.down_button, self.remove_button) def retranslateUi(self, InterfaceToolbarOptionsPage): self.customize_toolbar_box.setTitle(_("Customize Action Toolbar")) self.add_button.setToolTip(_("Add a new button to Toolbar")) self.add_button.setText(_("Add Action")) self.insert_separator_button.setToolTip(_("Insert a separator")) self.insert_separator_button.setText(_("Add Separator")) self.up_button.setToolTip(_("Move selected item up")) self.down_button.setToolTip(_("Move selected item down")) self.remove_button.setToolTip(_("Remove button from toolbar")) self.remove_button.setText(_("Remove"))
5,017
Python
.py
80
54.8875
135
0.749747
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,014
ui_options_tags_compatibility_wave.py
metabrainz_picard/picard/ui/forms/ui_options_tags_compatibility_wave.py
# Form implementation generated from reading ui file 'ui/options_tags_compatibility_wave.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsCompatibilityOptionsPage(object): def setupUi(self, TagsCompatibilityOptionsPage): TagsCompatibilityOptionsPage.setObjectName("TagsCompatibilityOptionsPage") TagsCompatibilityOptionsPage.resize(539, 705) self.vboxlayout = QtWidgets.QVBoxLayout(TagsCompatibilityOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.wave_files = QtWidgets.QGroupBox(parent=TagsCompatibilityOptionsPage) self.wave_files.setObjectName("wave_files") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.wave_files) self.verticalLayout_3.setObjectName("verticalLayout_3") self.label = QtWidgets.QLabel(parent=self.wave_files) self.label.setWordWrap(True) self.label.setObjectName("label") self.verticalLayout_3.addWidget(self.label) spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.verticalLayout_3.addItem(spacerItem) self.write_wave_riff_info = QtWidgets.QCheckBox(parent=self.wave_files) self.write_wave_riff_info.setObjectName("write_wave_riff_info") self.verticalLayout_3.addWidget(self.write_wave_riff_info) self.remove_wave_riff_info = QtWidgets.QCheckBox(parent=self.wave_files) self.remove_wave_riff_info.setObjectName("remove_wave_riff_info") self.verticalLayout_3.addWidget(self.remove_wave_riff_info) self.wave_riff_info_encoding = QtWidgets.QGroupBox(parent=self.wave_files) self.wave_riff_info_encoding.setObjectName("wave_riff_info_encoding") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.wave_riff_info_encoding) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.wave_riff_info_enc_cp1252 = QtWidgets.QRadioButton(parent=self.wave_riff_info_encoding) self.wave_riff_info_enc_cp1252.setChecked(True) self.wave_riff_info_enc_cp1252.setObjectName("wave_riff_info_enc_cp1252") self.horizontalLayout_3.addWidget(self.wave_riff_info_enc_cp1252) self.wave_riff_info_enc_utf8 = QtWidgets.QRadioButton(parent=self.wave_riff_info_encoding) self.wave_riff_info_enc_utf8.setObjectName("wave_riff_info_enc_utf8") self.horizontalLayout_3.addWidget(self.wave_riff_info_enc_utf8) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(spacerItem1) self.verticalLayout_3.addWidget(self.wave_riff_info_encoding) self.vboxlayout.addWidget(self.wave_files) spacerItem2 = QtWidgets.QSpacerItem(274, 41, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem2) self.retranslateUi(TagsCompatibilityOptionsPage) self.write_wave_riff_info.toggled['bool'].connect(self.remove_wave_riff_info.setDisabled) # type: ignore QtCore.QMetaObject.connectSlotsByName(TagsCompatibilityOptionsPage) def retranslateUi(self, TagsCompatibilityOptionsPage): self.wave_files.setTitle(_("WAVE files")) self.label.setText(_("Picard will tag WAVE files using ID3v2 tags. This is not supported by all software. For compatibility with software which does not support ID3v2 tags in WAVE files additional RIFF INFO tags can be written to the files. RIFF INFO has only limited support for tags and character encodings.")) self.write_wave_riff_info.setText(_("Also include RIFF INFO tags in the files")) self.remove_wave_riff_info.setText(_("Remove existing RIFF INFO tags from WAVE files")) self.wave_riff_info_encoding.setTitle(_("RIFF INFO text encoding")) self.wave_riff_info_enc_cp1252.setText(_("Windows-1252")) self.wave_riff_info_enc_utf8.setText(_("UTF-8"))
4,196
Python
.py
62
60.193548
320
0.750727
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,015
ui_options_maintenance.py
metabrainz_picard/picard/ui/forms/ui_options_maintenance.py
# Form implementation generated from reading ui file 'ui/options_maintenance.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_MaintenanceOptionsPage(object): def setupUi(self, MaintenanceOptionsPage): MaintenanceOptionsPage.setObjectName("MaintenanceOptionsPage") MaintenanceOptionsPage.resize(334, 397) self.vboxlayout = QtWidgets.QVBoxLayout(MaintenanceOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.label = QtWidgets.QLabel(parent=MaintenanceOptionsPage) self.label.setObjectName("label") self.vboxlayout.addWidget(self.label) self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.config_file = QtWidgets.QLineEdit(parent=MaintenanceOptionsPage) self.config_file.setReadOnly(True) self.config_file.setObjectName("config_file") self.horizontalLayout_3.addWidget(self.config_file) self.open_folder_button = QtWidgets.QToolButton(parent=MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.open_folder_button.sizePolicy().hasHeightForWidth()) self.open_folder_button.setSizePolicy(sizePolicy) self.open_folder_button.setObjectName("open_folder_button") self.horizontalLayout_3.addWidget(self.open_folder_button) self.vboxlayout.addLayout(self.horizontalLayout_3) self.label_2 = QtWidgets.QLabel(parent=MaintenanceOptionsPage) self.label_2.setObjectName("label_2") self.vboxlayout.addWidget(self.label_2) self.horizontalLayout_6 = QtWidgets.QHBoxLayout() self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.autobackup_dir = QtWidgets.QLineEdit(parent=MaintenanceOptionsPage) self.autobackup_dir.setObjectName("autobackup_dir") self.horizontalLayout_6.addWidget(self.autobackup_dir) self.browse_autobackup_dir = QtWidgets.QToolButton(parent=MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.browse_autobackup_dir.sizePolicy().hasHeightForWidth()) self.browse_autobackup_dir.setSizePolicy(sizePolicy) self.browse_autobackup_dir.setObjectName("browse_autobackup_dir") self.horizontalLayout_6.addWidget(self.browse_autobackup_dir) self.vboxlayout.addLayout(self.horizontalLayout_6) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.load_backup_button = QtWidgets.QToolButton(parent=MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.load_backup_button.sizePolicy().hasHeightForWidth()) self.load_backup_button.setSizePolicy(sizePolicy) self.load_backup_button.setObjectName("load_backup_button") self.horizontalLayout.addWidget(self.load_backup_button) self.save_backup_button = QtWidgets.QToolButton(parent=MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.save_backup_button.sizePolicy().hasHeightForWidth()) self.save_backup_button.setSizePolicy(sizePolicy) self.save_backup_button.setObjectName("save_backup_button") self.horizontalLayout.addWidget(self.save_backup_button) self.vboxlayout.addLayout(self.horizontalLayout) self.line_2 = QtWidgets.QFrame(parent=MaintenanceOptionsPage) self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine) self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) self.line_2.setObjectName("line_2") self.vboxlayout.addWidget(self.line_2) self.option_counts = QtWidgets.QLabel(parent=MaintenanceOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.option_counts.sizePolicy().hasHeightForWidth()) self.option_counts.setSizePolicy(sizePolicy) self.option_counts.setText("") self.option_counts.setObjectName("option_counts") self.vboxlayout.addWidget(self.option_counts) self.description = QtWidgets.QLabel(parent=MaintenanceOptionsPage) self.description.setText("") self.description.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.description.setWordWrap(True) self.description.setIndent(0) self.description.setObjectName("description") self.vboxlayout.addWidget(self.description) spacerItem1 = QtWidgets.QSpacerItem(20, 8, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.vboxlayout.addItem(spacerItem1) self.line = QtWidgets.QFrame(parent=MaintenanceOptionsPage) self.line.setFrameShape(QtWidgets.QFrame.Shape.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) self.line.setObjectName("line") self.vboxlayout.addWidget(self.line) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.select_all = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage) self.select_all.setObjectName("select_all") self.horizontalLayout_2.addWidget(self.select_all) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(spacerItem2) self.enable_cleanup = QtWidgets.QCheckBox(parent=MaintenanceOptionsPage) self.enable_cleanup.setObjectName("enable_cleanup") self.horizontalLayout_2.addWidget(self.enable_cleanup) self.vboxlayout.addLayout(self.horizontalLayout_2) self.tableWidget = QtWidgets.QTableWidget(parent=MaintenanceOptionsPage) self.tableWidget.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.SizeAdjustPolicy.AdjustToContents) self.tableWidget.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) self.tableWidget.setColumnCount(2) self.tableWidget.setObjectName("tableWidget") self.tableWidget.setRowCount(0) self.tableWidget.horizontalHeader().setStretchLastSection(True) self.tableWidget.verticalHeader().setVisible(False) self.vboxlayout.addWidget(self.tableWidget) self.retranslateUi(MaintenanceOptionsPage) QtCore.QMetaObject.connectSlotsByName(MaintenanceOptionsPage) MaintenanceOptionsPage.setTabOrder(self.config_file, self.open_folder_button) MaintenanceOptionsPage.setTabOrder(self.open_folder_button, self.autobackup_dir) MaintenanceOptionsPage.setTabOrder(self.autobackup_dir, self.browse_autobackup_dir) MaintenanceOptionsPage.setTabOrder(self.browse_autobackup_dir, self.load_backup_button) MaintenanceOptionsPage.setTabOrder(self.load_backup_button, self.save_backup_button) MaintenanceOptionsPage.setTabOrder(self.save_backup_button, self.select_all) MaintenanceOptionsPage.setTabOrder(self.select_all, self.enable_cleanup) MaintenanceOptionsPage.setTabOrder(self.enable_cleanup, self.tableWidget) def retranslateUi(self, MaintenanceOptionsPage): self.label.setText(_("Configuration file:")) self.open_folder_button.setText(_("Open folder…")) self.label_2.setText(_("Automatic configuration backups directory:")) self.browse_autobackup_dir.setText(_("Browse…")) self.load_backup_button.setText(_("Load backup…")) self.save_backup_button.setText(_("Save backup…")) self.select_all.setText(_("Select all")) self.enable_cleanup.setText(_("Remove selected options"))
9,149
Python
.py
144
55.131944
142
0.757647
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,016
ui_options_fingerprinting.py
metabrainz_picard/picard/ui/forms/ui_options_fingerprinting.py
# Form implementation generated from reading ui file 'ui/options_fingerprinting.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_FingerprintingOptionsPage(object): def setupUi(self, FingerprintingOptionsPage): FingerprintingOptionsPage.setObjectName("FingerprintingOptionsPage") FingerprintingOptionsPage.resize(371, 408) self.verticalLayout = QtWidgets.QVBoxLayout(FingerprintingOptionsPage) self.verticalLayout.setObjectName("verticalLayout") self.fingerprinting = QtWidgets.QGroupBox(parent=FingerprintingOptionsPage) self.fingerprinting.setCheckable(False) self.fingerprinting.setObjectName("fingerprinting") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.fingerprinting) self.verticalLayout_3.setObjectName("verticalLayout_3") self.disable_fingerprinting = QtWidgets.QRadioButton(parent=self.fingerprinting) self.disable_fingerprinting.setObjectName("disable_fingerprinting") self.verticalLayout_3.addWidget(self.disable_fingerprinting) self.use_acoustid = QtWidgets.QRadioButton(parent=self.fingerprinting) self.use_acoustid.setObjectName("use_acoustid") self.verticalLayout_3.addWidget(self.use_acoustid) self.verticalLayout.addWidget(self.fingerprinting) self.acoustid_settings = QtWidgets.QGroupBox(parent=FingerprintingOptionsPage) self.acoustid_settings.setObjectName("acoustid_settings") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.acoustid_settings) self.verticalLayout_2.setObjectName("verticalLayout_2") self.ignore_existing_acoustid_fingerprints = QtWidgets.QCheckBox(parent=self.acoustid_settings) self.ignore_existing_acoustid_fingerprints.setObjectName("ignore_existing_acoustid_fingerprints") self.verticalLayout_2.addWidget(self.ignore_existing_acoustid_fingerprints) self.save_acoustid_fingerprints = QtWidgets.QCheckBox(parent=self.acoustid_settings) self.save_acoustid_fingerprints.setObjectName("save_acoustid_fingerprints") self.verticalLayout_2.addWidget(self.save_acoustid_fingerprints) self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_3 = QtWidgets.QLabel(parent=self.acoustid_settings) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) self.label_3.setSizePolicy(sizePolicy) self.label_3.setObjectName("label_3") self.horizontalLayout_3.addWidget(self.label_3) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_3.addItem(spacerItem) self.fpcalc_threads = QtWidgets.QSpinBox(parent=self.acoustid_settings) self.fpcalc_threads.setMinimum(1) self.fpcalc_threads.setMaximum(9) self.fpcalc_threads.setObjectName("fpcalc_threads") self.horizontalLayout_3.addWidget(self.fpcalc_threads) self.verticalLayout_2.addLayout(self.horizontalLayout_3) self.label = QtWidgets.QLabel(parent=self.acoustid_settings) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.acoustid_fpcalc = QtWidgets.QLineEdit(parent=self.acoustid_settings) self.acoustid_fpcalc.setObjectName("acoustid_fpcalc") self.horizontalLayout_2.addWidget(self.acoustid_fpcalc) self.acoustid_fpcalc_browse = QtWidgets.QPushButton(parent=self.acoustid_settings) self.acoustid_fpcalc_browse.setObjectName("acoustid_fpcalc_browse") self.horizontalLayout_2.addWidget(self.acoustid_fpcalc_browse) self.acoustid_fpcalc_download = QtWidgets.QPushButton(parent=self.acoustid_settings) self.acoustid_fpcalc_download.setObjectName("acoustid_fpcalc_download") self.horizontalLayout_2.addWidget(self.acoustid_fpcalc_download) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.acoustid_fpcalc_info = QtWidgets.QLabel(parent=self.acoustid_settings) self.acoustid_fpcalc_info.setText("") self.acoustid_fpcalc_info.setObjectName("acoustid_fpcalc_info") self.verticalLayout_2.addWidget(self.acoustid_fpcalc_info) self.label_2 = QtWidgets.QLabel(parent=self.acoustid_settings) self.label_2.setObjectName("label_2") self.verticalLayout_2.addWidget(self.label_2) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.acoustid_apikey = QtWidgets.QLineEdit(parent=self.acoustid_settings) self.acoustid_apikey.setObjectName("acoustid_apikey") self.horizontalLayout.addWidget(self.acoustid_apikey) self.acoustid_apikey_get = QtWidgets.QPushButton(parent=self.acoustid_settings) self.acoustid_apikey_get.setObjectName("acoustid_apikey_get") self.horizontalLayout.addWidget(self.acoustid_apikey_get) self.verticalLayout_2.addLayout(self.horizontalLayout) self.verticalLayout.addWidget(self.acoustid_settings) spacerItem1 = QtWidgets.QSpacerItem(181, 21, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.retranslateUi(FingerprintingOptionsPage) QtCore.QMetaObject.connectSlotsByName(FingerprintingOptionsPage) def retranslateUi(self, FingerprintingOptionsPage): self.fingerprinting.setTitle(_("Audio Fingerprinting")) self.disable_fingerprinting.setText(_("Do not use audio fingerprinting")) self.use_acoustid.setText(_("Use AcoustID")) self.acoustid_settings.setTitle(_("AcoustID Settings")) self.ignore_existing_acoustid_fingerprints.setText(_("Ignore existing AcoustID fingerprints")) self.save_acoustid_fingerprints.setText(_("Save AcoustID fingerprints to file tags")) self.label_3.setText(_("Maximum threads to use for calculator:")) self.label.setText(_("Fingerprint calculator:")) self.acoustid_fpcalc_browse.setText(_("Browse…")) self.acoustid_fpcalc_download.setText(_("Download…")) self.label_2.setText(_("API key:")) self.acoustid_apikey_get.setText(_("Get API key…"))
6,922
Python
.py
108
55.907407
130
0.75419
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,017
ui_cdlookup.py
metabrainz_picard/picard/ui/forms/ui_cdlookup.py
# Form implementation generated from reading ui file 'ui/cdlookup.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CDLookupDialog(object): def setupUi(self, CDLookupDialog): CDLookupDialog.setObjectName("CDLookupDialog") CDLookupDialog.resize(720, 320) self.vboxlayout = QtWidgets.QVBoxLayout(CDLookupDialog) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.results_view = QtWidgets.QStackedWidget(parent=CDLookupDialog) self.results_view.setObjectName("results_view") self.results_page = QtWidgets.QWidget() self.results_page.setObjectName("results_page") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.results_page) self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label = QtWidgets.QLabel(parent=self.results_page) self.label.setObjectName("label") self.verticalLayout_4.addWidget(self.label) self.release_list = QtWidgets.QTreeWidget(parent=self.results_page) self.release_list.setObjectName("release_list") self.release_list.headerItem().setText(0, "1") self.verticalLayout_4.addWidget(self.release_list) self.results_view.addWidget(self.results_page) self.no_results_page = QtWidgets.QWidget() self.no_results_page.setObjectName("no_results_page") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.no_results_page) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.no_results_label = QtWidgets.QLabel(parent=self.no_results_page) self.no_results_label.setStyleSheet("margin-bottom: 9px;") self.no_results_label.setObjectName("no_results_label") self.verticalLayout_3.addWidget(self.no_results_label, 0, QtCore.Qt.AlignmentFlag.AlignHCenter) self.submit_button = QtWidgets.QToolButton(parent=self.no_results_page) self.submit_button.setStyleSheet("") icon = QtGui.QIcon.fromTheme("media-optical") self.submit_button.setIcon(icon) self.submit_button.setIconSize(QtCore.QSize(128, 128)) self.submit_button.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonTextUnderIcon) self.submit_button.setObjectName("submit_button") self.verticalLayout_3.addWidget(self.submit_button, 0, QtCore.Qt.AlignmentFlag.AlignHCenter) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem1) self.results_view.addWidget(self.no_results_page) self.vboxlayout.addWidget(self.results_view) self.hboxlayout = QtWidgets.QHBoxLayout() self.hboxlayout.setContentsMargins(0, 0, 0, 0) self.hboxlayout.setSpacing(6) self.hboxlayout.setObjectName("hboxlayout") spacerItem2 = QtWidgets.QSpacerItem(111, 31, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.hboxlayout.addItem(spacerItem2) self.ok_button = QtWidgets.QPushButton(parent=CDLookupDialog) self.ok_button.setEnabled(False) self.ok_button.setObjectName("ok_button") self.hboxlayout.addWidget(self.ok_button) self.lookup_button = QtWidgets.QPushButton(parent=CDLookupDialog) self.lookup_button.setObjectName("lookup_button") self.hboxlayout.addWidget(self.lookup_button) self.cancel_button = QtWidgets.QPushButton(parent=CDLookupDialog) self.cancel_button.setObjectName("cancel_button") self.hboxlayout.addWidget(self.cancel_button) self.vboxlayout.addLayout(self.hboxlayout) self.retranslateUi(CDLookupDialog) self.results_view.setCurrentIndex(0) self.ok_button.clicked.connect(CDLookupDialog.accept) # type: ignore self.cancel_button.clicked.connect(CDLookupDialog.reject) # type: ignore QtCore.QMetaObject.connectSlotsByName(CDLookupDialog) CDLookupDialog.setTabOrder(self.release_list, self.submit_button) CDLookupDialog.setTabOrder(self.submit_button, self.ok_button) CDLookupDialog.setTabOrder(self.ok_button, self.lookup_button) CDLookupDialog.setTabOrder(self.lookup_button, self.cancel_button) def retranslateUi(self, CDLookupDialog): CDLookupDialog.setWindowTitle(_("CD Lookup")) self.label.setText(_("The following releases on MusicBrainz match the CD:")) self.no_results_label.setText(_("No matching releases found for this disc.")) self.submit_button.setText(_("Submit disc ID")) self.ok_button.setText(_("&Load into Picard")) self.lookup_button.setText(_("&Submit disc ID")) self.cancel_button.setText(_("&Cancel"))
5,245
Python
.py
91
49.67033
130
0.730186
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,018
ui_options_releases.py
metabrainz_picard/picard/ui/forms/ui_options_releases.py
# Form implementation generated from reading ui file 'ui/options_releases.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ReleasesOptionsPage(object): def setupUi(self, ReleasesOptionsPage): ReleasesOptionsPage.setObjectName("ReleasesOptionsPage") ReleasesOptionsPage.resize(551, 497) self.verticalLayout_3 = QtWidgets.QVBoxLayout(ReleasesOptionsPage) self.verticalLayout_3.setObjectName("verticalLayout_3") self.type_group = QtWidgets.QGroupBox(parent=ReleasesOptionsPage) self.type_group.setObjectName("type_group") self.gridLayout = QtWidgets.QGridLayout(self.type_group) self.gridLayout.setVerticalSpacing(6) self.gridLayout.setObjectName("gridLayout") self.verticalLayout_3.addWidget(self.type_group) self.country_group = QtWidgets.QGroupBox(parent=ReleasesOptionsPage) self.country_group.setObjectName("country_group") self.horizontalLayout = QtWidgets.QHBoxLayout(self.country_group) self.horizontalLayout.setSpacing(4) self.horizontalLayout.setObjectName("horizontalLayout") self.country_list = QtWidgets.QListWidget(parent=self.country_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.country_list.sizePolicy().hasHeightForWidth()) self.country_list.setSizePolicy(sizePolicy) self.country_list.setObjectName("country_list") self.horizontalLayout.addWidget(self.country_list) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem) self.add_countries = QtWidgets.QPushButton(parent=self.country_group) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-next.png") self.add_countries.setIcon(icon) self.add_countries.setObjectName("add_countries") self.verticalLayout.addWidget(self.add_countries) self.remove_countries = QtWidgets.QPushButton(parent=self.country_group) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-previous.png") self.remove_countries.setIcon(icon) self.remove_countries.setObjectName("remove_countries") self.verticalLayout.addWidget(self.remove_countries) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.horizontalLayout.addLayout(self.verticalLayout) self.preferred_country_list = QtWidgets.QListWidget(parent=self.country_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.preferred_country_list.sizePolicy().hasHeightForWidth()) self.preferred_country_list.setSizePolicy(sizePolicy) self.preferred_country_list.setDragEnabled(True) self.preferred_country_list.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) self.preferred_country_list.setObjectName("preferred_country_list") self.horizontalLayout.addWidget(self.preferred_country_list) self.verticalLayout_3.addWidget(self.country_group) self.format_group = QtWidgets.QGroupBox(parent=ReleasesOptionsPage) self.format_group.setObjectName("format_group") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.format_group) self.horizontalLayout_2.setSpacing(4) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.format_list = QtWidgets.QListWidget(parent=self.format_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.format_list.sizePolicy().hasHeightForWidth()) self.format_list.setSizePolicy(sizePolicy) self.format_list.setObjectName("format_list") self.horizontalLayout_2.addWidget(self.format_list) self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_2.addItem(spacerItem2) self.add_formats = QtWidgets.QPushButton(parent=self.format_group) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-next.png") self.add_formats.setIcon(icon) self.add_formats.setObjectName("add_formats") self.verticalLayout_2.addWidget(self.add_formats) self.remove_formats = QtWidgets.QPushButton(parent=self.format_group) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-previous.png") self.remove_formats.setIcon(icon) self.remove_formats.setObjectName("remove_formats") self.verticalLayout_2.addWidget(self.remove_formats) spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_2.addItem(spacerItem3) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.preferred_format_list = QtWidgets.QListWidget(parent=self.format_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.preferred_format_list.sizePolicy().hasHeightForWidth()) self.preferred_format_list.setSizePolicy(sizePolicy) self.preferred_format_list.setDragEnabled(True) self.preferred_format_list.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) self.preferred_format_list.setObjectName("preferred_format_list") self.horizontalLayout_2.addWidget(self.preferred_format_list) self.verticalLayout_3.addWidget(self.format_group) self.retranslateUi(ReleasesOptionsPage) QtCore.QMetaObject.connectSlotsByName(ReleasesOptionsPage) def retranslateUi(self, ReleasesOptionsPage): self.type_group.setTitle(_("Preferred release types")) self.country_group.setTitle(_("Preferred release countries")) self.add_countries.setToolTip(_("Add to preferred release countries")) self.add_countries.setAccessibleDescription(_("Add to preferred release countries")) self.remove_countries.setToolTip(_("Remove from preferred release countries")) self.remove_countries.setAccessibleDescription(_("Remove from preferred release countries")) self.format_group.setTitle(_("Preferred medium formats")) self.add_formats.setToolTip(_("Add to preferred release formats")) self.add_formats.setAccessibleName(_("Add to preferred release formats")) self.remove_formats.setToolTip(_("Remove from preferred release formats")) self.remove_formats.setAccessibleDescription(_("Remove from preferred release formats"))
7,714
Python
.py
120
56.066667
129
0.755403
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,019
ui_options_metadata.py
metabrainz_picard/picard/ui/forms/ui_options_metadata.py
# Form implementation generated from reading ui file 'ui/options_metadata.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_MetadataOptionsPage(object): def setupUi(self, MetadataOptionsPage): MetadataOptionsPage.setObjectName("MetadataOptionsPage") MetadataOptionsPage.resize(423, 553) self.verticalLayout = QtWidgets.QVBoxLayout(MetadataOptionsPage) self.verticalLayout.setObjectName("verticalLayout") self.metadata_groupbox = QtWidgets.QGroupBox(parent=MetadataOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.metadata_groupbox.sizePolicy().hasHeightForWidth()) self.metadata_groupbox.setSizePolicy(sizePolicy) self.metadata_groupbox.setMinimumSize(QtCore.QSize(397, 135)) self.metadata_groupbox.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.metadata_groupbox.setObjectName("metadata_groupbox") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.metadata_groupbox) self.verticalLayout_3.setObjectName("verticalLayout_3") self.translate_artist_names = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.translate_artist_names.setObjectName("translate_artist_names") self.verticalLayout_3.addWidget(self.translate_artist_names) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout.setObjectName("horizontalLayout") self.selected_locales = QtWidgets.QLineEdit(parent=self.metadata_groupbox) self.selected_locales.setReadOnly(True) self.selected_locales.setObjectName("selected_locales") self.horizontalLayout.addWidget(self.selected_locales) self.select_locales = QtWidgets.QPushButton(parent=self.metadata_groupbox) self.select_locales.setObjectName("select_locales") self.horizontalLayout.addWidget(self.select_locales) self.verticalLayout_3.addLayout(self.horizontalLayout) self.translate_artist_names_script_exception = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.translate_artist_names_script_exception.setObjectName("translate_artist_names_script_exception") self.verticalLayout_3.addWidget(self.translate_artist_names_script_exception) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.selected_scripts = QtWidgets.QLineEdit(parent=self.metadata_groupbox) self.selected_scripts.setReadOnly(True) self.selected_scripts.setObjectName("selected_scripts") self.horizontalLayout_4.addWidget(self.selected_scripts) self.select_scripts = QtWidgets.QPushButton(parent=self.metadata_groupbox) self.select_scripts.setObjectName("select_scripts") self.horizontalLayout_4.addWidget(self.select_scripts) self.verticalLayout_3.addLayout(self.horizontalLayout_4) self.standardize_artists = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.standardize_artists.setObjectName("standardize_artists") self.verticalLayout_3.addWidget(self.standardize_artists) self.standardize_instruments = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.standardize_instruments.setObjectName("standardize_instruments") self.verticalLayout_3.addWidget(self.standardize_instruments) self.convert_punctuation = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.convert_punctuation.setObjectName("convert_punctuation") self.verticalLayout_3.addWidget(self.convert_punctuation) self.release_ars = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.release_ars.setObjectName("release_ars") self.verticalLayout_3.addWidget(self.release_ars) self.track_ars = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.track_ars.setObjectName("track_ars") self.verticalLayout_3.addWidget(self.track_ars) self.guess_tracknumber_and_title = QtWidgets.QCheckBox(parent=self.metadata_groupbox) self.guess_tracknumber_and_title.setObjectName("guess_tracknumber_and_title") self.verticalLayout_3.addWidget(self.guess_tracknumber_and_title) self.verticalLayout.addWidget(self.metadata_groupbox) self.custom_fields_groupbox = QtWidgets.QGroupBox(parent=MetadataOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.custom_fields_groupbox.sizePolicy().hasHeightForWidth()) self.custom_fields_groupbox.setSizePolicy(sizePolicy) self.custom_fields_groupbox.setMinimumSize(QtCore.QSize(397, 0)) self.custom_fields_groupbox.setObjectName("custom_fields_groupbox") self.gridlayout = QtWidgets.QGridLayout(self.custom_fields_groupbox) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.label_6 = QtWidgets.QLabel(parent=self.custom_fields_groupbox) self.label_6.setObjectName("label_6") self.gridlayout.addWidget(self.label_6, 0, 0, 1, 2) self.label_7 = QtWidgets.QLabel(parent=self.custom_fields_groupbox) self.label_7.setObjectName("label_7") self.gridlayout.addWidget(self.label_7, 2, 0, 1, 2) self.nat_name = QtWidgets.QLineEdit(parent=self.custom_fields_groupbox) self.nat_name.setObjectName("nat_name") self.gridlayout.addWidget(self.nat_name, 3, 0, 1, 1) self.nat_name_default = QtWidgets.QPushButton(parent=self.custom_fields_groupbox) self.nat_name_default.setObjectName("nat_name_default") self.gridlayout.addWidget(self.nat_name_default, 3, 1, 1, 1) self.va_name_default = QtWidgets.QPushButton(parent=self.custom_fields_groupbox) self.va_name_default.setObjectName("va_name_default") self.gridlayout.addWidget(self.va_name_default, 1, 1, 1, 1) self.va_name = QtWidgets.QLineEdit(parent=self.custom_fields_groupbox) self.va_name.setObjectName("va_name") self.gridlayout.addWidget(self.va_name, 1, 0, 1, 1) self.verticalLayout.addWidget(self.custom_fields_groupbox) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem) self.label_6.setBuddy(self.va_name_default) self.label_7.setBuddy(self.nat_name_default) self.retranslateUi(MetadataOptionsPage) QtCore.QMetaObject.connectSlotsByName(MetadataOptionsPage) MetadataOptionsPage.setTabOrder(self.translate_artist_names, self.selected_locales) MetadataOptionsPage.setTabOrder(self.selected_locales, self.select_locales) MetadataOptionsPage.setTabOrder(self.select_locales, self.translate_artist_names_script_exception) MetadataOptionsPage.setTabOrder(self.translate_artist_names_script_exception, self.selected_scripts) MetadataOptionsPage.setTabOrder(self.selected_scripts, self.select_scripts) MetadataOptionsPage.setTabOrder(self.select_scripts, self.standardize_artists) MetadataOptionsPage.setTabOrder(self.standardize_artists, self.standardize_instruments) MetadataOptionsPage.setTabOrder(self.standardize_instruments, self.convert_punctuation) MetadataOptionsPage.setTabOrder(self.convert_punctuation, self.release_ars) MetadataOptionsPage.setTabOrder(self.release_ars, self.track_ars) MetadataOptionsPage.setTabOrder(self.track_ars, self.guess_tracknumber_and_title) MetadataOptionsPage.setTabOrder(self.guess_tracknumber_and_title, self.va_name) MetadataOptionsPage.setTabOrder(self.va_name, self.va_name_default) MetadataOptionsPage.setTabOrder(self.va_name_default, self.nat_name) MetadataOptionsPage.setTabOrder(self.nat_name, self.nat_name_default) def retranslateUi(self, MetadataOptionsPage): self.metadata_groupbox.setTitle(_("Metadata")) self.translate_artist_names.setText(_("Translate artist names to these locales where possible:")) self.select_locales.setText(_("Select…")) self.translate_artist_names_script_exception.setText(_("Ignore artist name translation for these language scripts:")) self.select_scripts.setText(_("Select…")) self.standardize_artists.setText(_("Use standardized artist names")) self.standardize_instruments.setText(_("Use standardized instrument and vocal credits")) self.convert_punctuation.setText(_("Convert Unicode punctuation characters to ASCII")) self.release_ars.setText(_("Use release relationships")) self.track_ars.setText(_("Use track relationships")) self.guess_tracknumber_and_title.setText(_("Guess track number and title from filename if empty")) self.custom_fields_groupbox.setTitle(_("Custom Fields")) self.label_6.setText(_("Various artists:")) self.label_7.setText(_("Standalone recordings:")) self.nat_name_default.setText(_("Default")) self.va_name_default.setText(_("Default"))
9,799
Python
.py
144
59.673611
148
0.7521
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,020
ui_options_cover.py
metabrainz_picard/picard/ui/forms/ui_options_cover.py
# Form implementation generated from reading ui file 'ui/options_cover.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CoverOptionsPage(object): def setupUi(self, CoverOptionsPage): CoverOptionsPage.setObjectName("CoverOptionsPage") CoverOptionsPage.resize(632, 560) self.verticalLayout = QtWidgets.QVBoxLayout(CoverOptionsPage) self.verticalLayout.setObjectName("verticalLayout") self.save_images_to_tags = QtWidgets.QGroupBox(parent=CoverOptionsPage) self.save_images_to_tags.setCheckable(True) self.save_images_to_tags.setChecked(False) self.save_images_to_tags.setObjectName("save_images_to_tags") self.vboxlayout = QtWidgets.QVBoxLayout(self.save_images_to_tags) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(2) self.vboxlayout.setObjectName("vboxlayout") self.cb_embed_front_only = QtWidgets.QCheckBox(parent=self.save_images_to_tags) self.cb_embed_front_only.setObjectName("cb_embed_front_only") self.vboxlayout.addWidget(self.cb_embed_front_only) self.cb_dont_replace_with_smaller = QtWidgets.QCheckBox(parent=self.save_images_to_tags) self.cb_dont_replace_with_smaller.setObjectName("cb_dont_replace_with_smaller") self.vboxlayout.addWidget(self.cb_dont_replace_with_smaller) self.never_replace_types_layout = QtWidgets.QHBoxLayout() self.never_replace_types_layout.setObjectName("never_replace_types_layout") self.cb_never_replace_types = QtWidgets.QCheckBox(parent=self.save_images_to_tags) self.cb_never_replace_types.setObjectName("cb_never_replace_types") self.never_replace_types_layout.addWidget(self.cb_never_replace_types) self.select_types_button = QtWidgets.QPushButton(parent=self.save_images_to_tags) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.select_types_button.sizePolicy().hasHeightForWidth()) self.select_types_button.setSizePolicy(sizePolicy) self.select_types_button.setObjectName("select_types_button") self.never_replace_types_layout.addWidget(self.select_types_button) self.vboxlayout.addLayout(self.never_replace_types_layout) self.verticalLayout.addWidget(self.save_images_to_tags) self.save_images_to_files = QtWidgets.QGroupBox(parent=CoverOptionsPage) self.save_images_to_files.setCheckable(True) self.save_images_to_files.setChecked(False) self.save_images_to_files.setObjectName("save_images_to_files") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.save_images_to_files) self.verticalLayout_2.setObjectName("verticalLayout_2") self.label_use_filename = QtWidgets.QLabel(parent=self.save_images_to_files) self.label_use_filename.setObjectName("label_use_filename") self.verticalLayout_2.addWidget(self.label_use_filename) self.cover_image_filename = QtWidgets.QLineEdit(parent=self.save_images_to_files) self.cover_image_filename.setObjectName("cover_image_filename") self.verticalLayout_2.addWidget(self.cover_image_filename) self.save_images_overwrite = QtWidgets.QCheckBox(parent=self.save_images_to_files) self.save_images_overwrite.setObjectName("save_images_overwrite") self.verticalLayout_2.addWidget(self.save_images_overwrite) self.save_only_one_front_image = QtWidgets.QCheckBox(parent=self.save_images_to_files) self.save_only_one_front_image.setObjectName("save_only_one_front_image") self.verticalLayout_2.addWidget(self.save_only_one_front_image) self.image_type_as_filename = QtWidgets.QCheckBox(parent=self.save_images_to_files) self.image_type_as_filename.setObjectName("image_type_as_filename") self.verticalLayout_2.addWidget(self.image_type_as_filename) self.verticalLayout.addWidget(self.save_images_to_files) self.ca_providers_groupbox = QtWidgets.QGroupBox(parent=CoverOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ca_providers_groupbox.sizePolicy().hasHeightForWidth()) self.ca_providers_groupbox.setSizePolicy(sizePolicy) self.ca_providers_groupbox.setObjectName("ca_providers_groupbox") self.ca_providers_layout = QtWidgets.QVBoxLayout(self.ca_providers_groupbox) self.ca_providers_layout.setObjectName("ca_providers_layout") self.ca_providers_list = QtWidgets.QListWidget(parent=self.ca_providers_groupbox) self.ca_providers_list.setObjectName("ca_providers_list") self.ca_providers_layout.addWidget(self.ca_providers_list) self.ca_layout = QtWidgets.QHBoxLayout() self.ca_layout.setObjectName("ca_layout") self.move_label = QtWidgets.QLabel(parent=self.ca_providers_groupbox) self.move_label.setObjectName("move_label") self.ca_layout.addWidget(self.move_label) self.up_button = QtWidgets.QToolButton(parent=self.ca_providers_groupbox) self.up_button.setLayoutDirection(QtCore.Qt.LayoutDirection.LeftToRight) self.up_button.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.up_button.setIcon(icon) self.up_button.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonIconOnly) self.up_button.setAutoRaise(False) self.up_button.setObjectName("up_button") self.ca_layout.addWidget(self.up_button) self.down_button = QtWidgets.QToolButton(parent=self.ca_providers_groupbox) self.down_button.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.down_button.setIcon(icon) self.down_button.setToolButtonStyle(QtCore.Qt.ToolButtonStyle.ToolButtonIconOnly) self.down_button.setObjectName("down_button") self.ca_layout.addWidget(self.down_button) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.ca_layout.addItem(spacerItem) self.ca_providers_layout.addLayout(self.ca_layout) self.verticalLayout.addWidget(self.ca_providers_groupbox, 0, QtCore.Qt.AlignmentFlag.AlignTop) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.retranslateUi(CoverOptionsPage) QtCore.QMetaObject.connectSlotsByName(CoverOptionsPage) def retranslateUi(self, CoverOptionsPage): self.save_images_to_tags.setTitle(_("Embed cover images into tags")) self.cb_embed_front_only.setText(_("Embed only a single front image")) self.cb_dont_replace_with_smaller.setText(_("Never replace cover images with smaller ones")) self.cb_never_replace_types.setText(_("Never replace cover images matching selected types")) self.select_types_button.setText(_("Select Types...")) self.save_images_to_files.setTitle(_("Save cover images as separate files")) self.label_use_filename.setText(_("Use the following file name for images:")) self.save_images_overwrite.setText(_("Overwrite the file if it already exists")) self.save_only_one_front_image.setText(_("Save only a single front image as separate file")) self.image_type_as_filename.setText(_("Always use the primary image type as the file name for non-front images")) self.ca_providers_groupbox.setTitle(_("Cover Art Providers")) self.move_label.setText(_("Reorder Priority:")) self.up_button.setToolTip(_("Move selected item up")) self.down_button.setToolTip(_("Move selected item down"))
8,274
Python
.py
125
57.944
129
0.738303
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,021
ui_provider_options_caa.py
metabrainz_picard/picard/ui/forms/ui_provider_options_caa.py
# Form implementation generated from reading ui file 'ui/provider_options_caa.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CaaOptions(object): def setupUi(self, CaaOptions): CaaOptions.setObjectName("CaaOptions") CaaOptions.resize(660, 194) self.verticalLayout = QtWidgets.QVBoxLayout(CaaOptions) self.verticalLayout.setObjectName("verticalLayout") self.select_caa_types_group = QtWidgets.QHBoxLayout() self.select_caa_types_group.setObjectName("select_caa_types_group") self.restrict_images_types = QtWidgets.QCheckBox(parent=CaaOptions) self.restrict_images_types.setObjectName("restrict_images_types") self.select_caa_types_group.addWidget(self.restrict_images_types) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.select_caa_types_group.addItem(spacerItem) self.select_caa_types = QtWidgets.QPushButton(parent=CaaOptions) self.select_caa_types.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(100) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.select_caa_types.sizePolicy().hasHeightForWidth()) self.select_caa_types.setSizePolicy(sizePolicy) self.select_caa_types.setObjectName("select_caa_types") self.select_caa_types_group.addWidget(self.select_caa_types) self.verticalLayout.addLayout(self.select_caa_types_group) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label = QtWidgets.QLabel(parent=CaaOptions) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.cb_image_size = QtWidgets.QComboBox(parent=CaaOptions) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.cb_image_size.sizePolicy().hasHeightForWidth()) self.cb_image_size.setSizePolicy(sizePolicy) self.cb_image_size.setObjectName("cb_image_size") self.horizontalLayout.addWidget(self.cb_image_size) self.verticalLayout.addLayout(self.horizontalLayout) self.cb_approved_only = QtWidgets.QCheckBox(parent=CaaOptions) self.cb_approved_only.setObjectName("cb_approved_only") self.verticalLayout.addWidget(self.cb_approved_only) spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem2) self.retranslateUi(CaaOptions) QtCore.QMetaObject.connectSlotsByName(CaaOptions) CaaOptions.setTabOrder(self.restrict_images_types, self.select_caa_types) CaaOptions.setTabOrder(self.select_caa_types, self.cb_image_size) CaaOptions.setTabOrder(self.cb_image_size, self.cb_approved_only) def retranslateUi(self, CaaOptions): CaaOptions.setWindowTitle(_("Form")) self.restrict_images_types.setText(_("Download only cover art images matching selected types")) self.select_caa_types.setText(_("Select types…")) self.label.setText(_("Only use images of at most the following size:")) self.cb_approved_only.setText(_("Download only approved images"))
4,293
Python
.py
72
51.930556
129
0.748754
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,022
ui_options_tags.py
metabrainz_picard/picard/ui/forms/ui_options_tags.py
# Form implementation generated from reading ui file 'ui/options_tags.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsOptionsPage(object): def setupUi(self, TagsOptionsPage): TagsOptionsPage.setObjectName("TagsOptionsPage") TagsOptionsPage.resize(567, 525) self.vboxlayout = QtWidgets.QVBoxLayout(TagsOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.write_tags = QtWidgets.QCheckBox(parent=TagsOptionsPage) self.write_tags.setObjectName("write_tags") self.vboxlayout.addWidget(self.write_tags) self.preserve_timestamps = QtWidgets.QCheckBox(parent=TagsOptionsPage) self.preserve_timestamps.setObjectName("preserve_timestamps") self.vboxlayout.addWidget(self.preserve_timestamps) self.before_tagging = QtWidgets.QGroupBox(parent=TagsOptionsPage) self.before_tagging.setObjectName("before_tagging") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.before_tagging) self.vboxlayout1.setContentsMargins(-1, 6, -1, 7) self.vboxlayout1.setSpacing(2) self.vboxlayout1.setObjectName("vboxlayout1") self.clear_existing_tags = QtWidgets.QCheckBox(parent=self.before_tagging) self.clear_existing_tags.setObjectName("clear_existing_tags") self.vboxlayout1.addWidget(self.clear_existing_tags) self.preserve_images = QtWidgets.QCheckBox(parent=self.before_tagging) self.preserve_images.setEnabled(False) self.preserve_images.setObjectName("preserve_images") self.vboxlayout1.addWidget(self.preserve_images) self.remove_id3_from_flac = QtWidgets.QCheckBox(parent=self.before_tagging) self.remove_id3_from_flac.setObjectName("remove_id3_from_flac") self.vboxlayout1.addWidget(self.remove_id3_from_flac) self.remove_ape_from_mp3 = QtWidgets.QCheckBox(parent=self.before_tagging) self.remove_ape_from_mp3.setObjectName("remove_ape_from_mp3") self.vboxlayout1.addWidget(self.remove_ape_from_mp3) self.fix_missing_seekpoints_flac = QtWidgets.QCheckBox(parent=self.before_tagging) self.fix_missing_seekpoints_flac.setObjectName("fix_missing_seekpoints_flac") self.vboxlayout1.addWidget(self.fix_missing_seekpoints_flac) spacerItem = QtWidgets.QSpacerItem(20, 6, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.vboxlayout1.addItem(spacerItem) self.preserved_tags_label = QtWidgets.QLabel(parent=self.before_tagging) self.preserved_tags_label.setObjectName("preserved_tags_label") self.vboxlayout1.addWidget(self.preserved_tags_label) self.preserved_tags = TagListEditor(parent=self.before_tagging) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.preserved_tags.sizePolicy().hasHeightForWidth()) self.preserved_tags.setSizePolicy(sizePolicy) self.preserved_tags.setObjectName("preserved_tags") self.vboxlayout1.addWidget(self.preserved_tags) self.vboxlayout.addWidget(self.before_tagging) self.retranslateUi(TagsOptionsPage) self.clear_existing_tags.toggled['bool'].connect(self.preserve_images.setEnabled) # type: ignore QtCore.QMetaObject.connectSlotsByName(TagsOptionsPage) TagsOptionsPage.setTabOrder(self.write_tags, self.preserve_timestamps) TagsOptionsPage.setTabOrder(self.preserve_timestamps, self.clear_existing_tags) TagsOptionsPage.setTabOrder(self.clear_existing_tags, self.preserve_images) TagsOptionsPage.setTabOrder(self.preserve_images, self.remove_id3_from_flac) TagsOptionsPage.setTabOrder(self.remove_id3_from_flac, self.remove_ape_from_mp3) TagsOptionsPage.setTabOrder(self.remove_ape_from_mp3, self.fix_missing_seekpoints_flac) def retranslateUi(self, TagsOptionsPage): self.write_tags.setText(_("Write tags to files")) self.preserve_timestamps.setText(_("Preserve timestamps of tagged files")) self.before_tagging.setTitle(_("Before Tagging")) self.clear_existing_tags.setText(_("Clear existing tags")) self.preserve_images.setText(_("Keep embedded images when clearing tags")) self.remove_id3_from_flac.setText(_("Remove ID3 tags from FLAC files")) self.remove_ape_from_mp3.setText(_("Remove APEv2 tags from MP3 files")) self.fix_missing_seekpoints_flac.setText(_("Fix missing seekpoints for FLAC files")) self.preserved_tags_label.setText(_("Preserve these tags from being cleared or overwritten with MusicBrainz data:")) from picard.ui.widgets.taglisteditor import TagListEditor
5,019
Python
.py
80
55.0125
124
0.748226
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,023
ui_widget_taglisteditor.py
metabrainz_picard/picard/ui/forms/ui_widget_taglisteditor.py
# Form implementation generated from reading ui file 'ui/widget_taglisteditor.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagListEditor(object): def setupUi(self, TagListEditor): TagListEditor.setObjectName("TagListEditor") TagListEditor.resize(400, 300) self.horizontalLayout = QtWidgets.QHBoxLayout(TagListEditor) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setSpacing(6) self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.tag_list_view = UniqueEditableListView(parent=TagListEditor) self.tag_list_view.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) self.tag_list_view.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.tag_list_view.setObjectName("tag_list_view") self.verticalLayout.addWidget(self.tag_list_view) self.edit_buttons = QtWidgets.QWidget(parent=TagListEditor) self.edit_buttons.setObjectName("edit_buttons") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.edit_buttons) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.tags_add_btn = QtWidgets.QToolButton(parent=self.edit_buttons) self.tags_add_btn.setObjectName("tags_add_btn") self.horizontalLayout_2.addWidget(self.tags_add_btn) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.sort_buttons = QtWidgets.QWidget(parent=self.edit_buttons) self.sort_buttons.setObjectName("sort_buttons") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.sort_buttons) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.tags_move_up_btn = QtWidgets.QToolButton(parent=self.sort_buttons) self.tags_move_up_btn.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.tags_move_up_btn.setIcon(icon) self.tags_move_up_btn.setObjectName("tags_move_up_btn") self.horizontalLayout_3.addWidget(self.tags_move_up_btn) self.tags_move_down_btn = QtWidgets.QToolButton(parent=self.sort_buttons) self.tags_move_down_btn.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.tags_move_down_btn.setIcon(icon) self.tags_move_down_btn.setObjectName("tags_move_down_btn") self.horizontalLayout_3.addWidget(self.tags_move_down_btn) self.horizontalLayout_2.addWidget(self.sort_buttons) self.tags_remove_btn = QtWidgets.QToolButton(parent=self.edit_buttons) self.tags_remove_btn.setObjectName("tags_remove_btn") self.horizontalLayout_2.addWidget(self.tags_remove_btn) self.verticalLayout.addWidget(self.edit_buttons) self.horizontalLayout.addLayout(self.verticalLayout) self.retranslateUi(TagListEditor) self.tags_add_btn.clicked.connect(self.tag_list_view.add_empty_row) # type: ignore self.tags_remove_btn.clicked.connect(self.tag_list_view.remove_selected_rows) # type: ignore self.tags_move_up_btn.clicked.connect(self.tag_list_view.move_selected_rows_up) # type: ignore self.tags_move_down_btn.clicked.connect(self.tag_list_view.move_selected_rows_down) # type: ignore QtCore.QMetaObject.connectSlotsByName(TagListEditor) def retranslateUi(self, TagListEditor): TagListEditor.setWindowTitle(_("Form")) self.tags_add_btn.setText(_("Add new tag")) self.tags_move_up_btn.setToolTip(_("Move tag up")) self.tags_move_up_btn.setAccessibleName(_("Move tag up")) self.tags_move_down_btn.setToolTip(_("Move tag down")) self.tags_move_down_btn.setAccessibleName(_("Move tag down")) self.tags_remove_btn.setToolTip(_("Remove selected tags")) self.tags_remove_btn.setAccessibleName(_("Remove selected tags")) self.tags_remove_btn.setText(_("Remove tags")) from picard.ui.widgets.editablelistview import UniqueEditableListView
4,557
Python
.py
77
51.506494
128
0.729101
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,024
ui_options_attached_profiles.py
metabrainz_picard/picard/ui/forms/ui_options_attached_profiles.py
# Form implementation generated from reading ui file 'ui/options_attached_profiles.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_AttachedProfilesDialog(object): def setupUi(self, AttachedProfilesDialog): AttachedProfilesDialog.setObjectName("AttachedProfilesDialog") AttachedProfilesDialog.resize(800, 450) self.vboxlayout = QtWidgets.QVBoxLayout(AttachedProfilesDialog) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.options_list = QtWidgets.QTableView(parent=AttachedProfilesDialog) self.options_list.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) self.options_list.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.SingleSelection) self.options_list.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.options_list.setObjectName("options_list") self.vboxlayout.addWidget(self.options_list) self.buttonBox = QtWidgets.QDialogButtonBox(parent=AttachedProfilesDialog) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.NoButton) self.buttonBox.setObjectName("buttonBox") self.vboxlayout.addWidget(self.buttonBox) self.retranslateUi(AttachedProfilesDialog) QtCore.QMetaObject.connectSlotsByName(AttachedProfilesDialog) def retranslateUi(self, AttachedProfilesDialog): AttachedProfilesDialog.setWindowTitle(_("Profiles Attached to Options"))
1,776
Python
.py
34
46
104
0.779954
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,025
ui_options_plugins.py
metabrainz_picard/picard/ui/forms/ui_options_plugins.py
# Form implementation generated from reading ui file 'ui/options_plugins.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_PluginsOptionsPage(object): def setupUi(self, PluginsOptionsPage): PluginsOptionsPage.setObjectName("PluginsOptionsPage") PluginsOptionsPage.resize(697, 441) self.vboxlayout = QtWidgets.QVBoxLayout(PluginsOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.plugins_container = QtWidgets.QSplitter(parent=PluginsOptionsPage) self.plugins_container.setEnabled(True) self.plugins_container.setOrientation(QtCore.Qt.Orientation.Vertical) self.plugins_container.setHandleWidth(2) self.plugins_container.setObjectName("plugins_container") self.groupBox_2 = QtWidgets.QGroupBox(parent=self.plugins_container) self.groupBox_2.setObjectName("groupBox_2") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.groupBox_2) self.vboxlayout1.setSpacing(2) self.vboxlayout1.setObjectName("vboxlayout1") self.plugins = QtWidgets.QTreeWidget(parent=self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.plugins.sizePolicy().hasHeightForWidth()) self.plugins.setSizePolicy(sizePolicy) self.plugins.setAcceptDrops(True) self.plugins.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.DropOnly) self.plugins.setRootIsDecorated(False) self.plugins.setObjectName("plugins") self.plugins.headerItem().setTextAlignment(2, QtCore.Qt.AlignmentFlag.AlignCenter) self.vboxlayout1.addWidget(self.plugins) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.install_plugin = QtWidgets.QPushButton(parent=self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.install_plugin.sizePolicy().hasHeightForWidth()) self.install_plugin.setSizePolicy(sizePolicy) self.install_plugin.setObjectName("install_plugin") self.horizontalLayout.addWidget(self.install_plugin) self.folder_open = QtWidgets.QPushButton(parent=self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.folder_open.sizePolicy().hasHeightForWidth()) self.folder_open.setSizePolicy(sizePolicy) self.folder_open.setObjectName("folder_open") self.horizontalLayout.addWidget(self.folder_open) self.reload_list_of_plugins = QtWidgets.QPushButton(parent=self.groupBox_2) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.reload_list_of_plugins.sizePolicy().hasHeightForWidth()) self.reload_list_of_plugins.setSizePolicy(sizePolicy) self.reload_list_of_plugins.setObjectName("reload_list_of_plugins") self.horizontalLayout.addWidget(self.reload_list_of_plugins) self.vboxlayout1.addLayout(self.horizontalLayout) self.groupBox = QtWidgets.QGroupBox(parent=self.plugins_container) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setObjectName("groupBox") self.vboxlayout2 = QtWidgets.QVBoxLayout(self.groupBox) self.vboxlayout2.setSpacing(0) self.vboxlayout2.setObjectName("vboxlayout2") self.scrollArea = QtWidgets.QScrollArea(parent=self.groupBox) self.scrollArea.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth()) self.scrollArea.setSizePolicy(sizePolicy) self.scrollArea.setFrameShape(QtWidgets.QFrame.Shape.HLine) self.scrollArea.setFrameShadow(QtWidgets.QFrame.Shadow.Plain) self.scrollArea.setLineWidth(0) self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAsNeeded) self.scrollArea.setWidgetResizable(True) self.scrollArea.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 655, 82)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scrollAreaWidgetContents.sizePolicy().hasHeightForWidth()) self.scrollAreaWidgetContents.setSizePolicy(sizePolicy) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetNoConstraint) self.verticalLayout.setContentsMargins(0, 0, 6, 0) self.verticalLayout.setObjectName("verticalLayout") self.details = QtWidgets.QLabel(parent=self.scrollAreaWidgetContents) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.details.sizePolicy().hasHeightForWidth()) self.details.setSizePolicy(sizePolicy) self.details.setMinimumSize(QtCore.QSize(0, 0)) self.details.setFrameShape(QtWidgets.QFrame.Shape.Box) self.details.setLineWidth(0) self.details.setText("") self.details.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.details.setWordWrap(True) self.details.setIndent(0) self.details.setOpenExternalLinks(True) self.details.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse) self.details.setObjectName("details") self.verticalLayout.addWidget(self.details) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.vboxlayout2.addWidget(self.scrollArea) self.vboxlayout.addWidget(self.plugins_container) self.retranslateUi(PluginsOptionsPage) QtCore.QMetaObject.connectSlotsByName(PluginsOptionsPage) PluginsOptionsPage.setTabOrder(self.plugins, self.install_plugin) PluginsOptionsPage.setTabOrder(self.install_plugin, self.folder_open) PluginsOptionsPage.setTabOrder(self.folder_open, self.reload_list_of_plugins) PluginsOptionsPage.setTabOrder(self.reload_list_of_plugins, self.scrollArea) def retranslateUi(self, PluginsOptionsPage): self.groupBox_2.setTitle(_("Plugins")) self.plugins.headerItem().setText(0, _("Name")) self.plugins.headerItem().setText(1, _("Version")) self.plugins.headerItem().setText(2, _("Actions")) self.install_plugin.setText(_("Install plugin…")) self.folder_open.setText(_("Open plugin folder")) self.reload_list_of_plugins.setText(_("Reload List of Plugins")) self.groupBox.setTitle(_("Details"))
8,568
Python
.py
138
53.768116
150
0.761159
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,026
ui_passworddialog.py
metabrainz_picard/picard/ui/forms/ui_passworddialog.py
# Form implementation generated from reading ui file 'ui/passworddialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_PasswordDialog(object): def setupUi(self, PasswordDialog): PasswordDialog.setObjectName("PasswordDialog") PasswordDialog.setWindowModality(QtCore.Qt.WindowModality.WindowModal) PasswordDialog.resize(378, 246) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(PasswordDialog.sizePolicy().hasHeightForWidth()) PasswordDialog.setSizePolicy(sizePolicy) self.verticalLayout = QtWidgets.QVBoxLayout(PasswordDialog) self.verticalLayout.setObjectName("verticalLayout") self.info_text = QtWidgets.QLabel(parent=PasswordDialog) self.info_text.setText("") self.info_text.setWordWrap(True) self.info_text.setObjectName("info_text") self.verticalLayout.addWidget(self.info_text) spacerItem = QtWidgets.QSpacerItem(20, 60, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem) self.label = QtWidgets.QLabel(parent=PasswordDialog) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.username = QtWidgets.QLineEdit(parent=PasswordDialog) self.username.setWindowModality(QtCore.Qt.WindowModality.NonModal) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.username.sizePolicy().hasHeightForWidth()) self.username.setSizePolicy(sizePolicy) self.username.setObjectName("username") self.verticalLayout.addWidget(self.username) self.label_2 = QtWidgets.QLabel(parent=PasswordDialog) self.label_2.setObjectName("label_2") self.verticalLayout.addWidget(self.label_2) self.password = QtWidgets.QLineEdit(parent=PasswordDialog) self.password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) self.password.setObjectName("password") self.verticalLayout.addWidget(self.password) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.buttonbox = QtWidgets.QDialogButtonBox(parent=PasswordDialog) self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonbox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonbox.setObjectName("buttonbox") self.verticalLayout.addWidget(self.buttonbox) self.retranslateUi(PasswordDialog) self.buttonbox.rejected.connect(PasswordDialog.reject) # type: ignore QtCore.QMetaObject.connectSlotsByName(PasswordDialog) def retranslateUi(self, PasswordDialog): PasswordDialog.setWindowTitle(_("Authentication Required")) self.label.setText(_("Username:")) self.label_2.setText(_("Password:"))
3,538
Python
.py
64
47.75
136
0.756344
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,027
ui_provider_options_local.py
metabrainz_picard/picard/ui/forms/ui_provider_options_local.py
# Form implementation generated from reading ui file 'ui/provider_options_local.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_LocalOptions(object): def setupUi(self, LocalOptions): LocalOptions.setObjectName("LocalOptions") LocalOptions.resize(472, 215) self.verticalLayout = QtWidgets.QVBoxLayout(LocalOptions) self.verticalLayout.setObjectName("verticalLayout") self.local_cover_regex_label = QtWidgets.QLabel(parent=LocalOptions) self.local_cover_regex_label.setObjectName("local_cover_regex_label") self.verticalLayout.addWidget(self.local_cover_regex_label) self.local_cover_regex_edit = QtWidgets.QLineEdit(parent=LocalOptions) self.local_cover_regex_edit.setObjectName("local_cover_regex_edit") self.verticalLayout.addWidget(self.local_cover_regex_edit) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.local_cover_regex_error = QtWidgets.QLabel(parent=LocalOptions) self.local_cover_regex_error.setText("") self.local_cover_regex_error.setObjectName("local_cover_regex_error") self.horizontalLayout_2.addWidget(self.local_cover_regex_error) self.local_cover_regex_default = QtWidgets.QPushButton(parent=LocalOptions) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.local_cover_regex_default.sizePolicy().hasHeightForWidth()) self.local_cover_regex_default.setSizePolicy(sizePolicy) self.local_cover_regex_default.setObjectName("local_cover_regex_default") self.horizontalLayout_2.addWidget(self.local_cover_regex_default) self.verticalLayout.addLayout(self.horizontalLayout_2) self.note = QtWidgets.QLabel(parent=LocalOptions) font = QtGui.QFont() font.setItalic(True) self.note.setFont(font) self.note.setWordWrap(True) self.note.setObjectName("note") self.verticalLayout.addWidget(self.note) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem) self.retranslateUi(LocalOptions) QtCore.QMetaObject.connectSlotsByName(LocalOptions) def retranslateUi(self, LocalOptions): LocalOptions.setWindowTitle(_("Form")) self.local_cover_regex_label.setText(_("Local cover art files match the following regular expression:")) self.local_cover_regex_default.setText(_("Default")) self.note.setText(_("First group in the regular expression, if any, will be used as type, ie. cover-back-spine.jpg will be set as types Back + Spine. If no type is found, it will default to Front type."))
3,150
Python
.py
55
49.981818
212
0.740693
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,028
ui_options_general.py
metabrainz_picard/picard/ui/forms/ui_options_general.py
# Form implementation generated from reading ui file 'ui/options_general.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_GeneralOptionsPage(object): def setupUi(self, GeneralOptionsPage): GeneralOptionsPage.setObjectName("GeneralOptionsPage") GeneralOptionsPage.resize(403, 640) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(GeneralOptionsPage.sizePolicy().hasHeightForWidth()) GeneralOptionsPage.setSizePolicy(sizePolicy) self.vboxlayout = QtWidgets.QVBoxLayout(GeneralOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.groupBox = QtWidgets.QGroupBox(parent=GeneralOptionsPage) self.groupBox.setObjectName("groupBox") self.gridlayout = QtWidgets.QGridLayout(self.groupBox) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.server_port = QtWidgets.QSpinBox(parent=self.groupBox) self.server_port.setMinimum(1) self.server_port.setMaximum(65535) self.server_port.setProperty("value", 80) self.server_port.setObjectName("server_port") self.gridlayout.addWidget(self.server_port, 1, 1, 1, 1) self.server_host_primary_warning = QtWidgets.QFrame(parent=self.groupBox) self.server_host_primary_warning.setStyleSheet("QFrame { background-color: #ffc107; color: black }\n" "QCheckBox { color: black }") self.server_host_primary_warning.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.server_host_primary_warning.setObjectName("server_host_primary_warning") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.server_host_primary_warning) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_4 = QtWidgets.QLabel(parent=self.server_host_primary_warning) self.label_4.setWordWrap(True) self.label_4.setObjectName("label_4") self.verticalLayout_4.addWidget(self.label_4) self.use_server_for_submission = QtWidgets.QCheckBox(parent=self.server_host_primary_warning) self.use_server_for_submission.setObjectName("use_server_for_submission") self.verticalLayout_4.addWidget(self.use_server_for_submission) self.gridlayout.addWidget(self.server_host_primary_warning, 3, 0, 1, 2) self.server_host = QtWidgets.QComboBox(parent=self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.server_host.sizePolicy().hasHeightForWidth()) self.server_host.setSizePolicy(sizePolicy) self.server_host.setEditable(True) self.server_host.setObjectName("server_host") self.gridlayout.addWidget(self.server_host, 1, 0, 1, 1) self.label_7 = QtWidgets.QLabel(parent=self.groupBox) self.label_7.setObjectName("label_7") self.gridlayout.addWidget(self.label_7, 0, 1, 1, 1) self.label = QtWidgets.QLabel(parent=self.groupBox) self.label.setObjectName("label") self.gridlayout.addWidget(self.label, 0, 0, 1, 1) spacerItem = QtWidgets.QSpacerItem(1, 4, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.gridlayout.addItem(spacerItem, 2, 0, 1, 1) self.vboxlayout.addWidget(self.groupBox) self.rename_files_2 = QtWidgets.QGroupBox(parent=GeneralOptionsPage) self.rename_files_2.setObjectName("rename_files_2") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.rename_files_2) self.verticalLayout_3.setSpacing(2) self.verticalLayout_3.setObjectName("verticalLayout_3") self.login_error = QtWidgets.QLabel(parent=self.rename_files_2) self.login_error.setText("") self.login_error.setObjectName("login_error") self.verticalLayout_3.addWidget(self.login_error) self.logged_in = QtWidgets.QLabel(parent=self.rename_files_2) self.logged_in.setText("") self.logged_in.setObjectName("logged_in") self.verticalLayout_3.addWidget(self.logged_in) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setSpacing(6) self.horizontalLayout.setObjectName("horizontalLayout") self.login = QtWidgets.QPushButton(parent=self.rename_files_2) self.login.setObjectName("login") self.horizontalLayout.addWidget(self.login) self.logout = QtWidgets.QPushButton(parent=self.rename_files_2) self.logout.setObjectName("logout") self.horizontalLayout.addWidget(self.logout) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.verticalLayout_3.addLayout(self.horizontalLayout) self.vboxlayout.addWidget(self.rename_files_2) self.groupBox_2 = QtWidgets.QGroupBox(parent=GeneralOptionsPage) self.groupBox_2.setObjectName("groupBox_2") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_2) self.verticalLayout.setObjectName("verticalLayout") self.analyze_new_files = QtWidgets.QCheckBox(parent=self.groupBox_2) self.analyze_new_files.setObjectName("analyze_new_files") self.verticalLayout.addWidget(self.analyze_new_files) self.cluster_new_files = QtWidgets.QCheckBox(parent=self.groupBox_2) self.cluster_new_files.setObjectName("cluster_new_files") self.verticalLayout.addWidget(self.cluster_new_files) self.ignore_file_mbids = QtWidgets.QCheckBox(parent=self.groupBox_2) self.ignore_file_mbids.setObjectName("ignore_file_mbids") self.verticalLayout.addWidget(self.ignore_file_mbids) self.vboxlayout.addWidget(self.groupBox_2) self.update_check_groupbox = QtWidgets.QGroupBox(parent=GeneralOptionsPage) self.update_check_groupbox.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.update_check_groupbox.sizePolicy().hasHeightForWidth()) self.update_check_groupbox.setSizePolicy(sizePolicy) self.update_check_groupbox.setObjectName("update_check_groupbox") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.update_check_groupbox) self.verticalLayout_2.setObjectName("verticalLayout_2") self.check_for_plugin_updates = QtWidgets.QCheckBox(parent=self.update_check_groupbox) self.check_for_plugin_updates.setObjectName("check_for_plugin_updates") self.verticalLayout_2.addWidget(self.check_for_plugin_updates) self.program_update_check_group = QtWidgets.QWidget(parent=self.update_check_groupbox) self.program_update_check_group.setMinimumSize(QtCore.QSize(0, 0)) self.program_update_check_group.setObjectName("program_update_check_group") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.program_update_check_group) self.verticalLayout_6.setContentsMargins(0, 0, 0, 0) self.verticalLayout_6.setObjectName("verticalLayout_6") self.check_for_updates = QtWidgets.QCheckBox(parent=self.program_update_check_group) self.check_for_updates.setObjectName("check_for_updates") self.verticalLayout_6.addWidget(self.check_for_updates) self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setContentsMargins(-1, -1, -1, 0) self.gridLayout.setObjectName("gridLayout") self.label_2 = QtWidgets.QLabel(parent=self.program_update_check_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) self.label_2.setSizePolicy(sizePolicy) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1) self.update_check_days = QtWidgets.QSpinBox(parent=self.program_update_check_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.update_check_days.sizePolicy().hasHeightForWidth()) self.update_check_days.setSizePolicy(sizePolicy) self.update_check_days.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter) self.update_check_days.setMinimum(1) self.update_check_days.setObjectName("update_check_days") self.gridLayout.addWidget(self.update_check_days, 0, 1, 1, 1) self.gridLayout_2 = QtWidgets.QGridLayout() self.gridLayout_2.setContentsMargins(-1, -1, -1, 0) self.gridLayout_2.setObjectName("gridLayout_2") self.label_3 = QtWidgets.QLabel(parent=self.program_update_check_group) self.label_3.setObjectName("label_3") self.gridLayout_2.addWidget(self.label_3, 0, 0, 1, 1) self.update_level = QtWidgets.QComboBox(parent=self.program_update_check_group) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.update_level.sizePolicy().hasHeightForWidth()) self.update_level.setSizePolicy(sizePolicy) self.update_level.setEditable(False) self.update_level.setObjectName("update_level") self.gridLayout_2.addWidget(self.update_level, 0, 1, 1, 1) self.gridLayout.addLayout(self.gridLayout_2, 1, 0, 1, 1) self.verticalLayout_6.addLayout(self.gridLayout) self.verticalLayout_2.addWidget(self.program_update_check_group) self.program_update_check_frame = QtWidgets.QFrame(parent=self.update_check_groupbox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.program_update_check_frame.sizePolicy().hasHeightForWidth()) self.program_update_check_frame.setSizePolicy(sizePolicy) self.program_update_check_frame.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.program_update_check_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Plain) self.program_update_check_frame.setObjectName("program_update_check_frame") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.program_update_check_frame) self.verticalLayout_5.setContentsMargins(0, 0, 0, 0) self.verticalLayout_5.setObjectName("verticalLayout_5") self.verticalLayout_2.addWidget(self.program_update_check_frame) self.vboxlayout.addWidget(self.update_check_groupbox) spacerItem2 = QtWidgets.QSpacerItem(181, 21, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem2) self.retranslateUi(GeneralOptionsPage) QtCore.QMetaObject.connectSlotsByName(GeneralOptionsPage) GeneralOptionsPage.setTabOrder(self.server_host, self.server_port) GeneralOptionsPage.setTabOrder(self.server_port, self.use_server_for_submission) GeneralOptionsPage.setTabOrder(self.use_server_for_submission, self.login) GeneralOptionsPage.setTabOrder(self.login, self.logout) GeneralOptionsPage.setTabOrder(self.logout, self.analyze_new_files) GeneralOptionsPage.setTabOrder(self.analyze_new_files, self.cluster_new_files) GeneralOptionsPage.setTabOrder(self.cluster_new_files, self.ignore_file_mbids) GeneralOptionsPage.setTabOrder(self.ignore_file_mbids, self.check_for_plugin_updates) GeneralOptionsPage.setTabOrder(self.check_for_plugin_updates, self.check_for_updates) GeneralOptionsPage.setTabOrder(self.check_for_updates, self.update_check_days) GeneralOptionsPage.setTabOrder(self.update_check_days, self.update_level) def retranslateUi(self, GeneralOptionsPage): self.groupBox.setTitle(_("MusicBrainz Server")) self.label_4.setText(_("You have configured an unofficial MusicBrainz server. By default submissions of releases, recordings and disc IDs will go to the primary database on musicbrainz.org.")) self.use_server_for_submission.setText(_("Submit data to the configured server")) self.label_7.setText(_("Port:")) self.label.setText(_("Server address:")) self.rename_files_2.setTitle(_("MusicBrainz Account")) self.login.setText(_("Log in")) self.logout.setText(_("Log out")) self.groupBox_2.setTitle(_("General")) self.analyze_new_files.setText(_("Automatically scan all new files")) self.cluster_new_files.setText(_("Automatically cluster all new files")) self.ignore_file_mbids.setText(_("Ignore MBIDs when loading new files")) self.update_check_groupbox.setTitle(_("Update Checking")) self.check_for_plugin_updates.setText(_("Check for plugin updates during startup")) self.check_for_updates.setText(_("Check for program updates during startup")) self.label_2.setText(_("Days between checks:")) self.label_3.setText(_("Updates to check:"))
14,096
Python
.py
215
57.037209
200
0.739748
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,029
ui_options_cdlookup.py
metabrainz_picard/picard/ui/forms/ui_options_cdlookup.py
# Form implementation generated from reading ui file 'ui/options_cdlookup.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CDLookupOptionsPage(object): def setupUi(self, CDLookupOptionsPage): CDLookupOptionsPage.setObjectName("CDLookupOptionsPage") CDLookupOptionsPage.resize(224, 176) self.vboxlayout = QtWidgets.QVBoxLayout(CDLookupOptionsPage) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.rename_files = QtWidgets.QGroupBox(parent=CDLookupOptionsPage) self.rename_files.setObjectName("rename_files") self.gridlayout = QtWidgets.QGridLayout(self.rename_files) self.gridlayout.setContentsMargins(9, 9, 9, 9) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.cd_lookup_device = QtWidgets.QLineEdit(parent=self.rename_files) self.cd_lookup_device.setObjectName("cd_lookup_device") self.gridlayout.addWidget(self.cd_lookup_device, 1, 0, 1, 1) self.label_3 = QtWidgets.QLabel(parent=self.rename_files) self.label_3.setObjectName("label_3") self.gridlayout.addWidget(self.label_3, 0, 0, 1, 1) self.vboxlayout.addWidget(self.rename_files) spacerItem = QtWidgets.QSpacerItem(161, 81, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem) self.label_3.setBuddy(self.cd_lookup_device) self.retranslateUi(CDLookupOptionsPage) QtCore.QMetaObject.connectSlotsByName(CDLookupOptionsPage) def retranslateUi(self, CDLookupOptionsPage): self.rename_files.setTitle(_("CD Lookup")) self.label_3.setText(_("CD-ROM device to use for lookups:"))
2,015
Python
.py
41
42.439024
129
0.729167
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,030
ui_aboutdialog.py
metabrainz_picard/picard/ui/forms/ui_aboutdialog.py
# Form implementation generated from reading ui file 'ui/aboutdialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_AboutDialog(object): def setupUi(self, AboutDialog): AboutDialog.setObjectName("AboutDialog") AboutDialog.resize(680, 480) AboutDialog.setMinimumSize(QtCore.QSize(400, 300)) self.vboxlayout = QtWidgets.QVBoxLayout(AboutDialog) self.vboxlayout.setContentsMargins(0, 0, 0, 0) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.header = QtWidgets.QHBoxLayout() self.header.setContentsMargins(9, 9, 9, 0) self.header.setObjectName("header") spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.header.addItem(spacerItem) self.logo = QtWidgets.QLabel(parent=AboutDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.logo.sizePolicy().hasHeightForWidth()) self.logo.setSizePolicy(sizePolicy) self.logo.setMinimumSize(QtCore.QSize(48, 48)) self.logo.setMaximumSize(QtCore.QSize(48, 48)) self.logo.setPixmap(QtGui.QPixmap(":/images/128x128/org.musicbrainz.Picard.png")) self.logo.setScaledContents(True) self.logo.setObjectName("logo") self.header.addWidget(self.logo) self.app_name = QtWidgets.QLabel(parent=AboutDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.app_name.sizePolicy().hasHeightForWidth()) self.app_name.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(20) font.setBold(True) font.setWeight(75) self.app_name.setFont(font) self.app_name.setTextFormat(QtCore.Qt.TextFormat.PlainText) self.app_name.setObjectName("app_name") self.header.addWidget(self.app_name) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.header.addItem(spacerItem1) self.vboxlayout.addLayout(self.header) self.scrollArea = QtWidgets.QScrollArea(parent=AboutDialog) self.scrollArea.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.scrollArea.setFrameShadow(QtWidgets.QFrame.Shadow.Plain) self.scrollArea.setLineWidth(0) self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.scrollArea.setWidgetResizable(True) self.scrollArea.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 680, 416)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setContentsMargins(9, 0, 9, 9) self.verticalLayout.setSpacing(6) self.verticalLayout.setObjectName("verticalLayout") self.label = QtWidgets.QLabel(parent=self.scrollAreaWidgetContents) self.label.setText("") self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter|QtCore.Qt.AlignmentFlag.AlignTop) self.label.setWordWrap(True) self.label.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByKeyboard|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.vboxlayout.addWidget(self.scrollArea) self.retranslateUi(AboutDialog) QtCore.QMetaObject.connectSlotsByName(AboutDialog) def retranslateUi(self, AboutDialog): AboutDialog.setWindowTitle(_("About Picard")) self.app_name.setText(_("MusicBrainz Picard"))
4,631
Python
.py
84
47.25
203
0.746311
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,031
ui_scripting_documentation_dialog.py
metabrainz_picard/picard/ui/forms/ui_scripting_documentation_dialog.py
# Form implementation generated from reading ui file 'ui/scripting_documentation_dialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ScriptingDocumentationDialog(object): def setupUi(self, ScriptingDocumentationDialog): ScriptingDocumentationDialog.setObjectName("ScriptingDocumentationDialog") ScriptingDocumentationDialog.resize(725, 457) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(ScriptingDocumentationDialog.sizePolicy().hasHeightForWidth()) ScriptingDocumentationDialog.setSizePolicy(sizePolicy) ScriptingDocumentationDialog.setModal(False) self.verticalLayout = QtWidgets.QVBoxLayout(ScriptingDocumentationDialog) self.verticalLayout.setObjectName("verticalLayout") self.documentation_layout = QtWidgets.QVBoxLayout() self.documentation_layout.setObjectName("documentation_layout") self.verticalLayout.addLayout(self.documentation_layout) self.buttonBox = QtWidgets.QDialogButtonBox(parent=ScriptingDocumentationDialog) self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Close) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(ScriptingDocumentationDialog) QtCore.QMetaObject.connectSlotsByName(ScriptingDocumentationDialog) def retranslateUi(self, ScriptingDocumentationDialog): ScriptingDocumentationDialog.setWindowTitle(_("Scripting Documentation"))
1,960
Python
.py
36
48.055556
122
0.791971
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,032
ui_options_cdlookup_select.py
metabrainz_picard/picard/ui/forms/ui_options_cdlookup_select.py
# Form implementation generated from reading ui file 'ui/options_cdlookup_select.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CDLookupOptionsPage(object): def setupUi(self, CDLookupOptionsPage): CDLookupOptionsPage.setObjectName("CDLookupOptionsPage") CDLookupOptionsPage.resize(255, 155) self.vboxlayout = QtWidgets.QVBoxLayout(CDLookupOptionsPage) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.rename_files = QtWidgets.QGroupBox(parent=CDLookupOptionsPage) self.rename_files.setObjectName("rename_files") self.gridlayout = QtWidgets.QGridLayout(self.rename_files) self.gridlayout.setContentsMargins(9, 9, 9, 9) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.cd_lookup_ = QtWidgets.QLabel(parent=self.rename_files) self.cd_lookup_.setObjectName("cd_lookup_") self.gridlayout.addWidget(self.cd_lookup_, 0, 0, 1, 1) self.hboxlayout = QtWidgets.QHBoxLayout() self.hboxlayout.setContentsMargins(0, 0, 0, 0) self.hboxlayout.setSpacing(6) self.hboxlayout.setObjectName("hboxlayout") self.cd_lookup_device = QtWidgets.QComboBox(parent=self.rename_files) self.cd_lookup_device.setObjectName("cd_lookup_device") self.hboxlayout.addWidget(self.cd_lookup_device) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.hboxlayout.addItem(spacerItem) self.gridlayout.addLayout(self.hboxlayout, 1, 0, 1, 1) self.vboxlayout.addWidget(self.rename_files) spacerItem1 = QtWidgets.QSpacerItem(161, 81, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem1) self.cd_lookup_.setBuddy(self.cd_lookup_device) self.retranslateUi(CDLookupOptionsPage) QtCore.QMetaObject.connectSlotsByName(CDLookupOptionsPage) def retranslateUi(self, CDLookupOptionsPage): self.rename_files.setTitle(_("CD Lookup")) self.cd_lookup_.setText(_("Default CD-ROM drive to use for lookups:"))
2,468
Python
.py
48
44.375
130
0.730323
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,033
ui_options_renaming.py
metabrainz_picard/picard/ui/forms/ui_options_renaming.py
# Form implementation generated from reading ui file 'ui/options_renaming.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_RenamingOptionsPage(object): def setupUi(self, RenamingOptionsPage): RenamingOptionsPage.setObjectName("RenamingOptionsPage") RenamingOptionsPage.setEnabled(True) RenamingOptionsPage.resize(453, 489) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(RenamingOptionsPage.sizePolicy().hasHeightForWidth()) RenamingOptionsPage.setSizePolicy(sizePolicy) self.verticalLayout_5 = QtWidgets.QVBoxLayout(RenamingOptionsPage) self.verticalLayout_5.setObjectName("verticalLayout_5") self.move_files = QtWidgets.QGroupBox(parent=RenamingOptionsPage) self.move_files.setFlat(False) self.move_files.setCheckable(True) self.move_files.setChecked(False) self.move_files.setObjectName("move_files") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.move_files) self.verticalLayout_4.setObjectName("verticalLayout_4") self.label = QtWidgets.QLabel(parent=self.move_files) self.label.setObjectName("label") self.verticalLayout_4.addWidget(self.label) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setSpacing(2) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.move_files_to = QtWidgets.QLineEdit(parent=self.move_files) self.move_files_to.setObjectName("move_files_to") self.horizontalLayout_4.addWidget(self.move_files_to) self.move_files_to_browse = QtWidgets.QPushButton(parent=self.move_files) self.move_files_to_browse.setObjectName("move_files_to_browse") self.horizontalLayout_4.addWidget(self.move_files_to_browse) self.verticalLayout_4.addLayout(self.horizontalLayout_4) self.move_additional_files = QtWidgets.QCheckBox(parent=self.move_files) self.move_additional_files.setObjectName("move_additional_files") self.verticalLayout_4.addWidget(self.move_additional_files) self.move_additional_files_pattern = QtWidgets.QLineEdit(parent=self.move_files) self.move_additional_files_pattern.setObjectName("move_additional_files_pattern") self.verticalLayout_4.addWidget(self.move_additional_files_pattern) self.delete_empty_dirs = QtWidgets.QCheckBox(parent=self.move_files) self.delete_empty_dirs.setObjectName("delete_empty_dirs") self.verticalLayout_4.addWidget(self.delete_empty_dirs) self.verticalLayout_5.addWidget(self.move_files) self.rename_files = QtWidgets.QCheckBox(parent=RenamingOptionsPage) self.rename_files.setObjectName("rename_files") self.verticalLayout_5.addWidget(self.rename_files) self.label_2 = QtWidgets.QLabel(parent=RenamingOptionsPage) self.label_2.setObjectName("label_2") self.verticalLayout_5.addWidget(self.label_2) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setSpacing(2) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.naming_script_selector = QtWidgets.QComboBox(parent=RenamingOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.naming_script_selector.sizePolicy().hasHeightForWidth()) self.naming_script_selector.setSizePolicy(sizePolicy) self.naming_script_selector.setObjectName("naming_script_selector") self.horizontalLayout_2.addWidget(self.naming_script_selector) self.open_script_editor = QtWidgets.QPushButton(parent=RenamingOptionsPage) self.open_script_editor.setObjectName("open_script_editor") self.horizontalLayout_2.addWidget(self.open_script_editor) self.verticalLayout_5.addLayout(self.horizontalLayout_2) self.groupBox = QtWidgets.QGroupBox(parent=RenamingOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setMinimumSize(QtCore.QSize(0, 120)) self.groupBox.setObjectName("groupBox") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.groupBox) self.verticalLayout_6.setContentsMargins(3, 3, 3, 3) self.verticalLayout_6.setObjectName("verticalLayout_6") self.renaming_options_examples_splitter = QtWidgets.QSplitter(parent=self.groupBox) self.renaming_options_examples_splitter.setOrientation(QtCore.Qt.Orientation.Horizontal) self.renaming_options_examples_splitter.setObjectName("renaming_options_examples_splitter") self.frame = QtWidgets.QFrame(parent=self.renaming_options_examples_splitter) self.frame.setMinimumSize(QtCore.QSize(100, 0)) self.frame.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame.setObjectName("frame") self.verticalLayout = QtWidgets.QVBoxLayout(self.frame) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setSpacing(3) self.verticalLayout.setObjectName("verticalLayout") self.example_filename_before_label = QtWidgets.QLabel(parent=self.frame) self.example_filename_before_label.setObjectName("example_filename_before_label") self.verticalLayout.addWidget(self.example_filename_before_label) self.example_filename_before = QtWidgets.QListWidget(parent=self.frame) self.example_filename_before.setObjectName("example_filename_before") self.verticalLayout.addWidget(self.example_filename_before) self.frame_2 = QtWidgets.QFrame(parent=self.renaming_options_examples_splitter) self.frame_2.setMinimumSize(QtCore.QSize(100, 0)) self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame_2.setObjectName("frame_2") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.frame_2) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.verticalLayout_3.setSpacing(3) self.verticalLayout_3.setObjectName("verticalLayout_3") self.example_filename_after_label = QtWidgets.QLabel(parent=self.frame_2) self.example_filename_after_label.setObjectName("example_filename_after_label") self.verticalLayout_3.addWidget(self.example_filename_after_label) self.example_filename_after = QtWidgets.QListWidget(parent=self.frame_2) self.example_filename_after.setObjectName("example_filename_after") self.verticalLayout_3.addWidget(self.example_filename_after) self.verticalLayout_6.addWidget(self.renaming_options_examples_splitter) self.verticalLayout_5.addWidget(self.groupBox) self.example_selection_note = QtWidgets.QLabel(parent=RenamingOptionsPage) self.example_selection_note.setText("") self.example_selection_note.setWordWrap(True) self.example_selection_note.setObjectName("example_selection_note") self.verticalLayout_5.addWidget(self.example_selection_note) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName("horizontalLayout") self.example_filename_sample_files_button = QtWidgets.QPushButton(parent=RenamingOptionsPage) self.example_filename_sample_files_button.setObjectName("example_filename_sample_files_button") self.horizontalLayout.addWidget(self.example_filename_sample_files_button) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.verticalLayout_5.addLayout(self.horizontalLayout) self.retranslateUi(RenamingOptionsPage) QtCore.QMetaObject.connectSlotsByName(RenamingOptionsPage) RenamingOptionsPage.setTabOrder(self.move_files, self.move_files_to) RenamingOptionsPage.setTabOrder(self.move_files_to, self.move_files_to_browse) RenamingOptionsPage.setTabOrder(self.move_files_to_browse, self.move_additional_files) RenamingOptionsPage.setTabOrder(self.move_additional_files, self.move_additional_files_pattern) RenamingOptionsPage.setTabOrder(self.move_additional_files_pattern, self.delete_empty_dirs) RenamingOptionsPage.setTabOrder(self.delete_empty_dirs, self.rename_files) RenamingOptionsPage.setTabOrder(self.rename_files, self.naming_script_selector) RenamingOptionsPage.setTabOrder(self.naming_script_selector, self.open_script_editor) RenamingOptionsPage.setTabOrder(self.open_script_editor, self.example_filename_before) RenamingOptionsPage.setTabOrder(self.example_filename_before, self.example_filename_after) RenamingOptionsPage.setTabOrder(self.example_filename_after, self.example_filename_sample_files_button) def retranslateUi(self, RenamingOptionsPage): self.move_files.setTitle(_("Move files when saving")) self.label.setText(_("Destination directory:")) self.move_files_to_browse.setText(_("Browse…")) self.move_additional_files.setText(_("Move additional files (case insensitive):")) self.delete_empty_dirs.setText(_("Delete empty directories")) self.rename_files.setText(_("Rename files when saving")) self.label_2.setText(_("Selected file naming script:")) self.open_script_editor.setText(_("Edit file naming script…")) self.groupBox.setTitle(_("Files will be named like this:")) self.example_filename_before_label.setText(_("Before")) self.example_filename_after_label.setText(_("After")) self.example_filename_sample_files_button.setText(_("Reload examples"))
10,621
Python
.py
161
57.52795
129
0.752249
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,034
ui_options_interface_colors.py
metabrainz_picard/picard/ui/forms/ui_options_interface_colors.py
# Form implementation generated from reading ui file 'ui/options_interface_colors.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InterfaceColorsOptionsPage(object): def setupUi(self, InterfaceColorsOptionsPage): InterfaceColorsOptionsPage.setObjectName("InterfaceColorsOptionsPage") InterfaceColorsOptionsPage.resize(171, 137) self.vboxlayout = QtWidgets.QVBoxLayout(InterfaceColorsOptionsPage) self.vboxlayout.setContentsMargins(0, 0, 0, 0) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.scrollArea = QtWidgets.QScrollArea(parent=InterfaceColorsOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scrollArea.sizePolicy().hasHeightForWidth()) self.scrollArea.setSizePolicy(sizePolicy) self.scrollArea.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.scrollArea.setFrameShadow(QtWidgets.QFrame.Shadow.Plain) self.scrollArea.setLineWidth(0) self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.scrollArea.setWidgetResizable(True) self.scrollArea.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.scrollArea.setObjectName("scrollArea") self.scrollAreaWidgetContents = QtWidgets.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 199, 137)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents) self.verticalLayout.setContentsMargins(9, 9, 9, 9) self.verticalLayout.setSpacing(6) self.verticalLayout.setObjectName("verticalLayout") self.colors = QtWidgets.QGroupBox(parent=self.scrollAreaWidgetContents) self.colors.setObjectName("colors") self.verticalLayout.addWidget(self.colors) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.vboxlayout.addWidget(self.scrollArea) self.retranslateUi(InterfaceColorsOptionsPage) QtCore.QMetaObject.connectSlotsByName(InterfaceColorsOptionsPage) def retranslateUi(self, InterfaceColorsOptionsPage): self.colors.setTitle(_("Colors"))
2,705
Python
.py
49
48.122449
141
0.772453
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,035
ui_options.py
metabrainz_picard/picard/ui/forms/ui_options.py
# Form implementation generated from reading ui file 'ui/options.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_OptionsDialog(object): def setupUi(self, OptionsDialog): OptionsDialog.setObjectName("OptionsDialog") OptionsDialog.resize(800, 450) self.vboxlayout = QtWidgets.QVBoxLayout(OptionsDialog) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.dialog_splitter = QtWidgets.QSplitter(parent=OptionsDialog) self.dialog_splitter.setOrientation(QtCore.Qt.Orientation.Horizontal) self.dialog_splitter.setChildrenCollapsible(False) self.dialog_splitter.setObjectName("dialog_splitter") self.pages_tree = QtWidgets.QTreeWidget(parent=self.dialog_splitter) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pages_tree.sizePolicy().hasHeightForWidth()) self.pages_tree.setSizePolicy(sizePolicy) self.pages_tree.setMinimumSize(QtCore.QSize(140, 0)) self.pages_tree.setObjectName("pages_tree") self.pages_stack = QtWidgets.QStackedWidget(parent=self.dialog_splitter) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.pages_stack.sizePolicy().hasHeightForWidth()) self.pages_stack.setSizePolicy(sizePolicy) self.pages_stack.setMinimumSize(QtCore.QSize(280, 0)) self.pages_stack.setObjectName("pages_stack") self.vboxlayout.addWidget(self.dialog_splitter) self.buttonbox = QtWidgets.QDialogButtonBox(parent=OptionsDialog) self.buttonbox.setMinimumSize(QtCore.QSize(0, 0)) self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonbox.setObjectName("buttonbox") self.vboxlayout.addWidget(self.buttonbox) self.retranslateUi(OptionsDialog) QtCore.QMetaObject.connectSlotsByName(OptionsDialog) def retranslateUi(self, OptionsDialog): OptionsDialog.setWindowTitle(_("Options"))
2,581
Python
.py
50
44.5
120
0.749307
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,036
ui_multi_locale_selector.py
metabrainz_picard/picard/ui/forms/ui_multi_locale_selector.py
# Form implementation generated from reading ui file 'ui/multi_locale_selector.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_MultiLocaleSelector(object): def setupUi(self, MultiLocaleSelector): MultiLocaleSelector.setObjectName("MultiLocaleSelector") MultiLocaleSelector.setWindowModality(QtCore.Qt.WindowModality.WindowModal) MultiLocaleSelector.resize(507, 284) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(MultiLocaleSelector.sizePolicy().hasHeightForWidth()) MultiLocaleSelector.setSizePolicy(sizePolicy) self.verticalLayout = QtWidgets.QVBoxLayout(MultiLocaleSelector) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.label = QtWidgets.QLabel(parent=MultiLocaleSelector) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.selected_locales = QtWidgets.QListWidget(parent=MultiLocaleSelector) self.selected_locales.setObjectName("selected_locales") self.verticalLayout_2.addWidget(self.selected_locales) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout_3 = QtWidgets.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.move_up = QtWidgets.QToolButton(parent=MultiLocaleSelector) self.move_up.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.move_up.setIcon(icon) self.move_up.setObjectName("move_up") self.verticalLayout_3.addWidget(self.move_up) self.add_locale = QtWidgets.QToolButton(parent=MultiLocaleSelector) self.add_locale.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-previous.png") self.add_locale.setIcon(icon) self.add_locale.setObjectName("add_locale") self.verticalLayout_3.addWidget(self.add_locale) self.remove_locale = QtWidgets.QToolButton(parent=MultiLocaleSelector) self.remove_locale.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-next.png") self.remove_locale.setIcon(icon) self.remove_locale.setObjectName("remove_locale") self.verticalLayout_3.addWidget(self.remove_locale) self.move_down = QtWidgets.QToolButton(parent=MultiLocaleSelector) self.move_down.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.move_down.setIcon(icon) self.move_down.setObjectName("move_down") self.verticalLayout_3.addWidget(self.move_down) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem1) self.horizontalLayout.addLayout(self.verticalLayout_3) self.verticalLayout_4 = QtWidgets.QVBoxLayout() self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_2 = QtWidgets.QLabel(parent=MultiLocaleSelector) self.label_2.setObjectName("label_2") self.verticalLayout_4.addWidget(self.label_2) self.available_locales = QtWidgets.QListWidget(parent=MultiLocaleSelector) self.available_locales.setObjectName("available_locales") self.verticalLayout_4.addWidget(self.available_locales) self.horizontalLayout.addLayout(self.verticalLayout_4) self.verticalLayout.addLayout(self.horizontalLayout) self.button_box = QtWidgets.QDialogButtonBox(parent=MultiLocaleSelector) self.button_box.setOrientation(QtCore.Qt.Orientation.Horizontal) self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Save) self.button_box.setObjectName("button_box") self.verticalLayout.addWidget(self.button_box) self.retranslateUi(MultiLocaleSelector) QtCore.QMetaObject.connectSlotsByName(MultiLocaleSelector) def retranslateUi(self, MultiLocaleSelector): MultiLocaleSelector.setWindowTitle(_("Locale Selector")) self.label.setText(_("Selected Locales")) self.move_up.setToolTip(_("Move selected locale up")) self.add_locale.setToolTip(_("Add to selected locales")) self.remove_locale.setToolTip(_("Remove selected locale")) self.move_down.setToolTip(_("Move selected locale down")) self.label_2.setText(_("Available Locales"))
5,217
Python
.py
91
49.362637
139
0.740625
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,037
ui_options_genres.py
metabrainz_picard/picard/ui/forms/ui_options_genres.py
# Form implementation generated from reading ui file 'ui/options_genres.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_GenresOptionsPage(object): def setupUi(self, GenresOptionsPage): GenresOptionsPage.setObjectName("GenresOptionsPage") GenresOptionsPage.resize(590, 471) self.verticalLayout_2 = QtWidgets.QVBoxLayout(GenresOptionsPage) self.verticalLayout_2.setObjectName("verticalLayout_2") self.use_genres = QtWidgets.QGroupBox(parent=GenresOptionsPage) self.use_genres.setFlat(False) self.use_genres.setCheckable(True) self.use_genres.setChecked(False) self.use_genres.setObjectName("use_genres") self.verticalLayout = QtWidgets.QVBoxLayout(self.use_genres) self.verticalLayout.setObjectName("verticalLayout") self.only_my_genres = QtWidgets.QCheckBox(parent=self.use_genres) self.only_my_genres.setObjectName("only_my_genres") self.verticalLayout.addWidget(self.only_my_genres) self.artists_genres = QtWidgets.QCheckBox(parent=self.use_genres) self.artists_genres.setObjectName("artists_genres") self.verticalLayout.addWidget(self.artists_genres) self.folksonomy_tags = QtWidgets.QCheckBox(parent=self.use_genres) self.folksonomy_tags.setObjectName("folksonomy_tags") self.verticalLayout.addWidget(self.folksonomy_tags) self.hboxlayout = QtWidgets.QHBoxLayout() self.hboxlayout.setContentsMargins(0, 0, 0, 0) self.hboxlayout.setSpacing(6) self.hboxlayout.setObjectName("hboxlayout") self.label_5 = QtWidgets.QLabel(parent=self.use_genres) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) self.label_5.setSizePolicy(sizePolicy) self.label_5.setObjectName("label_5") self.hboxlayout.addWidget(self.label_5) self.min_genre_usage = QtWidgets.QSpinBox(parent=self.use_genres) self.min_genre_usage.setMaximum(100) self.min_genre_usage.setObjectName("min_genre_usage") self.hboxlayout.addWidget(self.min_genre_usage) self.verticalLayout.addLayout(self.hboxlayout) self.hboxlayout1 = QtWidgets.QHBoxLayout() self.hboxlayout1.setContentsMargins(0, 0, 0, 0) self.hboxlayout1.setSpacing(6) self.hboxlayout1.setObjectName("hboxlayout1") self.label_6 = QtWidgets.QLabel(parent=self.use_genres) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) self.label_6.setSizePolicy(sizePolicy) self.label_6.setObjectName("label_6") self.hboxlayout1.addWidget(self.label_6) self.max_genres = QtWidgets.QSpinBox(parent=self.use_genres) self.max_genres.setMaximum(100) self.max_genres.setObjectName("max_genres") self.hboxlayout1.addWidget(self.max_genres) self.verticalLayout.addLayout(self.hboxlayout1) self.hboxlayout2 = QtWidgets.QHBoxLayout() self.hboxlayout2.setContentsMargins(0, 0, 0, 0) self.hboxlayout2.setSpacing(6) self.hboxlayout2.setObjectName("hboxlayout2") self.ignore_genres_4 = QtWidgets.QLabel(parent=self.use_genres) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(4) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ignore_genres_4.sizePolicy().hasHeightForWidth()) self.ignore_genres_4.setSizePolicy(sizePolicy) self.ignore_genres_4.setObjectName("ignore_genres_4") self.hboxlayout2.addWidget(self.ignore_genres_4) self.join_genres = QtWidgets.QComboBox(parent=self.use_genres) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.join_genres.sizePolicy().hasHeightForWidth()) self.join_genres.setSizePolicy(sizePolicy) self.join_genres.setEditable(True) self.join_genres.setObjectName("join_genres") self.join_genres.addItem("") self.join_genres.setItemText(0, "") self.join_genres.addItem("") self.join_genres.addItem("") self.hboxlayout2.addWidget(self.join_genres) self.verticalLayout.addLayout(self.hboxlayout2) self.label_genres_filter = QtWidgets.QLabel(parent=self.use_genres) self.label_genres_filter.setObjectName("label_genres_filter") self.verticalLayout.addWidget(self.label_genres_filter) self.genres_filter = QtWidgets.QPlainTextEdit(parent=self.use_genres) self.genres_filter.setObjectName("genres_filter") self.verticalLayout.addWidget(self.genres_filter) self.label_test_genres_filter = QtWidgets.QLabel(parent=self.use_genres) self.label_test_genres_filter.setObjectName("label_test_genres_filter") self.verticalLayout.addWidget(self.label_test_genres_filter) self.test_genres_filter = QtWidgets.QPlainTextEdit(parent=self.use_genres) self.test_genres_filter.setObjectName("test_genres_filter") self.verticalLayout.addWidget(self.test_genres_filter) self.label_test_genres_filter_error = QtWidgets.QLabel(parent=self.use_genres) self.label_test_genres_filter_error.setText("") self.label_test_genres_filter_error.setObjectName("label_test_genres_filter_error") self.verticalLayout.addWidget(self.label_test_genres_filter_error) self.verticalLayout_2.addWidget(self.use_genres) spacerItem = QtWidgets.QSpacerItem(181, 31, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_2.addItem(spacerItem) self.label_5.setBuddy(self.min_genre_usage) self.label_6.setBuddy(self.min_genre_usage) self.retranslateUi(GenresOptionsPage) QtCore.QMetaObject.connectSlotsByName(GenresOptionsPage) def retranslateUi(self, GenresOptionsPage): self.use_genres.setTitle(_("Use genres from MusicBrainz")) self.only_my_genres.setText(_("Use only my genres")) self.artists_genres.setText(_("Fall back on album\'s artists genres if no genres are found for the release or release group")) self.folksonomy_tags.setText(_("Use folksonomy tags as genre")) self.label_5.setText(_("Minimal genre usage:")) self.min_genre_usage.setSuffix(_(" %")) self.label_6.setText(_("Maximum number of genres:")) self.ignore_genres_4.setText(_("Join multiple genres with:")) self.join_genres.setItemText(1, _(" / ")) self.join_genres.setItemText(2, _(", ")) self.label_genres_filter.setText(_("Genres or folksonomy tags to include or exclude, one per line:")) self.label_test_genres_filter.setText(_("Playground for genres or folksonomy tags filters (cleared on exit):"))
7,619
Python
.py
130
50.330769
134
0.72805
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,038
ui_scripteditor.py
metabrainz_picard/picard/ui/forms/ui_scripteditor.py
# Form implementation generated from reading ui file 'ui/scripteditor.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ScriptEditor(object): def setupUi(self, ScriptEditor): ScriptEditor.setObjectName("ScriptEditor") ScriptEditor.resize(902, 729) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(ScriptEditor.sizePolicy().hasHeightForWidth()) ScriptEditor.setSizePolicy(sizePolicy) self.verticalLayout_3 = QtWidgets.QVBoxLayout(ScriptEditor) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.verticalLayout_3.setObjectName("verticalLayout_3") self.layout_for_menubar = QtWidgets.QHBoxLayout() self.layout_for_menubar.setSpacing(0) self.layout_for_menubar.setObjectName("layout_for_menubar") self.verticalLayout_3.addLayout(self.layout_for_menubar) self.content_layout = QtWidgets.QVBoxLayout() self.content_layout.setContentsMargins(9, 0, 9, 9) self.content_layout.setObjectName("content_layout") self.splitter_between_editor_and_examples = QtWidgets.QSplitter(parent=ScriptEditor) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.splitter_between_editor_and_examples.sizePolicy().hasHeightForWidth()) self.splitter_between_editor_and_examples.setSizePolicy(sizePolicy) self.splitter_between_editor_and_examples.setMinimumSize(QtCore.QSize(0, 0)) self.splitter_between_editor_and_examples.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.splitter_between_editor_and_examples.setOrientation(QtCore.Qt.Orientation.Vertical) self.splitter_between_editor_and_examples.setObjectName("splitter_between_editor_and_examples") self.frame_4 = QtWidgets.QFrame(parent=self.splitter_between_editor_and_examples) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(5) sizePolicy.setHeightForWidth(self.frame_4.sizePolicy().hasHeightForWidth()) self.frame_4.setSizePolicy(sizePolicy) self.frame_4.setMinimumSize(QtCore.QSize(0, 250)) self.frame_4.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame_4.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame_4.setObjectName("frame_4") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.frame_4) self.verticalLayout_5.setContentsMargins(0, 3, 0, 0) self.verticalLayout_5.setObjectName("verticalLayout_5") self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label = QtWidgets.QLabel(parent=self.frame_4) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) self.label.setMinimumSize(QtCore.QSize(0, 0)) self.label.setIndent(0) self.label.setObjectName("label") self.horizontalLayout_2.addWidget(self.label) self.preset_naming_scripts = QtWidgets.QComboBox(parent=self.frame_4) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.preset_naming_scripts.sizePolicy().hasHeightForWidth()) self.preset_naming_scripts.setSizePolicy(sizePolicy) self.preset_naming_scripts.setMinimumSize(QtCore.QSize(200, 0)) self.preset_naming_scripts.setObjectName("preset_naming_scripts") self.horizontalLayout_2.addWidget(self.preset_naming_scripts) self.verticalLayout_5.addLayout(self.horizontalLayout_2) self.frame = QtWidgets.QFrame(parent=self.frame_4) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth()) self.frame.setSizePolicy(sizePolicy) self.frame.setMinimumSize(QtCore.QSize(0, 200)) self.frame.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame.setObjectName("frame") self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.frame) self.verticalLayout_8.setContentsMargins(0, 0, 0, 0) self.verticalLayout_8.setObjectName("verticalLayout_8") self.splitter_between_editor_and_documentation = QtWidgets.QSplitter(parent=self.frame) self.splitter_between_editor_and_documentation.setMinimumSize(QtCore.QSize(0, 0)) self.splitter_between_editor_and_documentation.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.splitter_between_editor_and_documentation.setOrientation(QtCore.Qt.Orientation.Horizontal) self.splitter_between_editor_and_documentation.setOpaqueResize(True) self.splitter_between_editor_and_documentation.setObjectName("splitter_between_editor_and_documentation") self.frame_5 = QtWidgets.QFrame(parent=self.splitter_between_editor_and_documentation) self.frame_5.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame_5.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame_5.setObjectName("frame_5") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_5) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout.setObjectName("horizontalLayout") self.label_2 = QtWidgets.QLabel(parent=self.frame_5) self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) self.script_title = QtWidgets.QLineEdit(parent=self.frame_5) self.script_title.setObjectName("script_title") self.horizontalLayout.addWidget(self.script_title) self.verticalLayout_2.addLayout(self.horizontalLayout) self.file_naming_format = ScriptTextEdit(parent=self.frame_5) self.file_naming_format.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(5) sizePolicy.setHeightForWidth(self.file_naming_format.sizePolicy().hasHeightForWidth()) self.file_naming_format.setSizePolicy(sizePolicy) self.file_naming_format.setMinimumSize(QtCore.QSize(0, 50)) self.file_naming_format.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CursorShape.IBeamCursor)) self.file_naming_format.setTabChangesFocus(False) self.file_naming_format.setLineWrapMode(QtWidgets.QTextEdit.LineWrapMode.NoWrap) self.file_naming_format.setTabStopDistance(20.0) self.file_naming_format.setAcceptRichText(False) self.file_naming_format.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextEditorInteraction) self.file_naming_format.setObjectName("file_naming_format") self.verticalLayout_2.addWidget(self.file_naming_format) self.documentation_frame = QtWidgets.QFrame(parent=self.splitter_between_editor_and_documentation) self.documentation_frame.setMinimumSize(QtCore.QSize(100, 0)) self.documentation_frame.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.documentation_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.documentation_frame.setObjectName("documentation_frame") self.documentation_frame_layout = QtWidgets.QVBoxLayout(self.documentation_frame) self.documentation_frame_layout.setContentsMargins(0, 0, 0, 0) self.documentation_frame_layout.setObjectName("documentation_frame_layout") self.verticalLayout_8.addWidget(self.splitter_between_editor_and_documentation) self.verticalLayout_5.addWidget(self.frame) self.renaming_error = QtWidgets.QLabel(parent=self.frame_4) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.renaming_error.sizePolicy().hasHeightForWidth()) self.renaming_error.setSizePolicy(sizePolicy) self.renaming_error.setText("") self.renaming_error.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.renaming_error.setObjectName("renaming_error") self.verticalLayout_5.addWidget(self.renaming_error) self.groupBox = QtWidgets.QGroupBox(parent=self.splitter_between_editor_and_examples) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setMinimumSize(QtCore.QSize(300, 150)) self.groupBox.setMaximumSize(QtCore.QSize(16777215, 400)) self.groupBox.setBaseSize(QtCore.QSize(0, 150)) self.groupBox.setObjectName("groupBox") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox) self.verticalLayout.setContentsMargins(3, 3, 3, 3) self.verticalLayout.setObjectName("verticalLayout") self.splitter_between_before_and_after = QtWidgets.QSplitter(parent=self.groupBox) self.splitter_between_before_and_after.setOrientation(QtCore.Qt.Orientation.Horizontal) self.splitter_between_before_and_after.setOpaqueResize(True) self.splitter_between_before_and_after.setObjectName("splitter_between_before_and_after") self.frame_2 = QtWidgets.QFrame(parent=self.splitter_between_before_and_after) self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame_2.setObjectName("frame_2") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.frame_2) self.verticalLayout_4.setContentsMargins(0, 0, 0, 0) self.verticalLayout_4.setSpacing(3) self.verticalLayout_4.setObjectName("verticalLayout_4") self.example_filename_before_label = QtWidgets.QLabel(parent=self.frame_2) self.example_filename_before_label.setObjectName("example_filename_before_label") self.verticalLayout_4.addWidget(self.example_filename_before_label) self.example_filename_before = QtWidgets.QListWidget(parent=self.frame_2) self.example_filename_before.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.CurrentChanged|QtWidgets.QAbstractItemView.EditTrigger.DoubleClicked|QtWidgets.QAbstractItemView.EditTrigger.EditKeyPressed|QtWidgets.QAbstractItemView.EditTrigger.SelectedClicked) self.example_filename_before.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.example_filename_before.setObjectName("example_filename_before") self.verticalLayout_4.addWidget(self.example_filename_before) self.frame_3 = QtWidgets.QFrame(parent=self.splitter_between_before_and_after) self.frame_3.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.frame_3.setFrameShadow(QtWidgets.QFrame.Shadow.Raised) self.frame_3.setObjectName("frame_3") self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.frame_3) self.verticalLayout_6.setContentsMargins(0, 0, 0, 0) self.verticalLayout_6.setSpacing(3) self.verticalLayout_6.setObjectName("verticalLayout_6") self.example_filename_after_label = QtWidgets.QLabel(parent=self.frame_3) self.example_filename_after_label.setObjectName("example_filename_after_label") self.verticalLayout_6.addWidget(self.example_filename_after_label) self.example_filename_after = QtWidgets.QListWidget(parent=self.frame_3) self.example_filename_after.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.CurrentChanged|QtWidgets.QAbstractItemView.EditTrigger.DoubleClicked|QtWidgets.QAbstractItemView.EditTrigger.EditKeyPressed|QtWidgets.QAbstractItemView.EditTrigger.SelectedClicked) self.example_filename_after.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.example_filename_after.setObjectName("example_filename_after") self.verticalLayout_6.addWidget(self.example_filename_after) self.verticalLayout.addWidget(self.splitter_between_before_and_after) self.content_layout.addWidget(self.splitter_between_editor_and_examples) self.buttonbox = QtWidgets.QDialogButtonBox(parent=ScriptEditor) self.buttonbox.setObjectName("buttonbox") self.content_layout.addWidget(self.buttonbox) self.verticalLayout_3.addLayout(self.content_layout) self.retranslateUi(ScriptEditor) QtCore.QMetaObject.connectSlotsByName(ScriptEditor) def retranslateUi(self, ScriptEditor): self.label.setText(_("Selected file naming script:")) self.preset_naming_scripts.setToolTip(_("Select the file naming script to load into the editor")) self.label_2.setText(_("Title:")) self.groupBox.setTitle(_("Files will be named like this:")) self.example_filename_before_label.setText(_("Before")) self.example_filename_after_label.setText(_("After")) from picard.ui.widgets.scripttextedit import ScriptTextEdit
14,718
Python
.py
214
60.252336
273
0.760519
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,039
ui_options_script.py
metabrainz_picard/picard/ui/forms/ui_options_script.py
# Form implementation generated from reading ui file 'ui/options_script.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ScriptingOptionsPage(object): def setupUi(self, ScriptingOptionsPage): ScriptingOptionsPage.setObjectName("ScriptingOptionsPage") ScriptingOptionsPage.resize(605, 551) self.vboxlayout = QtWidgets.QVBoxLayout(ScriptingOptionsPage) self.vboxlayout.setContentsMargins(9, 9, 9, 0) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.enable_tagger_scripts = QtWidgets.QGroupBox(parent=ScriptingOptionsPage) self.enable_tagger_scripts.setCheckable(True) self.enable_tagger_scripts.setObjectName("enable_tagger_scripts") self.verticalLayout = QtWidgets.QVBoxLayout(self.enable_tagger_scripts) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label = QtWidgets.QLabel(parent=self.enable_tagger_scripts) self.label.setWordWrap(True) self.label.setObjectName("label") self.horizontalLayout_2.addWidget(self.label) self.verticalLayout.addLayout(self.horizontalLayout_2) self.scripting_options_splitter = QtWidgets.QSplitter(parent=self.enable_tagger_scripts) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scripting_options_splitter.sizePolicy().hasHeightForWidth()) self.scripting_options_splitter.setSizePolicy(sizePolicy) self.scripting_options_splitter.setOrientation(QtCore.Qt.Orientation.Horizontal) self.scripting_options_splitter.setChildrenCollapsible(False) self.scripting_options_splitter.setObjectName("scripting_options_splitter") self.script_list = ScriptListWidget(parent=self.scripting_options_splitter) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.script_list.sizePolicy().hasHeightForWidth()) self.script_list.setSizePolicy(sizePolicy) self.script_list.setMinimumSize(QtCore.QSize(120, 0)) self.script_list.setObjectName("script_list") self.formWidget = QtWidgets.QWidget(parent=self.scripting_options_splitter) self.formWidget.setObjectName("formWidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.formWidget) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.tagger_script = ScriptTextEdit(parent=self.formWidget) self.tagger_script.setAcceptRichText(False) self.tagger_script.setObjectName("tagger_script") self.verticalLayout_2.addWidget(self.tagger_script) self.verticalLayout.addWidget(self.scripting_options_splitter) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.move_up_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.move_up_button.setIcon(icon) self.move_up_button.setObjectName("move_up_button") self.horizontalLayout.addWidget(self.move_up_button) self.move_down_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.move_down_button.setIcon(icon) self.move_down_button.setObjectName("move_down_button") self.horizontalLayout.addWidget(self.move_down_button) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.add_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) self.add_button.setObjectName("add_button") self.horizontalLayout.addWidget(self.add_button) self.remove_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) self.remove_button.setObjectName("remove_button") self.horizontalLayout.addWidget(self.remove_button) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.import_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) self.import_button.setObjectName("import_button") self.horizontalLayout.addWidget(self.import_button) self.export_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) self.export_button.setObjectName("export_button") self.horizontalLayout.addWidget(self.export_button) spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem2) self.scripting_documentation_button = QtWidgets.QToolButton(parent=self.enable_tagger_scripts) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.scripting_documentation_button.sizePolicy().hasHeightForWidth()) self.scripting_documentation_button.setSizePolicy(sizePolicy) self.scripting_documentation_button.setObjectName("scripting_documentation_button") self.horizontalLayout.addWidget(self.scripting_documentation_button) self.verticalLayout.addLayout(self.horizontalLayout) self.script_error = QtWidgets.QLabel(parent=self.enable_tagger_scripts) self.script_error.setText("") self.script_error.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.script_error.setObjectName("script_error") self.verticalLayout.addWidget(self.script_error) self.vboxlayout.addWidget(self.enable_tagger_scripts) self.retranslateUi(ScriptingOptionsPage) self.add_button.clicked.connect(self.script_list.add_script) # type: ignore self.tagger_script.textChanged.connect(ScriptingOptionsPage.live_update_and_check) # type: ignore self.script_list.itemSelectionChanged.connect(ScriptingOptionsPage.script_selected) # type: ignore self.remove_button.clicked.connect(self.script_list.remove_selected_script) # type: ignore self.enable_tagger_scripts.toggled['bool'].connect(ScriptingOptionsPage.enable_tagger_scripts_toggled) # type: ignore QtCore.QMetaObject.connectSlotsByName(ScriptingOptionsPage) ScriptingOptionsPage.setTabOrder(self.enable_tagger_scripts, self.script_list) ScriptingOptionsPage.setTabOrder(self.script_list, self.tagger_script) ScriptingOptionsPage.setTabOrder(self.tagger_script, self.move_up_button) ScriptingOptionsPage.setTabOrder(self.move_up_button, self.move_down_button) ScriptingOptionsPage.setTabOrder(self.move_down_button, self.remove_button) def retranslateUi(self, ScriptingOptionsPage): self.enable_tagger_scripts.setTitle(_("Enable Tagger Script(s)")) self.label.setText(_("Tagger scripts that have been activated below will be executed automatically for each track of a release loaded from MusicBrainz.")) self.tagger_script.setPlaceholderText(_("Enter your tagger script here.")) self.move_up_button.setToolTip(_("Move tagger script up")) self.move_down_button.setToolTip(_("Move tagger script down")) self.add_button.setToolTip(_("Add new tagger script")) self.add_button.setText(_("Add new tagger script")) self.remove_button.setToolTip(_("Remove the selected tagger script")) self.remove_button.setText(_("Remove tagger script")) self.import_button.setText(_("Import")) self.export_button.setText(_("Export")) self.scripting_documentation_button.setText(_("Documentation")) from picard.ui.widgets.scriptlistwidget import ScriptListWidget from picard.ui.widgets.scripttextedit import ScriptTextEdit
8,759
Python
.py
132
58.189394
162
0.755365
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,040
ui_exception_script_selector.py
metabrainz_picard/picard/ui/forms/ui_exception_script_selector.py
# Form implementation generated from reading ui file 'ui/exception_script_selector.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ExceptionScriptSelector(object): def setupUi(self, ExceptionScriptSelector): ExceptionScriptSelector.setObjectName("ExceptionScriptSelector") ExceptionScriptSelector.setWindowModality(QtCore.Qt.WindowModality.WindowModal) ExceptionScriptSelector.resize(510, 250) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(ExceptionScriptSelector.sizePolicy().hasHeightForWidth()) ExceptionScriptSelector.setSizePolicy(sizePolicy) ExceptionScriptSelector.setMinimumSize(QtCore.QSize(510, 250)) self.verticalLayout = QtWidgets.QVBoxLayout(ExceptionScriptSelector) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.label = QtWidgets.QLabel(parent=ExceptionScriptSelector) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.selected_scripts = QtWidgets.QListWidget(parent=ExceptionScriptSelector) self.selected_scripts.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.selected_scripts.setObjectName("selected_scripts") self.verticalLayout_2.addWidget(self.selected_scripts) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(-1, -1, -1, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.threshold_label = QtWidgets.QLabel(parent=ExceptionScriptSelector) self.threshold_label.setObjectName("threshold_label") self.horizontalLayout_2.addWidget(self.threshold_label) self.weighting_selector = QtWidgets.QSpinBox(parent=ExceptionScriptSelector) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.weighting_selector.sizePolicy().hasHeightForWidth()) self.weighting_selector.setSizePolicy(sizePolicy) self.weighting_selector.setMaximumSize(QtCore.QSize(50, 16777215)) self.weighting_selector.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.weighting_selector.setMaximum(100) self.weighting_selector.setObjectName("weighting_selector") self.horizontalLayout_2.addWidget(self.weighting_selector) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout_3 = QtWidgets.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.move_up = QtWidgets.QToolButton(parent=ExceptionScriptSelector) self.move_up.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.move_up.setIcon(icon) self.move_up.setObjectName("move_up") self.verticalLayout_3.addWidget(self.move_up) self.add_script = QtWidgets.QToolButton(parent=ExceptionScriptSelector) self.add_script.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-previous.png") self.add_script.setIcon(icon) self.add_script.setObjectName("add_script") self.verticalLayout_3.addWidget(self.add_script) self.remove_script = QtWidgets.QToolButton(parent=ExceptionScriptSelector) self.remove_script.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-next.png") self.remove_script.setIcon(icon) self.remove_script.setObjectName("remove_script") self.verticalLayout_3.addWidget(self.remove_script) self.move_down = QtWidgets.QToolButton(parent=ExceptionScriptSelector) self.move_down.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.move_down.setIcon(icon) self.move_down.setObjectName("move_down") self.verticalLayout_3.addWidget(self.move_down) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_3.addItem(spacerItem1) self.horizontalLayout.addLayout(self.verticalLayout_3) self.verticalLayout_4 = QtWidgets.QVBoxLayout() self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_2 = QtWidgets.QLabel(parent=ExceptionScriptSelector) self.label_2.setObjectName("label_2") self.verticalLayout_4.addWidget(self.label_2) self.available_scripts = QtWidgets.QListWidget(parent=ExceptionScriptSelector) self.available_scripts.setObjectName("available_scripts") self.verticalLayout_4.addWidget(self.available_scripts) self.horizontalLayout.addLayout(self.verticalLayout_4) self.verticalLayout.addLayout(self.horizontalLayout) self.button_box = QtWidgets.QDialogButtonBox(parent=ExceptionScriptSelector) self.button_box.setOrientation(QtCore.Qt.Orientation.Horizontal) self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Save) self.button_box.setObjectName("button_box") self.verticalLayout.addWidget(self.button_box) self.retranslateUi(ExceptionScriptSelector) QtCore.QMetaObject.connectSlotsByName(ExceptionScriptSelector) def retranslateUi(self, ExceptionScriptSelector): ExceptionScriptSelector.setWindowTitle(_("Exception Language Script Selector")) self.label.setText(_("Selected Scripts")) self.threshold_label.setText(_("Selected language script match threshold:")) self.move_up.setToolTip(_("Move selected language script up")) self.add_script.setToolTip(_("Add to selected language scripts")) self.remove_script.setToolTip(_("Remove selected language script")) self.move_down.setToolTip(_("Move selected language script down")) self.label_2.setText(_("Available Language Scripts"))
6,924
Python
.py
112
53.660714
155
0.751984
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,041
ui_scripteditor_details.py
metabrainz_picard/picard/ui/forms/ui_scripteditor_details.py
# Form implementation generated from reading ui file 'ui/scripteditor_details.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ScriptDetails(object): def setupUi(self, ScriptDetails): ScriptDetails.setObjectName("ScriptDetails") ScriptDetails.setWindowModality(QtCore.Qt.WindowModality.WindowModal) ScriptDetails.resize(700, 284) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(ScriptDetails.sizePolicy().hasHeightForWidth()) ScriptDetails.setSizePolicy(sizePolicy) self.verticalLayout = QtWidgets.QVBoxLayout(ScriptDetails) self.verticalLayout.setObjectName("verticalLayout") self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.script_version = QtWidgets.QLineEdit(parent=ScriptDetails) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.script_version.sizePolicy().hasHeightForWidth()) self.script_version.setSizePolicy(sizePolicy) self.script_version.setMinimumSize(QtCore.QSize(100, 0)) self.script_version.setMaximumSize(QtCore.QSize(100, 16777215)) self.script_version.setBaseSize(QtCore.QSize(0, 0)) self.script_version.setObjectName("script_version") self.horizontalLayout.addWidget(self.script_version) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.label_4 = QtWidgets.QLabel(parent=ScriptDetails) self.label_4.setObjectName("label_4") self.horizontalLayout.addWidget(self.label_4) self.script_last_updated = QtWidgets.QLineEdit(parent=ScriptDetails) self.script_last_updated.setMinimumSize(QtCore.QSize(200, 0)) self.script_last_updated.setMaximumSize(QtCore.QSize(200, 16777215)) self.script_last_updated.setObjectName("script_last_updated") self.horizontalLayout.addWidget(self.script_last_updated) self.last_updated_now = QtWidgets.QPushButton(parent=ScriptDetails) self.last_updated_now.setObjectName("last_updated_now") self.horizontalLayout.addWidget(self.last_updated_now) self.gridLayout.addLayout(self.horizontalLayout, 2, 2, 1, 1) self.label_2 = QtWidgets.QLabel(parent=ScriptDetails) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.label_3 = QtWidgets.QLabel(parent=ScriptDetails) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) self.label_5 = QtWidgets.QLabel(parent=ScriptDetails) self.label_5.setObjectName("label_5") self.gridLayout.addWidget(self.label_5, 3, 0, 1, 1) self.label = QtWidgets.QLabel(parent=ScriptDetails) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.script_license = QtWidgets.QLineEdit(parent=ScriptDetails) self.script_license.setObjectName("script_license") self.gridLayout.addWidget(self.script_license, 3, 2, 1, 1) self.label_6 = QtWidgets.QLabel(parent=ScriptDetails) self.label_6.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop) self.label_6.setObjectName("label_6") self.gridLayout.addWidget(self.label_6, 4, 0, 1, 1) self.script_description = QtWidgets.QPlainTextEdit(parent=ScriptDetails) self.script_description.setObjectName("script_description") self.gridLayout.addWidget(self.script_description, 4, 2, 1, 1) self.script_author = QtWidgets.QLineEdit(parent=ScriptDetails) self.script_author.setObjectName("script_author") self.gridLayout.addWidget(self.script_author, 1, 2, 1, 1) self.script_title = QtWidgets.QLineEdit(parent=ScriptDetails) self.script_title.setObjectName("script_title") self.gridLayout.addWidget(self.script_title, 0, 2, 1, 1) self.verticalLayout.addLayout(self.gridLayout) self.buttonBox = QtWidgets.QDialogButtonBox(parent=ScriptDetails) self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Close|QtWidgets.QDialogButtonBox.StandardButton.Save) self.buttonBox.setObjectName("buttonBox") self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi(ScriptDetails) QtCore.QMetaObject.connectSlotsByName(ScriptDetails) def retranslateUi(self, ScriptDetails): ScriptDetails.setWindowTitle(_("File Naming Script Metadata")) self.script_version.setToolTip(_("Version number of the file naming script.")) self.label_4.setText(_("Last Updated:")) self.script_last_updated.setToolTip(_("Date and time the file naming script was last updated (UTC).")) self.last_updated_now.setText(_("Now")) self.label_2.setText(_("Author:")) self.label_3.setText(_("Version:")) self.label_5.setText(_("License:")) self.label.setText(_("Title:")) self.script_license.setToolTip(_("License under which the file naming script is available.")) self.label_6.setText(_("Description:")) self.script_description.setToolTip(_("Brief description of the file naming script, including any required plugins.")) self.script_author.setToolTip(_("The author of the file naming script."))
6,271
Python
.py
103
52.796117
186
0.732879
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,042
ui_tagsfromfilenames.py
metabrainz_picard/picard/ui/forms/ui_tagsfromfilenames.py
# Form implementation generated from reading ui file 'ui/tagsfromfilenames.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsFromFileNamesDialog(object): def setupUi(self, TagsFromFileNamesDialog): TagsFromFileNamesDialog.setObjectName("TagsFromFileNamesDialog") TagsFromFileNamesDialog.resize(560, 400) self.gridlayout = QtWidgets.QGridLayout(TagsFromFileNamesDialog) self.gridlayout.setContentsMargins(9, 9, 9, 9) self.gridlayout.setSpacing(6) self.gridlayout.setObjectName("gridlayout") self.files = QtWidgets.QTreeWidget(parent=TagsFromFileNamesDialog) self.files.setAlternatingRowColors(True) self.files.setRootIsDecorated(False) self.files.setObjectName("files") self.files.headerItem().setText(0, "1") self.gridlayout.addWidget(self.files, 1, 0, 1, 2) self.replace_underscores = QtWidgets.QCheckBox(parent=TagsFromFileNamesDialog) self.replace_underscores.setObjectName("replace_underscores") self.gridlayout.addWidget(self.replace_underscores, 2, 0, 1, 2) self.buttonbox = QtWidgets.QDialogButtonBox(parent=TagsFromFileNamesDialog) self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonbox.setObjectName("buttonbox") self.gridlayout.addWidget(self.buttonbox, 3, 0, 1, 2) self.preview = QtWidgets.QPushButton(parent=TagsFromFileNamesDialog) self.preview.setObjectName("preview") self.gridlayout.addWidget(self.preview, 0, 1, 1, 1) self.format = QtWidgets.QComboBox(parent=TagsFromFileNamesDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.format.sizePolicy().hasHeightForWidth()) self.format.setSizePolicy(sizePolicy) self.format.setEditable(True) self.format.setObjectName("format") self.gridlayout.addWidget(self.format, 0, 0, 1, 1) self.retranslateUi(TagsFromFileNamesDialog) QtCore.QMetaObject.connectSlotsByName(TagsFromFileNamesDialog) TagsFromFileNamesDialog.setTabOrder(self.format, self.preview) TagsFromFileNamesDialog.setTabOrder(self.preview, self.files) TagsFromFileNamesDialog.setTabOrder(self.files, self.replace_underscores) TagsFromFileNamesDialog.setTabOrder(self.replace_underscores, self.buttonbox) def retranslateUi(self, TagsFromFileNamesDialog): TagsFromFileNamesDialog.setWindowTitle(_("Convert File Names to Tags")) self.replace_underscores.setText(_("Replace underscores with spaces")) self.preview.setText(_("&Preview"))
2,981
Python
.py
55
46.909091
118
0.749315
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,043
ui_options_matching.py
metabrainz_picard/picard/ui/forms/ui_options_matching.py
# Form implementation generated from reading ui file 'ui/options_matching.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_MatchingOptionsPage(object): def setupUi(self, MatchingOptionsPage): MatchingOptionsPage.setObjectName("MatchingOptionsPage") MatchingOptionsPage.resize(413, 612) self.vboxlayout = QtWidgets.QVBoxLayout(MatchingOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.rename_files = QtWidgets.QGroupBox(parent=MatchingOptionsPage) self.rename_files.setObjectName("rename_files") self.gridlayout = QtWidgets.QGridLayout(self.rename_files) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.label_6 = QtWidgets.QLabel(parent=self.rename_files) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_6.sizePolicy().hasHeightForWidth()) self.label_6.setSizePolicy(sizePolicy) self.label_6.setObjectName("label_6") self.gridlayout.addWidget(self.label_6, 2, 0, 1, 1) self.track_matching_threshold = QtWidgets.QSpinBox(parent=self.rename_files) self.track_matching_threshold.setMaximum(100) self.track_matching_threshold.setObjectName("track_matching_threshold") self.gridlayout.addWidget(self.track_matching_threshold, 2, 1, 1, 1) self.cluster_lookup_threshold = QtWidgets.QSpinBox(parent=self.rename_files) self.cluster_lookup_threshold.setMaximum(100) self.cluster_lookup_threshold.setObjectName("cluster_lookup_threshold") self.gridlayout.addWidget(self.cluster_lookup_threshold, 1, 1, 1, 1) self.file_lookup_threshold = QtWidgets.QSpinBox(parent=self.rename_files) self.file_lookup_threshold.setMaximum(100) self.file_lookup_threshold.setObjectName("file_lookup_threshold") self.gridlayout.addWidget(self.file_lookup_threshold, 0, 1, 1, 1) self.label_4 = QtWidgets.QLabel(parent=self.rename_files) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth()) self.label_4.setSizePolicy(sizePolicy) self.label_4.setObjectName("label_4") self.gridlayout.addWidget(self.label_4, 0, 0, 1, 1) self.label_5 = QtWidgets.QLabel(parent=self.rename_files) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) self.label_5.setSizePolicy(sizePolicy) self.label_5.setObjectName("label_5") self.gridlayout.addWidget(self.label_5, 1, 0, 1, 1) self.vboxlayout.addWidget(self.rename_files) spacerItem = QtWidgets.QSpacerItem(20, 41, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem) self.label_6.setBuddy(self.file_lookup_threshold) self.label_4.setBuddy(self.file_lookup_threshold) self.label_5.setBuddy(self.file_lookup_threshold) self.retranslateUi(MatchingOptionsPage) QtCore.QMetaObject.connectSlotsByName(MatchingOptionsPage) MatchingOptionsPage.setTabOrder(self.file_lookup_threshold, self.cluster_lookup_threshold) MatchingOptionsPage.setTabOrder(self.cluster_lookup_threshold, self.track_matching_threshold) def retranslateUi(self, MatchingOptionsPage): self.rename_files.setTitle(_("Thresholds")) self.label_6.setText(_("Minimal similarity for matching files to tracks:")) self.track_matching_threshold.setSuffix(_(" %")) self.cluster_lookup_threshold.setSuffix(_(" %")) self.file_lookup_threshold.setSuffix(_(" %")) self.label_4.setText(_("Minimal similarity for file lookups:")) self.label_5.setText(_("Minimal similarity for cluster lookups:"))
4,539
Python
.py
77
51.168831
128
0.737657
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,044
ui_options_ratings.py
metabrainz_picard/picard/ui/forms/ui_options_ratings.py
# Form implementation generated from reading ui file 'ui/options_ratings.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_RatingsOptionsPage(object): def setupUi(self, RatingsOptionsPage): RatingsOptionsPage.setObjectName("RatingsOptionsPage") RatingsOptionsPage.resize(397, 267) self.vboxlayout = QtWidgets.QVBoxLayout(RatingsOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.enable_ratings = QtWidgets.QGroupBox(parent=RatingsOptionsPage) self.enable_ratings.setCheckable(True) self.enable_ratings.setChecked(True) self.enable_ratings.setObjectName("enable_ratings") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.enable_ratings) self.vboxlayout1.setObjectName("vboxlayout1") self.label = QtWidgets.QLabel(parent=self.enable_ratings) self.label.setWordWrap(True) self.label.setObjectName("label") self.vboxlayout1.addWidget(self.label) self.ignore_tags_2 = QtWidgets.QLabel(parent=self.enable_ratings) self.ignore_tags_2.setEnabled(True) self.ignore_tags_2.setWordWrap(True) self.ignore_tags_2.setObjectName("ignore_tags_2") self.vboxlayout1.addWidget(self.ignore_tags_2) self.rating_user_email = QtWidgets.QLineEdit(parent=self.enable_ratings) self.rating_user_email.setReadOnly(False) self.rating_user_email.setObjectName("rating_user_email") self.vboxlayout1.addWidget(self.rating_user_email) self.submit_ratings = QtWidgets.QCheckBox(parent=self.enable_ratings) self.submit_ratings.setObjectName("submit_ratings") self.vboxlayout1.addWidget(self.submit_ratings) self.vboxlayout.addWidget(self.enable_ratings) spacerItem = QtWidgets.QSpacerItem(181, 31, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem) self.retranslateUi(RatingsOptionsPage) QtCore.QMetaObject.connectSlotsByName(RatingsOptionsPage) def retranslateUi(self, RatingsOptionsPage): self.enable_ratings.setTitle(_("Enable track ratings")) self.label.setText(_("Picard saves the ratings together with an e-mail address identifying the user who did the rating. That way different ratings for different users can be stored in the files. Please specify the e-mail you want to use to save your ratings.")) self.ignore_tags_2.setText(_("E-mail:")) self.submit_ratings.setText(_("Submit ratings to MusicBrainz"))
2,740
Python
.py
50
47.68
269
0.739568
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,045
ui_options_cover_processing.py
metabrainz_picard/picard/ui/forms/ui_options_cover_processing.py
# Form implementation generated from reading ui file 'ui/options_cover_processing.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_CoverProcessingOptionsPage(object): def setupUi(self, CoverProcessingOptionsPage): CoverProcessingOptionsPage.setObjectName("CoverProcessingOptionsPage") CoverProcessingOptionsPage.resize(535, 475) self.verticalLayout = QtWidgets.QVBoxLayout(CoverProcessingOptionsPage) self.verticalLayout.setObjectName("verticalLayout") self.filtering = QtWidgets.QGroupBox(parent=CoverProcessingOptionsPage) self.filtering.setCheckable(True) self.filtering.setChecked(False) self.filtering.setObjectName("filtering") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.filtering) self.verticalLayout_2.setObjectName("verticalLayout_2") self.filtering_width_widget = QtWidgets.QWidget(parent=self.filtering) self.filtering_width_widget.setObjectName("filtering_width_widget") self.horizontalLayout = QtWidgets.QHBoxLayout(self.filtering_width_widget) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") self.filtering_width_label = QtWidgets.QLabel(parent=self.filtering_width_widget) self.filtering_width_label.setObjectName("filtering_width_label") self.horizontalLayout.addWidget(self.filtering_width_label) self.filtering_width_value = QtWidgets.QSpinBox(parent=self.filtering_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.filtering_width_value.sizePolicy().hasHeightForWidth()) self.filtering_width_value.setSizePolicy(sizePolicy) self.filtering_width_value.setMaximum(9999) self.filtering_width_value.setProperty("value", 250) self.filtering_width_value.setObjectName("filtering_width_value") self.horizontalLayout.addWidget(self.filtering_width_value) self.px_label1 = QtWidgets.QLabel(parent=self.filtering_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label1.sizePolicy().hasHeightForWidth()) self.px_label1.setSizePolicy(sizePolicy) self.px_label1.setObjectName("px_label1") self.horizontalLayout.addWidget(self.px_label1) self.verticalLayout_2.addWidget(self.filtering_width_widget) self.filtering_height_widget = QtWidgets.QWidget(parent=self.filtering) self.filtering_height_widget.setObjectName("filtering_height_widget") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.filtering_height_widget) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.filtering_height_label = QtWidgets.QLabel(parent=self.filtering_height_widget) self.filtering_height_label.setObjectName("filtering_height_label") self.horizontalLayout_2.addWidget(self.filtering_height_label) self.filtering_height_value = QtWidgets.QSpinBox(parent=self.filtering_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.filtering_height_value.sizePolicy().hasHeightForWidth()) self.filtering_height_value.setSizePolicy(sizePolicy) self.filtering_height_value.setMaximum(9999) self.filtering_height_value.setProperty("value", 250) self.filtering_height_value.setObjectName("filtering_height_value") self.horizontalLayout_2.addWidget(self.filtering_height_value) self.px_label2 = QtWidgets.QLabel(parent=self.filtering_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label2.sizePolicy().hasHeightForWidth()) self.px_label2.setSizePolicy(sizePolicy) self.px_label2.setObjectName("px_label2") self.horizontalLayout_2.addWidget(self.px_label2) self.verticalLayout_2.addWidget(self.filtering_height_widget) self.verticalLayout.addWidget(self.filtering) self.resizing = QtWidgets.QGroupBox(parent=CoverProcessingOptionsPage) self.resizing.setCheckable(False) self.resizing.setChecked(False) self.resizing.setObjectName("resizing") self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.resizing) self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.tags_scale_down = QtWidgets.QGroupBox(parent=self.resizing) self.tags_scale_down.setCheckable(True) self.tags_scale_down.setChecked(False) self.tags_scale_down.setObjectName("tags_scale_down") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.tags_scale_down) self.verticalLayout_3.setObjectName("verticalLayout_3") self.tags_resize_mode = QtWidgets.QComboBox(parent=self.tags_scale_down) self.tags_resize_mode.setObjectName("tags_resize_mode") self.verticalLayout_3.addWidget(self.tags_resize_mode) self.tags_resize_width_widget = QtWidgets.QWidget(parent=self.tags_scale_down) self.tags_resize_width_widget.setObjectName("tags_resize_width_widget") self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.tags_resize_width_widget) self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_5.setSpacing(4) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.tags_resize_width_label = QtWidgets.QLabel(parent=self.tags_resize_width_widget) self.tags_resize_width_label.setObjectName("tags_resize_width_label") self.horizontalLayout_5.addWidget(self.tags_resize_width_label) self.tags_resize_width_value = QtWidgets.QSpinBox(parent=self.tags_resize_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tags_resize_width_value.sizePolicy().hasHeightForWidth()) self.tags_resize_width_value.setSizePolicy(sizePolicy) self.tags_resize_width_value.setMinimum(1) self.tags_resize_width_value.setMaximum(9999) self.tags_resize_width_value.setProperty("value", 1000) self.tags_resize_width_value.setObjectName("tags_resize_width_value") self.horizontalLayout_5.addWidget(self.tags_resize_width_value) self.px_label5 = QtWidgets.QLabel(parent=self.tags_resize_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label5.sizePolicy().hasHeightForWidth()) self.px_label5.setSizePolicy(sizePolicy) self.px_label5.setObjectName("px_label5") self.horizontalLayout_5.addWidget(self.px_label5) self.verticalLayout_3.addWidget(self.tags_resize_width_widget) self.tags_resize_height_widget = QtWidgets.QWidget(parent=self.tags_scale_down) self.tags_resize_height_widget.setObjectName("tags_resize_height_widget") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.tags_resize_height_widget) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_3.setSpacing(4) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.tags_resize_height_label = QtWidgets.QLabel(parent=self.tags_resize_height_widget) self.tags_resize_height_label.setObjectName("tags_resize_height_label") self.horizontalLayout_3.addWidget(self.tags_resize_height_label) self.tags_resize_height_value = QtWidgets.QSpinBox(parent=self.tags_resize_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tags_resize_height_value.sizePolicy().hasHeightForWidth()) self.tags_resize_height_value.setSizePolicy(sizePolicy) self.tags_resize_height_value.setMinimum(1) self.tags_resize_height_value.setMaximum(9999) self.tags_resize_height_value.setProperty("value", 1000) self.tags_resize_height_value.setObjectName("tags_resize_height_value") self.horizontalLayout_3.addWidget(self.tags_resize_height_value) self.px_label6 = QtWidgets.QLabel(parent=self.tags_resize_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label6.sizePolicy().hasHeightForWidth()) self.px_label6.setSizePolicy(sizePolicy) self.px_label6.setObjectName("px_label6") self.horizontalLayout_3.addWidget(self.px_label6) self.verticalLayout_3.addWidget(self.tags_resize_height_widget) self.tags_scale_up = QtWidgets.QCheckBox(parent=self.tags_scale_down) self.tags_scale_up.setObjectName("tags_scale_up") self.verticalLayout_3.addWidget(self.tags_scale_up) self.horizontalLayout_7.addWidget(self.tags_scale_down) self.file_scale_down = QtWidgets.QGroupBox(parent=self.resizing) self.file_scale_down.setCheckable(True) self.file_scale_down.setObjectName("file_scale_down") self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.file_scale_down) self.verticalLayout_4.setObjectName("verticalLayout_4") self.file_resize_mode = QtWidgets.QComboBox(parent=self.file_scale_down) self.file_resize_mode.setObjectName("file_resize_mode") self.verticalLayout_4.addWidget(self.file_resize_mode) self.file_scale_widget = QtWidgets.QWidget(parent=self.file_scale_down) self.file_scale_widget.setObjectName("file_scale_widget") self.horizontalLayout_9 = QtWidgets.QHBoxLayout(self.file_scale_widget) self.horizontalLayout_9.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_9.setObjectName("horizontalLayout_9") self.verticalLayout_4.addWidget(self.file_scale_widget) self.file_resize_width_widget = QtWidgets.QWidget(parent=self.file_scale_down) self.file_resize_width_widget.setObjectName("file_resize_width_widget") self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.file_resize_width_widget) self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_6.setSpacing(4) self.horizontalLayout_6.setObjectName("horizontalLayout_6") self.file_resize_width_label = QtWidgets.QLabel(parent=self.file_resize_width_widget) self.file_resize_width_label.setObjectName("file_resize_width_label") self.horizontalLayout_6.addWidget(self.file_resize_width_label) self.file_resize_width_value = QtWidgets.QSpinBox(parent=self.file_resize_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.file_resize_width_value.sizePolicy().hasHeightForWidth()) self.file_resize_width_value.setSizePolicy(sizePolicy) self.file_resize_width_value.setMinimum(1) self.file_resize_width_value.setMaximum(9999) self.file_resize_width_value.setProperty("value", 1000) self.file_resize_width_value.setObjectName("file_resize_width_value") self.horizontalLayout_6.addWidget(self.file_resize_width_value) self.px_label3 = QtWidgets.QLabel(parent=self.file_resize_width_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label3.sizePolicy().hasHeightForWidth()) self.px_label3.setSizePolicy(sizePolicy) self.px_label3.setObjectName("px_label3") self.horizontalLayout_6.addWidget(self.px_label3) self.verticalLayout_4.addWidget(self.file_resize_width_widget) self.file_resize_height_widget = QtWidgets.QWidget(parent=self.file_scale_down) self.file_resize_height_widget.setObjectName("file_resize_height_widget") self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.file_resize_height_widget) self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_4.setSpacing(4) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.file_resize_height_label = QtWidgets.QLabel(parent=self.file_resize_height_widget) self.file_resize_height_label.setObjectName("file_resize_height_label") self.horizontalLayout_4.addWidget(self.file_resize_height_label) self.file_resize_height_value = QtWidgets.QSpinBox(parent=self.file_resize_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.file_resize_height_value.sizePolicy().hasHeightForWidth()) self.file_resize_height_value.setSizePolicy(sizePolicy) self.file_resize_height_value.setMinimum(1) self.file_resize_height_value.setMaximum(9999) self.file_resize_height_value.setProperty("value", 1000) self.file_resize_height_value.setObjectName("file_resize_height_value") self.horizontalLayout_4.addWidget(self.file_resize_height_value) self.px_label4 = QtWidgets.QLabel(parent=self.file_resize_height_widget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.px_label4.sizePolicy().hasHeightForWidth()) self.px_label4.setSizePolicy(sizePolicy) self.px_label4.setObjectName("px_label4") self.horizontalLayout_4.addWidget(self.px_label4) self.verticalLayout_4.addWidget(self.file_resize_height_widget) self.file_scale_up = QtWidgets.QCheckBox(parent=self.file_scale_down) self.file_scale_up.setObjectName("file_scale_up") self.verticalLayout_4.addWidget(self.file_scale_up) self.horizontalLayout_7.addWidget(self.file_scale_down) self.verticalLayout.addWidget(self.resizing) self.converting = QtWidgets.QGroupBox(parent=CoverProcessingOptionsPage) self.converting.setCheckable(False) self.converting.setChecked(False) self.converting.setObjectName("converting") self.horizontalLayout_12 = QtWidgets.QHBoxLayout(self.converting) self.horizontalLayout_12.setObjectName("horizontalLayout_12") self.convert_tags = QtWidgets.QGroupBox(parent=self.converting) self.convert_tags.setCheckable(True) self.convert_tags.setObjectName("convert_tags") self.horizontalLayout_13 = QtWidgets.QHBoxLayout(self.convert_tags) self.horizontalLayout_13.setObjectName("horizontalLayout_13") self.convert_tags_label = QtWidgets.QLabel(parent=self.convert_tags) self.convert_tags_label.setObjectName("convert_tags_label") self.horizontalLayout_13.addWidget(self.convert_tags_label) self.convert_tags_format = QtWidgets.QComboBox(parent=self.convert_tags) self.convert_tags_format.setObjectName("convert_tags_format") self.horizontalLayout_13.addWidget(self.convert_tags_format) self.horizontalLayout_12.addWidget(self.convert_tags) self.convert_file = QtWidgets.QGroupBox(parent=self.converting) self.convert_file.setCheckable(True) self.convert_file.setObjectName("convert_file") self.horizontalLayout_14 = QtWidgets.QHBoxLayout(self.convert_file) self.horizontalLayout_14.setObjectName("horizontalLayout_14") self.convert_file_label = QtWidgets.QLabel(parent=self.convert_file) self.convert_file_label.setObjectName("convert_file_label") self.horizontalLayout_14.addWidget(self.convert_file_label) self.convert_file_format = QtWidgets.QComboBox(parent=self.convert_file) self.convert_file_format.setObjectName("convert_file_format") self.horizontalLayout_14.addWidget(self.convert_file_format) self.horizontalLayout_12.addWidget(self.convert_file) self.verticalLayout.addWidget(self.converting) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem) self.retranslateUi(CoverProcessingOptionsPage) QtCore.QMetaObject.connectSlotsByName(CoverProcessingOptionsPage) def retranslateUi(self, CoverProcessingOptionsPage): CoverProcessingOptionsPage.setWindowTitle(_("Form")) self.filtering.setTitle(_("Discard images if below the given size")) self.filtering_width_label.setText(_("Minimum width:")) self.px_label1.setText(_("px")) self.filtering_height_label.setText(_("Minimum height:")) self.px_label2.setText(_("px")) self.resizing.setTitle(_("Resize images to the given size")) self.tags_scale_down.setTitle(_("Resize images saved to tags ")) self.tags_resize_width_label.setText(_("Maximum width:")) self.px_label5.setText(_("px")) self.tags_resize_height_label.setText(_("Maximum height:")) self.px_label6.setText(_("px")) self.tags_scale_up.setText(_("Enlarge")) self.file_scale_down.setTitle(_("Resize images saved to files")) self.file_resize_width_label.setText(_("Maximum width:")) self.px_label3.setText(_("px")) self.file_resize_height_label.setText(_("Maximum height:")) self.px_label4.setText(_("px")) self.file_scale_up.setText(_("Enlarge")) self.converting.setTitle(_("Convert images to the given format")) self.convert_tags.setTitle(_("Convert images saved to tags")) self.convert_tags_label.setText(_("New format:")) self.convert_file.setTitle(_("Convert images saved to files")) self.convert_file_label.setText(_("New format:"))
19,451
Python
.py
293
57.706485
128
0.745092
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,046
ui_options_profiles.py
metabrainz_picard/picard/ui/forms/ui_options_profiles.py
# Form implementation generated from reading ui file 'ui/options_profiles.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_ProfileEditorDialog(object): def setupUi(self, ProfileEditorDialog): ProfileEditorDialog.setObjectName("ProfileEditorDialog") ProfileEditorDialog.resize(430, 551) self.vboxlayout = QtWidgets.QVBoxLayout(ProfileEditorDialog) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.option_profiles_groupbox = QtWidgets.QGroupBox(parent=ProfileEditorDialog) self.option_profiles_groupbox.setCheckable(False) self.option_profiles_groupbox.setObjectName("option_profiles_groupbox") self.verticalLayout = QtWidgets.QVBoxLayout(self.option_profiles_groupbox) self.verticalLayout.setObjectName("verticalLayout") self.profile_editor_splitter = QtWidgets.QSplitter(parent=self.option_profiles_groupbox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.profile_editor_splitter.sizePolicy().hasHeightForWidth()) self.profile_editor_splitter.setSizePolicy(sizePolicy) self.profile_editor_splitter.setOrientation(QtCore.Qt.Orientation.Horizontal) self.profile_editor_splitter.setChildrenCollapsible(False) self.profile_editor_splitter.setObjectName("profile_editor_splitter") self.profile_list = ProfileListWidget(parent=self.profile_editor_splitter) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.profile_list.sizePolicy().hasHeightForWidth()) self.profile_list.setSizePolicy(sizePolicy) self.profile_list.setMinimumSize(QtCore.QSize(120, 0)) self.profile_list.setObjectName("profile_list") self.settings_tree = QtWidgets.QTreeWidget(parent=self.profile_editor_splitter) self.settings_tree.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.MultiSelection) self.settings_tree.setColumnCount(1) self.settings_tree.setObjectName("settings_tree") self.settings_tree.headerItem().setText(0, "1") self.settings_tree.header().setVisible(True) self.verticalLayout.addWidget(self.profile_editor_splitter) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setContentsMargins(-1, 0, -1, -1) self.horizontalLayout.setObjectName("horizontalLayout") self.move_up_button = QtWidgets.QToolButton(parent=self.option_profiles_groupbox) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.move_up_button.setIcon(icon) self.move_up_button.setObjectName("move_up_button") self.horizontalLayout.addWidget(self.move_up_button) self.move_down_button = QtWidgets.QToolButton(parent=self.option_profiles_groupbox) icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.move_down_button.setIcon(icon) self.move_down_button.setObjectName("move_down_button") self.horizontalLayout.addWidget(self.move_down_button) self.profile_list_buttonbox = QtWidgets.QDialogButtonBox(parent=self.option_profiles_groupbox) self.profile_list_buttonbox.setMinimumSize(QtCore.QSize(0, 10)) self.profile_list_buttonbox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.NoButton) self.profile_list_buttonbox.setObjectName("profile_list_buttonbox") self.horizontalLayout.addWidget(self.profile_list_buttonbox) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.verticalLayout.addLayout(self.horizontalLayout) self.vboxlayout.addWidget(self.option_profiles_groupbox) self.retranslateUi(ProfileEditorDialog) QtCore.QMetaObject.connectSlotsByName(ProfileEditorDialog) def retranslateUi(self, ProfileEditorDialog): self.option_profiles_groupbox.setTitle(_("Option Profile(s)")) self.move_up_button.setToolTip(_("Move profile up")) self.move_down_button.setToolTip(_("Move profile down")) from picard.ui.widgets.profilelistwidget import ProfileListWidget
4,809
Python
.py
78
53.961538
129
0.758307
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,047
ui_options_renaming_compat.py
metabrainz_picard/picard/ui/forms/ui_options_renaming_compat.py
# Form implementation generated from reading ui file 'ui/options_renaming_compat.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_RenamingCompatOptionsPage(object): def setupUi(self, RenamingCompatOptionsPage): RenamingCompatOptionsPage.setObjectName("RenamingCompatOptionsPage") RenamingCompatOptionsPage.setEnabled(True) RenamingCompatOptionsPage.resize(453, 332) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(RenamingCompatOptionsPage.sizePolicy().hasHeightForWidth()) RenamingCompatOptionsPage.setSizePolicy(sizePolicy) self.verticalLayout_5 = QtWidgets.QVBoxLayout(RenamingCompatOptionsPage) self.verticalLayout_5.setObjectName("verticalLayout_5") self.ascii_filenames = QtWidgets.QCheckBox(parent=RenamingCompatOptionsPage) self.ascii_filenames.setObjectName("ascii_filenames") self.verticalLayout_5.addWidget(self.ascii_filenames) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.windows_compatibility = QtWidgets.QCheckBox(parent=RenamingCompatOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.windows_compatibility.sizePolicy().hasHeightForWidth()) self.windows_compatibility.setSizePolicy(sizePolicy) self.windows_compatibility.setObjectName("windows_compatibility") self.horizontalLayout.addWidget(self.windows_compatibility) self.btn_windows_compatibility_change = QtWidgets.QPushButton(parent=RenamingCompatOptionsPage) self.btn_windows_compatibility_change.setEnabled(False) self.btn_windows_compatibility_change.setObjectName("btn_windows_compatibility_change") self.horizontalLayout.addWidget(self.btn_windows_compatibility_change) self.verticalLayout_5.addLayout(self.horizontalLayout) self.windows_long_paths = QtWidgets.QCheckBox(parent=RenamingCompatOptionsPage) self.windows_long_paths.setEnabled(False) self.windows_long_paths.setObjectName("windows_long_paths") self.verticalLayout_5.addWidget(self.windows_long_paths) self.replace_spaces_with_underscores = QtWidgets.QCheckBox(parent=RenamingCompatOptionsPage) self.replace_spaces_with_underscores.setObjectName("replace_spaces_with_underscores") self.verticalLayout_5.addWidget(self.replace_spaces_with_underscores) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_replace_dir_separator = QtWidgets.QLabel(parent=RenamingCompatOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_replace_dir_separator.sizePolicy().hasHeightForWidth()) self.label_replace_dir_separator.setSizePolicy(sizePolicy) self.label_replace_dir_separator.setObjectName("label_replace_dir_separator") self.horizontalLayout_2.addWidget(self.label_replace_dir_separator) self.replace_dir_separator = QtWidgets.QLineEdit(parent=RenamingCompatOptionsPage) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_dir_separator.sizePolicy().hasHeightForWidth()) self.replace_dir_separator.setSizePolicy(sizePolicy) self.replace_dir_separator.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_dir_separator.setText("_") self.replace_dir_separator.setMaxLength(1) self.replace_dir_separator.setObjectName("replace_dir_separator") self.horizontalLayout_2.addWidget(self.replace_dir_separator) self.verticalLayout_5.addLayout(self.horizontalLayout_2) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout_5.addItem(spacerItem) self.example_selection_note = QtWidgets.QLabel(parent=RenamingCompatOptionsPage) self.example_selection_note.setText("") self.example_selection_note.setWordWrap(True) self.example_selection_note.setObjectName("example_selection_note") self.verticalLayout_5.addWidget(self.example_selection_note) self.retranslateUi(RenamingCompatOptionsPage) self.windows_compatibility.toggled['bool'].connect(self.windows_long_paths.setEnabled) # type: ignore self.windows_compatibility.toggled['bool'].connect(self.btn_windows_compatibility_change.setEnabled) # type: ignore QtCore.QMetaObject.connectSlotsByName(RenamingCompatOptionsPage) RenamingCompatOptionsPage.setTabOrder(self.ascii_filenames, self.windows_compatibility) RenamingCompatOptionsPage.setTabOrder(self.windows_compatibility, self.btn_windows_compatibility_change) RenamingCompatOptionsPage.setTabOrder(self.btn_windows_compatibility_change, self.windows_long_paths) RenamingCompatOptionsPage.setTabOrder(self.windows_long_paths, self.replace_spaces_with_underscores) RenamingCompatOptionsPage.setTabOrder(self.replace_spaces_with_underscores, self.replace_dir_separator) def retranslateUi(self, RenamingCompatOptionsPage): self.ascii_filenames.setText(_("Replace non-ASCII characters")) self.windows_compatibility.setText(_("Windows compatibility")) self.btn_windows_compatibility_change.setText(_("Customize…")) self.windows_long_paths.setText(_("Allow paths longer than 259 characters")) self.replace_spaces_with_underscores.setText(_("Replace spaces with underscores")) self.label_replace_dir_separator.setText(_("Replace directory separators with:"))
6,531
Python
.py
94
61.478723
128
0.776085
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,048
ui_infostatus.py
metabrainz_picard/picard/ui/forms/ui_infostatus.py
# Form implementation generated from reading ui file 'ui/infostatus.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InfoStatus(object): def setupUi(self, InfoStatus): InfoStatus.setObjectName("InfoStatus") InfoStatus.resize(683, 145) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(InfoStatus.sizePolicy().hasHeightForWidth()) InfoStatus.setSizePolicy(sizePolicy) InfoStatus.setMinimumSize(QtCore.QSize(0, 0)) self.horizontalLayout = QtWidgets.QHBoxLayout(InfoStatus) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setSpacing(2) self.horizontalLayout.setObjectName("horizontalLayout") self.val1 = QtWidgets.QLabel(parent=InfoStatus) self.val1.setMinimumSize(QtCore.QSize(40, 0)) self.val1.setText("") self.val1.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.val1.setObjectName("val1") self.horizontalLayout.addWidget(self.val1) self.label1 = QtWidgets.QLabel(parent=InfoStatus) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label1.sizePolicy().hasHeightForWidth()) self.label1.setSizePolicy(sizePolicy) self.label1.setMinimumSize(QtCore.QSize(0, 0)) self.label1.setFrameShape(QtWidgets.QFrame.Shape.NoFrame) self.label1.setTextFormat(QtCore.Qt.TextFormat.AutoText) self.label1.setScaledContents(False) self.label1.setObjectName("label1") self.horizontalLayout.addWidget(self.label1) self.val2 = QtWidgets.QLabel(parent=InfoStatus) self.val2.setMinimumSize(QtCore.QSize(40, 0)) self.val2.setText("") self.val2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.val2.setObjectName("val2") self.horizontalLayout.addWidget(self.val2) self.label2 = QtWidgets.QLabel(parent=InfoStatus) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label2.sizePolicy().hasHeightForWidth()) self.label2.setSizePolicy(sizePolicy) self.label2.setText("") self.label2.setObjectName("label2") self.horizontalLayout.addWidget(self.label2) self.val3 = QtWidgets.QLabel(parent=InfoStatus) self.val3.setMinimumSize(QtCore.QSize(40, 0)) self.val3.setText("") self.val3.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.val3.setObjectName("val3") self.horizontalLayout.addWidget(self.val3) self.label3 = QtWidgets.QLabel(parent=InfoStatus) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label3.sizePolicy().hasHeightForWidth()) self.label3.setSizePolicy(sizePolicy) self.label3.setText("") self.label3.setObjectName("label3") self.horizontalLayout.addWidget(self.label3) self.val4 = QtWidgets.QLabel(parent=InfoStatus) self.val4.setMinimumSize(QtCore.QSize(40, 0)) self.val4.setText("") self.val4.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.val4.setObjectName("val4") self.horizontalLayout.addWidget(self.val4) self.label4 = QtWidgets.QLabel(parent=InfoStatus) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label4.sizePolicy().hasHeightForWidth()) self.label4.setSizePolicy(sizePolicy) self.label4.setText("") self.label4.setScaledContents(False) self.label4.setObjectName("label4") self.horizontalLayout.addWidget(self.label4) self.val5 = QtWidgets.QLabel(parent=InfoStatus) self.val5.setMinimumSize(QtCore.QSize(40, 0)) self.val5.setText("") self.val5.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.val5.setObjectName("val5") self.horizontalLayout.addWidget(self.val5) self.label5 = QtWidgets.QLabel(parent=InfoStatus) self.label5.setMinimumSize(QtCore.QSize(0, 0)) self.label5.setText("") self.label5.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.label5.setObjectName("label5") self.horizontalLayout.addWidget(self.label5) self.retranslateUi(InfoStatus) QtCore.QMetaObject.connectSlotsByName(InfoStatus) def retranslateUi(self, InfoStatus): InfoStatus.setWindowTitle(_("Form"))
5,843
Python
.py
106
47.009434
143
0.742628
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,049
ui_options_advanced.py
metabrainz_picard/picard/ui/forms/ui_options_advanced.py
# Form implementation generated from reading ui file 'ui/options_advanced.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_AdvancedOptionsPage(object): def setupUi(self, AdvancedOptionsPage): AdvancedOptionsPage.setObjectName("AdvancedOptionsPage") AdvancedOptionsPage.resize(570, 455) self.vboxlayout = QtWidgets.QVBoxLayout(AdvancedOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.groupBox = QtWidgets.QGroupBox(parent=AdvancedOptionsPage) self.groupBox.setObjectName("groupBox") self.gridlayout = QtWidgets.QGridLayout(self.groupBox) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.label_ignore_regex = QtWidgets.QLabel(parent=self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_ignore_regex.sizePolicy().hasHeightForWidth()) self.label_ignore_regex.setSizePolicy(sizePolicy) self.label_ignore_regex.setWordWrap(True) self.label_ignore_regex.setObjectName("label_ignore_regex") self.gridlayout.addWidget(self.label_ignore_regex, 1, 0, 1, 1) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_query_limit = QtWidgets.QLabel(parent=self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_query_limit.sizePolicy().hasHeightForWidth()) self.label_query_limit.setSizePolicy(sizePolicy) self.label_query_limit.setObjectName("label_query_limit") self.horizontalLayout_2.addWidget(self.label_query_limit) self.query_limit = QtWidgets.QComboBox(parent=self.groupBox) self.query_limit.setCurrentText("50") self.query_limit.setObjectName("query_limit") self.query_limit.addItem("") self.query_limit.setItemText(0, "25") self.query_limit.addItem("") self.query_limit.setItemText(1, "50") self.query_limit.addItem("") self.query_limit.setItemText(2, "75") self.query_limit.addItem("") self.query_limit.setItemText(3, "100") self.horizontalLayout_2.addWidget(self.query_limit) self.gridlayout.addLayout(self.horizontalLayout_2, 8, 0, 1, 1) self.regex_error = QtWidgets.QLabel(parent=self.groupBox) self.regex_error.setText("") self.regex_error.setObjectName("regex_error") self.gridlayout.addWidget(self.regex_error, 3, 0, 1, 1) self.ignore_regex = QtWidgets.QLineEdit(parent=self.groupBox) self.ignore_regex.setObjectName("ignore_regex") self.gridlayout.addWidget(self.ignore_regex, 2, 0, 1, 1) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetDefaultConstraint) self.horizontalLayout.setObjectName("horizontalLayout") self.label_track_duration_diff = QtWidgets.QLabel(parent=self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_track_duration_diff.sizePolicy().hasHeightForWidth()) self.label_track_duration_diff.setSizePolicy(sizePolicy) self.label_track_duration_diff.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter) self.label_track_duration_diff.setObjectName("label_track_duration_diff") self.horizontalLayout.addWidget(self.label_track_duration_diff) self.ignore_track_duration_difference_under = QtWidgets.QSpinBox(parent=self.groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ignore_track_duration_difference_under.sizePolicy().hasHeightForWidth()) self.ignore_track_duration_difference_under.setSizePolicy(sizePolicy) self.ignore_track_duration_difference_under.setButtonSymbols(QtWidgets.QAbstractSpinBox.ButtonSymbols.UpDownArrows) self.ignore_track_duration_difference_under.setAccelerated(True) self.ignore_track_duration_difference_under.setSuffix("") self.ignore_track_duration_difference_under.setMinimum(1) self.ignore_track_duration_difference_under.setMaximum(7200) self.ignore_track_duration_difference_under.setProperty("value", 2) self.ignore_track_duration_difference_under.setObjectName("ignore_track_duration_difference_under") self.horizontalLayout.addWidget(self.ignore_track_duration_difference_under) self.gridlayout.addLayout(self.horizontalLayout, 6, 0, 2, 1) self.recursively_add_files = QtWidgets.QCheckBox(parent=self.groupBox) self.recursively_add_files.setObjectName("recursively_add_files") self.gridlayout.addWidget(self.recursively_add_files, 5, 0, 1, 1) self.ignore_hidden_files = QtWidgets.QCheckBox(parent=self.groupBox) self.ignore_hidden_files.setObjectName("ignore_hidden_files") self.gridlayout.addWidget(self.ignore_hidden_files, 4, 0, 1, 1) self.vboxlayout.addWidget(self.groupBox) self.groupBox_completeness = QtWidgets.QGroupBox(parent=AdvancedOptionsPage) self.groupBox_completeness.setObjectName("groupBox_completeness") self.gridLayout = QtWidgets.QGridLayout(self.groupBox_completeness) self.gridLayout.setObjectName("gridLayout") self.completeness_ignore_videos = QtWidgets.QCheckBox(parent=self.groupBox_completeness) self.completeness_ignore_videos.setObjectName("completeness_ignore_videos") self.gridLayout.addWidget(self.completeness_ignore_videos, 0, 0, 1, 1) self.completeness_ignore_data = QtWidgets.QCheckBox(parent=self.groupBox_completeness) self.completeness_ignore_data.setCheckable(True) self.completeness_ignore_data.setObjectName("completeness_ignore_data") self.gridLayout.addWidget(self.completeness_ignore_data, 3, 0, 1, 1) self.completeness_ignore_pregap = QtWidgets.QCheckBox(parent=self.groupBox_completeness) self.completeness_ignore_pregap.setObjectName("completeness_ignore_pregap") self.gridLayout.addWidget(self.completeness_ignore_pregap, 0, 1, 1, 1) self.completeness_ignore_silence = QtWidgets.QCheckBox(parent=self.groupBox_completeness) self.completeness_ignore_silence.setObjectName("completeness_ignore_silence") self.gridLayout.addWidget(self.completeness_ignore_silence, 3, 1, 1, 1) self.vboxlayout.addWidget(self.groupBox_completeness) self.groupBox_ignore_tags = QtWidgets.QGroupBox(parent=AdvancedOptionsPage) self.groupBox_ignore_tags.setObjectName("groupBox_ignore_tags") self.verticalLayout = QtWidgets.QVBoxLayout(self.groupBox_ignore_tags) self.verticalLayout.setObjectName("verticalLayout") self.compare_ignore_tags = TagListEditor(parent=self.groupBox_ignore_tags) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.compare_ignore_tags.sizePolicy().hasHeightForWidth()) self.compare_ignore_tags.setSizePolicy(sizePolicy) self.compare_ignore_tags.setObjectName("compare_ignore_tags") self.verticalLayout.addWidget(self.compare_ignore_tags) self.vboxlayout.addWidget(self.groupBox_ignore_tags) self.retranslateUi(AdvancedOptionsPage) self.query_limit.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(AdvancedOptionsPage) AdvancedOptionsPage.setTabOrder(self.ignore_regex, self.ignore_hidden_files) AdvancedOptionsPage.setTabOrder(self.ignore_hidden_files, self.recursively_add_files) AdvancedOptionsPage.setTabOrder(self.recursively_add_files, self.ignore_track_duration_difference_under) AdvancedOptionsPage.setTabOrder(self.ignore_track_duration_difference_under, self.query_limit) AdvancedOptionsPage.setTabOrder(self.query_limit, self.completeness_ignore_videos) AdvancedOptionsPage.setTabOrder(self.completeness_ignore_videos, self.completeness_ignore_data) def retranslateUi(self, AdvancedOptionsPage): self.groupBox.setTitle(_("Advanced options")) self.label_ignore_regex.setText(_("Ignore file paths matching the following regular expression:")) self.label_query_limit.setText(_("Maximum number of entities to return per MusicBrainz query")) self.label_track_duration_diff.setText(_("Ignore track duration difference under this number of seconds")) self.recursively_add_files.setText(_("Include sub-folders when adding files from folder")) self.ignore_hidden_files.setText(_("Ignore hidden files")) self.groupBox_completeness.setTitle(_("Ignore the following tracks when determining whether a release is complete")) self.completeness_ignore_videos.setText(_("Video tracks")) self.completeness_ignore_data.setText(_("Data tracks")) self.completeness_ignore_pregap.setText(_("Pregap tracks")) self.completeness_ignore_silence.setText(_("Silent tracks")) self.groupBox_ignore_tags.setTitle(_("Tags to ignore for comparison:")) from picard.ui.widgets.taglisteditor import TagListEditor
10,223
Python
.py
150
59.833333
160
0.753949
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,050
ui_options_tags_compatibility_id3.py
metabrainz_picard/picard/ui/forms/ui_options_tags_compatibility_id3.py
# Form implementation generated from reading ui file 'ui/options_tags_compatibility_id3.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsCompatibilityOptionsPage(object): def setupUi(self, TagsCompatibilityOptionsPage): TagsCompatibilityOptionsPage.setObjectName("TagsCompatibilityOptionsPage") TagsCompatibilityOptionsPage.resize(539, 705) self.vboxlayout = QtWidgets.QVBoxLayout(TagsCompatibilityOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.tag_compatibility = QtWidgets.QGroupBox(parent=TagsCompatibilityOptionsPage) self.tag_compatibility.setObjectName("tag_compatibility") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.tag_compatibility) self.vboxlayout1.setContentsMargins(-1, 6, -1, 7) self.vboxlayout1.setSpacing(2) self.vboxlayout1.setObjectName("vboxlayout1") self.id3v2_version = QtWidgets.QGroupBox(parent=self.tag_compatibility) self.id3v2_version.setFlat(False) self.id3v2_version.setCheckable(False) self.id3v2_version.setObjectName("id3v2_version") self.horizontalLayout = QtWidgets.QHBoxLayout(self.id3v2_version) self.horizontalLayout.setContentsMargins(-1, 6, -1, 7) self.horizontalLayout.setObjectName("horizontalLayout") self.write_id3v24 = QtWidgets.QRadioButton(parent=self.id3v2_version) self.write_id3v24.setChecked(True) self.write_id3v24.setObjectName("write_id3v24") self.horizontalLayout.addWidget(self.write_id3v24) self.write_id3v23 = QtWidgets.QRadioButton(parent=self.id3v2_version) self.write_id3v23.setChecked(False) self.write_id3v23.setObjectName("write_id3v23") self.horizontalLayout.addWidget(self.write_id3v23) self.label = QtWidgets.QLabel(parent=self.id3v2_version) self.label.setText("") self.label.setWordWrap(True) self.label.setObjectName("label") self.horizontalLayout.addWidget(self.label) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.vboxlayout1.addWidget(self.id3v2_version) self.id3v2_text_encoding = QtWidgets.QGroupBox(parent=self.tag_compatibility) self.id3v2_text_encoding.setObjectName("id3v2_text_encoding") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.id3v2_text_encoding) self.horizontalLayout_2.setContentsMargins(-1, 6, -1, 7) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.enc_utf8 = QtWidgets.QRadioButton(parent=self.id3v2_text_encoding) self.enc_utf8.setObjectName("enc_utf8") self.horizontalLayout_2.addWidget(self.enc_utf8) self.enc_utf16 = QtWidgets.QRadioButton(parent=self.id3v2_text_encoding) self.enc_utf16.setObjectName("enc_utf16") self.horizontalLayout_2.addWidget(self.enc_utf16) self.enc_iso88591 = QtWidgets.QRadioButton(parent=self.id3v2_text_encoding) self.enc_iso88591.setObjectName("enc_iso88591") self.horizontalLayout_2.addWidget(self.enc_iso88591) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.label_2 = QtWidgets.QLabel(parent=self.id3v2_text_encoding) self.label_2.setText("") self.label_2.setWordWrap(True) self.label_2.setObjectName("label_2") self.horizontalLayout_2.addWidget(self.label_2) self.vboxlayout1.addWidget(self.id3v2_text_encoding) self.hbox_id3v23_join_with = QtWidgets.QHBoxLayout() self.hbox_id3v23_join_with.setObjectName("hbox_id3v23_join_with") self.label_id3v23_join_with = QtWidgets.QLabel(parent=self.tag_compatibility) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(4) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_id3v23_join_with.sizePolicy().hasHeightForWidth()) self.label_id3v23_join_with.setSizePolicy(sizePolicy) self.label_id3v23_join_with.setObjectName("label_id3v23_join_with") self.hbox_id3v23_join_with.addWidget(self.label_id3v23_join_with) self.id3v23_join_with = QtWidgets.QComboBox(parent=self.tag_compatibility) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.id3v23_join_with.sizePolicy().hasHeightForWidth()) self.id3v23_join_with.setSizePolicy(sizePolicy) self.id3v23_join_with.setEditable(True) self.id3v23_join_with.setObjectName("id3v23_join_with") self.id3v23_join_with.addItem("") self.id3v23_join_with.setItemText(0, "/") self.id3v23_join_with.addItem("") self.id3v23_join_with.setItemText(1, "; ") self.id3v23_join_with.addItem("") self.id3v23_join_with.setItemText(2, " / ") self.hbox_id3v23_join_with.addWidget(self.id3v23_join_with) self.vboxlayout1.addLayout(self.hbox_id3v23_join_with) self.itunes_compatible_grouping = QtWidgets.QCheckBox(parent=self.tag_compatibility) self.itunes_compatible_grouping.setObjectName("itunes_compatible_grouping") self.vboxlayout1.addWidget(self.itunes_compatible_grouping) self.write_id3v1 = QtWidgets.QCheckBox(parent=self.tag_compatibility) self.write_id3v1.setObjectName("write_id3v1") self.vboxlayout1.addWidget(self.write_id3v1) self.vboxlayout.addWidget(self.tag_compatibility) spacerItem2 = QtWidgets.QSpacerItem(274, 41, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem2) self.retranslateUi(TagsCompatibilityOptionsPage) QtCore.QMetaObject.connectSlotsByName(TagsCompatibilityOptionsPage) TagsCompatibilityOptionsPage.setTabOrder(self.write_id3v24, self.write_id3v23) TagsCompatibilityOptionsPage.setTabOrder(self.write_id3v23, self.enc_utf8) TagsCompatibilityOptionsPage.setTabOrder(self.enc_utf8, self.enc_utf16) TagsCompatibilityOptionsPage.setTabOrder(self.enc_utf16, self.enc_iso88591) TagsCompatibilityOptionsPage.setTabOrder(self.enc_iso88591, self.id3v23_join_with) TagsCompatibilityOptionsPage.setTabOrder(self.id3v23_join_with, self.itunes_compatible_grouping) TagsCompatibilityOptionsPage.setTabOrder(self.itunes_compatible_grouping, self.write_id3v1) def retranslateUi(self, TagsCompatibilityOptionsPage): self.tag_compatibility.setTitle(_("ID3")) self.id3v2_version.setTitle(_("ID3v2 Version")) self.write_id3v24.setText(_("2.4")) self.write_id3v23.setText(_("2.3")) self.id3v2_text_encoding.setTitle(_("ID3v2 text encoding")) self.enc_utf8.setText(_("UTF-8")) self.enc_utf16.setText(_("UTF-16")) self.enc_iso88591.setText(_("ISO-8859-1")) self.label_id3v23_join_with.setText(_("Join multiple ID3v2.3 tags with:")) self.id3v23_join_with.setToolTip(_("<html><head/><body><p>Default is \'/\' to maintain compatibility with previous Picard releases.</p><p>New alternatives are \';_\' or \'_/_\' or type your own. </p></body></html>")) self.itunes_compatible_grouping.setText(_("Save iTunes compatible grouping and work")) self.write_id3v1.setText(_("Also include ID3v1 tags in the files"))
7,937
Python
.py
126
54.738095
224
0.737092
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,051
ui_options_tags_compatibility_aac.py
metabrainz_picard/picard/ui/forms/ui_options_tags_compatibility_aac.py
# Form implementation generated from reading ui file 'ui/options_tags_compatibility_aac.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsCompatibilityOptionsPage(object): def setupUi(self, TagsCompatibilityOptionsPage): TagsCompatibilityOptionsPage.setObjectName("TagsCompatibilityOptionsPage") TagsCompatibilityOptionsPage.resize(539, 705) self.vboxlayout = QtWidgets.QVBoxLayout(TagsCompatibilityOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.aac_tags = QtWidgets.QGroupBox(parent=TagsCompatibilityOptionsPage) self.aac_tags.setObjectName("aac_tags") self.verticalLayout = QtWidgets.QVBoxLayout(self.aac_tags) self.verticalLayout.setObjectName("verticalLayout") self.info_label = QtWidgets.QLabel(parent=self.aac_tags) self.info_label.setWordWrap(True) self.info_label.setObjectName("info_label") self.verticalLayout.addWidget(self.info_label) spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.verticalLayout.addItem(spacerItem) self.aac_save_ape = QtWidgets.QRadioButton(parent=self.aac_tags) self.aac_save_ape.setChecked(True) self.aac_save_ape.setObjectName("aac_save_ape") self.verticalLayout.addWidget(self.aac_save_ape) self.aac_no_tags = QtWidgets.QRadioButton(parent=self.aac_tags) self.aac_no_tags.setObjectName("aac_no_tags") self.verticalLayout.addWidget(self.aac_no_tags) self.remove_ape_from_aac = QtWidgets.QCheckBox(parent=self.aac_tags) self.remove_ape_from_aac.setObjectName("remove_ape_from_aac") self.verticalLayout.addWidget(self.remove_ape_from_aac) self.vboxlayout.addWidget(self.aac_tags) spacerItem1 = QtWidgets.QSpacerItem(274, 41, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem1) self.retranslateUi(TagsCompatibilityOptionsPage) QtCore.QMetaObject.connectSlotsByName(TagsCompatibilityOptionsPage) def retranslateUi(self, TagsCompatibilityOptionsPage): self.aac_tags.setTitle(_("AAC files")) self.info_label.setText(_("Picard can save APEv2 tags to pure AAC files, which by default do not support tagging. APEv2 tags in AAC are supported by some players, but players not supporting AAC files with APEv2 tags can have issues loading and playing those files. To deal with this you can choose whether to save tags to those files.")) self.aac_save_ape.setText(_("Save APEv2 tags")) self.aac_no_tags.setText(_("Do not save tags")) self.remove_ape_from_aac.setText(_("Remove APEv2 tags from AAC files"))
2,965
Python
.py
49
53.428571
345
0.746048
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,052
ui_edittagdialog.py
metabrainz_picard/picard/ui/forms/ui_edittagdialog.py
# Form implementation generated from reading ui file 'ui/edittagdialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_EditTagDialog(object): def setupUi(self, EditTagDialog): EditTagDialog.setObjectName("EditTagDialog") EditTagDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) EditTagDialog.resize(400, 250) EditTagDialog.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus) EditTagDialog.setModal(True) self.verticalLayout_2 = QtWidgets.QVBoxLayout(EditTagDialog) self.verticalLayout_2.setObjectName("verticalLayout_2") self.tag_names = QtWidgets.QComboBox(parent=EditTagDialog) self.tag_names.setEditable(True) self.tag_names.setObjectName("tag_names") self.verticalLayout_2.addWidget(self.tag_names) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.value_list = QtWidgets.QListWidget(parent=EditTagDialog) self.value_list.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus) self.value_list.setTabKeyNavigation(False) self.value_list.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove) self.value_list.setMovement(QtWidgets.QListView.Movement.Free) self.value_list.setObjectName("value_list") self.horizontalLayout.addWidget(self.value_list) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.edit_value = QtWidgets.QPushButton(parent=EditTagDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(100) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.edit_value.sizePolicy().hasHeightForWidth()) self.edit_value.setSizePolicy(sizePolicy) self.edit_value.setMinimumSize(QtCore.QSize(100, 0)) self.edit_value.setAutoDefault(False) self.edit_value.setObjectName("edit_value") self.verticalLayout.addWidget(self.edit_value) self.add_value = QtWidgets.QPushButton(parent=EditTagDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(100) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.add_value.sizePolicy().hasHeightForWidth()) self.add_value.setSizePolicy(sizePolicy) self.add_value.setMinimumSize(QtCore.QSize(100, 0)) self.add_value.setAutoDefault(False) self.add_value.setObjectName("add_value") self.verticalLayout.addWidget(self.add_value) self.remove_value = QtWidgets.QPushButton(parent=EditTagDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(120) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.remove_value.sizePolicy().hasHeightForWidth()) self.remove_value.setSizePolicy(sizePolicy) self.remove_value.setMinimumSize(QtCore.QSize(120, 0)) self.remove_value.setAutoDefault(False) self.remove_value.setObjectName("remove_value") self.verticalLayout.addWidget(self.remove_value) spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Maximum) self.verticalLayout.addItem(spacerItem) self.move_value_up = QtWidgets.QPushButton(parent=EditTagDialog) self.move_value_up.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-up.png") self.move_value_up.setIcon(icon) self.move_value_up.setObjectName("move_value_up") self.verticalLayout.addWidget(self.move_value_up) self.move_value_down = QtWidgets.QPushButton(parent=EditTagDialog) self.move_value_down.setText("") icon = QtGui.QIcon.fromTheme(":/images/16x16/go-down.png") self.move_value_down.setIcon(icon) self.move_value_down.setObjectName("move_value_down") self.verticalLayout.addWidget(self.move_value_down) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.horizontalLayout.addLayout(self.verticalLayout) self.verticalLayout_2.addLayout(self.horizontalLayout) self.buttonbox = QtWidgets.QDialogButtonBox(parent=EditTagDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(150) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.buttonbox.sizePolicy().hasHeightForWidth()) self.buttonbox.setSizePolicy(sizePolicy) self.buttonbox.setMinimumSize(QtCore.QSize(150, 0)) self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonbox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok) self.buttonbox.setObjectName("buttonbox") self.verticalLayout_2.addWidget(self.buttonbox) self.retranslateUi(EditTagDialog) self.buttonbox.accepted.connect(EditTagDialog.accept) # type: ignore self.buttonbox.rejected.connect(EditTagDialog.reject) # type: ignore self.move_value_up.clicked.connect(EditTagDialog.move_row_up) # type: ignore self.move_value_down.clicked.connect(EditTagDialog.move_row_down) # type: ignore self.edit_value.clicked.connect(EditTagDialog.edit_value) # type: ignore self.add_value.clicked.connect(EditTagDialog.add_value) # type: ignore self.value_list.itemChanged['QListWidgetItem*'].connect(EditTagDialog.value_edited) # type: ignore self.remove_value.clicked.connect(EditTagDialog.remove_value) # type: ignore self.value_list.itemSelectionChanged.connect(EditTagDialog.value_selection_changed) # type: ignore self.tag_names.editTextChanged['QString'].connect(EditTagDialog.tag_changed) # type: ignore self.tag_names.activated['int'].connect(EditTagDialog.tag_selected) # type: ignore QtCore.QMetaObject.connectSlotsByName(EditTagDialog) EditTagDialog.setTabOrder(self.tag_names, self.value_list) EditTagDialog.setTabOrder(self.value_list, self.edit_value) EditTagDialog.setTabOrder(self.edit_value, self.add_value) EditTagDialog.setTabOrder(self.add_value, self.remove_value) EditTagDialog.setTabOrder(self.remove_value, self.buttonbox) def retranslateUi(self, EditTagDialog): EditTagDialog.setWindowTitle(_("Edit Tag")) self.edit_value.setText(_("Edit value")) self.add_value.setText(_("Add value")) self.remove_value.setText(_("Remove value")) self.move_value_up.setToolTip(_("Move selected value up")) self.move_value_up.setAccessibleDescription(_("Move selected value up")) self.move_value_down.setToolTip(_("Move selected value down")) self.move_value_down.setAccessibleDescription(_("Move selected value down"))
7,516
Python
.py
122
53.377049
136
0.745533
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,053
ui_win_compat_dialog.py
metabrainz_picard/picard/ui/forms/ui_win_compat_dialog.py
# Form implementation generated from reading ui file 'ui/win_compat_dialog.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_WinCompatDialog(object): def setupUi(self, WinCompatDialog): WinCompatDialog.setObjectName("WinCompatDialog") WinCompatDialog.setWindowModality(QtCore.Qt.WindowModality.WindowModal) WinCompatDialog.resize(285, 295) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(WinCompatDialog.sizePolicy().hasHeightForWidth()) WinCompatDialog.setSizePolicy(sizePolicy) self.verticalLayout = QtWidgets.QVBoxLayout(WinCompatDialog) self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetFixedSize) self.verticalLayout.setObjectName("verticalLayout") self.gridLayout = QtWidgets.QGridLayout() self.gridLayout.setObjectName("gridLayout") self.label_header_character = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setBold(True) font.setWeight(75) self.label_header_character.setFont(font) self.label_header_character.setObjectName("label_header_character") self.gridLayout.addWidget(self.label_header_character, 0, 0, 1, 1) self.label_header_replace = QtWidgets.QLabel(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_header_replace.sizePolicy().hasHeightForWidth()) self.label_header_replace.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setBold(True) font.setWeight(75) self.label_header_replace.setFont(font) self.label_header_replace.setObjectName("label_header_replace") self.gridLayout.addWidget(self.label_header_replace, 0, 2, 1, 1) self.label_lt = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_lt.setFont(font) self.label_lt.setText("<") self.label_lt.setObjectName("label_lt") self.gridLayout.addWidget(self.label_lt, 3, 0, 1, 1) self.label_colon = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_colon.setFont(font) self.label_colon.setText(":") self.label_colon.setObjectName("label_colon") self.gridLayout.addWidget(self.label_colon, 2, 0, 1, 1) self.label_gt = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_gt.setFont(font) self.label_gt.setText(">") self.label_gt.setObjectName("label_gt") self.gridLayout.addWidget(self.label_gt, 4, 0, 1, 1) self.replace_questionmark = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_questionmark.sizePolicy().hasHeightForWidth()) self.replace_questionmark.setSizePolicy(sizePolicy) self.replace_questionmark.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_questionmark.setText("_") self.replace_questionmark.setMaxLength(1) self.replace_questionmark.setObjectName("replace_questionmark") self.gridLayout.addWidget(self.replace_questionmark, 5, 2, 1, 1) self.label_questionmark = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_questionmark.setFont(font) self.label_questionmark.setText("?") self.label_questionmark.setObjectName("label_questionmark") self.gridLayout.addWidget(self.label_questionmark, 5, 0, 1, 1) self.label_pipe = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_pipe.setFont(font) self.label_pipe.setText("|") self.label_pipe.setObjectName("label_pipe") self.gridLayout.addWidget(self.label_pipe, 6, 0, 1, 1) self.replace_asterisk = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_asterisk.sizePolicy().hasHeightForWidth()) self.replace_asterisk.setSizePolicy(sizePolicy) self.replace_asterisk.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_asterisk.setText("_") self.replace_asterisk.setMaxLength(1) self.replace_asterisk.setObjectName("replace_asterisk") self.gridLayout.addWidget(self.replace_asterisk, 1, 2, 1, 1) self.replace_gt = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_gt.sizePolicy().hasHeightForWidth()) self.replace_gt.setSizePolicy(sizePolicy) self.replace_gt.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_gt.setText("_") self.replace_gt.setMaxLength(1) self.replace_gt.setObjectName("replace_gt") self.gridLayout.addWidget(self.replace_gt, 4, 2, 1, 1) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.gridLayout.addItem(spacerItem, 0, 3, 1, 1) self.replace_lt = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_lt.sizePolicy().hasHeightForWidth()) self.replace_lt.setSizePolicy(sizePolicy) self.replace_lt.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_lt.setText("_") self.replace_lt.setMaxLength(1) self.replace_lt.setObjectName("replace_lt") self.gridLayout.addWidget(self.replace_lt, 3, 2, 1, 1) self.label_asterisk = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_asterisk.setFont(font) self.label_asterisk.setText("*") self.label_asterisk.setObjectName("label_asterisk") self.gridLayout.addWidget(self.label_asterisk, 1, 0, 1, 1) self.replace_pipe = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_pipe.sizePolicy().hasHeightForWidth()) self.replace_pipe.setSizePolicy(sizePolicy) self.replace_pipe.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_pipe.setText("_") self.replace_pipe.setMaxLength(1) self.replace_pipe.setObjectName("replace_pipe") self.gridLayout.addWidget(self.replace_pipe, 6, 2, 1, 1) self.replace_colon = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_colon.sizePolicy().hasHeightForWidth()) self.replace_colon.setSizePolicy(sizePolicy) self.replace_colon.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_colon.setText("_") self.replace_colon.setMaxLength(1) self.replace_colon.setObjectName("replace_colon") self.gridLayout.addWidget(self.replace_colon, 2, 2, 1, 1) self.label_quotationmark = QtWidgets.QLabel(parent=WinCompatDialog) font = QtGui.QFont() font.setFamily("Monospace") self.label_quotationmark.setFont(font) self.label_quotationmark.setText("\"") self.label_quotationmark.setObjectName("label_quotationmark") self.gridLayout.addWidget(self.label_quotationmark, 7, 0, 1, 1) self.replace_quotationmark = QtWidgets.QLineEdit(parent=WinCompatDialog) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.replace_quotationmark.sizePolicy().hasHeightForWidth()) self.replace_quotationmark.setSizePolicy(sizePolicy) self.replace_quotationmark.setMaximumSize(QtCore.QSize(20, 16777215)) self.replace_quotationmark.setText("_") self.replace_quotationmark.setObjectName("replace_quotationmark") self.gridLayout.addWidget(self.replace_quotationmark, 7, 2, 1, 1) self.verticalLayout.addLayout(self.gridLayout) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.verticalLayout.addItem(spacerItem1) self.buttonbox = QtWidgets.QDialogButtonBox(parent=WinCompatDialog) self.buttonbox.setOrientation(QtCore.Qt.Orientation.Horizontal) self.buttonbox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Save) self.buttonbox.setObjectName("buttonbox") self.verticalLayout.addWidget(self.buttonbox) self.retranslateUi(WinCompatDialog) QtCore.QMetaObject.connectSlotsByName(WinCompatDialog) WinCompatDialog.setTabOrder(self.replace_asterisk, self.replace_colon) WinCompatDialog.setTabOrder(self.replace_colon, self.replace_lt) WinCompatDialog.setTabOrder(self.replace_lt, self.replace_gt) WinCompatDialog.setTabOrder(self.replace_gt, self.replace_questionmark) WinCompatDialog.setTabOrder(self.replace_questionmark, self.replace_pipe) WinCompatDialog.setTabOrder(self.replace_pipe, self.replace_quotationmark) def retranslateUi(self, WinCompatDialog): WinCompatDialog.setWindowTitle(_("Windows compatibility")) self.label_header_character.setText(_("Character")) self.label_header_replace.setText(_("Replacement"))
11,202
Python
.py
193
49.528497
138
0.732073
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,054
ui_options_tags_compatibility_ac3.py
metabrainz_picard/picard/ui/forms/ui_options_tags_compatibility_ac3.py
# Form implementation generated from reading ui file 'ui/options_tags_compatibility_ac3.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_TagsCompatibilityOptionsPage(object): def setupUi(self, TagsCompatibilityOptionsPage): TagsCompatibilityOptionsPage.setObjectName("TagsCompatibilityOptionsPage") TagsCompatibilityOptionsPage.resize(539, 705) self.vboxlayout = QtWidgets.QVBoxLayout(TagsCompatibilityOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.ac3_files = QtWidgets.QGroupBox(parent=TagsCompatibilityOptionsPage) self.ac3_files.setObjectName("ac3_files") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.ac3_files) self.verticalLayout_2.setObjectName("verticalLayout_2") self.info_label = QtWidgets.QLabel(parent=self.ac3_files) self.info_label.setWordWrap(True) self.info_label.setObjectName("info_label") self.verticalLayout_2.addWidget(self.info_label) spacerItem = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) self.verticalLayout_2.addItem(spacerItem) self.ac3_save_ape = QtWidgets.QRadioButton(parent=self.ac3_files) self.ac3_save_ape.setChecked(True) self.ac3_save_ape.setObjectName("ac3_save_ape") self.verticalLayout_2.addWidget(self.ac3_save_ape) self.ac3_no_tags = QtWidgets.QRadioButton(parent=self.ac3_files) self.ac3_no_tags.setObjectName("ac3_no_tags") self.verticalLayout_2.addWidget(self.ac3_no_tags) self.remove_ape_from_ac3 = QtWidgets.QCheckBox(parent=self.ac3_files) self.remove_ape_from_ac3.setObjectName("remove_ape_from_ac3") self.verticalLayout_2.addWidget(self.remove_ape_from_ac3) self.vboxlayout.addWidget(self.ac3_files) spacerItem1 = QtWidgets.QSpacerItem(274, 41, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem1) self.retranslateUi(TagsCompatibilityOptionsPage) QtCore.QMetaObject.connectSlotsByName(TagsCompatibilityOptionsPage) def retranslateUi(self, TagsCompatibilityOptionsPage): self.ac3_files.setTitle(_("AC3 files")) self.info_label.setText(_("Picard can save APEv2 tags to pure AC3 files, which by default do not support tagging. APEv2 tags in AC3 are supported by some players, but players not supporting AC3 files with APEv2 tags can have issues loading and playing those files. To deal with this you can choose whether to save tags to those files.")) self.ac3_save_ape.setText(_("Save APEv2 tags")) self.ac3_no_tags.setText(_("Do not save tags")) self.remove_ape_from_ac3.setText(_("Remove APEv2 tags from AC3 files"))
2,991
Python
.py
49
53.959184
345
0.745572
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,055
ui_options_network.py
metabrainz_picard/picard/ui/forms/ui_options_network.py
# Form implementation generated from reading ui file 'ui/options_network.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_NetworkOptionsPage(object): def setupUi(self, NetworkOptionsPage): NetworkOptionsPage.setObjectName("NetworkOptionsPage") NetworkOptionsPage.resize(316, 491) self.vboxlayout = QtWidgets.QVBoxLayout(NetworkOptionsPage) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.web_proxy = QtWidgets.QGroupBox(parent=NetworkOptionsPage) self.web_proxy.setCheckable(True) self.web_proxy.setObjectName("web_proxy") self.gridlayout = QtWidgets.QGridLayout(self.web_proxy) self.gridlayout.setContentsMargins(9, 9, 9, 9) self.gridlayout.setSpacing(2) self.gridlayout.setObjectName("gridlayout") self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.proxy_type_http = QtWidgets.QRadioButton(parent=self.web_proxy) self.proxy_type_http.setChecked(True) self.proxy_type_http.setObjectName("proxy_type_http") self.horizontalLayout_2.addWidget(self.proxy_type_http) self.proxy_type_socks = QtWidgets.QRadioButton(parent=self.web_proxy) self.proxy_type_socks.setObjectName("proxy_type_socks") self.horizontalLayout_2.addWidget(self.proxy_type_socks) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.gridlayout.addLayout(self.horizontalLayout_2, 0, 0, 1, 1) self.server_host = QtWidgets.QLineEdit(parent=self.web_proxy) self.server_host.setObjectName("server_host") self.gridlayout.addWidget(self.server_host, 5, 0, 1, 1) self.username = QtWidgets.QLineEdit(parent=self.web_proxy) self.username.setObjectName("username") self.gridlayout.addWidget(self.username, 7, 0, 1, 2) self.password = QtWidgets.QLineEdit(parent=self.web_proxy) self.password.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password) self.password.setObjectName("password") self.gridlayout.addWidget(self.password, 9, 0, 1, 2) self.server_port = QtWidgets.QSpinBox(parent=self.web_proxy) self.server_port.setMinimum(1) self.server_port.setMaximum(65535) self.server_port.setProperty("value", 80) self.server_port.setObjectName("server_port") self.gridlayout.addWidget(self.server_port, 5, 1, 1, 1) self.label_6 = QtWidgets.QLabel(parent=self.web_proxy) self.label_6.setObjectName("label_6") self.gridlayout.addWidget(self.label_6, 6, 0, 1, 2) self.label_7 = QtWidgets.QLabel(parent=self.web_proxy) self.label_7.setObjectName("label_7") self.gridlayout.addWidget(self.label_7, 4, 1, 1, 1) self.label_5 = QtWidgets.QLabel(parent=self.web_proxy) self.label_5.setObjectName("label_5") self.gridlayout.addWidget(self.label_5, 8, 0, 1, 2) self.label = QtWidgets.QLabel(parent=self.web_proxy) self.label.setObjectName("label") self.gridlayout.addWidget(self.label, 4, 0, 1, 1) self.vboxlayout.addWidget(self.web_proxy) self.networkopts = QtWidgets.QGroupBox(parent=NetworkOptionsPage) self.networkopts.setObjectName("networkopts") self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.networkopts) self.verticalLayout_5.setObjectName("verticalLayout_5") self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_3 = QtWidgets.QLabel(parent=self.networkopts) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth()) self.label_3.setSizePolicy(sizePolicy) self.label_3.setObjectName("label_3") self.horizontalLayout_3.addWidget(self.label_3) self.transfer_timeout = QtWidgets.QSpinBox(parent=self.networkopts) self.transfer_timeout.setMaximum(900) self.transfer_timeout.setProperty("value", 30) self.transfer_timeout.setObjectName("transfer_timeout") self.horizontalLayout_3.addWidget(self.transfer_timeout) self.verticalLayout_5.addLayout(self.horizontalLayout_3) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.label_cache_size = QtWidgets.QLabel(parent=self.networkopts) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_cache_size.sizePolicy().hasHeightForWidth()) self.label_cache_size.setSizePolicy(sizePolicy) self.label_cache_size.setObjectName("label_cache_size") self.horizontalLayout.addWidget(self.label_cache_size, 0, QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignVCenter) self.network_cache_size = QtWidgets.QLineEdit(parent=self.networkopts) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.network_cache_size.sizePolicy().hasHeightForWidth()) self.network_cache_size.setSizePolicy(sizePolicy) self.network_cache_size.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter) self.network_cache_size.setObjectName("network_cache_size") self.horizontalLayout.addWidget(self.network_cache_size) self.verticalLayout_5.addLayout(self.horizontalLayout) self.vboxlayout.addWidget(self.networkopts, 0, QtCore.Qt.AlignmentFlag.AlignVCenter) self.browser_integration = QtWidgets.QGroupBox(parent=NetworkOptionsPage) self.browser_integration.setCheckable(True) self.browser_integration.setChecked(True) self.browser_integration.setObjectName("browser_integration") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.browser_integration) self.verticalLayout_2.setObjectName("verticalLayout_2") self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.label_2 = QtWidgets.QLabel(parent=self.browser_integration) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth()) self.label_2.setSizePolicy(sizePolicy) self.label_2.setObjectName("label_2") self.horizontalLayout_4.addWidget(self.label_2) self.browser_integration_port = QtWidgets.QSpinBox(parent=self.browser_integration) self.browser_integration_port.setMinimum(1) self.browser_integration_port.setMaximum(65535) self.browser_integration_port.setProperty("value", 8000) self.browser_integration_port.setObjectName("browser_integration_port") self.horizontalLayout_4.addWidget(self.browser_integration_port) self.verticalLayout_2.addLayout(self.horizontalLayout_4) self.browser_integration_localhost_only = QtWidgets.QCheckBox(parent=self.browser_integration) self.browser_integration_localhost_only.setChecked(False) self.browser_integration_localhost_only.setObjectName("browser_integration_localhost_only") self.verticalLayout_2.addWidget(self.browser_integration_localhost_only) self.vboxlayout.addWidget(self.browser_integration) spacerItem1 = QtWidgets.QSpacerItem(101, 31, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem1) self.label_6.setBuddy(self.username) self.label_5.setBuddy(self.password) self.label.setBuddy(self.server_host) self.retranslateUi(NetworkOptionsPage) QtCore.QMetaObject.connectSlotsByName(NetworkOptionsPage) NetworkOptionsPage.setTabOrder(self.web_proxy, self.proxy_type_http) NetworkOptionsPage.setTabOrder(self.proxy_type_http, self.proxy_type_socks) NetworkOptionsPage.setTabOrder(self.proxy_type_socks, self.server_host) NetworkOptionsPage.setTabOrder(self.server_host, self.server_port) NetworkOptionsPage.setTabOrder(self.server_port, self.username) NetworkOptionsPage.setTabOrder(self.username, self.password) NetworkOptionsPage.setTabOrder(self.password, self.network_cache_size) NetworkOptionsPage.setTabOrder(self.network_cache_size, self.browser_integration) NetworkOptionsPage.setTabOrder(self.browser_integration, self.browser_integration_port) NetworkOptionsPage.setTabOrder(self.browser_integration_port, self.browser_integration_localhost_only) def retranslateUi(self, NetworkOptionsPage): self.web_proxy.setTitle(_("Web Proxy")) self.proxy_type_http.setText(_("HTTP")) self.proxy_type_socks.setText(_("SOCKS")) self.label_6.setText(_("Username:")) self.label_7.setText(_("Port:")) self.label_5.setText(_("Password:")) self.label.setText(_("Server address:")) self.networkopts.setTitle(_("Network options")) self.label_3.setText(_("Request timeout in seconds:")) self.label_cache_size.setText(_("Cache size (MB):")) self.browser_integration.setTitle(_("Browser Integration")) self.label_2.setText(_("Default listening port:")) self.browser_integration_localhost_only.setText(_("Listen only on localhost"))
10,426
Python
.py
168
53.619048
155
0.73771
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,056
ui_options_interface.py
metabrainz_picard/picard/ui/forms/ui_options_interface.py
# Form implementation generated from reading ui file 'ui/options_interface.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InterfaceOptionsPage(object): def setupUi(self, InterfaceOptionsPage): InterfaceOptionsPage.setObjectName("InterfaceOptionsPage") InterfaceOptionsPage.resize(466, 543) self.vboxlayout = QtWidgets.QVBoxLayout(InterfaceOptionsPage) self.vboxlayout.setObjectName("vboxlayout") self.groupBox = QtWidgets.QGroupBox(parent=InterfaceOptionsPage) self.groupBox.setObjectName("groupBox") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.groupBox) self.verticalLayout_3.setObjectName("verticalLayout_3") self.toolbar_show_labels = QtWidgets.QCheckBox(parent=self.groupBox) self.toolbar_show_labels.setObjectName("toolbar_show_labels") self.verticalLayout_3.addWidget(self.toolbar_show_labels) self.show_menu_icons = QtWidgets.QCheckBox(parent=self.groupBox) self.show_menu_icons.setObjectName("show_menu_icons") self.verticalLayout_3.addWidget(self.show_menu_icons) self.label = QtWidgets.QLabel(parent=self.groupBox) self.label.setObjectName("label") self.verticalLayout_3.addWidget(self.label) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.ui_language = QtWidgets.QComboBox(parent=self.groupBox) self.ui_language.setObjectName("ui_language") self.horizontalLayout.addWidget(self.ui_language) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout.addItem(spacerItem) self.verticalLayout_3.addLayout(self.horizontalLayout) self.label_theme = QtWidgets.QLabel(parent=self.groupBox) self.label_theme.setObjectName("label_theme") self.verticalLayout_3.addWidget(self.label_theme) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.ui_theme = QtWidgets.QComboBox(parent=self.groupBox) self.ui_theme.setObjectName("ui_theme") self.horizontalLayout_2.addWidget(self.ui_theme) spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) self.horizontalLayout_2.addItem(spacerItem1) self.verticalLayout_3.addLayout(self.horizontalLayout_2) self.vboxlayout.addWidget(self.groupBox) self.miscellaneous_box = QtWidgets.QGroupBox(parent=InterfaceOptionsPage) self.miscellaneous_box.setObjectName("miscellaneous_box") self.vboxlayout1 = QtWidgets.QVBoxLayout(self.miscellaneous_box) self.vboxlayout1.setObjectName("vboxlayout1") self.allow_multi_dirs_selection = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.allow_multi_dirs_selection.setObjectName("allow_multi_dirs_selection") self.vboxlayout1.addWidget(self.allow_multi_dirs_selection) self.builtin_search = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.builtin_search.setObjectName("builtin_search") self.vboxlayout1.addWidget(self.builtin_search) self.use_adv_search_syntax = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.use_adv_search_syntax.setObjectName("use_adv_search_syntax") self.vboxlayout1.addWidget(self.use_adv_search_syntax) self.new_user_dialog = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.new_user_dialog.setObjectName("new_user_dialog") self.vboxlayout1.addWidget(self.new_user_dialog) self.quit_confirmation = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.quit_confirmation.setObjectName("quit_confirmation") self.vboxlayout1.addWidget(self.quit_confirmation) self.file_save_warning = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.file_save_warning.setObjectName("file_save_warning") self.vboxlayout1.addWidget(self.file_save_warning) self.filebrowser_horizontal_autoscroll = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.filebrowser_horizontal_autoscroll.setObjectName("filebrowser_horizontal_autoscroll") self.vboxlayout1.addWidget(self.filebrowser_horizontal_autoscroll) self.starting_directory = QtWidgets.QCheckBox(parent=self.miscellaneous_box) self.starting_directory.setObjectName("starting_directory") self.vboxlayout1.addWidget(self.starting_directory) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setSpacing(2) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.starting_directory_path = QtWidgets.QLineEdit(parent=self.miscellaneous_box) self.starting_directory_path.setEnabled(False) self.starting_directory_path.setObjectName("starting_directory_path") self.horizontalLayout_4.addWidget(self.starting_directory_path) self.starting_directory_browse = QtWidgets.QPushButton(parent=self.miscellaneous_box) self.starting_directory_browse.setEnabled(False) self.starting_directory_browse.setObjectName("starting_directory_browse") self.horizontalLayout_4.addWidget(self.starting_directory_browse) self.vboxlayout1.addLayout(self.horizontalLayout_4) self.ui_theme_container = QtWidgets.QWidget(parent=self.miscellaneous_box) self.ui_theme_container.setEnabled(True) self.ui_theme_container.setObjectName("ui_theme_container") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.ui_theme_container) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.vboxlayout1.addWidget(self.ui_theme_container) self.vboxlayout.addWidget(self.miscellaneous_box) spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.vboxlayout.addItem(spacerItem2) self.retranslateUi(InterfaceOptionsPage) QtCore.QMetaObject.connectSlotsByName(InterfaceOptionsPage) InterfaceOptionsPage.setTabOrder(self.toolbar_show_labels, self.show_menu_icons) InterfaceOptionsPage.setTabOrder(self.show_menu_icons, self.ui_language) InterfaceOptionsPage.setTabOrder(self.ui_language, self.ui_theme) InterfaceOptionsPage.setTabOrder(self.ui_theme, self.allow_multi_dirs_selection) InterfaceOptionsPage.setTabOrder(self.allow_multi_dirs_selection, self.builtin_search) InterfaceOptionsPage.setTabOrder(self.builtin_search, self.use_adv_search_syntax) InterfaceOptionsPage.setTabOrder(self.use_adv_search_syntax, self.new_user_dialog) InterfaceOptionsPage.setTabOrder(self.new_user_dialog, self.quit_confirmation) InterfaceOptionsPage.setTabOrder(self.quit_confirmation, self.file_save_warning) InterfaceOptionsPage.setTabOrder(self.file_save_warning, self.filebrowser_horizontal_autoscroll) InterfaceOptionsPage.setTabOrder(self.filebrowser_horizontal_autoscroll, self.starting_directory) InterfaceOptionsPage.setTabOrder(self.starting_directory, self.starting_directory_path) InterfaceOptionsPage.setTabOrder(self.starting_directory_path, self.starting_directory_browse) def retranslateUi(self, InterfaceOptionsPage): self.groupBox.setTitle(_("Appearance")) self.toolbar_show_labels.setText(_("Show text labels under icons")) self.show_menu_icons.setText(_("Show icons in menus")) self.label.setText(_("User interface language:")) self.label_theme.setText(_("User interface color theme:")) self.miscellaneous_box.setTitle(_("Miscellaneous")) self.allow_multi_dirs_selection.setText(_("Allow selection of multiple directories")) self.builtin_search.setText(_("Use builtin search rather than looking in browser")) self.use_adv_search_syntax.setText(_("Use advanced query syntax")) self.new_user_dialog.setText(_("Show the new user dialog when starting Picard")) self.quit_confirmation.setText(_("Show a quit confirmation dialog for unsaved changes")) self.file_save_warning.setText(_("Show a confirmation dialog when saving files")) self.filebrowser_horizontal_autoscroll.setText(_("Adjust horizontal position in file browser automatically")) self.starting_directory.setText(_("Begin browsing in the following directory:")) self.starting_directory_browse.setText(_("Browse…"))
8,890
Python
.py
132
59.060606
129
0.754113
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,057
ui_options_interface_top_tags.py
metabrainz_picard/picard/ui/forms/ui_options_interface_top_tags.py
# Form implementation generated from reading ui file 'ui/options_interface_top_tags.ui' # # Created by: PyQt6 UI code generator 6.6.1 # # Automatically generated - do not edit. # Use `python setup.py build_ui` to update it. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.i18n import gettext as _ class Ui_InterfaceTopTagsOptionsPage(object): def setupUi(self, InterfaceTopTagsOptionsPage): InterfaceTopTagsOptionsPage.setObjectName("InterfaceTopTagsOptionsPage") InterfaceTopTagsOptionsPage.resize(418, 310) self.vboxlayout = QtWidgets.QVBoxLayout(InterfaceTopTagsOptionsPage) self.vboxlayout.setContentsMargins(9, 9, 9, 9) self.vboxlayout.setSpacing(6) self.vboxlayout.setObjectName("vboxlayout") self.top_tags_groupBox = QtWidgets.QGroupBox(parent=InterfaceTopTagsOptionsPage) self.top_tags_groupBox.setObjectName("top_tags_groupBox") self.verticalLayout = QtWidgets.QVBoxLayout(self.top_tags_groupBox) self.verticalLayout.setObjectName("verticalLayout") self.top_tags_list = TagListEditor(parent=self.top_tags_groupBox) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.top_tags_list.sizePolicy().hasHeightForWidth()) self.top_tags_list.setSizePolicy(sizePolicy) self.top_tags_list.setObjectName("top_tags_list") self.verticalLayout.addWidget(self.top_tags_list) self.vboxlayout.addWidget(self.top_tags_groupBox) self.retranslateUi(InterfaceTopTagsOptionsPage) QtCore.QMetaObject.connectSlotsByName(InterfaceTopTagsOptionsPage) def retranslateUi(self, InterfaceTopTagsOptionsPage): self.top_tags_groupBox.setTitle(_("Show the below tags above all other tags in the metadata view")) from picard.ui.widgets.taglisteditor import TagListEditor
2,025
Python
.py
38
46.973684
122
0.767289
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,058
matching.py
metabrainz_picard/picard/ui/options/matching.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011 Lukáš Lalinský # Copyright (C) 2009, 2011, 2019-2021 Philipp Wolfer # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2018, 2020-2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_matching import Ui_MatchingOptionsPage from picard.ui.options import OptionsPage class MatchingOptionsPage(OptionsPage): NAME = 'matching' TITLE = N_("Matching") PARENT = 'advanced' SORT_ORDER = 30 ACTIVE = True HELP_URL = "/config/options_matching.html" _release_type_sliders = {} def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_MatchingOptionsPage() self.ui.setupUi(self) self.register_setting('file_lookup_threshold', ['file_lookup_threshold']) self.register_setting('cluster_lookup_threshold', ['cluster_lookup_threshold']) self.register_setting('track_matching_threshold', ['track_matching_threshold']) def load(self): config = get_config() self.ui.file_lookup_threshold.setValue(int(config.setting['file_lookup_threshold'] * 100)) self.ui.cluster_lookup_threshold.setValue(int(config.setting['cluster_lookup_threshold'] * 100)) self.ui.track_matching_threshold.setValue(int(config.setting['track_matching_threshold'] * 100)) def save(self): config = get_config() config.setting['file_lookup_threshold'] = float(self.ui.file_lookup_threshold.value()) / 100.0 config.setting['cluster_lookup_threshold'] = float(self.ui.cluster_lookup_threshold.value()) / 100.0 config.setting['track_matching_threshold'] = float(self.ui.track_matching_threshold.value()) / 100.0 register_options_page(MatchingOptionsPage)
2,658
Python
.py
53
45.981132
108
0.736578
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,059
interface_toolbar.py
metabrainz_picard/picard/ui/options/interface_toolbar.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2007-2008 Lukáš Lalinský # Copyright (C) 2008 Will # Copyright (C) 2009, 2019-2023 Philipp Wolfer # Copyright (C) 2011, 2013 Michael Wiencek # Copyright (C) 2013, 2019 Wieland Hoffmann # Copyright (C) 2013-2014, 2018, 2020-2021, 2023-2024 Laurent Monin # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016-2018 Sambhav Kothari # Copyright (C) 2017 Antonio Larrosa # Copyright (C) 2018 Bob Swift # Copyright (C) 2021 Gabriel Ferreira # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from collections import namedtuple import os.path from PyQt6 import ( QtCore, QtWidgets, ) from picard import log from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.util import icontheme from picard.ui import PicardDialog from picard.ui.enums import MainAction from picard.ui.forms.ui_options_interface_toolbar import ( Ui_InterfaceToolbarOptionsPage, ) from picard.ui.moveable_list_view import MoveableListView from picard.ui.options import OptionsPage from picard.ui.util import ( FileDialog, qlistwidget_items, ) ToolbarButtonDesc = namedtuple('ToolbarButtonDesc', ('label', 'icon')) DisplayListItem = namedtuple('DisplayListItem', ('translated_label', 'action_id')) class InterfaceToolbarOptionsPage(OptionsPage): NAME = 'interface_toolbar' TITLE = N_("Action Toolbar") PARENT = 'interface' SORT_ORDER = 60 ACTIVE = True HELP_URL = "/config/options_interface_toolbar.html" SEPARATOR = '—' * 5 TOOLBAR_BUTTONS = { MainAction.ADD_DIRECTORY: ToolbarButtonDesc( N_("Add Folder"), 'folder', ), MainAction.ADD_FILES: ToolbarButtonDesc( N_("Add Files"), 'document-open', ), MainAction.CLUSTER: ToolbarButtonDesc( N_("Cluster"), 'picard-cluster', ), MainAction.AUTOTAG: ToolbarButtonDesc( N_("Lookup"), 'picard-auto-tag', ), MainAction.ANALYZE: ToolbarButtonDesc( N_("Scan"), 'picard-analyze', ), MainAction.BROWSER_LOOKUP: ToolbarButtonDesc( N_("Lookup in Browser"), 'lookup-musicbrainz', ), MainAction.SAVE: ToolbarButtonDesc( N_("Save"), 'document-save', ), MainAction.VIEW_INFO: ToolbarButtonDesc( N_("Info"), 'picard-edit-tags', ), MainAction.REMOVE: ToolbarButtonDesc( N_("Remove"), 'list-remove', ), MainAction.SUBMIT_ACOUSTID: ToolbarButtonDesc( N_("Submit AcoustIDs"), 'acoustid-fingerprinter', ), MainAction.GENERATE_FINGERPRINTS: ToolbarButtonDesc( N_("Generate Fingerprints"), 'fingerprint', ), MainAction.PLAY_FILE: ToolbarButtonDesc( N_("Open in Player"), 'play-music', ), MainAction.CD_LOOKUP: ToolbarButtonDesc( N_("Lookup CD…"), 'media-optical', ), MainAction.TAGS_FROM_FILENAMES: ToolbarButtonDesc( N_("Parse File Names…"), 'picard-tags-from-filename', ), MainAction.SIMILAR_ITEMS_SEARCH: ToolbarButtonDesc( N_("Similar items"), 'system-search', ), } ACTION_IDS = set(TOOLBAR_BUTTONS) def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_InterfaceToolbarOptionsPage() self.ui.setupUi(self) self.ui.add_button.clicked.connect(self.add_to_toolbar) self.ui.insert_separator_button.clicked.connect(self.insert_separator) self.ui.remove_button.clicked.connect(self.remove_action) self.move_view = MoveableListView(self.ui.toolbar_layout_list, self.ui.up_button, self.ui.down_button, self.update_action_buttons) self.update_buttons = self.move_view.update_buttons self.register_setting('toolbar_layout', ['toolbar_layout_list']) def load(self): self.populate_action_list() self.ui.toolbar_layout_list.setCurrentRow(0) self.update_buttons() def save(self): self.tagger.window.update_toolbar_style() self.update_layout_config() def restore_defaults(self): super().restore_defaults() self.update_buttons() def starting_directory_browse(self): item = self.ui.starting_directory_path path = FileDialog.getExistingDirectory( parent=self, dir=item.text(), ) if path: path = os.path.normpath(path) item.setText(path) def _insert_item(self, data, index=None): list_item = QtWidgets.QListWidgetItem() list_item.setToolTip(_("Drag and Drop to re-order")) if isinstance(data, MainAction) and data in self.TOOLBAR_BUTTONS: action_id = data button = self.TOOLBAR_BUTTONS[action_id] list_item.setText(_(button.label)) list_item.setIcon(icontheme.lookup(button.icon, icontheme.ICON_SIZE_MENU)) list_item.setData(QtCore.Qt.ItemDataRole.UserRole, action_id) else: list_item.setText(self.SEPARATOR) list_item.setData(QtCore.Qt.ItemDataRole.UserRole, '-') if index is not None: self.ui.toolbar_layout_list.insertItem(index, list_item) else: self.ui.toolbar_layout_list.addItem(list_item) return list_item def _itemlist_datas(self): for item in qlistwidget_items(self.ui.toolbar_layout_list): yield item.data(QtCore.Qt.ItemDataRole.UserRole) def _added_actions(self): return set(data for data in self._itemlist_datas() if isinstance(data, MainAction)) def populate_action_list(self): self.ui.toolbar_layout_list.clear() config = get_config() for name in config.setting['toolbar_layout']: if name in {'-', 'separator'}: self._insert_item('-') else: try: action_id = MainAction(name) if action_id in self.ACTION_IDS: self._insert_item(action_id) except ValueError as e: log.debug(e) def update_action_buttons(self): self.ui.add_button.setEnabled(self._added_actions() != self.ACTION_IDS) def _make_missing_actions_list(self): for action_id in set.difference(self.ACTION_IDS, self._added_actions()): button = self.TOOLBAR_BUTTONS[action_id] yield DisplayListItem(_(button.label), action_id) def add_to_toolbar(self): display_list = sorted(self._make_missing_actions_list()) selected_action = AddActionDialog.get_selected_action(display_list, self) if selected_action is not None: insert_index = self.ui.toolbar_layout_list.currentRow() + 1 list_item = self._insert_item(selected_action, index=insert_index) self.ui.toolbar_layout_list.setCurrentItem(list_item) self.update_buttons() def insert_separator(self): insert_index = self.ui.toolbar_layout_list.currentRow() + 1 self._insert_item('-', index=insert_index) def remove_action(self): item = self.ui.toolbar_layout_list.takeItem(self.ui.toolbar_layout_list.currentRow()) del item self.update_buttons() def _data2layout(self): for data in self._itemlist_datas(): if isinstance(data, MainAction): yield data.value else: yield data def update_layout_config(self): config = get_config() config.setting['toolbar_layout'] = list(self._data2layout()) self._update_toolbar() def _update_toolbar(self): widget = self.parent() while not isinstance(widget, QtWidgets.QMainWindow): widget = widget.parent() # Call the main window's create toolbar method widget.create_action_toolbar() widget.update_toolbar_style() widget.set_tab_order() class AddActionDialog(PicardDialog): def __init__(self, display_list, parent=None): super().__init__(parent=parent) self.display_list = display_list self.setWindowModality(QtCore.Qt.WindowModality.WindowModal) self.setWindowTitle(_("Select an action")) layout = QtWidgets.QVBoxLayout(self) self.combo_box = QtWidgets.QComboBox(self) for item in self.display_list: self.combo_box.addItem(item.translated_label, item.action_id) layout.addWidget(self.combo_box) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.StandardButton.Ok | QtWidgets.QDialogButtonBox.StandardButton.Cancel, QtCore.Qt.Orientation.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) def selected_action(self): return self.combo_box.currentData() @staticmethod def get_selected_action(display_list, parent=None): dialog = AddActionDialog(display_list, parent=parent) if dialog.exec() == QtWidgets.QDialog.DialogCode.Accepted: return dialog.selected_action() else: return None register_options_page(InterfaceToolbarOptionsPage)
10,325
Python
.py
258
31.631783
108
0.647669
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,060
dialog.py
metabrainz_picard/picard/ui/options/dialog.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011 Lukáš Lalinský # Copyright (C) 2008-2009 Nikolai Prokoschenko # Copyright (C) 2008-2009, 2018-2022 Philipp Wolfer # Copyright (C) 2011 Pavan Chander # Copyright (C) 2011-2012, 2019 Wieland Hoffmann # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2013, 2017-2024 Laurent Monin # Copyright (C) 2014 Sophist-UK # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017 Suhas # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2021 Gabriel Ferreira # Copyright (C) 2021-2023 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import log from picard.config import ( Option, OptionError, SettingConfigSection, get_config, ) from picard.const import PICARD_URLS from picard.extension_points.options_pages import ext_point_options_pages from picard.i18n import ( N_, gettext as _, ) from picard.profile import ( profile_groups_group_from_page, profile_groups_order, ) from picard.util import restore_method from picard.ui import ( HashableTreeWidgetItem, PicardDialog, SingletonDialog, ) from picard.ui.forms.ui_options_attached_profiles import ( Ui_AttachedProfilesDialog, ) from picard.ui.options import ( # noqa: F401 # pylint: disable=unused-import OptionsCheckError, OptionsPage, advanced, cdlookup, cover, cover_processing, fingerprinting, general, genres, interface, interface_colors, interface_toolbar, interface_top_tags, maintenance, matching, metadata, network, plugins, profiles, ratings, releases, renaming, renaming_compat, scripting, tags, tags_compatibility_aac, tags_compatibility_ac3, tags_compatibility_id3, tags_compatibility_wave, ) from picard.ui.util import StandardButton class ErrorOptionsPage(OptionsPage): def __init__(self, parent=None, errmsg='', from_cls=None, dialog=None): # copy properties from failing page self.NAME = from_cls.NAME self.TITLE = from_cls.TITLE self.PARENT = from_cls.PARENT self.SORT_ORDER = from_cls.SORT_ORDER self.ACTIVE = from_cls.ACTIVE self.HELP_URL = from_cls.HELP_URL super().__init__(parent=parent) self.error = _("This page failed to initialize") title_widget = QtWidgets.QLabel( _("Error while initializing option page '%s':") % _(from_cls.TITLE) ) error_widget = QtWidgets.QLabel() error_widget.setTextFormat(QtCore.Qt.TextFormat.PlainText) error_widget.setText(errmsg) error_widget.setWordWrap(True) error_widget.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel) error_widget.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) error_widget.setLineWidth(1) error_widget.setTextInteractionFlags( QtCore.Qt.TextInteractionFlag.TextSelectableByKeyboard | QtCore.Qt.TextInteractionFlag.TextSelectableByMouse ) report_bug_widget = QtWidgets.QLabel( _('Please see <a href="%s">Troubleshooting documentation</a>' ' and eventually report a bug.') % PICARD_URLS['troubleshooting'] ) report_bug_widget.setOpenExternalLinks(True) layout = QtWidgets.QVBoxLayout(self) layout.addWidget(title_widget) layout.addWidget(error_widget) layout.addWidget(report_bug_widget) layout.addStretch() self.ui = layout self.dialog = dialog class OptionsDialog(PicardDialog, SingletonDialog): suspend_signals = False def add_pages(self, parent_pagename, default_pagename, parent_item): pages = (p for p in self.pages if p.PARENT == parent_pagename) items = [] for page in sorted(pages, key=lambda p: (p.SORT_ORDER, p.NAME)): item = HashableTreeWidgetItem(parent_item) if not page.initialized: title = _("%s (error)") % _(page.TITLE) else: title = _(page.TITLE) item.setText(0, title) if page.ACTIVE: self.item_to_page[item] = page self.pagename_to_item[page.NAME] = item profile_groups_order(page.NAME) else: item.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled) self.add_pages(page.NAME, default_pagename, item) if page.NAME == default_pagename: self.default_item = item items.append(item) if not self.default_item and not parent_pagename: self.default_item = items[0] def __init__(self, default_page=None, parent=None): super().__init__(parent=parent) self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) self.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) from picard.ui.forms.ui_options import Ui_OptionsDialog self.ui = Ui_OptionsDialog() self.ui.setupUi(self) self.ui.reset_all_button = QtWidgets.QPushButton(_("&Restore all Defaults")) self.ui.reset_all_button.setToolTip(_("Reset all of Picard's settings")) self.ui.reset_button = QtWidgets.QPushButton(_("Restore &Defaults")) self.ui.reset_button.setToolTip(_("Reset all settings for current option page")) ok = StandardButton(StandardButton.OK) ok.setText(_("Make It So!")) self.ui.buttonbox.addButton(ok, QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole) self.ui.buttonbox.addButton(StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole) self.ui.buttonbox.addButton(StandardButton(StandardButton.HELP), QtWidgets.QDialogButtonBox.ButtonRole.HelpRole) self.ui.buttonbox.addButton(self.ui.reset_all_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.ui.buttonbox.addButton(self.ui.reset_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.ui.buttonbox.accepted.connect(self.accept) self.ui.buttonbox.rejected.connect(self.reject) self.ui.reset_all_button.clicked.connect(self.confirm_reset_all) self.ui.reset_button.clicked.connect(self.confirm_reset) self.ui.buttonbox.helpRequested.connect(self.show_help) self.ui.attached_profiles_button = QtWidgets.QPushButton(_("Attached Profiles")) self.ui.attached_profiles_button.setToolTip(_("Show which profiles are attached to the options on this page")) self.ui.buttonbox.addButton(self.ui.attached_profiles_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.ui.attached_profiles_button.clicked.connect(self.show_attached_profiles_dialog) config = get_config() self.pages = [] for Page in ext_point_options_pages: try: page = Page() page.set_dialog(self) page.initialized = True except Exception as e: log.exception("Failed initializing options page %r", Page) # create an empty page with the error message in place of the failing page # this approach still allows subpages of the failing page to load page = ErrorOptionsPage(from_cls=Page, errmsg=str(e), dialog=self) self.ui.pages_stack.addWidget(page) self.pages.append(page) self.item_to_page = {} self.pagename_to_item = {} self.default_item = None if not default_page: default_pagename = config.persist['options_last_active_page'] self.add_pages(None, default_pagename, self.ui.pages_tree) # work-around to set optimal option pane width self.ui.pages_tree.expandAll() max_page_name = self.ui.pages_tree.sizeHintForColumn(0) + 2*self.ui.pages_tree.frameWidth() self.ui.dialog_splitter.setSizes([max_page_name, self.geometry().width() - max_page_name]) self.ui.pages_tree.setHeaderLabels([""]) self.ui.pages_tree.header().hide() self.restoreWindowState() self.finished.connect(self.saveWindowState) self.load_all_pages() self.first_enter = True self.installEventFilter(self) maintenance_page = self.get_page('maintenance') if maintenance_page.loaded: maintenance_page.signal_reload.connect(self.load_all_pages) profile_page = self.get_page('profiles') if profile_page.loaded: profile_page.signal_refresh.connect(self.update_from_profile_changes) self.highlight_enabled_profile_options() self.ui.pages_tree.itemSelectionChanged.connect(self.switch_page) self.ui.pages_tree.setCurrentItem(self.default_item) # this will call switch_page @property def initialized_pages(self): yield from (page for page in self.pages if page.initialized) @property def loaded_pages(self): yield from (page for page in self.pages if page.loaded) def load_all_pages(self): for page in self.initialized_pages: try: page.load() page.loaded = True except Exception: log.exception("Failed loading options page %r", page) self.disable_page(page.NAME) def show_attached_profiles_dialog(self): items = self.ui.pages_tree.selectedItems() if not items: return page = self.item_to_page[items[0]] option_group = profile_groups_group_from_page(page) if option_group: self.display_attached_profiles(option_group) else: self.display_simple_message_box( _("Profiles Attached to Options"), _("The options on this page are not currently available to be managed using profiles."), ) def display_simple_message_box(self, window_title, message): message_box = QtWidgets.QMessageBox(self) message_box.setIcon(QtWidgets.QMessageBox.Icon.Information) message_box.setWindowModality(QtCore.Qt.WindowModality.WindowModal) message_box.setWindowTitle(window_title) message_box.setText(message) message_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) message_box.exec() def display_attached_profiles(self, option_group): profile_page = self.get_page('profiles') override_profiles = profile_page._clean_and_get_all_profiles() override_settings = profile_page.profile_settings profile_dialog = AttachedProfilesDialog( option_group, parent=self, override_profiles=override_profiles, override_settings=override_settings ) profile_dialog.show() profile_dialog.raise_() profile_dialog.activateWindow() def update_from_profile_changes(self): if not self.suspend_signals: self.highlight_enabled_profile_options(load_settings=True) def get_working_profile_data(self): profile_page = self.get_page('profiles') working_profiles = profile_page._clean_and_get_all_profiles() if working_profiles is None: working_profiles = [] working_settings = profile_page.profile_settings return working_profiles, working_settings def highlight_enabled_profile_options(self, load_settings=False): working_profiles, working_settings = self.get_working_profile_data() from picard.ui.colors import interface_colors as colors fg_color = colors.get_color('profile_hl_fg') bg_color = colors.get_color('profile_hl_bg') for page in self.loaded_pages: option_group = profile_groups_group_from_page(page) if option_group: if load_settings: page.load() for opt in option_group['settings']: for objname in opt.highlights: try: obj = getattr(page.ui, objname) except AttributeError: continue style = "#%s { color: %s; background-color: %s; }" % (objname, fg_color, bg_color) self._check_and_highlight_option(obj, opt.name, working_profiles, working_settings, style) def _check_and_highlight_option(self, obj, option_name, working_profiles, working_settings, style): obj.setStyleSheet(None) obj.setToolTip(None) for item in working_profiles: if item['enabled']: profile_id = item['id'] profile_title = item['title'] if profile_id in working_settings: profile_settings = working_settings[profile_id] else: profile_settings = {} if option_name in profile_settings: tooltip = _("This option will be saved to profile: %s") % profile_title try: obj.setStyleSheet(style) obj.setToolTip(tooltip) except AttributeError: pass break def eventFilter(self, object, event): """Process selected events. """ evtype = event.type() if evtype == QtCore.QEvent.Type.Enter: if self.first_enter: self.first_enter = False if self.tagger and self.tagger.window.script_editor_dialog is not None: self.get_page('filerenaming').show_script_editing_page() self.activateWindow() return False def get_page(self, pagename): return self.item_to_page[self.pagename_to_item[pagename]] def page_has_attached_profiles(self, page, enabled_profiles_only=False): if not page.loaded: return False profile_page = self.get_page('profiles') if not profile_page.loaded: return False option_group = profile_groups_group_from_page(page) if not option_group: return False working_profiles, working_settings = self.get_working_profile_data() for opt in option_group['settings']: for item in working_profiles: if enabled_profiles_only and not item['enabled']: continue profile_id = item['id'] if opt.name in working_settings[profile_id]: return True return False def set_profiles_button_and_highlight(self, page): if self.page_has_attached_profiles(page): self.ui.attached_profiles_button.setDisabled(False) else: self.ui.attached_profiles_button.setDisabled(True) def switch_page(self): items = self.ui.pages_tree.selectedItems() if items: page = self.item_to_page[items[0]] self.set_profiles_button_and_highlight(page) self.ui.reset_button.setDisabled(not page.loaded) self.ui.pages_stack.setCurrentWidget(page) config = get_config() config.persist['options_last_active_page'] = page.NAME def disable_page(self, pagename): item = self.pagename_to_item[pagename] item.setDisabled(True) @property def help_url(self): current_page = self.ui.pages_stack.currentWidget() url = current_page.HELP_URL # If URL is empty, use the first non empty parent help URL. while current_page.PARENT and not url: current_page = self.get_page(current_page.PARENT) url = current_page.HELP_URL if not url: url = 'doc_options' # key in PICARD_URLS return url def accept(self): for page in self.loaded_pages: try: page.check() except OptionsCheckError as e: self._show_page_error(page, e) return except Exception as e: log.exception("Failed checking options page %r", page) self._show_page_error(page, e) return for page in self.loaded_pages: try: page.save() except Exception as e: log.exception("Failed saving options page %r", page) self._show_page_error(page, e) return super().accept() def _show_page_error(self, page, error): if not isinstance(error, OptionsCheckError): error = OptionsCheckError(_("Unexpected error"), str(error)) self.ui.pages_tree.setCurrentItem(self.pagename_to_item[page.NAME]) page.display_error(error) def saveWindowState(self): expanded_pages = [] for pagename, item in self.pagename_to_item.items(): index = self.ui.pages_tree.indexFromItem(item) is_expanded = self.ui.pages_tree.isExpanded(index) expanded_pages.append((pagename, is_expanded)) config = get_config() config.persist['options_pages_tree_state'] = expanded_pages config.setting.set_profiles_override() config.setting.set_settings_override() @restore_method def restoreWindowState(self): config = get_config() pages_tree_state = config.persist['options_pages_tree_state'] if not pages_tree_state: self.ui.pages_tree.expandAll() else: for pagename, is_expanded in pages_tree_state: try: item = self.pagename_to_item[pagename] item.setExpanded(is_expanded) except KeyError as e: log.debug("Failed restoring expanded state: %s", e) def restore_all_defaults(self): self.suspend_signals = True for page in self.loaded_pages: try: page.restore_defaults() except Exception as e: log.error("Failed restoring all defaults for page %r: %s", page, e) self.highlight_enabled_profile_options(load_settings=False) self.suspend_signals = False def restore_page_defaults(self): current_page = self.ui.pages_stack.currentWidget() if current_page.loaded: current_page.restore_defaults() self.highlight_enabled_profile_options(load_settings=False) def confirm_reset(self): msg = _("You are about to reset your options for this page.") self._show_dialog(msg, self.restore_page_defaults) def confirm_reset_all(self): msg = _("Warning! This will reset all of your settings.") self._show_dialog(msg, self.restore_all_defaults) def _show_dialog(self, msg, function): message_box = QtWidgets.QMessageBox(self) message_box.setIcon(QtWidgets.QMessageBox.Icon.Warning) message_box.setWindowModality(QtCore.Qt.WindowModality.WindowModal) message_box.setWindowTitle(_("Confirm Reset")) message_box.setText(_("Are you sure?") + "\n\n" + msg) message_box.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No) if message_box.exec() == QtWidgets.QMessageBox.StandardButton.Yes: function() class AttachedProfilesDialog(PicardDialog): NAME = 'attachedprofiles' TITLE = N_("Attached Profiles") def __init__(self, option_group, parent=None, override_profiles=None, override_settings=None): super().__init__(parent=parent) self.option_group = option_group self.ui = Ui_AttachedProfilesDialog() self.ui.setupUi(self) self.ui.buttonBox.addButton(StandardButton(StandardButton.CLOSE), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole) self.ui.buttonBox.rejected.connect(self.close_window) config = get_config() if override_profiles is None or override_settings is None: self.profiles = config.profiles[SettingConfigSection.PROFILES_KEY] self.settings = config.profiles[SettingConfigSection.SETTINGS_KEY] else: self.profiles = override_profiles self.settings = override_settings self.populate_table() self.ui.buttonBox.setFocus() self.setModal(True) def populate_table(self): model = QtGui.QStandardItemModel() model.setColumnCount(2) header_names = (_("Option"), _("Attached Profiles")) model.setHorizontalHeaderLabels(header_names) window_title = _("Profiles Attached to Options in %s Section") % self.option_group['title'] self.setWindowTitle(window_title) for setting in self.option_group['settings']: try: title = Option.get_title('setting', setting.name) except OptionError as e: log.debug(e) continue option_item = QtGui.QStandardItem(_(title)) option_item.setEditable(False) attached = [] for profile in self.profiles: if setting.name in self.settings[profile['id']]: attached.append("{0}{1}".format(profile['title'], _(" [Enabled]") if profile['enabled'] else "",)) attached_profiles = "\n".join(attached) or _("None") profile_item = QtGui.QStandardItem(attached_profiles) profile_item.setEditable(False) model.appendRow((option_item, profile_item)) self.ui.options_list.setModel(model) self.ui.options_list.resizeColumnsToContents() self.ui.options_list.resizeRowsToContents() self.ui.options_list.horizontalHeader().setStretchLastSection(True) def close_window(self): """Close the script metadata editor window. """ self.close()
22,668
Python
.py
505
35.073267
124
0.644662
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,061
interface_colors.py
metabrainz_picard/picard/ui/options/interface_colors.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2023 Philipp Wolfer # Copyright (C) 2019-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.const.sys import IS_MACOS from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, sort_key, ) from picard.util import icontheme from picard.ui.colors import interface_colors from picard.ui.forms.ui_options_interface_colors import ( Ui_InterfaceColorsOptionsPage, ) from picard.ui.options import OptionsPage from picard.ui.util import changes_require_restart_warning class ColorButton(QtWidgets.QPushButton): color_changed = QtCore.pyqtSignal(str) def __init__(self, initial_color=None, parent=None): super().__init__(' ', parent=parent) # On macOS the style override in picard.ui.theme breaks styling these # buttons. Explicitly reset the style for this widget only. if IS_MACOS: self.setStyle(QtWidgets.QStyleFactory.create('macos')) color = QtGui.QColor(initial_color) if not color.isValid(): color = QtGui.QColor('black') self.color = color self.clicked.connect(self.open_color_dialog) self.update_color() def update_color(self, qcolor=None): if qcolor is not None: self.color = qcolor self.setStyleSheet("QPushButton { background-color: %s; }" % self.color.name()) def open_color_dialog(self): new_color = QtWidgets.QColorDialog.getColor( self.color, title=_("Choose a color"), parent=self.parent()) if new_color.isValid(): self.color = new_color self.update_color() self.color_changed.emit(self.color.name()) def delete_items_of_layout(layout): # Credits: # https://stackoverflow.com/a/45790404 # https://riverbankcomputing.com/pipermail/pyqt/2009-November/025214.html if layout is not None: while layout.count(): item = layout.takeAt(0) widget = item.widget() if widget is not None: widget.setParent(None) else: delete_items_of_layout(item.layout()) class InterfaceColorsOptionsPage(OptionsPage): NAME = 'interface_colors' TITLE = N_("Colors") PARENT = 'interface' SORT_ORDER = 30 ACTIVE = True HELP_URL = "/config/options_interface_colors.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_InterfaceColorsOptionsPage() self.ui.setupUi(self) self.new_colors = {} self.colors_list = QtWidgets.QVBoxLayout() self.ui.colors.setLayout(self.colors_list) self.register_setting('interface_colors', ['colors']) self.register_setting('interface_colors_dark', ['colors']) def update_color_selectors(self): if self.colors_list: delete_items_of_layout(self.colors_list) def color_changed(color_key, color_value): interface_colors.set_color(color_key, color_value) def restore_default_color(color_key, color_button): interface_colors.set_default_color(color_key) color_button.update_color(interface_colors.get_qcolor(color_key)) def colors(): for color_key, color_value in interface_colors.get_colors().items(): group = interface_colors.get_color_group(color_key) title = interface_colors.get_color_title(color_key) yield color_key, color_value, title, group prev_group = None for color_key, color_value, title, group in sorted(colors(), key=lambda c: (sort_key(c[3]), sort_key(c[2]))): if prev_group != group: groupbox = QtWidgets.QGroupBox(group) self.colors_list.addWidget(groupbox) groupbox_layout = QtWidgets.QVBoxLayout() groupbox.setLayout(groupbox_layout) prev_group = group widget = QtWidgets.QWidget() hlayout = QtWidgets.QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) label = QtWidgets.QLabel(title) label.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) hlayout.addWidget(label) color_button = ColorButton(color_value) color_button.color_changed.connect(partial(color_changed, color_key)) hlayout.addWidget(color_button, 0, QtCore.Qt.AlignmentFlag.AlignRight) refresh_button = QtWidgets.QPushButton(icontheme.lookup('view-refresh'), "") refresh_button.setToolTip(_("Restore default color")) refresh_button.clicked.connect(partial(restore_default_color, color_key, color_button)) hlayout.addWidget(refresh_button, 0, QtCore.Qt.AlignmentFlag.AlignRight) widget.setLayout(hlayout) groupbox_layout.addWidget(widget) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding) self.colors_list.addItem(spacerItem1) def load(self): interface_colors.load_from_config() self.update_color_selectors() def save(self): if interface_colors.save_to_config(): changes_require_restart_warning(self, warnings=[_("You have changed the interface colors.")]) def restore_defaults(self): interface_colors.set_default_colors() self.update_color_selectors() register_options_page(InterfaceColorsOptionsPage)
6,429
Python
.py
141
37.673759
129
0.677223
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,062
cdlookup.py
metabrainz_picard/picard/ui/options/cdlookup.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2004 Robert Kaye # Copyright (C) 2006-2007 Lukáš Lalinský # Copyright (C) 2008, 2019-2021 Philipp Wolfer # Copyright (C) 2012-2013 Michael Wiencek # Copyright (C) 2013, 2018-2021, 2023-2024 Laurent Monin # Copyright (C) 2017 Sambhav Kothari # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.util.cdrom import ( AUTO_DETECT_DRIVES, get_cdrom_drives, ) from picard.ui.options import OptionsPage if AUTO_DETECT_DRIVES: from picard.ui.forms.ui_options_cdlookup_select import ( Ui_CDLookupOptionsPage, ) else: from picard.ui.forms.ui_options_cdlookup import Ui_CDLookupOptionsPage class CDLookupOptionsPage(OptionsPage): NAME = 'cdlookup' TITLE = N_("CD Lookup") PARENT = None SORT_ORDER = 50 ACTIVE = True HELP_URL = "/config/options_cdlookup.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_CDLookupOptionsPage() self.ui.setupUi(self) if AUTO_DETECT_DRIVES: self._device_list = get_cdrom_drives() self.ui.cd_lookup_device.addItems(self._device_list) self.register_setting('cd_lookup_device') def load(self): config = get_config() device = config.setting['cd_lookup_device'] if AUTO_DETECT_DRIVES: try: self.ui.cd_lookup_device.setCurrentIndex(self._device_list.index(device)) except ValueError: pass else: self.ui.cd_lookup_device.setText(device) def save(self): config = get_config() if AUTO_DETECT_DRIVES: device = self.ui.cd_lookup_device.currentText() device_list = self._device_list else: device = self.ui.cd_lookup_device.text() device_list = [device] config.setting['cd_lookup_device'] = device self.tagger.window.update_cd_lookup_drives(device_list) register_options_page(CDLookupOptionsPage)
2,864
Python
.py
74
33.202703
89
0.699603
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,063
general.py
metabrainz_picard/picard/ui/options/general.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007, 2014 Lukáš Lalinský # Copyright (C) 2008, 2018-2024 Philipp Wolfer # Copyright (C) 2011, 2013 Michael Wiencek # Copyright (C) 2011, 2019 Wieland Hoffmann # Copyright (C) 2013-2014 Sophist-UK # Copyright (C) 2013-2014, 2018, 2020-2021, 2023-2024 Laurent Monin # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017 Frederik “Freso” S. Olesen # Copyright (C) 2018 virusMac # Copyright (C) 2018, 2023 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtWidgets, ) from picard.config import get_config from picard.const import ( MUSICBRAINZ_SERVERS, PROGRAM_UPDATE_LEVELS, ) from picard.const.defaults import DEFAULT_PROGRAM_UPDATE_LEVEL from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, gettext_constants, ) from picard.util.mbserver import is_official_server from picard.ui.forms.ui_options_general import Ui_GeneralOptionsPage from picard.ui.options import OptionsPage class GeneralOptionsPage(OptionsPage): NAME = 'general' TITLE = N_("General") PARENT = None SORT_ORDER = 1 ACTIVE = True HELP_URL = "/config/options_general.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_GeneralOptionsPage() self.ui.setupUi(self) self.ui.server_host.addItems(MUSICBRAINZ_SERVERS) self.ui.server_host.currentTextChanged.connect(self.update_server_host) self.ui.login.clicked.connect(self.login) self.ui.logout.clicked.connect(self.logout) self.ui.analyze_new_files.toggled.connect(self._update_cluster_new_files) self.ui.cluster_new_files.toggled.connect(self._update_analyze_new_files) self.ui.login_error.setStyleSheet(self.STYLESHEET_ERROR) self.ui.login_error.hide() self.update_login_logout() self.register_setting('server_host', ['server_host']) self.register_setting('server_port', ['server_port']) self.register_setting('analyze_new_files', ['analyze_new_files']) self.register_setting('cluster_new_files', ['cluster_new_files']) self.register_setting('ignore_file_mbids', ['ignore_file_mbids']) self.register_setting('check_for_plugin_updates', ['check_for_plugin_updates']) self.register_setting('check_for_updates', ['check_for_updates']) self.register_setting('update_check_days', ['update_check_days']) self.register_setting('update_level', ['update_level']) self.register_setting('use_server_for_submission') def load(self): config = get_config() self.ui.server_host.setEditText(config.setting['server_host']) self.ui.server_port.setValue(config.setting['server_port']) self.ui.use_server_for_submission.setChecked(config.setting['use_server_for_submission']) self.update_server_host() self.ui.analyze_new_files.setChecked(config.setting['analyze_new_files']) self.ui.cluster_new_files.setChecked(config.setting['cluster_new_files']) self.ui.ignore_file_mbids.setChecked(config.setting['ignore_file_mbids']) self.ui.check_for_plugin_updates.setChecked(config.setting['check_for_plugin_updates']) self.ui.check_for_updates.setChecked(config.setting['check_for_updates']) self.set_update_level(config.setting['update_level']) self.ui.update_check_days.setValue(config.setting['update_check_days']) if not self.tagger.autoupdate_enabled: self.ui.program_update_check_group.hide() def set_update_level(self, value): if value not in PROGRAM_UPDATE_LEVELS: value = DEFAULT_PROGRAM_UPDATE_LEVEL self.ui.update_level.clear() for level, description in PROGRAM_UPDATE_LEVELS.items(): # TODO: Remove temporary workaround once https://github.com/python-babel/babel/issues/415 has been resolved. babel_415_workaround = description['title'] self.ui.update_level.addItem(gettext_constants(babel_415_workaround), level) idx = self.ui.update_level.findData(value) if idx == -1: idx = self.ui.update_level.findData(DEFAULT_PROGRAM_UPDATE_LEVEL) self.ui.update_level.setCurrentIndex(idx) def save(self): config = get_config() config.setting['server_host'] = self.ui.server_host.currentText().strip() config.setting['server_port'] = self.ui.server_port.value() config.setting['use_server_for_submission'] = self.ui.use_server_for_submission.isChecked() config.setting['analyze_new_files'] = self.ui.analyze_new_files.isChecked() config.setting['cluster_new_files'] = self.ui.cluster_new_files.isChecked() config.setting['ignore_file_mbids'] = self.ui.ignore_file_mbids.isChecked() config.setting['check_for_plugin_updates'] = self.ui.check_for_plugin_updates.isChecked() config.setting['check_for_updates'] = self.ui.check_for_updates.isChecked() config.setting['update_level'] = self.ui.update_level.currentData(QtCore.Qt.ItemDataRole.UserRole) config.setting['update_check_days'] = self.ui.update_check_days.value() def update_server_host(self): host = self.ui.server_host.currentText().strip() if host and is_official_server(host): self.ui.server_host_primary_warning.hide() else: self.ui.server_host_primary_warning.show() def update_login_logout(self, error_msg=None): if self.deleted: return if self.tagger.webservice.oauth_manager.is_logged_in(): config = get_config() self.ui.logged_in.setText(_("Logged in as <b>%s</b>.") % config.persist['oauth_username']) self.ui.logged_in.show() self.ui.login_error.hide() self.ui.login.hide() self.ui.logout.show() elif error_msg: self.ui.logged_in.hide() self.ui.login_error.setText(_("Login failed: %s") % error_msg) self.ui.login_error.show() self.ui.login.show() self.ui.logout.hide() else: self.ui.logged_in.hide() self.ui.login_error.hide() self.ui.login.show() self.ui.logout.hide() def login(self): self.tagger.mb_login(self.on_login_finished, self) def on_login_finished(self, successful, error_msg=None): self.update_login_logout(error_msg) def logout(self): self.tagger.mb_logout(self.on_logout_finished) def on_logout_finished(self, successful, error_msg=None): if not successful: msg = QtWidgets.QMessageBox(self) msg.setIcon(QtWidgets.QMessageBox.Icon.Warning) msg.setWindowTitle(_("Logout error")) msg.setText(_( "A server error occurred while revoking access to the MusicBrainz server: %s\n" "\n" "Remove locally stored credentials anyway?" ) % error_msg) msg.setStandardButtons( QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No | QtWidgets.QMessageBox.StandardButton.Retry) result = msg.exec() if result == QtWidgets.QMessageBox.StandardButton.Yes: oauth_manager = self.tagger.webservice.oauth_manager oauth_manager.forget_access_token() oauth_manager.forget_refresh_token() elif result == QtWidgets.QMessageBox.StandardButton.Retry: self.logout() self.update_login_logout() def restore_defaults(self): super().restore_defaults() self.logout() def _update_analyze_new_files(self, cluster_new_files): if cluster_new_files: self.ui.analyze_new_files.setChecked(False) def _update_cluster_new_files(self, analyze_new_files): if analyze_new_files: self.ui.cluster_new_files.setChecked(False) register_options_page(GeneralOptionsPage)
8,874
Python
.py
181
41.077348
120
0.678864
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,064
network.py
metabrainz_picard/picard/ui/options/network.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2013, 2018, 2020-2021, 2023-2024 Laurent Monin # Copyright (C) 2013, 2020-2021 Philipp Wolfer # Copyright (C) 2016-2017 Sambhav Kothari # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.const import CACHE_SIZE_DISPLAY_UNIT from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_network import Ui_NetworkOptionsPage from picard.ui.options import OptionsPage class NetworkOptionsPage(OptionsPage): NAME = 'network' TITLE = N_("Network") PARENT = 'advanced' SORT_ORDER = 10 ACTIVE = True HELP_URL = "/config/options_network.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_NetworkOptionsPage() self.ui.setupUi(self) self.register_setting('use_proxy', []) self.register_setting('proxy_type', ['proxy_type_socks', 'proxy_type_http']) self.register_setting('proxy_server_host', ['server_host']) self.register_setting('proxy_server_port', ['server_port']) self.register_setting('proxy_username', ['username']) self.register_setting('proxy_password', ['password']) self.register_setting('network_transfer_timeout_seconds', ['transfer_timeout']) self.register_setting('network_cache_size_bytes', ['network_cache_size']) self.register_setting('browser_integration', []) self.register_setting('browser_integration_port', ['browser_integration_port']) self.register_setting('browser_integration_localhost_only', ['browser_integration_localhost_only']) def load(self): config = get_config() self.ui.web_proxy.setChecked(config.setting['use_proxy']) if config.setting['proxy_type'] == 'socks': self.ui.proxy_type_socks.setChecked(True) else: self.ui.proxy_type_http.setChecked(True) self.ui.server_host.setText(config.setting['proxy_server_host']) self.ui.server_port.setValue(config.setting['proxy_server_port']) self.ui.username.setText(config.setting['proxy_username']) self.ui.password.setText(config.setting['proxy_password']) self.ui.transfer_timeout.setValue(config.setting['network_transfer_timeout_seconds']) self.ui.browser_integration.setChecked(config.setting['browser_integration']) self.ui.browser_integration_port.setValue(config.setting['browser_integration_port']) self.ui.browser_integration_localhost_only.setChecked( config.setting['browser_integration_localhost_only']) self.cachesize2display(config) def save(self): config = get_config() config.setting['use_proxy'] = self.ui.web_proxy.isChecked() if self.ui.proxy_type_socks.isChecked(): config.setting['proxy_type'] = 'socks' else: config.setting['proxy_type'] = 'http' config.setting['proxy_server_host'] = self.ui.server_host.text() config.setting['proxy_server_port'] = self.ui.server_port.value() config.setting['proxy_username'] = self.ui.username.text() config.setting['proxy_password'] = self.ui.password.text() self.tagger.webservice.setup_proxy() transfer_timeout = self.ui.transfer_timeout.value() config.setting['network_transfer_timeout_seconds'] = transfer_timeout self.tagger.webservice.set_transfer_timeout(transfer_timeout) config.setting['browser_integration'] = self.ui.browser_integration.isChecked() config.setting['browser_integration_port'] = self.ui.browser_integration_port.value() config.setting['browser_integration_localhost_only'] = \ self.ui.browser_integration_localhost_only.isChecked() self.tagger.update_browser_integration() self.display2cachesize(config) def display2cachesize(self, config): try: cache_size = int(self.ui.network_cache_size.text()) except ValueError: return config.setting['network_cache_size_bytes'] = int(cache_size * CACHE_SIZE_DISPLAY_UNIT) self.tagger.webservice.set_cache_size() def cachesize2display(self, config): cache_size = self.tagger.webservice.get_valid_cache_size() value = int(cache_size / CACHE_SIZE_DISPLAY_UNIT) self.ui.network_cache_size.setText(str(value)) register_options_page(NetworkOptionsPage)
5,243
Python
.py
100
45.78
107
0.706204
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,065
plugins.py
metabrainz_picard/picard/ui/options/plugins.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2007 Lukáš Lalinský # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009, 2018-2023 Philipp Wolfer # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2013, 2015, 2018-2024 Laurent Monin # Copyright (C) 2013, 2017 Sophist-UK # Copyright (C) 2014 Shadab Zafar # Copyright (C) 2015, 2017 Wieland Hoffmann # Copyright (C) 2016-2018 Sambhav Kothari # Copyright (C) 2017 Suhas # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2018 yagyanshbhatia # Copyright (C) 2023 tuspar # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from html import escape from operator import attrgetter import os.path import re from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from PyQt6.QtWidgets import QTreeWidgetItemIterator from picard import log from picard.config import get_config from picard.const import ( PLUGINS_API, USER_PLUGIN_DIR, ) from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.util import ( icontheme, open_local_path, reconnect, ) from picard.ui import HashableTreeWidgetItem from picard.ui.forms.ui_options_plugins import Ui_PluginsOptionsPage from picard.ui.options import OptionsPage from picard.ui.theme import theme from picard.ui.util import FileDialog COLUMN_NAME, COLUMN_VERSION, COLUMN_ACTIONS = range(3) class PluginActionButton(QtWidgets.QToolButton): def __init__(self, icon=None, tooltip=None, retain_space=False, switch_method=None, parent=None): super().__init__(parent=parent) if tooltip is not None: self.setToolTip(tooltip) if icon is not None: self.setIcon(self, icon) if retain_space is True: sp_retain = self.sizePolicy() sp_retain.setRetainSizeWhenHidden(True) self.setSizePolicy(sp_retain) if switch_method is not None: self.switch_method = switch_method def mode(self, mode): if self.switch_method is not None: self.switch_method(self, mode) def setIcon(self, icon): super().setIcon(icon) # Workaround for Qt sometimes not updating the icon. # See https://tickets.metabrainz.org/browse/PICARD-1647 self.repaint() class PluginTreeWidgetItem(HashableTreeWidgetItem): def __init__(self, icons, *args, **kwargs): super().__init__(*args, **kwargs) self._icons = icons self._sortData = {} self.upgrade_to_version = None self.new_version = None self.is_enabled = False self.is_installed = False self.installed_font = None self.enabled_font = None self.available_font = None self.buttons = {} self.buttons_widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout() layout.setContentsMargins(0, 2, 5, 2) layout.addStretch(1) self.buttons_widget.setLayout(layout) def add_button(name, method): button = PluginActionButton(switch_method=method) layout.addWidget(button) self.buttons[name] = button button.mode('hide') add_button('update', self.show_update) add_button('uninstall', self.show_uninstall) add_button('enable', self.show_enable) add_button('install', self.show_install) self.treeWidget().setItemWidget(self, COLUMN_ACTIONS, self.buttons_widget) def show_install(self, button, mode): if mode == 'hide': button.hide() else: button.show() button.setToolTip(_("Download and install plugin")) button.setIcon(self._icons['download']) def show_update(self, button, mode): if mode == 'hide': button.hide() else: button.show() button.setToolTip(_("Download and upgrade plugin to version %s") % self.new_version.short_str()) button.setIcon(self._icons['update']) def show_enable(self, button, mode): if mode == 'enabled': button.show() button.setToolTip(_("Enabled")) button.setIcon(self._icons['enabled']) elif mode == 'disabled': button.show() button.setToolTip(_("Disabled")) button.setIcon(self._icons['disabled']) else: button.hide() def show_uninstall(self, button, mode): if mode == 'hide': button.hide() else: button.show() button.setToolTip(_("Uninstall plugin")) button.setIcon(self._icons['uninstall']) def save_state(self): return { 'is_enabled': self.is_enabled, 'upgrade_to_version': self.upgrade_to_version, 'new_version': self.new_version, 'is_installed': self.is_installed, } def restore_state(self, states): self.upgrade_to_version = states['upgrade_to_version'] self.new_version = states['new_version'] self.is_enabled = states['is_enabled'] self.is_installed = states['is_installed'] def __lt__(self, other): if not isinstance(other, PluginTreeWidgetItem): return super().__lt__(other) tree = self.treeWidget() if not tree: column = 0 else: column = tree.sortColumn() return self.sortData(column) < other.sortData(column) def sortData(self, column): return self._sortData.get(column, self.text(column)) def setSortData(self, column, data): self._sortData[column] = data @property def plugin(self): return self.data(COLUMN_NAME, QtCore.Qt.ItemDataRole.UserRole) def enable(self, boolean, greyout=None): if boolean is not None: self.is_enabled = boolean if self.is_enabled: self.buttons['enable'].mode('enabled') else: self.buttons['enable'].mode('disabled') if greyout is not None: self.buttons['enable'].setEnabled(not greyout) class PluginsOptionsPage(OptionsPage): NAME = 'plugins' TITLE = N_("Plugins") PARENT = None SORT_ORDER = 70 ACTIVE = True HELP_URL = "/config/options_plugins.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_PluginsOptionsPage() self.ui.setupUi(self) plugins = self.ui.plugins # fix for PICARD-1226, QT bug (https://bugreports.qt.io/browse/QTBUG-22572) workaround plugins.setStyleSheet('') plugins.itemSelectionChanged.connect(self.change_details) plugins.mimeTypes = self.mimeTypes plugins.dropEvent = self.dropEvent plugins.dragEnterEvent = self.dragEnterEvent plugins.dragMoveEvent = self.dragMoveEvent self.ui.install_plugin.clicked.connect(self.open_plugins) self.ui.folder_open.clicked.connect(self.open_plugin_dir) self.ui.reload_list_of_plugins.clicked.connect(self.reload_list_of_plugins) self.manager = self.tagger.pluginmanager self.manager.plugin_installed.connect(self.plugin_installed) self.manager.plugin_updated.connect(self.plugin_updated) self.manager.plugin_removed.connect(self.plugin_removed) self.manager.plugin_errored.connect(self.plugin_loading_error) self._preserve = {} self._preserve_selected = None self.icons = { 'download': self.create_icon('plugin-download'), 'update': self.create_icon('plugin-update'), 'uninstall': self.create_icon('plugin-uninstall'), 'enabled': self.create_icon('plugin-enabled'), 'disabled': self.create_icon('plugin-disabled'), } def create_icon(self, icon_name): if theme.is_dark_theme: icon_name += '-dark' return icontheme.lookup(icon_name, icontheme.ICON_SIZE_MENU) def items(self): iterator = QTreeWidgetItemIterator(self.ui.plugins, QTreeWidgetItemIterator.IteratorFlag.All) while iterator.value(): item = iterator.value() iterator += 1 yield item def find_item_by_plugin_name(self, plugin_name): for item in self.items(): if plugin_name == item.plugin.module_name: return item return None def selected_item(self): try: return self.ui.plugins.selectedItems()[COLUMN_NAME] except IndexError: return None def save_state(self): header = self.ui.plugins.header() config = get_config() config.persist['plugins_list_state'] = header.saveState() config.persist['plugins_list_sort_section'] = header.sortIndicatorSection() config.persist['plugins_list_sort_order'] = header.sortIndicatorOrder() def set_current_item(self, item, scroll=False): if scroll: self.ui.plugins.scrollToItem(item) self.ui.plugins.setCurrentItem(item) self.refresh_details(item) def restore_state(self): header = self.ui.plugins.header() config = get_config() header.restoreState(config.persist['plugins_list_state']) idx = config.persist['plugins_list_sort_section'] order = config.persist['plugins_list_sort_order'] header.setSortIndicator(idx, order) self.ui.plugins.sortByColumn(idx, order) @staticmethod def is_plugin_enabled(plugin): config = get_config() return bool(plugin.module_name in config.setting['enabled_plugins']) def available_plugins_name_version(self): return {p.module_name: p.version for p in self.manager.available_plugins} def installable_plugins(self): if self.manager.available_plugins is not None: installed_plugins = [plugin.module_name for plugin in self.installed_plugins()] for plugin in sorted(self.manager.available_plugins, key=attrgetter('name')): if plugin.module_name not in installed_plugins: yield plugin def installed_plugins(self): return sorted(self.manager.plugins, key=attrgetter('name')) def enabled_plugins(self): return [item.plugin.module_name for item in self.items() if item.is_enabled] def _populate(self): self._user_interaction(False) if self.manager.available_plugins is None: available_plugins = {} self.manager.query_available_plugins(self._reload) else: available_plugins = self.available_plugins_name_version() self.ui.details.setText("") self.ui.plugins.setSortingEnabled(False) for plugin in self.installed_plugins(): new_version = None if plugin.module_name in available_plugins: latest = available_plugins[plugin.module_name] if latest > plugin.version: new_version = latest self.update_plugin_item(None, plugin, enabled=self.is_plugin_enabled(plugin), new_version=new_version, is_installed=True ) for plugin in self.installable_plugins(): self.update_plugin_item(None, plugin, enabled=False, is_installed=False) self.ui.plugins.setSortingEnabled(True) self._user_interaction(True) header = self.ui.plugins.header() header.setStretchLastSection(False) header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Fixed) header.setSectionResizeMode(COLUMN_NAME, QtWidgets.QHeaderView.ResizeMode.Stretch) header.setSectionResizeMode(COLUMN_VERSION, QtWidgets.QHeaderView.ResizeMode.ResizeToContents) header.setSectionResizeMode(COLUMN_ACTIONS, QtWidgets.QHeaderView.ResizeMode.ResizeToContents) def _remove_all(self): for item in self.items(): idx = self.ui.plugins.indexOfTopLevelItem(item) self.ui.plugins.takeTopLevelItem(idx) def restore_defaults(self): self._user_interaction(False) self._remove_all() super().restore_defaults() self.set_current_item(self.ui.plugins.topLevelItem(0), scroll=True) def load(self): self._populate() self.restore_state() def _preserve_plugins_states(self): self._preserve = {item.plugin.module_name: item.save_state() for item in self.items()} item = self.selected_item() if item: self._preserve_selected = item.plugin.module_name else: self._preserve_selected = None def _restore_plugins_states(self): for item in self.items(): plugin = item.plugin if plugin.module_name in self._preserve: item.restore_state(self._preserve[plugin.module_name]) if self._preserve_selected == plugin.module_name: self.set_current_item(item, scroll=True) def _reload(self): if self.deleted: return self._remove_all() self._populate() self._restore_plugins_states() def _user_interaction(self, enabled): self.ui.plugins.blockSignals(not enabled) self.ui.plugins_container.setEnabled(enabled) def reload_list_of_plugins(self): self.ui.details.setText(_("Reloading list of available plugins…")) self._user_interaction(False) self._preserve_plugins_states() self.manager.query_available_plugins(callback=self._reload) def plugin_loading_error(self, plugin_name, error): QtWidgets.QMessageBox.critical( self, _('Plugin "%(plugin)s"') % {'plugin': plugin_name}, _('An error occurred while loading the plugin "%(plugin)s":\n\n%(error)s') % { 'plugin': plugin_name, 'error': error, }) def plugin_installed(self, plugin): log.debug("Plugin %r installed", plugin.name) if not plugin.compatible: params = {'plugin': plugin.name} QtWidgets.QMessageBox.warning( self, _('Plugin "%(plugin)s"') % params, _('The plugin "%(plugin)s" is not compatible with this version of Picard.') % params ) return item = self.find_item_by_plugin_name(plugin.module_name) if item: self.update_plugin_item(item, plugin, make_current=True, enabled=True, is_installed=True) else: self._reload() item = self.find_item_by_plugin_name(plugin.module_name) if item: self.set_current_item(item, scroll=True) def plugin_updated(self, plugin_name): log.debug("Plugin %r updated", plugin_name) item = self.find_item_by_plugin_name(plugin_name) if item: plugin = item.plugin QtWidgets.QMessageBox.information( self, _('Plugin "%(plugin)s"') % {'plugin': plugin_name}, _('The plugin "%(plugin)s" will be upgraded to version %(version)s on next run of Picard.') % { 'plugin': plugin.name, 'version': item.new_version.short_str(), }) item.upgrade_to_version = item.new_version self.update_plugin_item(item, plugin, make_current=True) def plugin_removed(self, plugin_name): log.debug("Plugin %r removed", plugin_name) item = self.find_item_by_plugin_name(plugin_name) if item: if self.manager.is_available(plugin_name): self.update_plugin_item(item, None, make_current=True, is_installed=False) else: # Remove local plugin self.ui.plugins.invisibleRootItem().removeChild(item) def uninstall_plugin(self, item): plugin = item.plugin params = {'plugin': plugin.name} buttonReply = QtWidgets.QMessageBox.question( self, _('Uninstall plugin "%(plugin)s"?') % params, _('Do you really want to uninstall the plugin "%(plugin)s"?') % params, QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.No ) if buttonReply == QtWidgets.QMessageBox.StandardButton.Yes: self.manager.remove_plugin(plugin.module_name, with_update=True) def update_plugin_item(self, item, plugin, make_current=False, enabled=None, new_version=None, is_installed=None ): if item is None: item = PluginTreeWidgetItem(self.icons, self.ui.plugins) if plugin is not None: item.setData(COLUMN_NAME, QtCore.Qt.ItemDataRole.UserRole, plugin) else: plugin = item.plugin if new_version is not None: item.new_version = new_version if is_installed is not None: item.is_installed = is_installed if enabled is None: enabled = item.is_enabled def update_text(): if item.new_version is not None: version = "%s → %s" % (plugin.version.short_str(), item.new_version.short_str()) else: version = plugin.version.short_str() if item.installed_font is None: item.installed_font = item.font(COLUMN_NAME) if item.enabled_font is None: item.enabled_font = QtGui.QFont(item.installed_font) item.enabled_font.setBold(True) if item.available_font is None: item.available_font = QtGui.QFont(item.installed_font) if item.is_enabled: item.setFont(COLUMN_NAME, item.enabled_font) else: if item.is_installed: item.setFont(COLUMN_NAME, item.installed_font) else: item.setFont(COLUMN_NAME, item.available_font) item.setText(COLUMN_NAME, plugin.name) item.setText(COLUMN_VERSION, version) def toggle_enable(): item.enable(not item.is_enabled, greyout=not item.is_installed) log.debug("Plugin %r enabled: %r", item.plugin.name, item.is_enabled) update_text() reconnect(item.buttons['enable'].clicked, toggle_enable) install_enabled = not item.is_installed or bool(item.new_version) if item.upgrade_to_version: if item.upgrade_to_version != item.new_version: # case when a new version is known after a plugin was marked for update install_enabled = True else: install_enabled = False if install_enabled: if item.new_version is not None: def download_and_update(): self.download_plugin(item, update=True) reconnect(item.buttons['update'].clicked, download_and_update) item.buttons['install'].mode('hide') item.buttons['update'].mode('show') else: def download_and_install(): self.download_plugin(item) reconnect(item.buttons['install'].clicked, download_and_install) item.buttons['install'].mode('show') item.buttons['update'].mode('hide') if item.is_installed: item.buttons['install'].mode('hide') item.buttons['uninstall'].mode( 'show' if plugin.is_user_installed else 'hide') item.enable(enabled, greyout=False) def uninstall_processor(): self.uninstall_plugin(item) reconnect(item.buttons['uninstall'].clicked, uninstall_processor) else: item.buttons['uninstall'].mode('hide') item.enable(False) item.buttons['enable'].mode('hide') update_text() if make_current: self.set_current_item(item) actions_sort_score = 2 if item.is_installed: if item.is_enabled: actions_sort_score = 0 else: actions_sort_score = 1 item.setSortData(COLUMN_ACTIONS, actions_sort_score) item.setSortData(COLUMN_NAME, plugin.name.lower()) def v2int(elem): try: return int(elem) except ValueError: return 0 item.setSortData(COLUMN_VERSION, plugin.version) return item def save(self): config = get_config() config.setting['enabled_plugins'] = self.enabled_plugins() self.save_state() def refresh_details(self, item): plugin = item.plugin text = [] if item.new_version is not None: if item.upgrade_to_version: label = _("Restart Picard to upgrade to new version") else: label = _("New version available") version_str = item.new_version.short_str() text.append("<b>{0}: {1}</b>".format(label, version_str)) if plugin.description: text.append(plugin.description + "<hr width='90%'/>") infos = [ (_("Name"), escape(plugin.name)), (_("Authors"), self.link_authors(plugin.author)), (_("License"), plugin.license), (_("Files"), escape(plugin.files_list)), (_("User Guide"), self.link_user_guide(plugin.user_guide_url)), ] for label, value in infos: if value: text.append("<b>{0}:</b> {1}".format(label, value)) self.ui.details.setText("<p>{0}</p>".format("<br/>\n".join(text))) @staticmethod def link_authors(authors): formatted_authors = [] re_author = re.compile(r"(?P<author>.*?)\s*<(?P<email>.*?@.*?)>") for author in authors.split(','): author = author.strip() match_ = re_author.fullmatch(author) if match_: author_str = '<a href="mailto:{email}">{author}</a>'.format( email=escape(match_['email']), author=escape(match_['author']), ) formatted_authors.append(author_str) else: formatted_authors.append(escape(author)) return ', '.join(formatted_authors) @staticmethod def link_user_guide(user_guide): if user_guide: user_guide = '<a href="{url}">{url}</a>'.format( url=escape(user_guide) ) return user_guide def change_details(self): item = self.selected_item() if item: self.refresh_details(item) def open_plugins(self): files, _filter = FileDialog.getOpenFileNames( parent=self, dir=QtCore.QDir.homePath(), filter="Picard plugin (*.py *.pyc *.zip)", ) if files: for path in files: self.manager.install_plugin(path) def download_plugin(self, item, update=False): plugin = item.plugin self.tagger.webservice.get_url( url=PLUGINS_API['urls']['download'], handler=partial(self.download_handler, update, plugin=plugin), parse_response_type=None, priority=True, important=True, unencoded_queryargs={'id': plugin.module_name, 'version': plugin.version.short_str()}, ) def download_handler(self, update, response, reply, error, plugin): if self.deleted: return if error: params = {'plugin': plugin.module_name} msgbox = QtWidgets.QMessageBox(self) msgbox.setText(_('The plugin "%(plugin)s" could not be downloaded.') % params) msgbox.setInformativeText(_("Please try again later.")) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.exec() log.error('Error occurred while trying to download the plugin: "%(plugin)s"', params) return self.manager.install_plugin( None, update=update, plugin_name=plugin.module_name, plugin_data=response, ) @staticmethod def open_plugin_dir(): open_local_path(USER_PLUGIN_DIR) def mimeTypes(self): return ['text/uri-list'] def dragEnterEvent(self, event): event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() def dragMoveEvent(self, event): event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() def dropEvent(self, event): if event.proposedAction() == QtCore.Qt.DropAction.IgnoreAction: event.acceptProposedAction() return for path in (os.path.normpath(u.toLocalFile()) for u in event.mimeData().urls()): self.manager.install_plugin(path) event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() register_options_page(PluginsOptionsPage)
26,441
Python
.py
617
32.202593
111
0.607501
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,066
tags_compatibility_wave.py
metabrainz_picard/picard/ui/options/tags_compatibility_wave.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2019-2021 Philipp Wolfer # Copyright (C) 2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.formats.wav import WAVFile from picard.i18n import N_ from picard.ui.forms.ui_options_tags_compatibility_wave import ( Ui_TagsCompatibilityOptionsPage, ) from picard.ui.options import OptionsPage class TagsCompatibilityWaveOptionsPage(OptionsPage): NAME = 'tags_compatibility_wave' TITLE = N_("WAVE") PARENT = 'tags' SORT_ORDER = 60 ACTIVE = True HELP_URL = "/config/options_tags_compatibility_wave.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagsCompatibilityOptionsPage() self.ui.setupUi(self) self.register_setting('write_wave_riff_info', ['write_wave_riff_info']) self.register_setting('remove_wave_riff_info', ['remove_wave_riff_info']) self.register_setting('wave_riff_info_encoding', ['wave_riff_info_enc_cp1252', 'wave_riff_info_enc_utf8']) def load(self): config = get_config() self.ui.write_wave_riff_info.setChecked(config.setting['write_wave_riff_info']) self.ui.remove_wave_riff_info.setChecked(config.setting['remove_wave_riff_info']) if config.setting['wave_riff_info_encoding'] == 'utf-8': self.ui.wave_riff_info_enc_utf8.setChecked(True) else: self.ui.wave_riff_info_enc_cp1252.setChecked(True) def save(self): config = get_config() config.setting['write_wave_riff_info'] = self.ui.write_wave_riff_info.isChecked() config.setting['remove_wave_riff_info'] = self.ui.remove_wave_riff_info.isChecked() if self.ui.wave_riff_info_enc_utf8.isChecked(): config.setting['wave_riff_info_encoding'] = 'utf-8' else: config.setting['wave_riff_info_encoding'] = 'windows-1252' if WAVFile.supports_tag('artist'): register_options_page(TagsCompatibilityWaveOptionsPage)
2,875
Python
.py
61
42.278689
114
0.721329
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,067
tags_compatibility_ac3.py
metabrainz_picard/picard/ui/options/tags_compatibility_ac3.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2019-2021 Philipp Wolfer # Copyright (C) 2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_tags_compatibility_ac3 import ( Ui_TagsCompatibilityOptionsPage, ) from picard.ui.options import OptionsPage class TagsCompatibilityAC3OptionsPage(OptionsPage): NAME = 'tags_compatibility_ac3' TITLE = N_("AC3") PARENT = 'tags' SORT_ORDER = 50 ACTIVE = True HELP_URL = "/config/options_tags_compatibility_ac3.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagsCompatibilityOptionsPage() self.ui.setupUi(self) self.ui.ac3_no_tags.toggled.connect(self.ui.remove_ape_from_ac3.setEnabled) self.register_setting('ac3_save_ape', ['ac3_save_ape', 'ac3_no_tags']) self.register_setting('remove_ape_from_ac3', ['remove_ape_from_ac3']) def load(self): config = get_config() if config.setting['ac3_save_ape']: self.ui.ac3_save_ape.setChecked(True) else: self.ui.ac3_no_tags.setChecked(True) self.ui.remove_ape_from_ac3.setChecked(config.setting['remove_ape_from_ac3']) self.ui.remove_ape_from_ac3.setEnabled(not config.setting['ac3_save_ape']) def save(self): config = get_config() config.setting['ac3_save_ape'] = self.ui.ac3_save_ape.isChecked() config.setting['remove_ape_from_ac3'] = self.ui.remove_ape_from_ac3.isChecked() register_options_page(TagsCompatibilityAC3OptionsPage)
2,474
Python
.py
55
40.509091
87
0.725458
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,068
interface.py
metabrainz_picard/picard/ui/options/interface.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2007-2008 Lukáš Lalinský # Copyright (C) 2008 Will # Copyright (C) 2009, 2019-2023 Philipp Wolfer # Copyright (C) 2011, 2013 Michael Wiencek # Copyright (C) 2013, 2019 Wieland Hoffmann # Copyright (C) 2013-2014, 2018, 2020-2024 Laurent Monin # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016-2018 Sambhav Kothari # Copyright (C) 2017 Antonio Larrosa # Copyright (C) 2018, 2023-2024 Bob Swift # Copyright (C) 2021 Gabriel Ferreira # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os.path from PyQt6 import ( QtCore, QtWidgets, ) from picard.config import get_config from picard.const.languages import UI_LANGUAGES from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, gettext_constants, sort_key, ) from picard.ui.forms.ui_options_interface import Ui_InterfaceOptionsPage from picard.ui.options import OptionsPage from picard.ui.theme import ( AVAILABLE_UI_THEMES, OS_SUPPORTS_THEMES, UiTheme, ) from picard.ui.util import ( FileDialog, changes_require_restart_warning, ) class InterfaceOptionsPage(OptionsPage): NAME = 'interface' TITLE = N_("User Interface") PARENT = None SORT_ORDER = 80 ACTIVE = True HELP_URL = "/config/options_interface.html" # Those are labels for theme display _UI_THEME_LABELS = { UiTheme.DEFAULT: { 'label': N_("Default"), 'desc': N_("The default color scheme based on the operating system display settings"), }, UiTheme.DARK: { 'label': N_("Dark"), 'desc': N_("A dark display theme"), }, UiTheme.LIGHT: { 'label': N_("Light"), 'desc': N_("A light display theme"), }, UiTheme.SYSTEM: { 'label': N_("System"), 'desc': N_("The Qt6 theme configured in the desktop environment"), }, } def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_InterfaceOptionsPage() self.ui.setupUi(self) self.ui.ui_theme.clear() for theme in AVAILABLE_UI_THEMES: label = self._UI_THEME_LABELS[theme]['label'] desc = self._UI_THEME_LABELS[theme]['desc'] self.ui.ui_theme.addItem(_(label), theme) idx = self.ui.ui_theme.findData(theme) self.ui.ui_theme.setItemData(idx, _(desc), QtCore.Qt.ItemDataRole.ToolTipRole) self.ui.ui_theme.setCurrentIndex(self.ui.ui_theme.findData(UiTheme.DEFAULT)) self.ui.ui_language.addItem(_("System default"), '') language_list = [(lang[0], lang[1], gettext_constants(lang[2])) for lang in UI_LANGUAGES] def fcmp(x): return sort_key(x[2]) for lang_code, native, translation in sorted(language_list, key=fcmp): if native and native != translation: name = '%s (%s)' % (translation, native) else: name = translation self.ui.ui_language.addItem(name, lang_code) self.ui.starting_directory.toggled.connect( self.ui.starting_directory_path.setEnabled ) self.ui.starting_directory.toggled.connect( self.ui.starting_directory_browse.setEnabled ) self.ui.starting_directory_browse.clicked.connect(self.starting_directory_browse) if not OS_SUPPORTS_THEMES: self.ui.ui_theme_container.hide() self.ui.allow_multi_dirs_selection.stateChanged.connect(self.multi_selection_warning) self.register_setting('toolbar_show_labels', ['toolbar_show_labels']) self.register_setting('show_menu_icons', ['show_menu_icons']) self.register_setting('ui_language', ['ui_language', 'label']) self.register_setting('ui_theme', ['ui_theme', 'label_theme']) self.register_setting('allow_multi_dirs_selection', ['allow_multi_dirs_selection']) self.register_setting('builtin_search', ['builtin_search']) self.register_setting('use_adv_search_syntax', ['use_adv_search_syntax']) self.register_setting('show_new_user_dialog', ['new_user_dialog']) self.register_setting('quit_confirmation', ['quit_confirmation']) self.register_setting('file_save_warning', ['file_save_warning']) self.register_setting('filebrowser_horizontal_autoscroll', ['filebrowser_horizontal_autoscroll']) self.register_setting('starting_directory', ['starting_directory']) self.register_setting('starting_directory_path', ['starting_directory_path']) def load(self): # Don't display the multi-selection warning when loading values. # This is required because loading a different option profile could trigger the warning. self.ui.allow_multi_dirs_selection.blockSignals(True) config = get_config() self.ui.toolbar_show_labels.setChecked(config.setting['toolbar_show_labels']) self.ui.allow_multi_dirs_selection.setChecked(config.setting['allow_multi_dirs_selection']) self.ui.show_menu_icons.setChecked(config.setting['show_menu_icons']) self.ui.builtin_search.setChecked(config.setting['builtin_search']) self.ui.use_adv_search_syntax.setChecked(config.setting['use_adv_search_syntax']) self.ui.new_user_dialog.setChecked(config.setting['show_new_user_dialog']) self.ui.quit_confirmation.setChecked(config.setting['quit_confirmation']) self.ui.file_save_warning.setChecked(config.setting['file_save_warning']) current_ui_language = config.setting['ui_language'] self.ui.ui_language.setCurrentIndex(self.ui.ui_language.findData(current_ui_language)) self.ui.filebrowser_horizontal_autoscroll.setChecked(config.setting['filebrowser_horizontal_autoscroll']) self.ui.starting_directory.setChecked(config.setting['starting_directory']) self.ui.starting_directory_path.setText(config.setting['starting_directory_path']) current_theme = UiTheme(config.setting['ui_theme']) self.ui.ui_theme.setCurrentIndex(self.ui.ui_theme.findData(current_theme)) # re-enable the multi-selection warning self.ui.allow_multi_dirs_selection.blockSignals(False) def save(self): config = get_config() config.setting['toolbar_show_labels'] = self.ui.toolbar_show_labels.isChecked() config.setting['allow_multi_dirs_selection'] = self.ui.allow_multi_dirs_selection.isChecked() config.setting['show_menu_icons'] = self.ui.show_menu_icons.isChecked() self.tagger.enable_menu_icons(config.setting['show_menu_icons']) config.setting['builtin_search'] = self.ui.builtin_search.isChecked() config.setting['use_adv_search_syntax'] = self.ui.use_adv_search_syntax.isChecked() config.setting['show_new_user_dialog'] = self.ui.new_user_dialog.isChecked() config.setting['quit_confirmation'] = self.ui.quit_confirmation.isChecked() config.setting['file_save_warning'] = self.ui.file_save_warning.isChecked() self.tagger.window.update_toolbar_style() new_theme_setting = str(self.ui.ui_theme.itemData(self.ui.ui_theme.currentIndex())) new_language = self.ui.ui_language.itemData(self.ui.ui_language.currentIndex()) warnings = [] notes = [] if new_theme_setting != config.setting['ui_theme']: warnings.append(_("You have changed the application theme.")) if new_theme_setting == str(UiTheme.SYSTEM): notes.append(_( 'Please note that using the system theme might cause the user interface to be not shown correctly. ' 'If this is the case select the "Default" theme option to use Picard\'s default theme again.' )) config.setting['ui_theme'] = new_theme_setting if new_language != config.setting['ui_language']: config.setting['ui_language'] = new_language warnings.append(_("You have changed the interface language.")) changes_require_restart_warning(self, warnings=warnings, notes=notes) config.setting['filebrowser_horizontal_autoscroll'] = self.ui.filebrowser_horizontal_autoscroll.isChecked() config.setting['starting_directory'] = self.ui.starting_directory.isChecked() config.setting['starting_directory_path'] = os.path.normpath(self.ui.starting_directory_path.text()) def starting_directory_browse(self): item = self.ui.starting_directory_path path = FileDialog.getExistingDirectory( parent=self, dir=item.text(), ) if path: path = os.path.normpath(path) item.setText(path) def multi_selection_warning(self): if not self.ui.allow_multi_dirs_selection.isChecked(): return dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Warning, _('Option Setting Warning'), _( 'When enabling the multiple directories option setting Picard will no longer use the system ' 'file picker for selecting directories. This may result in reduced functionality.\n\n' 'Are you sure that you want to enable this setting?' ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, self) if dialog.exec() == QtWidgets.QMessageBox.StandardButton.No: self.ui.allow_multi_dirs_selection.setCheckState(QtCore.Qt.CheckState.Unchecked) register_options_page(InterfaceOptionsPage)
10,386
Python
.py
203
43.162562
120
0.678747
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,069
tags_compatibility_aac.py
metabrainz_picard/picard/ui/options/tags_compatibility_aac.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2019-2021 Philipp Wolfer # Copyright (C) 2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_tags_compatibility_aac import ( Ui_TagsCompatibilityOptionsPage, ) from picard.ui.options import OptionsPage class TagsCompatibilityAACOptionsPage(OptionsPage): NAME = 'tags_compatibility_aac' TITLE = N_("AAC") PARENT = 'tags' SORT_ORDER = 40 ACTIVE = True HELP_URL = "/config/options_tags_compatibility_aac.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagsCompatibilityOptionsPage() self.ui.setupUi(self) self.ui.aac_no_tags.toggled.connect(self.ui.remove_ape_from_aac.setEnabled) self.register_setting('aac_save_ape', ['aac_save_ape', 'aac_no_tags']) self.register_setting('remove_ape_from_aac', ['remove_ape_from_aac']) def load(self): config = get_config() if config.setting['aac_save_ape']: self.ui.aac_save_ape.setChecked(True) else: self.ui.aac_no_tags.setChecked(True) self.ui.remove_ape_from_aac.setChecked(config.setting['remove_ape_from_aac']) self.ui.remove_ape_from_aac.setEnabled(not config.setting['aac_save_ape']) def save(self): config = get_config() config.setting['aac_save_ape'] = self.ui.aac_save_ape.isChecked() config.setting['remove_ape_from_aac'] = self.ui.remove_ape_from_aac.isChecked() register_options_page(TagsCompatibilityAACOptionsPage)
2,474
Python
.py
55
40.509091
87
0.725458
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,070
tags.py
metabrainz_picard/picard/ui/options/tags.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007, 2011 Lukáš Lalinský # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2009-2010, 2018-2021 Philipp Wolfer # Copyright (C) 2012 Erik Wasser # Copyright (C) 2012 Johannes Weißl # Copyright (C) 2012-2013 Michael Wiencek # Copyright (C) 2013, 2017 Sophist-UK # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017-2018, 2020-2024 Laurent Monin # Copyright (C) 2022 Marcin Szalowicz # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.enums import MainAction from picard.ui.forms.ui_options_tags import Ui_TagsOptionsPage from picard.ui.options import OptionsPage class TagsOptionsPage(OptionsPage): NAME = 'tags' TITLE = N_("Tags") PARENT = None SORT_ORDER = 30 ACTIVE = True HELP_URL = "/config/options_tags.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagsOptionsPage() self.ui.setupUi(self) self.register_setting('dont_write_tags', ['write_tags']) self.register_setting('preserve_timestamps', ['preserve_timestamps']) self.register_setting('clear_existing_tags', ['clear_existing_tags']) self.register_setting('preserve_images', ['preserve_images']) self.register_setting('remove_id3_from_flac', ['remove_id3_from_flac']) self.register_setting('remove_ape_from_mp3', ['remove_ape_from_mp3']) self.register_setting('fix_missing_seekpoints_flac', ['fix_missing_seekpoints_flac']) self.register_setting('preserved_tags', ['preserved_tags']) def load(self): config = get_config() self.ui.write_tags.setChecked(not config.setting['dont_write_tags']) self.ui.preserve_timestamps.setChecked(config.setting['preserve_timestamps']) self.ui.clear_existing_tags.setChecked(config.setting['clear_existing_tags']) self.ui.preserve_images.setChecked(config.setting['preserve_images']) self.ui.remove_ape_from_mp3.setChecked(config.setting['remove_ape_from_mp3']) self.ui.remove_id3_from_flac.setChecked(config.setting['remove_id3_from_flac']) self.ui.fix_missing_seekpoints_flac.setChecked(config.setting['fix_missing_seekpoints_flac']) self.ui.preserved_tags.update(config.setting['preserved_tags']) self.ui.preserved_tags.set_user_sortable(False) def save(self): config = get_config() config.setting['dont_write_tags'] = not self.ui.write_tags.isChecked() config.setting['preserve_timestamps'] = self.ui.preserve_timestamps.isChecked() clear_existing_tags = self.ui.clear_existing_tags.isChecked() if clear_existing_tags != config.setting['clear_existing_tags']: config.setting['clear_existing_tags'] = clear_existing_tags self.tagger.window.metadata_box.update() config.setting['preserve_images'] = self.ui.preserve_images.isChecked() config.setting['remove_ape_from_mp3'] = self.ui.remove_ape_from_mp3.isChecked() config.setting['remove_id3_from_flac'] = self.ui.remove_id3_from_flac.isChecked() config.setting['fix_missing_seekpoints_flac'] = self.ui.fix_missing_seekpoints_flac.isChecked() config.setting['preserved_tags'] = list(self.ui.preserved_tags.tags) self.tagger.window.actions[MainAction.ENABLE_TAG_SAVING].setChecked(not config.setting['dont_write_tags']) register_options_page(TagsOptionsPage)
4,293
Python
.py
79
49.139241
114
0.727013
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,071
genres.py
metabrainz_picard/picard/ui/options/genres.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2008 Lukáš Lalinský # Copyright (C) 2018, 2020-2023 Philipp Wolfer # Copyright (C) 2019 Wieland Hoffmann # Copyright (C) 2019-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6.QtCore import Qt from PyQt6.QtGui import ( QTextBlockFormat, QTextCursor, ) from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.track import TagGenreFilter from picard.ui.forms.ui_options_genres import Ui_GenresOptionsPage from picard.ui.options import OptionsPage TOOLTIP_GENRES_FILTER = N_("""<html><head/><body> <p>Lines not starting with <b>-</b> or <b>+</b> are ignored.</p> <p>One expression per line, case-insensitive</p> <p>Examples:</p> <p><b> #comment<br/> !comment<br/> comment </b></p> <p><u>Strict filtering:</u></p> <p> <b>-word</b>: exclude <i>word</i><br/> <b>+word</b>: include <i>word</i> </p> <p><u>Wildcard filtering:</u></p> <p> <b>-*word</b>: exclude all genres ending with <i>word</i><br/> <b>+word*</b>: include all genres starting with <i>word</i><br/> <b>+wor?</b>: include all genres starting with <i>wor</i> and ending with an arbitrary character<br/> <b>+wor[dk]</b>: include all genres starting with <i>wor</i> and ending with <i>d</i> or <i>k</i><br/> <b>-w*rd</b>: exclude all genres starting with <i>w</i> and ending with <i>rd</i> </p> <p><u>Regular expressions filtering (Python re syntax):</u></p> <p><b>-/^w.rd+/</b>: exclude genres starting with <i>w</i> followed by any character, then <i>r</i> followed by at least one <i>d</i> </p> </body></html>""") TOOLTIP_TEST_GENRES_FILTER = N_("""<html><head/><body> <p>You can add genres to test filters against, one per line.<br/> This playground will not be preserved on Options exit. </p> <p> Red background means the tag will be skipped.<br/> Green background means the tag will be kept. </p> </body></html>""") class GenresOptionsPage(OptionsPage): NAME = 'genres' TITLE = N_("Genres") PARENT = 'metadata' SORT_ORDER = 20 ACTIVE = True HELP_URL = "/config/options_genres.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_GenresOptionsPage() self.ui.setupUi(self) self.ui.genres_filter.setToolTip(_(TOOLTIP_GENRES_FILTER)) self.ui.genres_filter.textChanged.connect(self.update_test_genres_filter) self.ui.test_genres_filter.setToolTip(_(TOOLTIP_TEST_GENRES_FILTER)) self.ui.test_genres_filter.textChanged.connect(self.update_test_genres_filter) # FIXME: colors aren't great from accessibility POV self.fmt_keep = QTextBlockFormat() self.fmt_keep.setBackground(Qt.GlobalColor.green) self.fmt_skip = QTextBlockFormat() self.fmt_skip.setBackground(Qt.GlobalColor.red) self.fmt_clear = QTextBlockFormat() self.fmt_clear.clearBackground() self.register_setting('use_genres', []) self.register_setting('only_my_genres', ['only_my_genres']) self.register_setting('artists_genres', ['artists_genres']) self.register_setting('folksonomy_tags', ['folksonomy_tags']) self.register_setting('min_genre_usage', ['min_genre_usage']) self.register_setting('max_genres', ['max_genres']) self.register_setting('join_genres', ['join_genres']) self.register_setting('genres_filter', ['genres_filter']) def load(self): config = get_config() self.ui.use_genres.setChecked(config.setting['use_genres']) self.ui.max_genres.setValue(config.setting["max_genres"]) self.ui.min_genre_usage.setValue(config.setting["min_genre_usage"]) self.ui.join_genres.setEditText(config.setting["join_genres"]) self.ui.genres_filter.setPlainText(config.setting["genres_filter"]) self.ui.only_my_genres.setChecked(config.setting["only_my_genres"]) self.ui.artists_genres.setChecked(config.setting["artists_genres"]) self.ui.folksonomy_tags.setChecked(config.setting["folksonomy_tags"]) def save(self): config = get_config() config.setting['use_genres'] = self.ui.use_genres.isChecked() config.setting['max_genres'] = self.ui.max_genres.value() config.setting['min_genre_usage'] = self.ui.min_genre_usage.value() config.setting['join_genres'] = self.ui.join_genres.currentText() config.setting['genres_filter'] = self.ui.genres_filter.toPlainText() config.setting['only_my_genres'] = self.ui.only_my_genres.isChecked() config.setting['artists_genres'] = self.ui.artists_genres.isChecked() config.setting['folksonomy_tags'] = self.ui.folksonomy_tags.isChecked() def update_test_genres_filter(self): test_text = self.ui.test_genres_filter.toPlainText() filters = self.ui.genres_filter.toPlainText() tagfilter = TagGenreFilter(filters) # FIXME: very simple error reporting, improve self.ui.label_test_genres_filter_error.setText( "\n".join(tagfilter.format_errors()) ) def set_line_fmt(lineno, textformat): obj = self.ui.test_genres_filter if lineno < 0: # use current cursor position cursor = obj.textCursor() else: cursor = QTextCursor(obj.document().findBlockByNumber(lineno)) obj.blockSignals(True) cursor.setBlockFormat(textformat) obj.blockSignals(False) set_line_fmt(-1, self.fmt_clear) for lineno, line in enumerate(test_text.splitlines()): line = line.strip() fmt = self.fmt_clear if line: if tagfilter.skip(line): fmt = self.fmt_skip else: fmt = self.fmt_keep set_line_fmt(lineno, fmt) register_options_page(GenresOptionsPage)
6,709
Python
.py
150
38.866667
133
0.677948
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,072
advanced.py
metabrainz_picard/picard/ui/options/advanced.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007 Lukáš Lalinský # Copyright (C) 2013-2015, 2018, 2020-2021, 2023-2024 Laurent Monin # Copyright (C) 2014, 2019-2022 Philipp Wolfer # Copyright (C) 2016-2017 Sambhav Kothari # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_advanced import Ui_AdvancedOptionsPage from picard.ui.options import OptionsPage class AdvancedOptionsPage(OptionsPage): NAME = 'advanced' TITLE = N_("Advanced") PARENT = None SORT_ORDER = 90 ACTIVE = True HELP_URL = "/config/options_advanced.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_AdvancedOptionsPage() self.ui.setupUi(self) self.init_regex_checker(self.ui.ignore_regex, self.ui.regex_error) self.register_setting('ignore_regex', ['ignore_regex']) self.register_setting('ignore_hidden_files', ['ignore_hidden_files']) self.register_setting('recursively_add_files', ['recursively_add_files']) self.register_setting('ignore_track_duration_difference_under', ['ignore_track_duration_difference_under', 'label_track_duration_diff']) self.register_setting('query_limit', ['query_limit', 'label_query_limit']) self.register_setting('completeness_ignore_videos', ['completeness_ignore_videos']) self.register_setting('completeness_ignore_pregap', ['completeness_ignore_pregap']) self.register_setting('completeness_ignore_data', ['completeness_ignore_data']) self.register_setting('completeness_ignore_silence', ['completeness_ignore_silence']) self.register_setting('compare_ignore_tags', ['groupBox_ignore_tags']) def load(self): config = get_config() self.ui.ignore_regex.setText(config.setting['ignore_regex']) self.ui.ignore_hidden_files.setChecked(config.setting['ignore_hidden_files']) self.ui.recursively_add_files.setChecked(config.setting['recursively_add_files']) self.ui.ignore_track_duration_difference_under.setValue(config.setting['ignore_track_duration_difference_under']) self.ui.query_limit.setCurrentText(str(config.setting['query_limit'])) self.ui.completeness_ignore_videos.setChecked(config.setting['completeness_ignore_videos']) self.ui.completeness_ignore_pregap.setChecked(config.setting['completeness_ignore_pregap']) self.ui.completeness_ignore_data.setChecked(config.setting['completeness_ignore_data']) self.ui.completeness_ignore_silence.setChecked(config.setting['completeness_ignore_silence']) self.ui.compare_ignore_tags.update(config.setting['compare_ignore_tags']) self.ui.compare_ignore_tags.set_user_sortable(False) def save(self): config = get_config() config.setting['ignore_regex'] = self.ui.ignore_regex.text() config.setting['ignore_hidden_files'] = self.ui.ignore_hidden_files.isChecked() config.setting['recursively_add_files'] = self.ui.recursively_add_files.isChecked() config.setting['ignore_track_duration_difference_under'] = self.ui.ignore_track_duration_difference_under.value() config.setting['query_limit'] = self.ui.query_limit.currentText() config.setting['completeness_ignore_videos'] = self.ui.completeness_ignore_videos.isChecked() config.setting['completeness_ignore_pregap'] = self.ui.completeness_ignore_pregap.isChecked() config.setting['completeness_ignore_data'] = self.ui.completeness_ignore_data.isChecked() config.setting['completeness_ignore_silence'] = self.ui.completeness_ignore_silence.isChecked() tags = list(self.ui.compare_ignore_tags.tags) if tags != config.setting['compare_ignore_tags']: config.setting['compare_ignore_tags'] = tags def restore_defaults(self): self.ui.compare_ignore_tags.clear() super().restore_defaults() register_options_page(AdvancedOptionsPage)
4,822
Python
.py
80
54.425
144
0.733813
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,073
maintenance.py
metabrainz_picard/picard/ui/options/maintenance.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2021-2022, 2024 Bob Swift # Copyright (C) 2021-2023 Philipp Wolfer # Copyright (C) 2021-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import datetime import os from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import log from picard.config import ( Option, get_config, load_new_config, ) from picard.config_upgrade import upgrade_config from picard.const.defaults import DEFAULT_AUTOBACKUP_DIRECTORY from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.util import open_local_path from picard.ui.forms.ui_options_maintenance import Ui_MaintenanceOptionsPage from picard.ui.options import OptionsPage from picard.ui.util import FileDialog OPTIONS_NOT_IN_PAGES = { # Include options that are required but are not entered directly from the options pages. 'file_renaming_scripts', 'selected_file_naming_script_id', 'log_verbosity', # Items missed if TagsCompatibilityWaveOptionsPage does not register. 'remove_wave_riff_info', 'wave_riff_info_encoding', 'write_wave_riff_info', } def _safe_autobackup_dir(path): if not path or not os.path.isdir(path): return DEFAULT_AUTOBACKUP_DIRECTORY return os.path.normpath(path) class MaintenanceOptionsPage(OptionsPage): NAME = 'maintenance' TITLE = N_("Maintenance") PARENT = 'advanced' SORT_ORDER = 99 ACTIVE = True HELP_URL = "/config/options_maintenance.html" signal_reload = QtCore.pyqtSignal() def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_MaintenanceOptionsPage() self.ui.setupUi(self) self.ui.description.setText(_( "Settings that are found in the configuration file that do not appear on any option " "settings page are listed below. If your configuration file does not contain any " "unused option settings, then the list will be empty and the removal checkbox will be " "disabled.\n\n" "Note that unused option settings could come from plugins that have been uninstalled, " "so please be careful to not remove settings that you may want to use later when " "the plugin is reinstalled. Options belonging to plugins that are installed but " "currently disabled are not listed for possible removal.\n\n" "To remove one or more settings, select the settings that you want to remove by " "checking the box next to the setting, and enable the removal by checking the \"Remove " "selected options\" box. When you choose \"Make It So!\" to save your option " "settings, the selected items will be removed." )) self.ui.tableWidget.setHorizontalHeaderLabels([_("Option"), _("Value")]) self.ui.select_all.stateChanged.connect(self.select_all_changed) self.ui.open_folder_button.clicked.connect(self.open_config_dir) self.ui.save_backup_button.clicked.connect(self.save_backup) self.ui.load_backup_button.clicked.connect(self.load_backup) self.ui.browse_autobackup_dir.clicked.connect(self._dialog_autobackup_dir_browse) self.ui.autobackup_dir.editingFinished.connect(self._check_autobackup_dir) # Set the palette of the config file QLineEdit widget to inactive. palette_normal = self.ui.config_file.palette() palette_readonly = QtGui.QPalette(palette_normal) disabled_color = palette_normal.color(QtGui.QPalette.ColorGroup.Inactive, QtGui.QPalette.ColorRole.Window) palette_readonly.setColor(QtGui.QPalette.ColorRole.Base, disabled_color) self.ui.config_file.setPalette(palette_readonly) self.last_valid_path = _safe_autobackup_dir('') self.register_setting('autobackup_directory', ['autobackup_dir']) def get_current_autobackup_dir(self): return _safe_autobackup_dir(self.ui.autobackup_dir.text()) def set_current_autobackup_dir(self, path): self.last_valid_path = _safe_autobackup_dir(path) self.ui.autobackup_dir.setText(self.last_valid_path) def _check_autobackup_dir(self): path = self.ui.autobackup_dir.text() if not path or not os.path.isdir(path): self._dialog_invalid_backup_dir(path) else: self.last_valid_path = _safe_autobackup_dir(path) self.ui.autobackup_dir.setText(self.last_valid_path) def _dialog_invalid_backup_dir(self, path): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Critical, _("Configuration File Backup Directory Error"), _("The path provided isn't a valid directory, reverting to:\n" "%s\n") % self.last_valid_path, QtWidgets.QMessageBox.StandardButton.Ok, self, ) dialog.exec() def _dialog_autobackup_dir_browse(self): path = FileDialog.getExistingDirectory( parent=self, dir=self.get_current_autobackup_dir(), ) if path: self.set_current_autobackup_dir(path) def load(self): config = get_config() self.set_current_autobackup_dir(config.setting['autobackup_directory']) # Show the path and file name of the currently used configuration file. self.ui.config_file.setText(config.fileName()) # Setting options from all option pages and loaded plugins (including plugins currently disabled). key_options = set(config.setting.as_dict()) # Combine all page and plugin settings with required options not appearing in option pages. current_options = OPTIONS_NOT_IN_PAGES.union(key_options) # All setting options included in the INI file. config.beginGroup('setting') file_options = set(config.childKeys()) config.endGroup() orphan_options = file_options.difference(current_options) self.ui.option_counts.setText( _("The configuration file currently contains %(totalcount)d option " "settings (%(unusedcount)d unused).") % { 'totalcount': len(file_options), 'unusedcount': len(orphan_options), }) self.ui.enable_cleanup.setChecked(False) self.ui.tableWidget.clearContents() self.ui.tableWidget.setRowCount(len(orphan_options)) for row, option_name in enumerate(sorted(orphan_options)): tableitem = QtWidgets.QTableWidgetItem(option_name) tableitem.setData(QtCore.Qt.ItemDataRole.UserRole, option_name) tableitem.setFlags(tableitem.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable) tableitem.setCheckState(QtCore.Qt.CheckState.Unchecked) self.ui.tableWidget.setItem(row, 0, tableitem) tableitem = QtWidgets.QTextEdit() tableitem.setFrameStyle(QtWidgets.QFrame.Shape.NoFrame) text = self.make_setting_value_text(option_name) tableitem.setPlainText(text) tableitem.setReadOnly(True) # Adjust row height to reasonably accommodate values with more than one line, with a minimum # height of 25 pixels. Long line or multi-line values will be expanded to display up to 5 # lines, assuming a standard line height of 18 pixels. Long lines are defined as having over # 50 characters. text_rows = max(text.count("\n") + 1, int(len(text) / 50)) row_height = max(25, 18 * min(5, text_rows)) self.ui.tableWidget.setRowHeight(row, row_height) self.ui.tableWidget.setCellWidget(row, 1, tableitem) self.ui.tableWidget.resizeColumnsToContents() self.ui.select_all.setCheckState(QtCore.Qt.CheckState.Unchecked) self._set_cleanup_state() def open_config_dir(self): config = get_config() config_dir = os.path.split(config.fileName())[0] open_local_path(config_dir) def _get_dialog_filetypes(self, _ext='.ini'): return ";;".join(( _("Configuration files") + " (*{0})".format(_ext,), _("All files") + " (*)", )) def _make_backup_filename(self, auto=False): config = get_config() _filename = os.path.split(config.fileName())[1] _root, _ext = os.path.splitext(_filename) return "{0}_{1}_Backup_{2}{3}".format( _root, 'Auto' if auto else 'User', datetime.datetime.now().strftime("%Y%m%d_%H%M"), _ext, ) def _dialog_save_backup_error(self, filename): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Critical, _("Backup Configuration File Save Error"), _("Failed to save the configuration file to:\n" "%s\n" "\n" "Please see the logs for more details." % filename), QtWidgets.QMessageBox.StandardButton.Ok, self, ) dialog.exec() def _dialog_ask_backup_filename(self, default_path, ext): filename, file_type = FileDialog.getSaveFileName( parent=self, caption=_("Backup Configuration File"), dir=default_path, filter=self._get_dialog_filetypes(ext), ) return filename def _dialog_save_backup_success(self, filename): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Information, _("Backup Configuration File"), _("Configuration successfully backed up to:\n" "%s") % filename, QtWidgets.QMessageBox.StandardButton.Ok, self, ) dialog.exec() def save_backup(self): config = get_config() directory = self.get_current_autobackup_dir() filename = self._make_backup_filename() ext = os.path.splitext(filename)[1] default_path = os.path.normpath(os.path.join(directory, filename)) filename = self._dialog_ask_backup_filename(default_path, ext) if not filename: return # Fix issue where Qt may set the extension twice (name, ext) = os.path.splitext(filename) if ext and str(name).endswith('.' + ext): filename = name if config.save_user_backup(filename): self._dialog_save_backup_success(filename) else: self._dialog_save_backup_error(filename) def _dialog_load_backup_confirmation(self, filename): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Warning, _("Load Backup Configuration File"), _("Loading a backup configuration file will replace the current configuration settings.\n" "Before any change, the current configuration will be automatically saved to:\n" "%s\n" "\n" "Do you want to continue?") % filename, QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel, self, ) dialog.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Cancel) return dialog.exec() == QtWidgets.QMessageBox.StandardButton.Ok def _dialog_load_backup_success(self, filename): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Information, _("Load Backup Configuration File"), _("Configuration successfully loaded from:\n" "%s") % filename, QtWidgets.QMessageBox.StandardButton.Ok, self, ) dialog.exec() def _dialog_load_backup_error(self, filename): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Information, _("Load Backup Configuration File"), _("There was a problem restoring the configuration file from:\n" "%s\n" "\n" "Please see the logs for more details.") % filename, QtWidgets.QMessageBox.StandardButton.Ok, self, ) dialog.exec() def _dialog_load_backup_select_filename(self, directory, ext): filename, file_type = FileDialog.getOpenFileName( parent=self, caption=_("Select Configuration File to Load"), dir=directory, filter=self._get_dialog_filetypes(ext), ) return filename def load_backup(self): directory = self.get_current_autobackup_dir() filename = os.path.join(directory, self._make_backup_filename(auto=True)) if not self._dialog_load_backup_confirmation(filename): return config = get_config() if not config.save_user_backup(filename): self._dialog_save_backup_error(filename) return ext = os.path.splitext(filename)[1] filename = self._dialog_load_backup_select_filename(directory, ext) if not filename: return log.warning("Loading configuration from %s", filename) if load_new_config(filename): config = get_config() upgrade_config(config) self.signal_reload.emit() self._dialog_load_backup_success(filename) else: self._dialog_load_backup_error(filename) def column_items(self, column): for idx in range(self.ui.tableWidget.rowCount()): yield self.ui.tableWidget.item(idx, column) def selected_options(self): for item in self.column_items(0): if item.checkState() == QtCore.Qt.CheckState.Checked: yield item.data(QtCore.Qt.ItemDataRole.UserRole) def select_all_changed(self): state = self.ui.select_all.checkState() for item in self.column_items(0): item.setCheckState(state) def _dialog_ask_remove_confirmation(self): return QtWidgets.QMessageBox.question( self, _("Confirm Remove"), _("Are you sure you want to remove the selected option settings?"), ) == QtWidgets.QMessageBox.StandardButton.Yes def save(self): config = get_config() config.setting['autobackup_directory'] = self.get_current_autobackup_dir() if not self.ui.enable_cleanup.checkState() == QtCore.Qt.CheckState.Checked: return to_remove = set(self.selected_options()) if to_remove and self._dialog_ask_remove_confirmation(): for item in to_remove: Option.add_if_missing('setting', item, None) log.warning("Removing option setting '%s' from the INI file.", item) config.setting.remove(item) def make_setting_value_text(self, key): config = get_config() value = config.setting.raw_value(key) return repr(value) def _set_cleanup_state(self): state = self.ui.tableWidget.rowCount() > 0 self.ui.select_all.setEnabled(state) self.ui.enable_cleanup.setChecked(False) self.ui.enable_cleanup.setEnabled(state) register_options_page(MaintenanceOptionsPage)
15,937
Python
.py
343
37.294461
114
0.653321
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,074
fingerprinting.py
metabrainz_picard/picard/ui/options/fingerprinting.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2011-2012 Lukáš Lalinský # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2013, 2018, 2020-2024 Laurent Monin # Copyright (C) 2015, 2020-2023 Philipp Wolfer # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2023 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os from PyQt6 import ( QtCore, QtGui, ) from picard.acoustid import find_fpcalc from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.util import webbrowser2 from picard.ui.forms.ui_options_fingerprinting import ( Ui_FingerprintingOptionsPage, ) from picard.ui.options import ( OptionsCheckError, OptionsPage, ) from picard.ui.util import FileDialog class ApiKeyValidator(QtGui.QValidator): def validate(self, input, pos): # Strip whitespace to avoid typical copy and paste user errors return (QtGui.QValidator.State.Acceptable, input.strip(), pos) class FingerprintingOptionsPage(OptionsPage): NAME = 'fingerprinting' TITLE = N_("Fingerprinting") PARENT = None SORT_ORDER = 45 ACTIVE = True HELP_URL = "/config/options_fingerprinting.html" def __init__(self, parent=None): super().__init__(parent=parent) self._fpcalc_valid = True self.ui = Ui_FingerprintingOptionsPage() self.ui.setupUi(self) self.ui.disable_fingerprinting.clicked.connect(self.update_groupboxes) self.ui.use_acoustid.clicked.connect(self.update_groupboxes) self.ui.acoustid_fpcalc.textChanged.connect(self._acoustid_fpcalc_check) self.ui.acoustid_fpcalc_browse.clicked.connect(self.acoustid_fpcalc_browse) self.ui.acoustid_fpcalc_download.clicked.connect(self.acoustid_fpcalc_download) self.ui.acoustid_apikey_get.clicked.connect(self.acoustid_apikey_get) self.ui.acoustid_apikey.setValidator(ApiKeyValidator()) self.register_setting('fingerprinting_system') self.register_setting('acoustid_fpcalc') self.register_setting('acoustid_apikey') self.register_setting('ignore_existing_acoustid_fingerprints') self.register_setting('save_acoustid_fingerprints') self.register_setting('fpcalc_threads') def load(self): config = get_config() if config.setting['fingerprinting_system'] == 'acoustid': self.ui.use_acoustid.setChecked(True) else: self.ui.disable_fingerprinting.setChecked(True) self.ui.acoustid_fpcalc.setPlaceholderText(find_fpcalc()) self.ui.acoustid_fpcalc.setText(config.setting['acoustid_fpcalc']) self.ui.acoustid_apikey.setText(config.setting['acoustid_apikey']) self.ui.ignore_existing_acoustid_fingerprints.setChecked(config.setting['ignore_existing_acoustid_fingerprints']) self.ui.save_acoustid_fingerprints.setChecked(config.setting['save_acoustid_fingerprints']) self.ui.fpcalc_threads.setValue(config.setting['fpcalc_threads']) self.update_groupboxes() def save(self): config = get_config() if self.ui.use_acoustid.isChecked(): config.setting['fingerprinting_system'] = 'acoustid' else: config.setting['fingerprinting_system'] = '' config.setting['acoustid_fpcalc'] = self.ui.acoustid_fpcalc.text() config.setting['acoustid_apikey'] = self.ui.acoustid_apikey.text() config.setting['ignore_existing_acoustid_fingerprints'] = self.ui.ignore_existing_acoustid_fingerprints.isChecked() config.setting['save_acoustid_fingerprints'] = self.ui.save_acoustid_fingerprints.isChecked() config.setting['fpcalc_threads'] = self.ui.fpcalc_threads.value() def update_groupboxes(self): if self.ui.use_acoustid.isChecked(): self.ui.acoustid_settings.setEnabled(True) else: self.ui.acoustid_settings.setEnabled(False) self._acoustid_fpcalc_check() def acoustid_fpcalc_browse(self): path, _filter = FileDialog.getOpenFileName( parent=self, dir=self.ui.acoustid_fpcalc.text(), ) if path: path = os.path.normpath(path) self.ui.acoustid_fpcalc.setText(path) def acoustid_fpcalc_download(self): webbrowser2.open('chromaprint') def acoustid_apikey_get(self): webbrowser2.open('acoustid_apikey') def _acoustid_fpcalc_check(self): if not self.ui.use_acoustid.isChecked(): self._acoustid_fpcalc_set_success("") return fpcalc = self.ui.acoustid_fpcalc.text() if not fpcalc: fpcalc = find_fpcalc() self._fpcalc_valid = False process = QtCore.QProcess(self) process.finished.connect(self._on_acoustid_fpcalc_check_finished) process.errorOccurred.connect(self._on_acoustid_fpcalc_check_error) process.start(fpcalc, ["-v"]) def _on_acoustid_fpcalc_check_finished(self, exit_code, exit_status): process = self.sender() if exit_code == 0 and exit_status == QtCore.QProcess.ExitStatus.NormalExit: output = bytes(process.readAllStandardOutput()).decode() if output.startswith("fpcalc version"): self._acoustid_fpcalc_set_success(output.strip()) else: self._acoustid_fpcalc_set_error() else: self._acoustid_fpcalc_set_error() def _on_acoustid_fpcalc_check_error(self, error): self._acoustid_fpcalc_set_error() def _acoustid_fpcalc_set_success(self, version): self._fpcalc_valid = True self.ui.acoustid_fpcalc_info.setStyleSheet("") self.ui.acoustid_fpcalc_info.setText(version) def _acoustid_fpcalc_set_error(self): self._fpcalc_valid = False self.ui.acoustid_fpcalc_info.setStyleSheet(self.STYLESHEET_ERROR) self.ui.acoustid_fpcalc_info.setText(_("Please select a valid fpcalc executable.")) def check(self): if not self._fpcalc_valid: raise OptionsCheckError(_("Invalid fpcalc executable"), _("Please select a valid fpcalc executable.")) def display_error(self, error): pass register_options_page(FingerprintingOptionsPage)
7,050
Python
.py
154
38.863636
123
0.702258
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,075
cover.py
metabrainz_picard/picard/ui/options/cover.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007 Lukáš Lalinský # Copyright (C) 2010, 2018-2021, 2024 Philipp Wolfer # Copyright (C) 2012, 2014 Wieland Hoffmann # Copyright (C) 2012-2014 Michael Wiencek # Copyright (C) 2013-2015, 2018-2021, 2023-2024 Laurent Monin # Copyright (C) 2016-2018 Sambhav Kothari # Copyright (C) 2017 Suhas # Copyright (C) 2021 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6.QtCore import Qt from picard.config import ( Option, get_config, ) from picard.const.defaults import ( DEFAULT_CA_NEVER_REPLACE_TYPE_EXCLUDE, DEFAULT_CA_NEVER_REPLACE_TYPE_INCLUDE, ) from picard.coverart.providers import cover_art_providers from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.ui.caa_types_selector import CAATypesSelectorDialog from picard.ui.forms.ui_options_cover import Ui_CoverOptionsPage from picard.ui.moveable_list_view import MoveableListView from picard.ui.options import OptionsPage from picard.ui.util import qlistwidget_items from picard.ui.widgets.checkbox_list_item import CheckboxListItem class CoverOptionsPage(OptionsPage): NAME = 'cover' TITLE = N_("Cover Art") PARENT = None SORT_ORDER = 35 ACTIVE = True HELP_URL = "/config/options_cover.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_CoverOptionsPage() self.ui.setupUi(self) self.ui.cover_image_filename.setPlaceholderText(Option.get('setting', 'cover_image_filename').default) self.ui.save_images_to_files.clicked.connect(self.update_ca_providers_groupbox_state) self.ui.save_images_to_tags.clicked.connect(self.update_ca_providers_groupbox_state) self.ui.save_only_one_front_image.toggled.connect(self.ui.image_type_as_filename.setDisabled) self.ui.cb_never_replace_types.toggled.connect(self.ui.select_types_button.setEnabled) self.ui.select_types_button.clicked.connect(self.select_never_replace_image_types) self.move_view = MoveableListView(self.ui.ca_providers_list, self.ui.up_button, self.ui.down_button) self.register_setting('save_images_to_tags', ['save_images_to_tags']) self.register_setting('embed_only_one_front_image', ['cb_embed_front_only']) self.register_setting('dont_replace_with_smaller_cover', ['dont_replace_with_smaller_cover']) self.register_setting('dont_replace_cover_of_types', ['dont_replace_cover_of_types']) self.register_setting('dont_replace_included_types', ['dont_replace_included_types']) self.register_setting('dont_replace_excluded_types', ['dont_replace_excluded_types']) self.register_setting('save_images_to_files', ['save_images_to_files']) self.register_setting('cover_image_filename', ['cover_image_filename']) self.register_setting('save_images_overwrite', ['save_images_overwrite']) self.register_setting('save_only_one_front_image', ['save_only_one_front_image']) self.register_setting('image_type_as_filename', ['image_type_as_filename']) self.register_setting('ca_providers', ['ca_providers_list']) def restore_defaults(self): # Remove previous entries self.ui.ca_providers_list.clear() self.dont_replace_included_types = DEFAULT_CA_NEVER_REPLACE_TYPE_INCLUDE self.dont_replace_excluded_types = DEFAULT_CA_NEVER_REPLACE_TYPE_EXCLUDE super().restore_defaults() def _load_cover_art_providers(self): """Load available providers, initialize provider-specific options, restore state of each """ self.ui.ca_providers_list.clear() for p in cover_art_providers(): item = CheckboxListItem(_(p.title), checked=p.enabled) item.setData(Qt.ItemDataRole.UserRole, p.name) self.ui.ca_providers_list.addItem(item) def load(self): config = get_config() self.ui.save_images_to_tags.setChecked(config.setting['save_images_to_tags']) self.ui.cb_embed_front_only.setChecked(config.setting['embed_only_one_front_image']) self.ui.cb_dont_replace_with_smaller.setChecked(config.setting['dont_replace_with_smaller_cover']) self.ui.cb_never_replace_types.setChecked(config.setting['dont_replace_cover_of_types']) self.ui.select_types_button.setEnabled(config.setting['dont_replace_cover_of_types']) self.dont_replace_included_types = config.setting['dont_replace_included_types'] self.dont_replace_excluded_types = config.setting['dont_replace_excluded_types'] self.ui.save_images_to_files.setChecked(config.setting['save_images_to_files']) self.ui.cover_image_filename.setText(config.setting['cover_image_filename']) self.ui.save_images_overwrite.setChecked(config.setting['save_images_overwrite']) self.ui.save_only_one_front_image.setChecked(config.setting['save_only_one_front_image']) self.ui.image_type_as_filename.setChecked(config.setting['image_type_as_filename']) self._load_cover_art_providers() self.ui.ca_providers_list.setCurrentRow(0) self.update_ca_providers_groupbox_state() def _ca_providers(self): for item in qlistwidget_items(self.ui.ca_providers_list): yield (item.data(Qt.ItemDataRole.UserRole), item.checked) def save(self): config = get_config() config.setting['save_images_to_tags'] = self.ui.save_images_to_tags.isChecked() config.setting['embed_only_one_front_image'] = self.ui.cb_embed_front_only.isChecked() config.setting['dont_replace_with_smaller_cover'] = self.ui.cb_dont_replace_with_smaller.isChecked() config.setting['dont_replace_cover_of_types'] = self.ui.cb_never_replace_types.isChecked() config.setting['dont_replace_included_types'] = self.dont_replace_included_types config.setting['dont_replace_excluded_types'] = self.dont_replace_excluded_types config.setting['save_images_to_files'] = self.ui.save_images_to_files.isChecked() config.setting['cover_image_filename'] = self.ui.cover_image_filename.text() config.setting['save_images_overwrite'] = self.ui.save_images_overwrite.isChecked() config.setting['save_only_one_front_image'] = self.ui.save_only_one_front_image.isChecked() config.setting['image_type_as_filename'] = self.ui.image_type_as_filename.isChecked() config.setting['ca_providers'] = list(self._ca_providers()) def update_ca_providers_groupbox_state(self): files_enabled = self.ui.save_images_to_files.isChecked() tags_enabled = self.ui.save_images_to_tags.isChecked() self.ui.ca_providers_groupbox.setEnabled(files_enabled or tags_enabled) def select_never_replace_image_types(self): instructions_bottom = N_( "Embedded cover art images with a type found in the 'Include' list will never be replaced " "by a newly downloaded image UNLESS they also have an image type in the 'Exclude' list. " "Images with types found in the 'Exclude' list will always be replaced by downloaded images " "of the same type. Images types not appearing in the 'Include' or 'Exclude' list will " "not be considered when determining whether or not to replace an embedded cover art image.\n" ) (included_types, excluded_types, ok) = CAATypesSelectorDialog.display( types_include=self.dont_replace_included_types, types_exclude=self.dont_replace_excluded_types, parent=self, instructions_bottom=instructions_bottom, ) if ok: self.dont_replace_included_types = included_types self.dont_replace_excluded_types = excluded_types register_options_page(CoverOptionsPage)
8,642
Python
.py
148
51.486486
110
0.715129
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,076
releases.py
metabrainz_picard/picard/ui/options/releases.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2011-2014 Michael Wiencek # Copyright (C) 2012 Frederik “Freso” S. Olesen # Copyright (C) 2013-2015, 2018-2024 Laurent Monin # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017 Suhas # Copyright (C) 2018-2022, 2024 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import ( QtCore, QtWidgets, ) from picard.config import get_config from picard.const import ( RELEASE_FORMATS, RELEASE_PRIMARY_GROUPS, RELEASE_SECONDARY_GROUPS, ) from picard.const.countries import RELEASE_COUNTRIES from picard.const.defaults import DEFAULT_RELEASE_SCORE from picard.const.sys import IS_WIN from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, gettext_countries, pgettext_attributes, sort_key, ) from picard.ui.forms.ui_options_releases import Ui_ReleasesOptionsPage from picard.ui.options import OptionsPage from picard.ui.util import qlistwidget_items from picard.ui.widgets import ClickableSlider class TipSlider(ClickableSlider): _offset = QtCore.QPoint(0, -30) _step = 5 _pagestep = 25 _minimum = 0 _maximum = 100 def __init__(self, parent=None): super().__init__(parent=parent) self.style = QtWidgets.QApplication.style() self.opt = QtWidgets.QStyleOptionSlider() self.setMinimum(self._minimum) self.setMaximum(self._maximum) self.setOrientation(QtCore.Qt.Orientation.Horizontal) self.setSingleStep(self._step) self.setTickInterval(self._step) self.setPageStep(self._pagestep) self.tagger = QtCore.QCoreApplication.instance() def showEvent(self, event): super().showEvent(event) if not IS_WIN: self.valueChanged.connect(self.show_tip) def hideEvent(self, event): super().hideEvent(event) if not IS_WIN: try: self.valueChanged.disconnect(self.show_tip) except TypeError: pass def show_tip(self, value): self.round_value(value) self.initStyleOption(self.opt) cc_slider = self.style.ComplexControl.CC_Slider sc_slider_handle = self.style.SubControl.SC_ScrollBarSlider rectHandle = self.style.subControlRect(cc_slider, self.opt, sc_slider_handle) offset = self._offset * self.tagger.primaryScreen().devicePixelRatio() pos_local = rectHandle.topLeft() + offset pos_global = self.mapToGlobal(pos_local) QtWidgets.QToolTip.showText(pos_global, str(self.value()), self) def round_value(self, value): step = max(1, int(self._step)) if step > 1: super().setValue(int(value / step) * step) class ReleaseTypeScore: def __init__(self, group, layout, label, cell): row, column = cell # it uses 2 cells (r,c and r,c+1) self.group = group self.layout = layout self.label = QtWidgets.QLabel(self.group) self.label.setText(label) self.layout.addWidget(self.label, row, column, 1, 1) self.slider = TipSlider(parent=self.group) self.layout.addWidget(self.slider, row, column + 1, 1, 1) self.reset() def setValue(self, value): self.slider.setValue(int(value * 100)) def value(self): return float(self.slider.value()) / 100.0 def reset(self): self.setValue(DEFAULT_RELEASE_SCORE) class RowColIter: def __init__(self, max_cells, max_cols=6, step=2): assert max_cols % step == 0 self.step = step self.cols = max_cols self.rows = int((max_cells - 1) / (self.cols / step)) + 1 self.current = (-1, 0) def __iter__(self): return self def __next__(self): row, col = self.current row += 1 if row == self.rows: col += self.step row = 0 self.current = (row, col) return self.current class ReleasesOptionsPage(OptionsPage): NAME = 'releases' TITLE = N_("Preferred Releases") PARENT = 'metadata' SORT_ORDER = 10 ACTIVE = True HELP_URL = "/config/options_releases.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_ReleasesOptionsPage() self.ui.setupUi(self) self._release_type_sliders = {} def add_slider(name, griditer, context): label = pgettext_attributes(context, name) self._release_type_sliders[name] = ReleaseTypeScore( self.ui.type_group, self.ui.gridLayout, label, next(griditer)) griditer = RowColIter(len(RELEASE_PRIMARY_GROUPS) + len(RELEASE_SECONDARY_GROUPS) + 1) # +1 for Reset button for name in RELEASE_PRIMARY_GROUPS: add_slider(name, griditer, context='release_group_primary_type') for name in sorted(RELEASE_SECONDARY_GROUPS, key=lambda v: pgettext_attributes('release_group_secondary_type', v)): add_slider(name, griditer, context='release_group_secondary_type') reset_types_btn = QtWidgets.QPushButton(self.ui.type_group) reset_types_btn.setText(_("Reset all")) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(reset_types_btn.sizePolicy().hasHeightForWidth()) reset_types_btn.setSizePolicy(sizePolicy) r, c = next(griditer) self.ui.gridLayout.addWidget(reset_types_btn, r, c, 1, 2) reset_types_btn.clicked.connect(self.reset_preferred_types) self.setTabOrder(reset_types_btn, self.ui.country_list) self.setTabOrder(self.ui.country_list, self.ui.preferred_country_list) self.setTabOrder(self.ui.preferred_country_list, self.ui.add_countries) self.setTabOrder(self.ui.add_countries, self.ui.remove_countries) self.setTabOrder(self.ui.remove_countries, self.ui.format_list) self.setTabOrder(self.ui.format_list, self.ui.preferred_format_list) self.setTabOrder(self.ui.preferred_format_list, self.ui.add_formats) self.setTabOrder(self.ui.add_formats, self.ui.remove_formats) self.ui.add_countries.clicked.connect(self.add_preferred_countries) self.ui.remove_countries.clicked.connect(self.remove_preferred_countries) self.ui.add_formats.clicked.connect(self.add_preferred_formats) self.ui.remove_formats.clicked.connect(self.remove_preferred_formats) self.ui.country_list.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.ui.preferred_country_list.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.ui.format_list.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.ui.preferred_format_list.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.register_setting('release_type_scores', ['type_group']) self.register_setting('preferred_release_countries', ['country_group']) self.register_setting('preferred_release_formats', ['format_group']) def restore_defaults(self): # Clear lists self.ui.preferred_country_list.clear() self.ui.preferred_format_list.clear() self.ui.country_list.clear() self.ui.format_list.clear() super().restore_defaults() def load(self): config = get_config() scores = dict(config.setting['release_type_scores']) for (release_type, release_type_slider) in self._release_type_sliders.items(): release_type_slider.setValue(scores.get(release_type, DEFAULT_RELEASE_SCORE)) self._load_list_items('preferred_release_countries', RELEASE_COUNTRIES, self.ui.country_list, self.ui.preferred_country_list) self._load_list_items('preferred_release_formats', RELEASE_FORMATS, self.ui.format_list, self.ui.preferred_format_list) def save(self): config = get_config() scores = [] for (release_type, release_type_slider) in self._release_type_sliders.items(): scores.append((release_type, release_type_slider.value())) config.setting['release_type_scores'] = scores self._save_list_items('preferred_release_countries', self.ui.preferred_country_list) self._save_list_items('preferred_release_formats', self.ui.preferred_format_list) def reset_preferred_types(self): for release_type_slider in self._release_type_sliders.values(): release_type_slider.reset() def add_preferred_countries(self): self._move_selected_items(self.ui.country_list, self.ui.preferred_country_list) def remove_preferred_countries(self): self._move_selected_items(self.ui.preferred_country_list, self.ui.country_list) self.ui.country_list.sortItems() def add_preferred_formats(self): self._move_selected_items(self.ui.format_list, self.ui.preferred_format_list) def remove_preferred_formats(self): self._move_selected_items(self.ui.preferred_format_list, self.ui.format_list) self.ui.format_list.sortItems() def _move_selected_items(self, list1, list2): for item in list1.selectedItems(): clone = item.clone() list2.addItem(clone) list1.takeItem(list1.row(item)) def _load_list_items(self, setting, source, list1, list2): if setting == 'preferred_release_countries': translate_func = gettext_countries elif setting == 'preferred_release_formats': translate_func = partial(pgettext_attributes, 'medium_format') else: translate_func = _ def fcmp(x): return sort_key(x[1]) source_list = [(c[0], translate_func(c[1])) for c in source.items()] source_list.sort(key=fcmp) config = get_config() saved_data = config.setting[setting] for data, name in source_list: item = QtWidgets.QListWidgetItem(name) item.setData(QtCore.Qt.ItemDataRole.UserRole, data) try: saved_data.index(data) list2.addItem(item) except ValueError: list1.addItem(item) def _save_list_items(self, setting, list1): data = [ item.data(QtCore.Qt.ItemDataRole.UserRole) for item in qlistwidget_items(list1) ] config = get_config() config.setting[setting] = data register_options_page(ReleasesOptionsPage)
11,730
Python
.py
255
37.631373
116
0.669733
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,077
scripting.py
metabrainz_picard/picard/ui/options/scripting.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007, 2009 Lukáš Lalinský # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2009-2010, 2019-2023 Philipp Wolfer # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2013-2015, 2017-2024 Laurent Monin # Copyright (C) 2014 m42i # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2016-2017 Suhas # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2021 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os from PyQt6 import QtCore from picard import log from picard.config import get_config from picard.const.sys import IS_MACOS from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.script import ( ScriptParser, TaggingScriptSetting, iter_tagging_scripts_from_config, save_tagging_scripts_to_config, ) from picard.script.serializer import ( ScriptSerializerImportExportError, TaggingScriptInfo, ) from picard.ui import ( PicardDialog, SingletonDialog, ) from picard.ui.forms.ui_options_script import Ui_ScriptingOptionsPage from picard.ui.forms.ui_scripting_documentation_dialog import ( Ui_ScriptingDocumentationDialog, ) from picard.ui.moveable_list_view import MoveableListView from picard.ui.options import ( OptionsCheckError, OptionsPage, ) from picard.ui.util import qlistwidget_items from picard.ui.widgets.scriptdocumentation import ScriptingDocumentationWidget from picard.ui.widgets.scriptlistwidget import ScriptListWidgetItem class ScriptCheckError(OptionsCheckError): pass class ScriptFileError(OptionsCheckError): pass class ScriptingDocumentationDialog(PicardDialog, SingletonDialog): defaultsize = QtCore.QSize(570, 400) def __init__(self, parent=None): super().__init__(parent=parent) # on macOS having this not a dialog causes the window to be placed # behind the options dialog. if not IS_MACOS: self.setWindowFlags(QtCore.Qt.WindowType.Window) self.setAttribute(QtCore.Qt.WidgetAttribute.WA_DeleteOnClose) self.ui = Ui_ScriptingDocumentationDialog() self.ui.setupUi(self) doc_widget = ScriptingDocumentationWidget(parent=self) self.ui.documentation_layout.addWidget(doc_widget) self.ui.buttonBox.rejected.connect(self.close) def closeEvent(self, event): super().closeEvent(event) class ScriptingOptionsPage(OptionsPage): NAME = 'scripting' TITLE = N_("Scripting") PARENT = None SORT_ORDER = 75 ACTIVE = True HELP_URL = "/config/options_scripting.html" default_script_directory = os.path.normpath(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.StandardLocation.DocumentsLocation)) default_script_extension = "ptsp" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_ScriptingOptionsPage() self.ui.setupUi(self) self.ui.tagger_script.setEnabled(False) self.ui.scripting_options_splitter.setStretchFactor(1, 2) self.move_view = MoveableListView(self.ui.script_list, self.ui.move_up_button, self.ui.move_down_button) self.ui.scripting_documentation_button.clicked.connect(self.show_scripting_documentation) self.ui.scripting_documentation_button.setToolTip(_("Show scripting documentation in new window.")) self.ui.import_button.clicked.connect(self.import_script) self.ui.import_button.setToolTip(_("Import a script file as a new script.")) self.ui.export_button.clicked.connect(self.export_script) self.ui.export_button.setToolTip(_("Export the current script to a file.")) self.FILE_TYPE_ALL = _("All files") + " (*)" self.FILE_TYPE_SCRIPT = _("Picard script files") + " (*.pts *.txt)" self.FILE_TYPE_PACKAGE = _("Picard tagging script package") + " (*.ptsp *.yaml)" self.ui.script_list.signal_reset_selected_item.connect(self.reset_selected_item) self.register_setting('enable_tagger_scripts', ['enable_tagger_scripts']) self.register_setting('list_of_scripts', ['script_list']) def show_scripting_documentation(self): ScriptingDocumentationDialog.show_instance(parent=self) def output_error(self, title, fmt, params): """Log error and display error message dialog. Args: title (str): Title to display on the error dialog box fmt (str): Format for the error type being displayed params: values used for substitution in fmt """ log.error(fmt, params) error_message = _(fmt) % params self.display_error(ScriptFileError(_(title), error_message)) def output_file_error(self, error: ScriptSerializerImportExportError): """Log file error and display error message dialog. Args: fmt (str): Format for the error type being displayed error (ScriptSerializerImportExportError): The error as a ScriptSerializerImportExportError instance """ params = { 'filename': error.filename, 'error': _(error.error_msg) } self.output_error(_("File Error"), error.format, params) def import_script(self): """Import from an external text file to a new script. Import can be either a plain text script or a Picard script package. """ try: tagging_script = TaggingScriptInfo().import_script(self) except ScriptSerializerImportExportError as error: self.output_file_error(error) return if tagging_script: title = _("%s (imported)") % tagging_script['title'] script = TaggingScriptSetting(name=title, enabled=False, content=tagging_script['script']) list_item = ScriptListWidgetItem(script) self.ui.script_list.addItem(list_item) self.ui.script_list.setCurrentRow(self.ui.script_list.count() - 1) def export_script(self): """Export the current script to an external file. Export can be either as a plain text script or a naming script package. """ list_items = self.ui.script_list.selectedItems() if not list_items: return list_item = list_items[0] content = list_item.script.content if content: name = list_item.script.name.strip() title = name or _("Unnamed Script") tagging_script = TaggingScriptInfo(title=title, script=content) try: tagging_script.export_script(parent=self) except ScriptSerializerImportExportError as error: self.output_file_error(error) def enable_tagger_scripts_toggled(self, on): if on and self.ui.script_list.count() == 0: self.ui.script_list.add_script() def script_selected(self): list_items = self.ui.script_list.selectedItems() if list_items: list_item = list_items[0] self.ui.tagger_script.setEnabled(True) self.ui.tagger_script.setText(list_item.script.content) self.ui.tagger_script.setFocus(QtCore.Qt.FocusReason.OtherFocusReason) self.ui.export_button.setEnabled(True) else: self.ui.tagger_script.setEnabled(False) self.ui.tagger_script.setText("") self.ui.export_button.setEnabled(False) def live_update_and_check(self): list_items = self.ui.script_list.selectedItems() if not list_items: return list_item = list_items[0] list_item.script.content = self.ui.tagger_script.toPlainText() self.ui.script_error.setStyleSheet("") self.ui.script_error.setText("") try: self.check() except OptionsCheckError as e: list_item.has_error = True self.ui.script_error.setStyleSheet(self.STYLESHEET_ERROR) self.ui.script_error.setText(e.info) return list_item.has_error = False def reset_selected_item(self): widget = self.ui.script_list widget.setCurrentRow(widget.bad_row) def check(self): parser = ScriptParser() try: parser.eval(self.ui.tagger_script.toPlainText()) except Exception as e: raise ScriptCheckError(_("Script Error"), str(e)) def restore_defaults(self): # Remove existing scripts self.ui.script_list.clear() self.ui.tagger_script.setText("") super().restore_defaults() def load(self): config = get_config() self.ui.enable_tagger_scripts.setChecked(config.setting['enable_tagger_scripts']) self.ui.script_list.clear() for script in iter_tagging_scripts_from_config(config=config): list_item = ScriptListWidgetItem(script) self.ui.script_list.addItem(list_item) # Select the last selected script item last_selected_script_pos = config.persist['last_selected_script_pos'] last_selected_script = self.ui.script_list.item(last_selected_script_pos) if last_selected_script: self.ui.script_list.setCurrentItem(last_selected_script) last_selected_script.setSelected(True) def _all_scripts(self): for item in qlistwidget_items(self.ui.script_list): yield item.get_script() def save(self): config = get_config() config.setting['enable_tagger_scripts'] = self.ui.enable_tagger_scripts.isChecked() save_tagging_scripts_to_config(self._all_scripts()) config.persist['last_selected_script_pos'] = self.ui.script_list.currentRow() def display_error(self, error): # Ignore scripting errors, those are handled inline if not isinstance(error, ScriptCheckError): super().display_error(error) register_options_page(ScriptingOptionsPage)
10,730
Python
.py
239
37.313808
145
0.68671
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,078
metadata.py
metabrainz_picard/picard/ui/options/metadata.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011 Lukáš Lalinský # Copyright (C) 2008-2009, 2018-2024 Philipp Wolfer # Copyright (C) 2011 Johannes Weißl # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2013, 2018, 2020-2024 Laurent Monin # Copyright (C) 2014 Wieland Hoffmann # Copyright (C) 2017 Sambhav Kothari # Copyright (C) 2021 Vladislav Karbovskii # Copyright (C) 2021-2023 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from PyQt6 import ( QtCore, QtWidgets, ) from picard.config import ( Option, get_config, ) from picard.const.locales import ALIAS_LOCALES from picard.const.scripts import ( SCRIPTS, scripts_sorted_by_localized_name, ) from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, gettext_constants, ) from picard.ui import PicardDialog from picard.ui.forms.ui_exception_script_selector import ( Ui_ExceptionScriptSelector, ) from picard.ui.forms.ui_multi_locale_selector import Ui_MultiLocaleSelector from picard.ui.forms.ui_options_metadata import Ui_MetadataOptionsPage from picard.ui.moveable_list_view import MoveableListView from picard.ui.options import OptionsPage from picard.ui.util import qlistwidget_items def iter_sorted_locales(locales): generic_names = [] grouped_locales = {} for locale, name in locales.items(): name = _(name) generic_locale = locale.split('_', 1)[0] if generic_locale == locale: generic_names.append((name, locale)) else: grouped_locales.setdefault(generic_locale, []).append((name, locale)) for name, locale in sorted(generic_names): yield (locale, 0) for name, locale in sorted(grouped_locales.get(locale, [])): yield (locale, 1) class MetadataOptionsPage(OptionsPage): NAME = 'metadata' TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True HELP_URL = "/config/options_metadata.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) self.ui.select_locales.clicked.connect(self.open_locale_selector) self.ui.select_scripts.clicked.connect(self.open_script_selector) self.ui.translate_artist_names.stateChanged.connect(self.set_enabled_states) self.ui.translate_artist_names_script_exception.stateChanged.connect(self.set_enabled_states) self.register_setting('translate_artist_names', ['translate_artist_names']) self.register_setting('artist_locales', ['selected_locales']) self.register_setting('translate_artist_names_script_exception', ['translate_artist_names_script_exception']) self.register_setting('script_exceptions', ['selected_scripts']) self.register_setting('standardize_artists', ['standardize_artists']) self.register_setting('standardize_instruments', ['standardize_instruments']) self.register_setting('convert_punctuation', ['convert_punctuation']) self.register_setting('release_ars', ['release_ars']) self.register_setting('track_ars', ['track_ars']) self.register_setting('guess_tracknumber_and_title', ['guess_tracknumber_and_title']) self.register_setting('va_name', ['va_name']) self.register_setting('nat_name', ['nat_name']) def load(self): config = get_config() self.ui.translate_artist_names.setChecked(config.setting['translate_artist_names']) self.current_locales = config.setting['artist_locales'] self.make_locales_text() self.current_scripts = config.setting['script_exceptions'] self.make_scripts_text() self.ui.translate_artist_names_script_exception.setChecked(config.setting['translate_artist_names_script_exception']) self.ui.convert_punctuation.setChecked(config.setting['convert_punctuation']) self.ui.release_ars.setChecked(config.setting['release_ars']) self.ui.track_ars.setChecked(config.setting['track_ars']) self.ui.va_name.setText(config.setting['va_name']) self.ui.nat_name.setText(config.setting['nat_name']) self.ui.standardize_artists.setChecked(config.setting['standardize_artists']) self.ui.standardize_instruments.setChecked(config.setting['standardize_instruments']) self.ui.guess_tracknumber_and_title.setChecked(config.setting['guess_tracknumber_and_title']) self.set_enabled_states() def make_locales_text(self): def translated_locales(): for locale in self.current_locales: yield gettext_constants(ALIAS_LOCALES[locale]) self.ui.selected_locales.setText('; '.join(translated_locales())) def make_scripts_text(self): def translated_scripts(): for script in self.current_scripts: yield ScriptExceptionSelector.make_label(script[0], script[1]) self.ui.selected_scripts.setText('; '.join(translated_scripts())) def save(self): config = get_config() config.setting['translate_artist_names'] = self.ui.translate_artist_names.isChecked() config.setting['artist_locales'] = self.current_locales config.setting['translate_artist_names_script_exception'] = self.ui.translate_artist_names_script_exception.isChecked() config.setting['script_exceptions'] = self.current_scripts config.setting['convert_punctuation'] = self.ui.convert_punctuation.isChecked() config.setting['release_ars'] = self.ui.release_ars.isChecked() config.setting['track_ars'] = self.ui.track_ars.isChecked() config.setting['va_name'] = self.ui.va_name.text() nat_name = self.ui.nat_name.text() if nat_name != config.setting['nat_name']: config.setting['nat_name'] = nat_name if self.tagger.nats is not None: self.tagger.nats.update() config.setting['standardize_artists'] = self.ui.standardize_artists.isChecked() config.setting['standardize_instruments'] = self.ui.standardize_instruments.isChecked() config.setting['guess_tracknumber_and_title'] = self.ui.guess_tracknumber_and_title.isChecked() def set_va_name_default(self): self.ui.va_name.setText(Option.get_default('setting', 'va_name')) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(Option.get_default('setting', 'nat_name')) self.ui.nat_name.setCursorPosition(0) def set_enabled_states(self): translate_checked = self.ui.translate_artist_names.isChecked() translate_exception_checked = self.ui.translate_artist_names_script_exception.isChecked() self.ui.select_locales.setEnabled(translate_checked) self.ui.selected_locales.setEnabled(translate_checked) self.ui.translate_artist_names_script_exception.setEnabled(translate_checked) select_scripts_enabled = translate_checked and translate_exception_checked self.ui.selected_scripts.setEnabled(select_scripts_enabled) self.ui.select_scripts.setEnabled(select_scripts_enabled) def open_locale_selector(self): dialog = MultiLocaleSelector(self) dialog.show() def open_script_selector(self): dialog = ScriptExceptionSelector(self) dialog.show() class MultiLocaleSelector(PicardDialog): def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_MultiLocaleSelector() self.ui.setupUi(self) self.ui.button_box.accepted.connect(self.save_changes) self.ui.button_box.rejected.connect(self.reject) self.move_view = MoveableListView(self.ui.selected_locales, self.ui.move_up, self.ui.move_down) self.ui.add_locale.clicked.connect(self.add_locale) self.ui.remove_locale.clicked.connect(self.remove_locale) self.ui.selected_locales.currentRowChanged.connect(self.set_button_state) self.load() def load(self): for locale in self.parent().current_locales: # Note that items in the selected locales list are not indented because # the root locale may not be in the list, or may not immediately precede # the specific locale. label = gettext_constants(ALIAS_LOCALES[locale]) item = QtWidgets.QListWidgetItem(label) item.setData(QtCore.Qt.ItemDataRole.UserRole, locale) self.ui.selected_locales.addItem(item) self.ui.selected_locales.setCurrentRow(0) def indented_translated_locale(locale, level): return _("{indent}{locale}").format( indent=" " * level, locale=gettext_constants(ALIAS_LOCALES[locale]) ) self.ui.available_locales.clear() for (locale, level) in iter_sorted_locales(ALIAS_LOCALES): label = indented_translated_locale(locale, level) item = QtWidgets.QListWidgetItem(label) item.setData(QtCore.Qt.ItemDataRole.UserRole, locale) self.ui.available_locales.addItem(item) self.ui.available_locales.setCurrentRow(0) self.set_button_state() def add_locale(self): item = self.ui.available_locales.currentItem() if item is None: return locale = item.data(QtCore.Qt.ItemDataRole.UserRole) for selected_item in qlistwidget_items(self.ui.selected_locales): if selected_item.data(QtCore.Qt.ItemDataRole.UserRole) == locale: return new_item = item.clone() # Note that items in the selected locales list are not indented because # the root locale may not be in the list, or may not immediately precede # the specific locale. new_item.setText(gettext_constants(ALIAS_LOCALES[locale])) self.ui.selected_locales.addItem(new_item) self.ui.selected_locales.setCurrentRow(self.ui.selected_locales.count() - 1) def remove_locale(self): row = self.ui.selected_locales.currentRow() self.ui.selected_locales.takeItem(row) def set_button_state(self): enabled = self.ui.selected_locales.count() > 1 self.ui.remove_locale.setEnabled(enabled) def save_changes(self): locales = [ item.data(QtCore.Qt.ItemDataRole.UserRole) for item in qlistwidget_items(self.ui.selected_locales) ] self.parent().current_locales = locales self.parent().make_locales_text() self.accept() class ScriptExceptionSelector(PicardDialog): def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_ExceptionScriptSelector() self.ui.setupUi(self) self.ui.button_box.accepted.connect(self.save_changes) self.ui.button_box.rejected.connect(self.reject) self.move_view = MoveableListView(self.ui.selected_scripts, self.ui.move_up, self.ui.move_down) self.ui.add_script.clicked.connect(self.add_script) self.ui.remove_script.clicked.connect(self.remove_script) self.ui.selected_scripts.currentRowChanged.connect(self.selected_script_changed) self.ui.weighting_selector.valueChanged.connect(self.weighting_changed) weighting_tooltip_text = _( "Each selected script includes a matching threshold value used to determine if that script should be used. When an artist name is " "evaluated to determine if it matches one of your selected scripts, it is first parsed to determine which scripts are represented " "in the name, and what weighted percentage of the name belongs to each script. Then each of your selected scripts are checked, and " "if the name contains characters belonging to the script and the percentage of script characters in the name meets or exceeds the " "match threshold specified for the script, then the artist name will not be translated." ) self.ui.weighting_selector.setToolTip(weighting_tooltip_text) self.ui.threshold_label.setToolTip(weighting_tooltip_text) self.load() @staticmethod def make_label(script_id, script_weighting): return "{script} ({weighting}%)".format( script=gettext_constants(SCRIPTS[script_id]), weighting=script_weighting, ) def load(self): self.ui.selected_scripts.clear() for script in self.parent().current_scripts: label = self.make_label(script_id=script[0], script_weighting=script[1]) item = QtWidgets.QListWidgetItem(label) item.setData(QtCore.Qt.ItemDataRole.UserRole, script) self.ui.selected_scripts.addItem(item) if self.ui.selected_scripts.count() > 0: self.ui.selected_scripts.setCurrentRow(0) self.set_weighting_selector() self.ui.available_scripts.clear() for script_id, label in scripts_sorted_by_localized_name(): item = QtWidgets.QListWidgetItem(label) item.setData(QtCore.Qt.ItemDataRole.UserRole, script_id) self.ui.available_scripts.addItem(item) self.ui.available_scripts.setCurrentRow(0) self.set_button_state() def add_script(self): item = self.ui.available_scripts.currentItem() if item is None: return script_id = item.data(QtCore.Qt.ItemDataRole.UserRole) for selected_item in qlistwidget_items(self.ui.selected_scripts): if selected_item.data(QtCore.Qt.ItemDataRole.UserRole)[0] == script_id: return new_item = QtWidgets.QListWidgetItem(self.make_label(script_id, 0)) new_item.setData(QtCore.Qt.ItemDataRole.UserRole, (script_id, 0)) self.ui.selected_scripts.addItem(new_item) self.ui.selected_scripts.setCurrentRow(self.ui.selected_scripts.count() - 1) self.set_weighting_selector() def remove_script(self): row = self.ui.selected_scripts.currentRow() self.ui.selected_scripts.takeItem(row) def selected_script_changed(self): self.set_weighting_selector() self.set_button_state() def weighting_changed(self): self.set_item_from_weighting() def set_button_state(self): enabled = self.ui.selected_scripts.count() > 0 self.ui.remove_script.setEnabled(enabled) self.ui.weighting_selector.setEnabled(enabled) def set_weighting_selector(self): row = self.ui.selected_scripts.currentRow() selected_item = self.ui.selected_scripts.item(row) if selected_item: weighting = selected_item.data(QtCore.Qt.ItemDataRole.UserRole)[1] else: weighting = 0 self.ui.weighting_selector.setValue(weighting) def set_item_from_weighting(self): row = self.ui.selected_scripts.currentRow() selected_item = self.ui.selected_scripts.item(row) if selected_item: item_data = selected_item.data(QtCore.Qt.ItemDataRole.UserRole) weighting = self.ui.weighting_selector.value() new_data = (item_data[0], weighting) selected_item.setData(QtCore.Qt.ItemDataRole.UserRole, new_data) label = self.make_label(script_id=item_data[0], script_weighting=weighting) selected_item.setText(label) def save_changes(self): scripts = [ item.data(QtCore.Qt.ItemDataRole.UserRole) for item in qlistwidget_items(self.ui.selected_scripts) ] self.parent().current_scripts = scripts self.parent().make_scripts_text() self.accept() register_options_page(MetadataOptionsPage)
16,654
Python
.py
325
43.089231
144
0.69174
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,079
cover_processing.py
metabrainz_picard/picard/ui/options/cover_processing.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2024 Giorgio Fontanive # Copyright (C) 2024 Bob Swift # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6.QtCore import Qt from PyQt6.QtWidgets import QSpinBox from picard.config import get_config from picard.const.cover_processing import ( COVER_CONVERTING_FORMATS, COVER_RESIZE_MODES, ResizeModes, ) from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, _, ) from picard.ui.forms.ui_options_cover_processing import ( Ui_CoverProcessingOptionsPage, ) from picard.ui.options import OptionsPage class CoverProcessingOptionsPage(OptionsPage): NAME = 'cover_processing' TITLE = N_("Processing") PARENT = 'cover' SORT_ORDER = 0 def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_CoverProcessingOptionsPage() self.ui.setupUi(self) self.register_setting('filter_cover_by_size') self.register_setting('cover_minimum_width') self.register_setting('cover_minimum_height') self.register_setting('cover_tags_enlarge') self.register_setting('cover_tags_resize') self.register_setting('cover_tags_resize_target_width') self.register_setting('cover_tags_resize_target_height') self.register_setting('cover_tags_resize_mode') self.register_setting('cover_tags_convert_images') self.register_setting('cover_tags_convert_to_format') self.register_setting('cover_file_enlarge') self.register_setting('cover_file_resize') self.register_setting('cover_file_resize_target_width') self.register_setting('cover_file_resize_target_height') self.register_setting('cover_file_resize_mode') self.register_setting('cover_file_convert_images') self.register_setting('cover_file_convert_to_format') for resize_mode in COVER_RESIZE_MODES: self.ui.tags_resize_mode.addItem(resize_mode.title, resize_mode.mode.value) self.ui.file_resize_mode.addItem(resize_mode.title, resize_mode.mode.value) self.ui.tags_resize_mode.setItemData(resize_mode.mode, _(resize_mode.tooltip), Qt.ItemDataRole.ToolTipRole) self.ui.file_resize_mode.setItemData(resize_mode.mode, _(resize_mode.tooltip), Qt.ItemDataRole.ToolTipRole) self.ui.convert_tags_format.addItems(COVER_CONVERTING_FORMATS) self.ui.convert_file_format.addItems(COVER_CONVERTING_FORMATS) tags_resize_mode_changed = partial( self._resize_mode_changed, self.ui.tags_resize_width_widget, self.ui.tags_resize_height_widget ) file_resize_mode_changed = partial( self._resize_mode_changed, self.ui.file_resize_width_widget, self.ui.file_resize_height_widget ) self.ui.tags_resize_mode.currentIndexChanged.connect(tags_resize_mode_changed) self.ui.file_resize_mode.currentIndexChanged.connect(file_resize_mode_changed) def _resize_mode_changed(self, width_widget, height_widget, index): width_visible = True height_visible = True if index == ResizeModes.SCALE_TO_WIDTH: height_visible = False elif index == ResizeModes.SCALE_TO_HEIGHT: width_visible = False width_widget.setEnabled(width_visible) width_spinbox = width_widget.findChildren(QSpinBox)[0] width_spinbox.lineEdit().setVisible(width_visible) height_widget.setEnabled(height_visible) height_spinbox = height_widget.findChildren(QSpinBox)[0] height_spinbox.lineEdit().setVisible(height_visible) def load(self): config = get_config() self.ui.filtering.setChecked(config.setting['filter_cover_by_size']) self.ui.filtering_width_value.setValue(config.setting['cover_minimum_width']) self.ui.filtering_height_value.setValue(config.setting['cover_minimum_height']) self.ui.tags_scale_up.setChecked(config.setting['cover_tags_enlarge']) self.ui.tags_scale_down.setChecked(config.setting['cover_tags_resize']) self.ui.tags_resize_width_value.setValue(config.setting['cover_tags_resize_target_width']) self.ui.tags_resize_height_value.setValue(config.setting['cover_tags_resize_target_height']) current_index = self.ui.tags_resize_mode.findData(config.setting['cover_tags_resize_mode']) if current_index == -1: current_index = ResizeModes.MAINTAIN_ASPECT_RATIO self.ui.tags_resize_mode.setCurrentIndex(current_index) self.ui.convert_tags.setChecked(config.setting['cover_tags_convert_images']) self.ui.convert_tags_format.setCurrentText(config.setting['cover_tags_convert_to_format']) self.ui.file_scale_up.setChecked(config.setting['cover_file_enlarge']) self.ui.file_scale_down.setChecked(config.setting['cover_file_resize']) self.ui.file_resize_width_value.setValue(config.setting['cover_file_resize_target_width']) self.ui.file_resize_height_value.setValue(config.setting['cover_file_resize_target_height']) current_index = self.ui.file_resize_mode.findData(config.setting['cover_file_resize_mode']) if current_index == -1: current_index = ResizeModes.MAINTAIN_ASPECT_RATIO self.ui.file_resize_mode.setCurrentIndex(current_index) self.ui.convert_file.setChecked(config.setting['cover_file_convert_images']) self.ui.convert_file_format.setCurrentText(config.setting['cover_file_convert_to_format']) def save(self): config = get_config() config.setting['filter_cover_by_size'] = self.ui.filtering.isChecked() config.setting['cover_minimum_width'] = self.ui.filtering_width_value.value() config.setting['cover_minimum_height'] = self.ui.filtering_height_value.value() config.setting['cover_tags_enlarge'] = self.ui.tags_scale_up.isChecked() config.setting['cover_tags_resize'] = self.ui.tags_scale_down.isChecked() config.setting['cover_tags_resize_target_width'] = self.ui.tags_resize_width_value.value() config.setting['cover_tags_resize_target_height'] = self.ui.tags_resize_height_value.value() config.setting['cover_tags_resize_mode'] = self.ui.tags_resize_mode.currentData() config.setting['cover_tags_convert_images'] = self.ui.convert_tags.isChecked() config.setting['cover_tags_convert_to_format'] = self.ui.convert_tags_format.currentText() config.setting['cover_file_enlarge'] = self.ui.file_scale_up.isChecked() config.setting['cover_file_resize'] = self.ui.file_scale_down.isChecked() config.setting['cover_file_resize_target_width'] = self.ui.file_resize_width_value.value() config.setting['cover_file_resize_target_height'] = self.ui.file_resize_height_value.value() config.setting['cover_file_resize_mode'] = self.ui.file_resize_mode.currentData() config.setting['cover_file_convert_images'] = self.ui.convert_file.isChecked() config.setting['cover_file_convert_to_format'] = self.ui.convert_file_format.currentText() register_options_page(CoverProcessingOptionsPage)
7,972
Python
.py
141
49.35461
119
0.715803
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,080
__init__.py
metabrainz_picard/picard/ui/options/__init__.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2007 Lukáš Lalinský # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2009, 2019-2022 Philipp Wolfer # Copyright (C) 2013, 2015, 2018-2024 Laurent Monin # Copyright (C) 2016-2017 Sambhav Kothari # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import re from PyQt6 import ( QtCore, QtWidgets, ) from picard import log from picard.config import ( Option, get_config, ) from picard.i18n import gettext as _ from picard.profile import profile_groups_add_setting class OptionsCheckError(Exception): def __init__(self, title, info): self.title = title self.info = info class OptionsPage(QtWidgets.QWidget): PARENT = None SORT_ORDER = 1000 ACTIVE = True HELP_URL = None STYLESHEET_ERROR = "QWidget { background-color: #f55; color: white; font-weight:bold; padding: 2px; }" STYLESHEET = "QLabel { qproperty-wordWrap: true; }" initialized = False loaded = False def __init__(self, parent=None): super().__init__(parent=parent) self.tagger = QtCore.QCoreApplication.instance() self.setStyleSheet(self.STYLESHEET) # Keep track whether the options page has been destroyed to avoid # trying to update deleted UI widgets after plugin list refresh. self.deleted = False # The on destroyed cannot be created as a method on this class or it will never get called. # See https://stackoverflow.com/questions/16842955/widgets-destroyed-signal-is-not-fired-pyqt def on_destroyed(obj=None): self.deleted = True self.destroyed.connect(on_destroyed) self._registered_settings = [] def set_dialog(self, dialog): self.dialog = dialog def check(self): pass def load(self): pass def save(self): pass def restore_defaults(self): config = get_config() old_options = {} for option in self._registered_settings: default_value = option.default name = option.name current_value = config.setting[name] if current_value != default_value: log.debug("Option %s %s: %r -> %r" % (self.NAME, name, current_value, default_value)) old_options[name] = current_value config.setting[name] = default_value self.load() # Restore the config values incase the user doesn't save after restoring defaults for key in old_options: config.setting[key] = old_options[key] def display_error(self, error): dialog = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Icon.Warning, error.title, error.info, QtWidgets.QMessageBox.StandardButton.Ok, self) dialog.exec() def init_regex_checker(self, regex_edit, regex_error): """ regex_edit : a widget supporting text() and textChanged() methods, ie QLineEdit regex_error : a widget supporting setStyleSheet() and setText() methods, ie. QLabel """ def check(): try: re.compile(regex_edit.text()) except re.error as e: raise OptionsCheckError(_("Regex Error"), str(e)) def live_checker(text): regex_error.setStyleSheet("") regex_error.setText("") try: check() except OptionsCheckError as e: regex_error.setStyleSheet(self.STYLESHEET_ERROR) regex_error.setText(e.info) regex_edit.textChanged.connect(live_checker) def register_setting(self, name, highlights=None): """Register a setting edited in the page, used to restore defaults and to highlight when profiles are used""" option = Option.get('setting', name) if option is None: raise Exception(f"Cannot register setting for non-existing option {name}") self._registered_settings.append(option) if highlights is not None: profile_groups_add_setting(self.NAME, name, tuple(highlights), title=self.TITLE)
4,833
Python
.py
117
34.025641
146
0.666382
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,081
tags_compatibility_id3.py
metabrainz_picard/picard/ui/options/tags_compatibility_id3.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006 Lukáš Lalinský # Copyright (C) 2019-2021, 2023 Philipp Wolfer # Copyright (C) 2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_tags_compatibility_id3 import ( Ui_TagsCompatibilityOptionsPage, ) from picard.ui.options import OptionsPage class TagsCompatibilityID3OptionsPage(OptionsPage): NAME = 'tags_compatibility_id3' TITLE = N_("ID3") PARENT = 'tags' SORT_ORDER = 30 ACTIVE = True HELP_URL = "/config/options_tags_compatibility_id3.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_TagsCompatibilityOptionsPage() self.ui.setupUi(self) self.ui.write_id3v23.clicked.connect(self.update_encodings) self.ui.write_id3v24.clicked.connect(partial(self.update_encodings, force_utf8=True)) self.register_setting('write_id3v23', ['write_id3v23', 'write_id3v24']) self.register_setting('id3v2_encoding', ['enc_utf8', 'enc_utf16', 'enc_iso88591']) self.register_setting('id3v23_join_with', ['id3v23_join_with']) self.register_setting('itunes_compatible_grouping', ['itunes_compatible_grouping']) self.register_setting('write_id3v1', ['write_id3v1']) def load(self): config = get_config() self.ui.write_id3v1.setChecked(config.setting['write_id3v1']) if config.setting['write_id3v23']: self.ui.write_id3v23.setChecked(True) else: self.ui.write_id3v24.setChecked(True) if config.setting['id3v2_encoding'] == 'iso-8859-1': self.ui.enc_iso88591.setChecked(True) elif config.setting['id3v2_encoding'] == 'utf-16': self.ui.enc_utf16.setChecked(True) else: self.ui.enc_utf8.setChecked(True) self.ui.id3v23_join_with.setEditText(config.setting['id3v23_join_with']) self.ui.itunes_compatible_grouping.setChecked(config.setting['itunes_compatible_grouping']) self.update_encodings() def save(self): config = get_config() config.setting['write_id3v1'] = self.ui.write_id3v1.isChecked() config.setting['write_id3v23'] = self.ui.write_id3v23.isChecked() config.setting['id3v23_join_with'] = self.ui.id3v23_join_with.currentText() if self.ui.enc_iso88591.isChecked(): config.setting['id3v2_encoding'] = 'iso-8859-1' elif self.ui.enc_utf16.isChecked(): config.setting['id3v2_encoding'] = 'utf-16' else: config.setting['id3v2_encoding'] = 'utf-8' config.setting['itunes_compatible_grouping'] = self.ui.itunes_compatible_grouping.isChecked() def update_encodings(self, force_utf8=False): if self.ui.write_id3v23.isChecked(): if self.ui.enc_utf8.isChecked(): self.ui.enc_utf16.setChecked(True) self.ui.enc_utf8.setEnabled(False) self.ui.label_id3v23_join_with.setEnabled(True) self.ui.id3v23_join_with.setEnabled(True) else: self.ui.enc_utf8.setEnabled(True) if force_utf8: self.ui.enc_utf8.setChecked(True) self.ui.label_id3v23_join_with.setEnabled(False) self.ui.id3v23_join_with.setEnabled(False) register_options_page(TagsCompatibilityID3OptionsPage)
4,271
Python
.py
89
41.089888
101
0.692677
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,082
profiles.py
metabrainz_picard/picard/ui/options/profiles.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2021 Bob Swift # Copyright (C) 2022-2023 Philipp Wolfer # Copyright (C) 2022-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from copy import deepcopy import uuid from PyQt6 import ( QtCore, QtWidgets, ) from picard import log from picard.config import ( Option, OptionError, SettingConfigSection, get_config, ) from picard.const.defaults import DEFAULT_COPY_TEXT from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, gettext_constants, ) from picard.profile import profile_groups_values from picard.script import ( get_file_naming_script_presets, iter_tagging_scripts_from_tuples, ) from picard.util import get_base_title from picard.ui.forms.ui_options_profiles import Ui_ProfileEditorDialog from picard.ui.moveable_list_view import MoveableListView from picard.ui.options import OptionsPage from picard.ui.util import qlistwidget_items from picard.ui.widgets.profilelistwidget import ProfileListWidgetItem class ProfilesOptionsPage(OptionsPage): NAME = 'profiles' TITLE = N_("Option Profiles") PARENT = None SORT_ORDER = 10 ACTIVE = True HELP_URL = "/config/options_profiles.html" TREEWIDGETITEM_COLUMN = 0 signal_refresh = QtCore.pyqtSignal() def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_ProfileEditorDialog() self.ui.setupUi(self) self.make_buttons() self.ui.profile_editor_splitter.setStretchFactor(1, 1) self.move_view = MoveableListView(self.ui.profile_list, self.ui.move_up_button, self.ui.move_down_button) self.ui.profile_list.itemChanged.connect(self.profile_item_changed) self.ui.profile_list.currentItemChanged.connect(self.current_item_changed) self.ui.profile_list.itemChanged.connect(self.reload_all_page_settings) self.ui.settings_tree.itemChanged.connect(self.set_profile_settings_changed) self.ui.settings_tree.itemExpanded.connect(self.update_current_expanded_items_list) self.ui.settings_tree.itemCollapsed.connect(self.update_current_expanded_items_list) self.current_profile_id = None self.expanded_sections = set() self.building_tree = False self.loading = False self.settings_changed = False self.ui.settings_tree.installEventFilter(self) def eventFilter(self, object, event): """Process selected events. """ event_type = event.type() if event_type == QtCore.QEvent.Type.FocusOut and object == self.ui.settings_tree: if self.settings_changed: self.settings_changed = False self.update_values_in_profile_options() self.reload_all_page_settings() return False def make_buttons(self): """Make buttons and add them to the button bars. """ self.new_profile_button = QtWidgets.QPushButton(_("New")) self.new_profile_button.setToolTip(_("Create a new profile")) self.new_profile_button.clicked.connect(self.new_profile) self.ui.profile_list_buttonbox.addButton(self.new_profile_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.copy_profile_button = QtWidgets.QPushButton(_("Copy")) self.copy_profile_button.setToolTip(_("Copy to a new profile")) self.copy_profile_button.clicked.connect(self.copy_profile) self.ui.profile_list_buttonbox.addButton(self.copy_profile_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.delete_profile_button = QtWidgets.QPushButton(_("Delete")) self.delete_profile_button.setToolTip(_("Delete the profile")) self.delete_profile_button.clicked.connect(self.delete_profile) self.ui.profile_list_buttonbox.addButton(self.delete_profile_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) def restore_defaults(self): """Remove all profiles and profile settings. """ self.ui.profile_list.clear() self.profile_settings = {} self.profile_selected() self.update_config_overrides() self.reload_all_page_settings() def load(self): """Load initial configuration. """ self.loading = True config = get_config() # Use deepcopy() to avoid changes made locally from being cascaded into `config.profiles` # before the user clicks "Make It So!" self.profile_settings = deepcopy(config.profiles[SettingConfigSection.SETTINGS_KEY]) self.ui.profile_list.clear() for profile in config.profiles[SettingConfigSection.PROFILES_KEY]: list_item = ProfileListWidgetItem(profile['title'], profile['enabled'], profile['id']) self.ui.profile_list.addItem(list_item) # Select the last selected profile item self.expanded_sections = set(config.persist['profile_settings_tree_expanded_list']) last_selected_profile_pos = config.persist['last_selected_profile_pos'] self.make_setting_tree(settings=self._last_settings(last_selected_profile_pos)) self.update_config_overrides() self.loading = False def _last_settings(self, last_selected_profile_pos): """Select last profile item and returns associated settings or None""" last = self.ui.profile_list.item(last_selected_profile_pos) if not last: return None self.ui.profile_list.setCurrentItem(last) last.setSelected(True) self.current_profile_id = last.profile_id return self.get_settings_for_profile(last.profile_id) def update_config_overrides(self): """Update the profile overrides used in `config.settings` when retrieving or saving a setting. """ config = get_config() config.setting.set_profiles_override(self._clean_and_get_all_profiles()) config.setting.set_settings_override(self.profile_settings) def get_settings_for_profile(self, profile_id): """Get the settings for the specified profile ID. Automatically adds an empty settings dictionary if there is no settings dictionary found for the ID. Args: profile_id (str): ID of the profile Returns: dict: Profile settings """ # Add empty settings dictionary if no dictionary found for the profile. # This happens when a new profile is created. if profile_id not in self.profile_settings: self.profile_settings[profile_id] = {} return self.profile_settings[profile_id] def _all_profiles(self): """Get all profiles from the profiles list in order from top to bottom. Yields: dict: Profile information in a format for saving to the user settings """ for item in qlistwidget_items(self.ui.profile_list): yield item.get_dict() def make_setting_tree(self, settings=None): """Update the profile settings tree based on the settings provided. If no settings are provided, displays an empty tree. Args: settings (dict, optional): Dictionary of settings for the profile. Defaults to None. """ self.set_button_states() self.ui.settings_tree.clear() self.ui.settings_tree.setHeaderItem(QtWidgets.QTreeWidgetItem()) self.ui.settings_tree.setHeaderLabels([_("Settings to include in profile")]) if settings is None: return self.building_tree = True for group in profile_groups_values(): title = _(group['title']) group_settings = group['settings'] widget_item = QtWidgets.QTreeWidgetItem([title]) widget_item.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsAutoTristate) widget_item.setCheckState(self.TREEWIDGETITEM_COLUMN, QtCore.Qt.CheckState.Unchecked) for setting in group_settings: try: opt_title = Option.get_title('setting', setting.name) except OptionError as e: log.debug(e) continue if opt_title is None: opt_title = setting.name log.debug("Missing title for option: %s", setting.name) widget_item.addChild(self._make_child_item(settings, setting.name, opt_title)) self.ui.settings_tree.addTopLevelItem(widget_item) if title in self.expanded_sections: widget_item.setExpanded(True) self.building_tree = False def _make_child_item(self, settings, name, title): in_settings = settings and name in settings item = QtWidgets.QTreeWidgetItem([_(title)]) item.setData(0, QtCore.Qt.ItemDataRole.UserRole, name) item.setFlags(QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsUserCheckable) state = QtCore.Qt.CheckState.Checked if in_settings else QtCore.Qt.CheckState.Unchecked item.setCheckState(self.TREEWIDGETITEM_COLUMN, state) tooltip = self.make_setting_value_text(name, settings[name] if in_settings else None) item.setToolTip(self.TREEWIDGETITEM_COLUMN, tooltip) return item def _get_naming_script(self, config, value): if value in config.setting['file_renaming_scripts']: return config.setting['file_renaming_scripts'][value]['title'] presets = {x['id']: x['title'] for x in get_file_naming_script_presets()} if value in presets: return presets[value] return _("Unknown script") def _get_scripts_list(self, scripts): enabled_scripts = ['<li>%s</li>' % s.name for s in iter_tagging_scripts_from_tuples(scripts) if s.enabled] if not enabled_scripts: return _("No enabled scripts") return _("Enabled scripts:") + '<ul>' + "".join(enabled_scripts) + '</ul>' def _get_ca_providers_list(self, providers): enabled_providers = ['<li>%s</li>' % name for (name, enabled) in providers if enabled] if not enabled_providers: return _("No enabled providers") return _("Enabled providers:") + '<ul>' + "".join(enabled_providers) + '</ul>' def make_setting_value_text(self, key, value): config = get_config() if value is None: return _("None") if key == 'selected_file_naming_script_id': return self._get_naming_script(config, value) if key == 'list_of_scripts': return self._get_scripts_list(config.setting[key]) if key == 'ca_providers': return self._get_ca_providers_list(config.setting[key]) if isinstance(value, str): return '"%s"' % value if type(value) in {bool, int, float}: return str(value) if type(value) in {set, tuple, list, dict}: return _("List of %i items") % len(value) return _("Unknown value format") def update_current_expanded_items_list(self): """Update the list of expanded sections in the settings tree for persistent settings. """ if self.building_tree: return self.expanded_sections = set() for i in range(self.ui.settings_tree.topLevelItemCount()): tl_item = self.ui.settings_tree.topLevelItem(i) if tl_item.isExpanded(): self.expanded_sections.add(tl_item.text(self.TREEWIDGETITEM_COLUMN)) def get_current_selected_item(self): """Gets the profile item currently selected in the profiles list. Returns: ProfileListWidgetItem: Currently selected item """ items = self.ui.profile_list.selectedItems() if items: return items[0] return None def profile_selected(self, update_settings=True): """Update working profile information for the selected item in the profiles list. Args: update_settings (bool, optional): Update settings tree. Defaults to True. """ item = self.get_current_selected_item() if item: profile_id = item.profile_id self.current_profile_id = profile_id if update_settings: settings = self.get_settings_for_profile(profile_id) self.make_setting_tree(settings=settings) else: self.current_profile_id = None self.make_setting_tree(settings=None) def reload_all_page_settings(self): """Trigger a reload of the settings and highlights for all pages containing options that can be managed in a profile. """ self.signal_refresh.emit() def update_values_in_profile_options(self): """Update the current profile's settings dictionary from the settings tree. Note that this update is delayed to avoid losing a profile's option setting value when a selected option (with an associated value) is de-selected and then re-selected. """ if not self.current_profile_id: return checked_items = set(self.get_checked_items_from_tree()) settings = set(self.profile_settings[self.current_profile_id].keys()) # Add new items to settings for item in checked_items.difference(settings): self.profile_settings[self.current_profile_id][item] = None # Remove unchecked items from settings for item in settings.difference(checked_items): del self.profile_settings[self.current_profile_id][item] def profile_item_changed(self, item): """Check title is not blank and remove leading and trailing spaces. Args: item (ProfileListWidgetItem): Item that changed """ if not self.loading: text = item.text().strip() if not text: QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Warning, _("Invalid Title"), _("The profile title cannot be blank."), QtWidgets.QMessageBox.StandardButton.Ok, self ).exec() item.setText(self.ui.profile_list.unique_profile_name()) elif text != item.text(): # Remove leading and trailing spaces from new title. item.setText(text) self.update_config_overrides() self.reload_all_page_settings() def current_item_changed(self, new_item, old_item): """Update the display when a new item is selected in the profile list. Args: new_item (ProfileListWidgetItem): Newly selected item old_item (ProfileListWidgetItem): Previously selected item """ if self.loading: return # Set self.loading to avoid looping through the `.currentItemChanged` event. self.loading = True self.ui.profile_list.setCurrentItem(new_item) self.loading = False self.profile_selected() def get_checked_items_from_tree(self): """Get the keys for the settings that are checked in the profile settings tree. Yields: str: Settings key """ for i in range(self.ui.settings_tree.topLevelItemCount()): tl_item = self.ui.settings_tree.topLevelItem(i) for j in range(tl_item.childCount()): item = tl_item.child(j) if item.checkState(self.TREEWIDGETITEM_COLUMN) == QtCore.Qt.CheckState.Checked: yield item.data(self.TREEWIDGETITEM_COLUMN, QtCore.Qt.ItemDataRole.UserRole) def set_profile_settings_changed(self): """Set flag to trigger option page updates later (when focus is lost from the settings tree) to avoid updating after each change to the settings selected for a profile. """ if self.current_profile_id: self.settings_changed = True def copy_profile(self): """Make a copy of the currently selected profile. """ item = self.get_current_selected_item() profile_id = str(uuid.uuid4()) settings = deepcopy(self.profile_settings[self.current_profile_id]) self.profile_settings[profile_id] = settings base_title = "%s %s" % (get_base_title(item.name), gettext_constants(DEFAULT_COPY_TEXT)) name = self.ui.profile_list.unique_profile_name(base_title) self.ui.profile_list.add_profile(name=name, profile_id=profile_id) self.update_config_overrides() self.reload_all_page_settings() def new_profile(self): """Add a new profile with no settings selected. """ self.ui.profile_list.add_profile() self.update_config_overrides() self.reload_all_page_settings() def delete_profile(self): """Delete the current profile. """ self.ui.profile_list.remove_selected_profile() self.profile_selected() self.update_config_overrides() self.reload_all_page_settings() def _clean_and_get_all_profiles(self): """Returns the list of profiles, adds any missing profile settings, and removes any "orphan" profile settings (i.e. settings dictionaries not associated with an existing profile). Returns: list: List of profiles suitable for storing in `config.profiles`. """ all_profiles = list(self._all_profiles()) all_profile_ids = set(x['id'] for x in all_profiles) keys = set(self.profile_settings.keys()) # Add any missing profile settings for profile_id in all_profile_ids.difference(keys): self.profile_settings[profile_id] = {} # Remove any "orphan" profile settings for profile_id in keys.difference(all_profile_ids): del self.profile_settings[profile_id] return all_profiles def save(self): """Save any changes to the current profile's settings, and save all updated profile information to the user settings. """ config = get_config() config.profiles[SettingConfigSection.PROFILES_KEY] = self._clean_and_get_all_profiles() config.profiles[SettingConfigSection.SETTINGS_KEY] = self.profile_settings config.persist['last_selected_profile_pos'] = self.ui.profile_list.currentRow() config.persist['profile_settings_tree_expanded_list'] = sorted(self.expanded_sections) def set_button_states(self): """Set the enabled / disabled states of the buttons. """ state = self.current_profile_id is not None self.copy_profile_button.setEnabled(state) self.delete_profile_button.setEnabled(state) register_options_page(ProfilesOptionsPage)
19,701
Python
.py
407
39.228501
147
0.661086
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,083
interface_top_tags.py
metabrainz_picard/picard/ui/options/interface_top_tags.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019-2021 Philipp Wolfer # Copyright (C) 2020-2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_interface_top_tags import ( Ui_InterfaceTopTagsOptionsPage, ) from picard.ui.options import OptionsPage class InterfaceTopTagsOptionsPage(OptionsPage): NAME = 'interface_top_tags' TITLE = N_("Top Tags") PARENT = 'interface' SORT_ORDER = 30 ACTIVE = True HELP_URL = "/config/options_interface_top_tags.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_InterfaceTopTagsOptionsPage() self.ui.setupUi(self) self.register_setting('metadatabox_top_tags', ['top_tags_groupBox']) def load(self): config = get_config() tags = config.setting['metadatabox_top_tags'] self.ui.top_tags_list.update(tags) def save(self): config = get_config() tags = list(self.ui.top_tags_list.tags) if tags != config.setting['metadatabox_top_tags']: config.setting['metadatabox_top_tags'] = tags self.tagger.window.metadata_box.update() def restore_defaults(self): self.ui.top_tags_list.clear() super().restore_defaults() register_options_page(InterfaceTopTagsOptionsPage)
2,198
Python
.py
53
37.132075
80
0.724672
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,084
renaming_compat.py
metabrainz_picard/picard/ui/options/renaming_compat.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011 Lukáš Lalinský # Copyright (C) 2008-2009 Nikolai Prokoschenko # Copyright (C) 2009-2010, 2014-2015, 2018-2024 Philipp Wolfer # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2011-2013 Wieland Hoffmann # Copyright (C) 2013 Calvin Walton # Copyright (C) 2013 Ionuț Ciocîrlan # Copyright (C) 2013-2014 Sophist-UK # Copyright (C) 2013-2015, 2018-2021, 2023-2024 Laurent Monin # Copyright (C) 2015 Alex Berman # Copyright (C) 2015 Ohm Patel # Copyright (C) 2016 Suhas # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Gabriel Ferreira # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os import re from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard.config import get_config from picard.const.defaults import DEFAULT_REPLACEMENT from picard.const.sys import IS_WIN from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.util import system_supports_long_paths from picard.ui import PicardDialog from picard.ui.forms.ui_options_renaming_compat import ( Ui_RenamingCompatOptionsPage, ) from picard.ui.forms.ui_win_compat_dialog import Ui_WinCompatDialog from picard.ui.options import ( OptionsCheckError, OptionsPage, ) class RenamingCompatOptionsPage(OptionsPage): NAME = 'filerenaming_compat' TITLE = N_("Compatibility") PARENT = 'filerenaming' ACTIVE = True HELP_URL = "/config/options_filerenaming_compat.html" options_changed = QtCore.pyqtSignal(dict) def __init__(self, parent=None): super().__init__(parent=parent) config = get_config() self.win_compat_replacements = config.setting['win_compat_replacements'] self.ui = Ui_RenamingCompatOptionsPage() self.ui.setupUi(self) self.ui.ascii_filenames.toggled.connect(self.on_options_changed) self.ui.windows_compatibility.toggled.connect(self.on_options_changed) self.ui.windows_long_paths.toggled.connect(self.on_options_changed) self.ui.replace_spaces_with_underscores.toggled.connect(self.on_options_changed) self.ui.replace_dir_separator.textChanged.connect(self.on_options_changed) self.ui.replace_dir_separator.setValidator(NoDirectorySeparatorValidator()) self.ui.btn_windows_compatibility_change.clicked.connect(self.open_win_compat_dialog) self.register_setting('ascii_filenames', ['ascii_filenames']) self.register_setting('windows_compatibility', ['windows_compatibility']) self.register_setting('win_compat_replacements', ['win_compat_replacements']) self.register_setting('windows_long_paths', ['windows_long_paths']) self.register_setting('replace_spaces_with_underscores', ['replace_spaces_with_underscores']) self.register_setting('replace_dir_separator', ['replace_dir_separator']) def load(self): config = get_config() self.win_compat_replacements = config.setting['win_compat_replacements'] try: self.ui.windows_long_paths.toggled.disconnect(self.toggle_windows_long_paths) except TypeError: pass if IS_WIN: self.ui.windows_compatibility.setChecked(True) self.ui.windows_compatibility.setEnabled(False) else: self.ui.windows_compatibility.setChecked(config.setting['windows_compatibility']) self.ui.windows_long_paths.setChecked(config.setting['windows_long_paths']) self.ui.ascii_filenames.setChecked(config.setting['ascii_filenames']) self.ui.replace_spaces_with_underscores.setChecked(config.setting['replace_spaces_with_underscores']) self.ui.replace_dir_separator.setText(config.setting['replace_dir_separator']) self.ui.windows_long_paths.toggled.connect(self.toggle_windows_long_paths) def save(self): config = get_config() options = self.get_options() for key, value in options.items(): config.setting[key] = value def check(self): (valid_state, _text, _pos) = self.ui.replace_dir_separator.validator().validate(self.ui.replace_dir_separator.text(), 0) if valid_state != QtGui.QValidator.State.Acceptable: raise OptionsCheckError( _("Invalid directory separator replacement"), _("The replacement for directory separators must not be itself a directory separator.") ) def toggle_windows_long_paths(self, state): if state and not system_supports_long_paths(): dialog = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Information, _("Windows long path support"), _( "Enabling long paths on Windows might cause files being saved with path names " "exceeding the 259 character limit traditionally imposed by the Windows API. " "Some software might not be able to properly access those files." ), QtWidgets.QMessageBox.StandardButton.Ok, self) dialog.exec() def on_options_changed(self): self.options_changed.emit(self.get_options()) def get_options(self): return { 'ascii_filenames': self.ui.ascii_filenames.isChecked(), 'windows_compatibility': self.ui.windows_compatibility.isChecked(), 'windows_long_paths': self.ui.windows_long_paths.isChecked(), 'replace_spaces_with_underscores': self.ui.replace_spaces_with_underscores.isChecked(), 'replace_dir_separator': self.ui.replace_dir_separator.text(), 'win_compat_replacements': self.win_compat_replacements, } def open_win_compat_dialog(self): dialog = WinCompatDialog(self.win_compat_replacements, parent=self) if dialog.exec() == QtWidgets.QDialog.DialogCode.Accepted: self.win_compat_replacements = dialog.replacements self.on_options_changed() class NoDirectorySeparatorValidator(QtGui.QValidator): def validate(self, text: str, pos): if os.sep in text or (os.altsep and os.altsep in text): state = QtGui.QValidator.State.Invalid else: state = QtGui.QValidator.State.Acceptable return state, text, pos class WinCompatReplacementValidator(QtGui.QValidator): _re_valid_win_replacement = re.compile(r'^[^"*:<>?|/\\\s]?$') def validate(self, text: str, pos): if self._re_valid_win_replacement.match(text): state = QtGui.QValidator.State.Acceptable else: state = QtGui.QValidator.State.Invalid return state, text, pos class WinCompatDialog(PicardDialog): def __init__(self, replacements, parent=None): super().__init__(parent=parent) self.replacements = dict(replacements) self.ui = Ui_WinCompatDialog() self.ui.setupUi(self) self.ui.replace_asterisk.setValidator(WinCompatReplacementValidator()) self.ui.replace_colon.setValidator(WinCompatReplacementValidator()) self.ui.replace_gt.setValidator(WinCompatReplacementValidator()) self.ui.replace_lt.setValidator(WinCompatReplacementValidator()) self.ui.replace_pipe.setValidator(WinCompatReplacementValidator()) self.ui.replace_questionmark.setValidator(WinCompatReplacementValidator()) self.ui.replace_quotationmark.setValidator(WinCompatReplacementValidator()) self.ui.buttonbox.accepted.connect(self.accept) self.ui.buttonbox.rejected.connect(self.reject) reset_button = QtWidgets.QPushButton(_("Restore &Defaults")) self.ui.buttonbox.addButton(reset_button, QtWidgets.QDialogButtonBox.ButtonRole.ResetRole) reset_button.clicked.connect(self.restore_defaults) self.load() def load(self): self.ui.replace_asterisk.setText(self.replacements['*']) self.ui.replace_colon.setText(self.replacements[':']) self.ui.replace_gt.setText(self.replacements['>']) self.ui.replace_lt.setText(self.replacements['<']) self.ui.replace_pipe.setText(self.replacements['|']) self.ui.replace_questionmark.setText(self.replacements['?']) self.ui.replace_quotationmark.setText(self.replacements['"']) def accept(self): self.replacements['*'] = self.ui.replace_asterisk.text() self.replacements[':'] = self.ui.replace_colon.text() self.replacements['>'] = self.ui.replace_gt.text() self.replacements['<'] = self.ui.replace_lt.text() self.replacements['|'] = self.ui.replace_pipe.text() self.replacements['?'] = self.ui.replace_questionmark.text() self.replacements['"'] = self.ui.replace_quotationmark.text() super().accept() def restore_defaults(self): self.ui.replace_asterisk.setText(DEFAULT_REPLACEMENT) self.ui.replace_colon.setText(DEFAULT_REPLACEMENT) self.ui.replace_gt.setText(DEFAULT_REPLACEMENT) self.ui.replace_lt.setText(DEFAULT_REPLACEMENT) self.ui.replace_pipe.setText(DEFAULT_REPLACEMENT) self.ui.replace_questionmark.setText(DEFAULT_REPLACEMENT) self.ui.replace_quotationmark.setText(DEFAULT_REPLACEMENT) register_options_page(RenamingCompatOptionsPage)
10,109
Python
.py
202
42.69802
128
0.704143
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,085
renaming.py
metabrainz_picard/picard/ui/options/renaming.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011 Lukáš Lalinský # Copyright (C) 2008-2009 Nikolai Prokoschenko # Copyright (C) 2009-2010, 2014-2015, 2018-2022 Philipp Wolfer # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2011-2013 Wieland Hoffmann # Copyright (C) 2013 Calvin Walton # Copyright (C) 2013 Ionuț Ciocîrlan # Copyright (C) 2013-2014 Sophist-UK # Copyright (C) 2013-2015, 2018-2024 Laurent Monin # Copyright (C) 2015 Alex Berman # Copyright (C) 2015 Ohm Patel # Copyright (C) 2016 Suhas # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Gabriel Ferreira # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os.path from PyQt6.QtGui import QPalette from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import ( N_, gettext as _, ) from picard.script import ScriptParser from picard.ui.enums import MainAction from picard.ui.forms.ui_options_renaming import Ui_RenamingOptionsPage from picard.ui.options import ( OptionsCheckError, OptionsPage, ) from picard.ui.options.scripting import ( ScriptCheckError, ScriptingDocumentationDialog, ) from picard.ui.scripteditor import ( ScriptEditorDialog, ScriptEditorExamples, populate_script_selection_combo_box, synchronize_vertical_scrollbars, ) from picard.ui.util import FileDialog class RenamingOptionsPage(OptionsPage): NAME = 'filerenaming' TITLE = N_("File Naming") PARENT = None SORT_ORDER = 40 ACTIVE = True HELP_URL = "/config/options_filerenaming.html" def __init__(self, parent=None): super().__init__(parent=parent) self.script_text = "" self.compat_options = {} self.ui = Ui_RenamingOptionsPage() self.ui.setupUi(self) self.ui.rename_files.clicked.connect(self.update_examples_from_local) self.ui.move_files.clicked.connect(self.update_examples_from_local) self.ui.move_files_to.editingFinished.connect(self.update_examples_from_local) self.ui.move_files.toggled.connect(self.toggle_file_naming_format) self.ui.rename_files.toggled.connect(self.toggle_file_naming_format) self.toggle_file_naming_format(None) self.ui.open_script_editor.clicked.connect(self.show_script_editing_page) self.ui.move_files_to_browse.clicked.connect(self.move_files_to_browse) self.ui.naming_script_selector.currentIndexChanged.connect(self.update_selector_in_editor) self.ui.example_filename_after.itemSelectionChanged.connect(self.match_before_to_after) self.ui.example_filename_before.itemSelectionChanged.connect(self.match_after_to_before) script_edit = self.ui.move_additional_files_pattern self.script_palette_normal = script_edit.palette() self.script_palette_readonly = QPalette(self.script_palette_normal) disabled_color = self.script_palette_normal.color(QPalette.ColorGroup.Inactive, QPalette.ColorRole.Window) self.script_palette_readonly.setColor(QPalette.ColorGroup.Disabled, QPalette.ColorRole.Base, disabled_color) self.ui.example_filename_sample_files_button.clicked.connect(self.update_example_files) self.examples = ScriptEditorExamples(tagger=self.tagger) # Script editor dialog object will not be created until it is specifically requested, in order to ensure proper window modality. self.script_editor_dialog = None self.ui.example_selection_note.setText(self.examples.get_notes_text()) self.ui.example_filename_sample_files_button.setToolTip(self.examples.get_tooltip_text()) # Sync example lists vertical scrolling and selection colors synchronize_vertical_scrollbars((self.ui.example_filename_before, self.ui.example_filename_after)) self.current_row = -1 self.register_setting('move_files', ['move_files']) self.register_setting('move_files_to', ['move_files_to']) self.register_setting('move_additional_files', ['move_additional_files']) self.register_setting('move_additional_files_pattern', ['move_additional_files_pattern']) self.register_setting('delete_empty_dirs', ['delete_empty_dirs']) self.register_setting('rename_files', ['rename_files']) self.register_setting('selected_file_naming_script_id', ['naming_script_selector']) def update_selector_from_editor(self): """Update the script selector combo box from the script editor page. """ self.naming_scripts = self.script_editor_dialog.naming_scripts self.selected_naming_script_id = self.script_editor_dialog.selected_script_id populate_script_selection_combo_box(self.naming_scripts, self.selected_naming_script_id, self.ui.naming_script_selector) self.display_examples() def update_selector_from_settings(self): """Update the script selector combo box from the settings. """ populate_script_selection_combo_box(self.naming_scripts, self.selected_naming_script_id, self.ui.naming_script_selector) self.update_selector_in_editor() def update_selector_in_editor(self): """Update the selection in the script editor page to match local selection. """ idx = self.ui.naming_script_selector.currentIndex() if self.script_editor_dialog: self.script_editor_dialog.set_selected_script_index(idx) else: script_item = self.ui.naming_script_selector.itemData(idx) self.script_text = script_item["script"] self.selected_naming_script_id = script_item["id"] self.examples.update_examples(script_text=self.script_text) self.update_examples_from_local() def match_after_to_before(self): """Sets the selected item in the 'after' list to the corresponding item in the 'before' list. """ self.examples.synchronize_selected_example_lines(self.current_row, self.ui.example_filename_before, self.ui.example_filename_after) def match_before_to_after(self): """Sets the selected item in the 'before' list to the corresponding item in the 'after' list. """ self.examples.synchronize_selected_example_lines(self.current_row, self.ui.example_filename_after, self.ui.example_filename_before) def show_script_editing_page(self): self.script_editor_dialog = ScriptEditorDialog.show_instance(parent=self, examples=self.examples) self.script_editor_dialog.signal_save.connect(self.save_from_editor) self.script_editor_dialog.signal_update.connect(self.display_examples) self.script_editor_dialog.signal_selection_changed.connect(self.update_selector_from_editor) self.script_editor_dialog.finished.connect(self.script_editor_dialog_close) if self.tagger.window.script_editor_dialog is not None: self.update_selector_from_editor() else: self.script_editor_dialog.loading = True self.script_editor_dialog.naming_scripts = self.naming_scripts self.script_editor_dialog.populate_script_selector() self.update_selector_in_editor() self.script_editor_dialog.loading = False self.update_examples_from_local() self.tagger.window.script_editor_dialog = True def script_editor_dialog_close(self): self.tagger.window.script_editor_dialog = None def show_scripting_documentation(self): ScriptingDocumentationDialog.show_instance(parent=self) def toggle_file_naming_format(self, state): active = self.ui.move_files.isChecked() or self.ui.rename_files.isChecked() self.ui.open_script_editor.setEnabled(active) def save_from_editor(self): self.script_text = self.script_editor_dialog.get_script() self.update_selector_from_editor() def check_formats(self): self.test() self.update_examples_from_local() def update_example_files(self): self.examples.update_sample_example_files() self.update_displayed_examples() def update_examples_from_local(self): override = dict(self.compat_options) override['move_files'] = self.ui.move_files.isChecked() override['move_files_to'] = os.path.normpath(self.ui.move_files_to.text()) override['rename_files'] = self.ui.rename_files.isChecked() self.examples.update_examples(override=override) self.update_displayed_examples() def update_displayed_examples(self): if self.script_editor_dialog is not None: # Update examples in script editor which will trigger update locally self.script_editor_dialog.display_examples() else: self.display_examples() def display_examples(self): self.current_row = -1 self.examples.update_example_listboxes(self.ui.example_filename_before, self.ui.example_filename_after) def load(self): # React to changes of compat options compat_page = self.dialog.get_page('filerenaming_compat') self.compat_options = compat_page.get_options() compat_page.options_changed.connect(self.on_compat_options_changed) config = get_config() self.ui.rename_files.setChecked(config.setting['rename_files']) self.ui.move_files.setChecked(config.setting['move_files']) self.ui.move_files_to.setText(config.setting['move_files_to']) self.ui.move_files_to.setCursorPosition(0) self.ui.move_additional_files.setChecked(config.setting['move_additional_files']) self.ui.move_additional_files_pattern.setText(config.setting['move_additional_files_pattern']) self.ui.delete_empty_dirs.setChecked(config.setting['delete_empty_dirs']) self.naming_scripts = config.setting['file_renaming_scripts'] self.selected_naming_script_id = config.setting['selected_file_naming_script_id'] if self.script_editor_dialog: self.script_editor_dialog.load() else: self.update_selector_from_settings() self.update_examples_from_local() def on_compat_options_changed(self, options): self.compat_options = options self.update_examples_from_local() def check(self): self.check_format() if self.ui.move_files.isChecked() and not self.ui.move_files_to.text().strip(): raise OptionsCheckError(_("Error"), _("The location to move files to must not be empty.")) def check_format(self): parser = ScriptParser() try: parser.eval(self.script_text) except Exception as e: raise ScriptCheckError("", str(e)) if self.ui.rename_files.isChecked(): if not self.script_text.strip(): raise ScriptCheckError("", _("The file naming format must not be empty.")) def save(self): config = get_config() config.setting['rename_files'] = self.ui.rename_files.isChecked() config.setting['move_files'] = self.ui.move_files.isChecked() config.setting['move_files_to'] = os.path.normpath(self.ui.move_files_to.text()) config.setting['move_additional_files'] = self.ui.move_additional_files.isChecked() config.setting['move_additional_files_pattern'] = self.ui.move_additional_files_pattern.text() config.setting['delete_empty_dirs'] = self.ui.delete_empty_dirs.isChecked() config.setting['selected_file_naming_script_id'] = self.selected_naming_script_id self.tagger.window.actions[MainAction.ENABLE_RENAMING].setChecked(config.setting['rename_files']) self.tagger.window.actions[MainAction.ENABLE_MOVING].setChecked(config.setting['move_files']) self.tagger.window.make_script_selector_menu() def display_error(self, error): # Ignore scripting errors, those are handled inline if not isinstance(error, ScriptCheckError): super().display_error(error) def move_files_to_browse(self): path = FileDialog.getExistingDirectory( parent=self, dir=self.ui.move_files_to.text(), ) if path: path = os.path.normpath(path) self.ui.move_files_to.setText(path) def test(self): self.ui.renaming_error.setStyleSheet("") self.ui.renaming_error.setText("") try: self.check_format() except ScriptCheckError as e: self.ui.renaming_error.setStyleSheet(self.STYLESHEET_ERROR) self.ui.renaming_error.setText(e.info) return register_options_page(RenamingOptionsPage)
13,414
Python
.py
254
45.30315
139
0.708553
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,086
ratings.py
metabrainz_picard/picard/ui/options/ratings.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2008-2009, 2020-2021 Philipp Wolfer # Copyright (C) 2012-2013 Michael Wiencek # Copyright (C) 2018, 2020-2021, 2023-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.extension_points.options_pages import register_options_page from picard.i18n import N_ from picard.ui.forms.ui_options_ratings import Ui_RatingsOptionsPage from picard.ui.options import OptionsPage class RatingsOptionsPage(OptionsPage): NAME = 'ratings' TITLE = N_("Ratings") PARENT = 'metadata' SORT_ORDER = 20 ACTIVE = True HELP_URL = "/config/options_ratings.html" def __init__(self, parent=None): super().__init__(parent=parent) self.ui = Ui_RatingsOptionsPage() self.ui.setupUi(self) self.register_setting('enable_ratings', []) self.register_setting('rating_user_email', ['rating_user_email']) self.register_setting('submit_ratings', ['submit_ratings']) def load(self): config = get_config() self.ui.enable_ratings.setChecked(config.setting['enable_ratings']) self.ui.rating_user_email.setText(config.setting['rating_user_email']) self.ui.submit_ratings.setChecked(config.setting['submit_ratings']) def save(self): config = get_config() config.setting['enable_ratings'] = self.ui.enable_ratings.isChecked() config.setting['rating_user_email'] = self.ui.rating_user_email.text() config.setting['submit_ratings'] = self.ui.submit_ratings.isChecked() register_options_page(RatingsOptionsPage)
2,339
Python
.py
51
41.72549
80
0.731986
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,087
basetreeview.py
metabrainz_picard/picard/ui/itemviews/basetreeview.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011-2012 Lukáš Lalinský # Copyright (C) 2007 Robert Kaye # Copyright (C) 2008 Gary van der Merwe # Copyright (C) 2008 Hendrik van Antwerpen # Copyright (C) 2008-2011, 2014-2015, 2018-2024 Philipp Wolfer # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2011 Tim Blechmann # Copyright (C) 2011-2012 Chad Wilson # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2012 Your Name # Copyright (C) 2012-2013 Wieland Hoffmann # Copyright (C) 2013-2014, 2016, 2018-2024 Laurent Monin # Copyright (C) 2013-2014, 2017, 2020 Sophist-UK # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016 Simon Legner # Copyright (C) 2016 Suhas # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2020-2021 Gabriel Ferreira # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Louis Sautier # Copyright (C) 2021 Petit Minion # Copyright (C) 2023 certuna # Copyright (C) 2024 Suryansh Shakya # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from heapq import ( heappop, heappush, ) from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import log from picard.album import ( Album, NatAlbum, ) from picard.cluster import ( Cluster, ClusterList, UnclusteredFiles, ) from picard.config import get_config from picard.extension_points.item_actions import ( ext_point_album_actions, ext_point_cluster_actions, ext_point_clusterlist_actions, ext_point_file_actions, ext_point_track_actions, ) from picard.file import File from picard.i18n import gettext as _ from picard.script import iter_tagging_scripts_from_tuples from picard.track import ( NonAlbumTrack, Track, ) from picard.util import ( icontheme, iter_files_from_objects, normpath, restore_method, ) from picard.ui.collectionmenu import CollectionMenu from picard.ui.enums import MainAction from picard.ui.itemviews.columns import ( DEFAULT_COLUMNS, ITEM_ICON_COLUMN, ) from picard.ui.ratingwidget import RatingWidget from picard.ui.scriptsmenu import ScriptsMenu from picard.ui.util import menu_builder from picard.ui.widgets.tristatesortheaderview import TristateSortHeaderView DEFAULT_SECTION_SIZE = 100 class ConfigurableColumnsHeader(TristateSortHeaderView): def __init__(self, parent=None): super().__init__(QtCore.Qt.Orientation.Horizontal, parent) self._visible_columns = set([ITEM_ICON_COLUMN]) self.sortIndicatorChanged.connect(self.on_sort_indicator_changed) # enable sorting, but don't actually use it by default # XXX it would be nice to be able to go to the 'no sort' mode, but the # internal model that QTreeWidget uses doesn't support it self.setSortIndicator(-1, QtCore.Qt.SortOrder.AscendingOrder) def show_column(self, column, show): if column == ITEM_ICON_COLUMN: # The first column always visible # Still execute following to ensure it is shown show = True self.parent().setColumnHidden(column, not show) if show: self._visible_columns.add(column) else: self._visible_columns.discard(column) def contextMenuEvent(self, event): menu = QtWidgets.QMenu(self) parent = self.parent() for i, column in enumerate(DEFAULT_COLUMNS): if i == ITEM_ICON_COLUMN: continue action = QtGui.QAction(_(column.title), parent) action.setCheckable(True) action.setChecked(i in self._visible_columns) action.setEnabled(not self.is_locked) action.triggered.connect(partial(self.show_column, i)) menu.addAction(action) menu.addSeparator() restore_action = QtGui.QAction(_("Restore default columns"), parent) restore_action.setEnabled(not self.is_locked) restore_action.triggered.connect(self.restore_defaults) menu.addAction(restore_action) lock_action = QtGui.QAction(_("Lock columns"), parent) lock_action.setCheckable(True) lock_action.setChecked(self.is_locked) lock_action.toggled.connect(self.lock) menu.addAction(lock_action) menu.exec(event.globalPos()) event.accept() def restore_defaults(self): self.parent().restore_default_columns() def paintSection(self, painter, rect, index): column = DEFAULT_COLUMNS[index] if column.is_icon: painter.save() super().paintSection(painter, rect, index) painter.restore() column.paint_icon(painter, rect) else: super().paintSection(painter, rect, index) def on_sort_indicator_changed(self, index, order): if DEFAULT_COLUMNS[index].is_icon: self.setSortIndicator(-1, QtCore.Qt.SortOrder.AscendingOrder) def lock(self, is_locked): super().lock(is_locked) def __str__(self): name = getattr(self.parent(), 'NAME', str(self.parent().__class__.__name__)) return f"{name}'s header" def _alternative_versions(album): config = get_config() versions = album.release_group.versions album_tracks_count = album.get_num_total_files() or len(album.tracks) preferred_countries = set(config.setting['preferred_release_countries']) preferred_formats = set(config.setting['preferred_release_formats']) ORDER_BEFORE, ORDER_AFTER = 0, 1 alternatives = [] for version in versions: trackmatch = countrymatch = formatmatch = ORDER_BEFORE if version['totaltracks'] != album_tracks_count: trackmatch = ORDER_AFTER if preferred_countries: countries = set(version['countries']) if not countries or not countries.intersection(preferred_countries): countrymatch = ORDER_AFTER if preferred_formats: formats = set(version['formats']) if not formats or not formats.intersection(preferred_formats): formatmatch = ORDER_AFTER group = (trackmatch, countrymatch, formatmatch) # order by group, name, and id on push heappush(alternatives, (group, version['name'], version['id'], version['extra'])) while alternatives: yield heappop(alternatives) def _build_other_versions_actions(releases_menu, album, alternative_versions): heading = QtGui.QAction(album.release_group.version_headings, parent=releases_menu) heading.setDisabled(True) font = heading.font() font.setBold(True) heading.setFont(font) yield heading prev_group = None for group, action_text, release_id, extra in alternative_versions: if group != prev_group: if prev_group is not None: sep = QtGui.QAction(parent=releases_menu) sep.setSeparator(True) yield sep prev_group = group action = QtGui.QAction(action_text, parent=releases_menu) action.setCheckable(True) if extra: action.setToolTip(extra) if album.id == release_id: action.setChecked(True) action.triggered.connect(partial(album.switch_release_version, release_id)) yield action def _add_other_versions(releases_menu, album, action_loading): if album.release_group.versions_count is not None: releases_menu.setTitle(_("&Other versions (%d)") % album.release_group.versions_count) actions = _build_other_versions_actions(releases_menu, album, _alternative_versions(album)) releases_menu.insertActions(action_loading, actions) releases_menu.removeAction(action_loading) class BaseTreeView(QtWidgets.QTreeWidget): def __init__(self, window, parent=None): super().__init__(parent=parent) self.setAccessibleName(_(self.NAME)) self.setAccessibleDescription(_(self.DESCRIPTION)) self.tagger = QtCore.QCoreApplication.instance() self.window = window # Should multiple files dropped be assigned to tracks sequentially? self._move_to_multi_tracks = True self._init_header() self.setAcceptDrops(True) self.setDragEnabled(True) self.setDropIndicatorShown(True) self.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.setSortingEnabled(True) self.expand_all_action = QtGui.QAction(_("&Expand all"), self) self.expand_all_action.triggered.connect(self.expandAll) self.collapse_all_action = QtGui.QAction(_("&Collapse all"), self) self.collapse_all_action.triggered.connect(self.collapseAll) self.select_all_action = QtGui.QAction(_("Select &all"), self) self.select_all_action.triggered.connect(self.selectAll) self.select_all_action.setShortcut(QtGui.QKeySequence(_("Ctrl+A"))) self.doubleClicked.connect(self.activate_item) self.setUniformRowHeights(True) self.icon_plugins = icontheme.lookup('applications-system', icontheme.ICON_SIZE_MENU) def contextMenuEvent(self, event): item = self.itemAt(event.pos()) if not item: return config = get_config() obj = item.obj plugin_actions = None can_view_info = self.window.actions[MainAction.VIEW_INFO].isEnabled() menu = QtWidgets.QMenu(self) menu.setSeparatorsCollapsible(True) def add_actions(*args): menu_builder(menu, self.window.actions, *args) if isinstance(obj, Track): add_actions( MainAction.VIEW_INFO if can_view_info else None, ) plugin_actions = list(ext_point_track_actions) if obj.num_linked_files == 1: add_actions( MainAction.PLAY_FILE, MainAction.OPEN_FOLDER, MainAction.TRACK_SEARCH, ) plugin_actions.extend(ext_point_file_actions) add_actions( MainAction.BROWSER_LOOKUP, MainAction.GENERATE_FINGERPRINTS if obj.num_linked_files > 0 else None, '-', MainAction.REFRESH if isinstance(obj, NonAlbumTrack) else None, ) elif isinstance(obj, Cluster): add_actions( MainAction.VIEW_INFO if can_view_info else None, MainAction.BROWSER_LOOKUP, MainAction.SUBMIT_CLUSTER, '-', MainAction.AUTOTAG, MainAction.ANALYZE, MainAction.CLUSTER if isinstance(obj, UnclusteredFiles) else MainAction.ALBUM_SEARCH, MainAction.GENERATE_FINGERPRINTS, ) plugin_actions = list(ext_point_cluster_actions) elif isinstance(obj, ClusterList): add_actions( MainAction.AUTOTAG, MainAction.ANALYZE, MainAction.GENERATE_FINGERPRINTS, ) plugin_actions = list(ext_point_clusterlist_actions) elif isinstance(obj, File): add_actions( MainAction.VIEW_INFO if can_view_info else None, MainAction.PLAY_FILE, MainAction.OPEN_FOLDER, MainAction.BROWSER_LOOKUP, MainAction.SUBMIT_FILE_AS_RECORDING, MainAction.SUBMIT_FILE_AS_RELEASE, '-', MainAction.AUTOTAG, MainAction.ANALYZE, MainAction.TRACK_SEARCH, MainAction.GENERATE_FINGERPRINTS, ) plugin_actions = list(ext_point_file_actions) elif isinstance(obj, Album): add_actions( MainAction.VIEW_INFO if can_view_info else None, MainAction.BROWSER_LOOKUP, MainAction.GENERATE_FINGERPRINTS if obj.get_num_total_files() > 0 else None, '-', MainAction.REFRESH, ) plugin_actions = list(ext_point_album_actions) add_actions( '-', MainAction.SAVE, MainAction.REMOVE, ) if isinstance(obj, Album) and not isinstance(obj, NatAlbum) and obj.loaded: releases_menu = QtWidgets.QMenu(_("&Other versions"), menu) releases_menu.setToolTipsVisible(True) releases_menu.setEnabled(False) add_actions( '-', releases_menu, ) action_more_details = releases_menu.addAction(_("Show &more details…")) action_more_details.triggered.connect(self.window.actions[MainAction.ALBUM_OTHER_VERSIONS].trigger) album = obj if len(self.selectedItems()) == 1 and album.release_group: action_loading = QtGui.QAction(_("Loading…"), parent=releases_menu) action_loading.setDisabled(True) action_other_versions_separator = QtGui.QAction(parent=releases_menu) action_other_versions_separator.setSeparator(True) releases_menu.insertActions(action_more_details, [action_loading, action_other_versions_separator]) if album.release_group.loaded: _add_other_versions(releases_menu, album, action_loading) else: callback = partial(_add_other_versions, releases_menu, album, action_loading) album.release_group.load_versions(callback) releases_menu.setEnabled(True) if config.setting['enable_ratings'] and \ len(self.window.selected_objects) == 1 and isinstance(obj, Track): action = QtWidgets.QWidgetAction(menu) action.setDefaultWidget(RatingWidget(obj, parent=menu)) add_actions( '-', action, ) # Using type here is intentional. isinstance will return true for the # NatAlbum instance, which can't be part of a collection. selected_albums = [a for a in self.window.selected_objects if type(a) == Album] # pylint: disable=C0123 # noqa: E721 if selected_albums: add_actions( '-', CollectionMenu(selected_albums, _("Collections"), parent=menu), ) if plugin_actions: plugin_menu = QtWidgets.QMenu(_("P&lugins"), menu) plugin_menu.setIcon(self.icon_plugins) add_actions( '-', plugin_menu, ) plugin_menus = {} for action in plugin_actions: action_menu = plugin_menu for index in range(1, len(action.MENU) + 1): key = tuple(action.MENU[:index]) if key in plugin_menus: action_menu = plugin_menus[key] else: action_menu = plugin_menus[key] = action_menu.addMenu(key[-1]) action_menu.addAction(action) scripts = config.setting['list_of_scripts'] if scripts: scripts_menu = ScriptsMenu(iter_tagging_scripts_from_tuples(scripts), _("&Run scripts"), parent=menu) scripts_menu.setIcon(self.icon_plugins) add_actions( '-', scripts_menu, ) if isinstance(obj, Cluster) or isinstance(obj, ClusterList) or isinstance(obj, Album): add_actions( '-', self.expand_all_action, self.collapse_all_action, ) add_actions(self.select_all_action) menu.exec(event.globalPos()) event.accept() @restore_method def restore_state(self): config = get_config() self.restore_default_columns() header_state = config.persist[self.header_state] header = self.header() if header_state and header.restoreState(header_state): log.debug("Restoring state of %s" % header) for i in range(0, self.columnCount()): header.show_column(i, not self.isColumnHidden(i)) header.lock(config.persist[self.header_locked]) def save_state(self): config = get_config() header = self.header() if header.prelock_state is not None: state = header.prelock_state else: state = header.saveState() log.debug("Saving state of %s" % header) config.persist[self.header_state] = state config.persist[self.header_locked] = header.is_locked def restore_default_columns(self): labels = [_(c.title) if not c.is_icon else '' for c in DEFAULT_COLUMNS] self.setHeaderLabels(labels) header = self.header() header.setStretchLastSection(True) header.setDefaultAlignment(QtCore.Qt.AlignmentFlag.AlignLeft | QtCore.Qt.AlignmentFlag.AlignVCenter) header.setDefaultSectionSize(DEFAULT_SECTION_SIZE) for i, c in enumerate(DEFAULT_COLUMNS): header.show_column(i, c.is_default) if c.is_icon: header.resizeSection(i, c.header_icon_size_with_border.width()) header.setSectionResizeMode(i, QtWidgets.QHeaderView.ResizeMode.Fixed) else: header.resizeSection(i, c.size if c.size is not None else DEFAULT_SECTION_SIZE) header.setSectionResizeMode(i, QtWidgets.QHeaderView.ResizeMode.Interactive) self.sortByColumn(-1, QtCore.Qt.SortOrder.AscendingOrder) def _init_header(self): header = ConfigurableColumnsHeader(self) self.setHeader(header) self.restore_state() def supportedDropActions(self): return QtCore.Qt.DropAction.CopyAction | QtCore.Qt.DropAction.MoveAction def mimeTypes(self): """List of MIME types accepted by this view.""" return ['text/uri-list', 'application/picard.album-list'] def dragEnterEvent(self, event): super().dragEnterEvent(event) self._handle_external_drag(event) def dragMoveEvent(self, event): super().dragMoveEvent(event) self._handle_external_drag(event) def _handle_external_drag(self, event): if event.isAccepted() and (not event.source() or event.mimeData().hasUrls()): event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() def startDrag(self, supportedActions): """Start drag, *without* using pixmap.""" items = self.selectedItems() if items: drag = QtGui.QDrag(self) drag.setMimeData(self.mimeData(items)) # Render the dragged element as drag representation item = self.currentItem() rectangle = self.visualItemRect(item) pixmap = QtGui.QPixmap(rectangle.width(), rectangle.height()) self.viewport().render(pixmap, QtCore.QPoint(), QtGui.QRegion(rectangle)) drag.setPixmap(pixmap) drag.exec(QtCore.Qt.DropAction.MoveAction) def mimeData(self, items): """Return MIME data for specified items.""" album_ids = [] files = [] url = QtCore.QUrl.fromLocalFile for item in items: obj = item.obj if isinstance(obj, Album): album_ids.append(obj.id) elif obj.iterfiles: files.extend([url(f.filename) for f in obj.iterfiles()]) mimeData = QtCore.QMimeData() mimeData.setData('application/picard.album-list', '\n'.join(album_ids).encode()) if files: mimeData.setUrls(files) return mimeData def scrollTo(self, index, scrolltype=QtWidgets.QAbstractItemView.ScrollHint.EnsureVisible): # QTreeView.scrollTo resets the horizontal scroll position to 0. # Reimplemented to maintain current horizontal scroll position. hscrollbar = self.horizontalScrollBar() xpos = hscrollbar.value() super().scrollTo(index, scrolltype) hscrollbar.setValue(xpos) @staticmethod def drop_urls(urls, target, move_to_multi_tracks=True): files = [] new_paths = [] tagger = QtCore.QCoreApplication.instance() for url in urls: log.debug("Dropped the URL: %r", url.toString(QtCore.QUrl.UrlFormattingOption.RemoveUserInfo)) if url.scheme() == 'file' or not url.scheme(): filename = normpath(url.toLocalFile().rstrip('\0')) file = tagger.files.get(filename) if file: files.append(file) else: new_paths.append(filename) elif url.scheme() in {'http', 'https'}: file_lookup = tagger.get_file_lookup() file_lookup.mbid_lookup(url.path(), browser_fallback=False) if files: tagger.move_files(files, target, move_to_multi_tracks) if new_paths: tagger.add_paths(new_paths, target=target) def dropEvent(self, event): if event.proposedAction() == QtCore.Qt.DropAction.IgnoreAction: event.acceptProposedAction() return # Dropping with Alt key pressed forces all dropped files being # assigned to the same track. if event.modifiers() == QtCore.Qt.KeyboardModifier.AltModifier: self._move_to_multi_tracks = False QtWidgets.QTreeView.dropEvent(self, event) # The parent dropEvent implementation automatically accepts the proposed # action. Override this, for external drops we never support move (which # can result in file deletion, e.g. on Windows). if event.isAccepted() and (not event.source() or event.mimeData().hasUrls()): event.setDropAction(QtCore.Qt.DropAction.CopyAction) event.accept() def dropMimeData(self, parent, index, data, action): target = None if parent: if index == parent.childCount(): item = parent else: item = parent.child(index) if item is not None: target = item.obj if target is None: target = self.default_drop_target log.debug("Drop target = %r", target) handled = False # text/uri-list urls = data.urls() if urls: # Use QTimer.singleShot to run expensive processing outside of the drop handler. QtCore.QTimer.singleShot(0, partial(self.drop_urls, urls, target, self._move_to_multi_tracks)) handled = True # application/picard.album-list albums = data.data('application/picard.album-list') if albums: album_ids = bytes(albums).decode().split("\n") log.debug("Dropped albums = %r", album_ids) files = iter_files_from_objects(self.tagger.load_album(id) for id in album_ids) # Use QTimer.singleShot to run expensive processing outside of the drop handler. move_files = partial(self.tagger.move_files, list(files), target) QtCore.QTimer.singleShot(0, move_files) handled = True self._move_to_multi_tracks = True # Reset for next drop return handled def activate_item(self, index): obj = self.itemFromIndex(index).obj # Double-clicking albums or clusters should expand them. The album info can be # viewed by using the toolbar button. if not isinstance(obj, (Album, Cluster)) and obj.can_view_info: self.window.view_info() def add_cluster(self, cluster, parent_item=None): if parent_item is None: parent_item = self.clusters from picard.ui.itemviews import ClusterItem cluster_item = ClusterItem(cluster, sortable=not cluster.special, parent=parent_item) if cluster.hide_if_empty and not cluster.files: cluster_item.update() cluster_item.setHidden(True) else: cluster_item.add_files(cluster.files) def moveCursor(self, action, modifiers): if action in {QtWidgets.QAbstractItemView.CursorAction.MoveUp, QtWidgets.QAbstractItemView.CursorAction.MoveDown}: item = self.currentItem() if item and not item.isSelected(): self.setCurrentItem(item) return QtWidgets.QTreeWidget.moveCursor(self, action, modifiers) @property def default_drop_target(self): return None
25,351
Python
.py
571
34.502627
125
0.638142
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,088
__init__.py
metabrainz_picard/picard/ui/itemviews/__init__.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011-2012 Lukáš Lalinský # Copyright (C) 2007 Robert Kaye # Copyright (C) 2008 Gary van der Merwe # Copyright (C) 2008 Hendrik van Antwerpen # Copyright (C) 2008-2011, 2014-2015, 2018-2024 Philipp Wolfer # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2011 Tim Blechmann # Copyright (C) 2011-2012 Chad Wilson # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2012 Your Name # Copyright (C) 2012-2013 Wieland Hoffmann # Copyright (C) 2013-2014, 2016, 2018-2024 Laurent Monin # Copyright (C) 2013-2014, 2017, 2020 Sophist-UK # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016 Simon Legner # Copyright (C) 2016 Suhas # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2020-2021 Gabriel Ferreira # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Louis Sautier # Copyright (C) 2021 Petit Minion # Copyright (C) 2023 certuna # Copyright (C) 2024 Suryansh Shakya # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from collections import defaultdict from functools import partial from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import log from picard.album import NatAlbum from picard.file import ( File, FileErrorType, ) from picard.i18n import ( N_, gettext as _, ngettext, sort_key, ) from picard.track import Track from picard.util import icontheme from picard.ui.colors import interface_colors from picard.ui.itemviews.basetreeview import BaseTreeView from picard.ui.itemviews.columns import ( DEFAULT_COLUMNS, ITEM_ICON_COLUMN, ColumnAlign, ColumnSortType, ) def get_match_color(similarity, basecolor): c1 = (basecolor.red(), basecolor.green(), basecolor.blue()) c2 = (223, 125, 125) return QtGui.QColor( int(c2[0] + (c1[0] - c2[0]) * similarity), int(c2[1] + (c1[1] - c2[1]) * similarity), int(c2[2] + (c1[2] - c2[2]) * similarity)) class MainPanel(QtWidgets.QSplitter): def __init__(self, window, parent=None): super().__init__(parent=parent) self.tagger = QtCore.QCoreApplication.instance() self.setChildrenCollapsible(False) self.window = window self.create_icons() self._views = [FileTreeView(window, self), AlbumTreeView(window, self)] self._selected_view = self._views[0] self._ignore_selection_changes = False self._sort_enabled = None # None at start, bool once set_sorting is called def _view_update_selection(view): if not self._ignore_selection_changes: self._ignore_selection_changes = True self._update_selection(view) self._ignore_selection_changes = False for view in self._views: view.itemSelectionChanged.connect(partial(_view_update_selection, view)) TreeItem.window = window TreeItem.base_color = self.palette().base().color() TreeItem.text_color = self.palette().text().color() TreeItem.text_color_secondary = self.palette() \ .brush(QtGui.QPalette.ColorGroup.Disabled, QtGui.QPalette.ColorRole.Text).color() TrackItem.track_colors = defaultdict(lambda: TreeItem.text_color, { File.NORMAL: interface_colors.get_qcolor('entity_saved'), File.CHANGED: TreeItem.text_color, File.PENDING: interface_colors.get_qcolor('entity_pending'), File.ERROR: interface_colors.get_qcolor('entity_error'), }) FileItem.file_colors = defaultdict(lambda: TreeItem.text_color, { File.NORMAL: TreeItem.text_color, File.CHANGED: TreeItem.text_color, File.PENDING: interface_colors.get_qcolor('entity_pending'), File.ERROR: interface_colors.get_qcolor('entity_error'), }) def set_processing(self, processing=True): self._ignore_selection_changes = processing def tab_order(self, tab_order, before, after): prev = before for view in self._views: tab_order(prev, view) prev = view tab_order(prev, after) def save_state(self): for view in self._views: view.save_state() def create_icons(self): if hasattr(QtWidgets.QStyle, 'SP_DirIcon'): ClusterItem.icon_dir = self.style().standardIcon(QtWidgets.QStyle.StandardPixmap.SP_DirIcon) else: ClusterItem.icon_dir = icontheme.lookup('folder', icontheme.ICON_SIZE_MENU) AlbumItem.icon_cd = icontheme.lookup('media-optical', icontheme.ICON_SIZE_MENU) AlbumItem.icon_cd_modified = icontheme.lookup('media-optical-modified', icontheme.ICON_SIZE_MENU) AlbumItem.icon_cd_saved = icontheme.lookup('media-optical-saved', icontheme.ICON_SIZE_MENU) AlbumItem.icon_cd_saved_modified = icontheme.lookup('media-optical-saved-modified', icontheme.ICON_SIZE_MENU) AlbumItem.icon_error = icontheme.lookup('media-optical-error', icontheme.ICON_SIZE_MENU) TrackItem.icon_audio = QtGui.QIcon(":/images/track-audio.png") TrackItem.icon_video = QtGui.QIcon(":/images/track-video.png") TrackItem.icon_data = QtGui.QIcon(":/images/track-data.png") TrackItem.icon_error = icontheme.lookup('dialog-error', icontheme.ICON_SIZE_MENU) FileItem.icon_file = QtGui.QIcon(":/images/file.png") FileItem.icon_file_pending = QtGui.QIcon(":/images/file-pending.png") FileItem.icon_error = icontheme.lookup('dialog-error', icontheme.ICON_SIZE_MENU) FileItem.icon_error_not_found = icontheme.lookup('error-not-found', icontheme.ICON_SIZE_MENU) FileItem.icon_error_no_access = icontheme.lookup('error-no-access', icontheme.ICON_SIZE_MENU) FileItem.icon_saved = QtGui.QIcon(":/images/track-saved.png") FileItem.icon_fingerprint = icontheme.lookup('fingerprint', icontheme.ICON_SIZE_MENU) FileItem.icon_fingerprint_gray = icontheme.lookup('fingerprint-gray', icontheme.ICON_SIZE_MENU) FileItem.match_icons = [ QtGui.QIcon(":/images/match-50.png"), QtGui.QIcon(":/images/match-60.png"), QtGui.QIcon(":/images/match-70.png"), QtGui.QIcon(":/images/match-80.png"), QtGui.QIcon(":/images/match-90.png"), QtGui.QIcon(":/images/match-100.png"), ] FileItem.match_icons_info = [ N_("Bad match"), N_("Poor match"), N_("Ok match"), N_("Good match"), N_("Great match"), N_("Excellent match"), ] FileItem.match_pending_icons = [ QtGui.QIcon(":/images/match-pending-50.png"), QtGui.QIcon(":/images/match-pending-60.png"), QtGui.QIcon(":/images/match-pending-70.png"), QtGui.QIcon(":/images/match-pending-80.png"), QtGui.QIcon(":/images/match-pending-90.png"), QtGui.QIcon(":/images/match-pending-100.png"), ] def _update_selection(self, selected_view): for view in self._views: if view != selected_view: view.clearSelection() else: self._selected_view = view self.window.update_selection([item.obj for item in view.selectedItems()]) def update_current_view(self): self._update_selection(self._selected_view) def remove(self, objects): self._ignore_selection_changes = True self.tagger.remove(objects) self._ignore_selection_changes = False view = self._selected_view index = view.currentIndex() if index.isValid(): # select the current index view.setCurrentIndex(index) else: self.update_current_view() def set_sorting(self, sort=True): if sort != self._sort_enabled: self._sort_enabled = sort log.debug("MainPanel sort=%r", sort) for view in self._views: view.setSortingEnabled(sort) def select_object(self, obj): item = obj.ui_item for view in self._views: if view.indexFromItem(item).isValid(): view.setCurrentItem(item) self._update_selection(view) break class FileTreeView(BaseTreeView): NAME = N_("file view") DESCRIPTION = N_("Contains unmatched files and clusters") header_state = 'file_view_header_state' header_locked = 'file_view_header_locked' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.unmatched_files = ClusterItem(self.tagger.unclustered_files, parent=self) self.unmatched_files.update() self.unmatched_files.setExpanded(True) self.clusters = ClusterItem(self.tagger.clusters, parent=self) self.set_clusters_text() self.clusters.setExpanded(True) self.tagger.cluster_added.connect(self.add_file_cluster) self.tagger.cluster_removed.connect(self.remove_file_cluster) def add_file_cluster(self, cluster, parent_item=None): self.add_cluster(cluster, parent_item) self.set_clusters_text() def remove_file_cluster(self, cluster): cluster.ui_item.setSelected(False) self.clusters.removeChild(cluster.ui_item) self.set_clusters_text() def set_clusters_text(self): self.clusters.setText(ITEM_ICON_COLUMN, "%s (%d)" % (_("Clusters"), len(self.tagger.clusters))) @property def default_drop_target(self): return self.tagger.unclustered_files class AlbumTreeView(BaseTreeView): NAME = N_("album view") DESCRIPTION = N_("Contains albums and matched files") header_state = 'album_view_header_state' header_locked = 'album_view_header_locked' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.tagger.album_added.connect(self.add_album) self.tagger.album_removed.connect(self.remove_album) def add_album(self, album): if isinstance(album, NatAlbum): item = NatAlbumItem(album, sortable=True) self.insertTopLevelItem(0, item) else: item = AlbumItem(album, sortable=True, parent=self) item.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_cd) for i, column in enumerate(DEFAULT_COLUMNS): font = item.font(i) font.setBold(True) item.setFont(i, font) item.setText(i, album.column(column.key)) self.add_cluster(album.unmatched_files, item) def remove_album(self, album): album.ui_item.setSelected(False) self.takeTopLevelItem(self.indexOfTopLevelItem(album.ui_item)) class TreeItem(QtWidgets.QTreeWidgetItem): def __init__(self, obj, sortable=False, parent=None): super().__init__(parent) self._obj = None self.obj = obj self.sortable = sortable self._sortkeys = {} self.post_init() @property def obj(self): return self._obj @obj.setter def obj(self, obj): if self._obj: self._obj.ui_item = None self._obj = obj if obj is not None: obj.ui_item = self def post_init(self): pass def setText(self, column, text): self._sortkeys[column] = None return super().setText(column, text) def __lt__(self, other): tree_widget = self.treeWidget() if not self.sortable or not tree_widget: return False column = tree_widget.sortColumn() return self.sortkey(column) < other.sortkey(column) def sortkey(self, column): sortkey = self._sortkeys.get(column) if sortkey is not None: return sortkey this_column = DEFAULT_COLUMNS[column] if this_column.sort_type == ColumnSortType.SORTKEY: sortkey = this_column.sortkey(self.obj) elif this_column.sort_type == ColumnSortType.NAT: sortkey = sort_key(self.text(column), numeric=True) else: sortkey = sort_key(self.text(column)) self._sortkeys[column] = sortkey return sortkey def update_colums_text(self, color=None, bgcolor=None): for i, column in enumerate(DEFAULT_COLUMNS): if color is not None: self.setForeground(i, color) if bgcolor is not None: self.setBackground(i, bgcolor) if column.is_icon: self.setSizeHint(i, column.header_icon_size_with_border) else: if column.align == ColumnAlign.RIGHT: self.setTextAlignment(i, QtCore.Qt.AlignmentFlag.AlignRight | QtCore.Qt.AlignmentFlag.AlignVCenter) self.setText(i, self.obj.column(column.key)) class ClusterItem(TreeItem): def post_init(self): self.setIcon(ITEM_ICON_COLUMN, ClusterItem.icon_dir) def update(self, update_selection=True): self.update_colums_text() album = self.obj.related_album if self.obj.special and album and album.loaded: album.ui_item.update(update_tracks=False) if update_selection and self.isSelected(): TreeItem.window.update_selection(new_selection=False) def add_file(self, file): self.add_files([file]) def add_files(self, files): if self.obj.hide_if_empty and self.obj.files: self.setHidden(False) self.update() # addChild used (rather than building an items list and adding with addChildren) # to be certain about item order in the cluster (addChildren adds in reverse order). # Benchmarked performance was not noticeably different. for file in files: item = FileItem(file, sortable=True) self.addChild(item) item.update() def remove_file(self, file): file.ui_item.setSelected(False) self.removeChild(file.ui_item) self.update() if self.obj.hide_if_empty and not self.obj.files: self.setHidden(True) class AlbumItem(TreeItem): def update(self, update_tracks=True, update_selection=True): album = self.obj selection_changed = self.isSelected() if update_tracks: oldnum = self.childCount() - 1 newnum = len(album.tracks) if oldnum > newnum: # remove old items for i in range(oldnum - newnum): item = self.child(newnum) selection_changed |= item.isSelected() self.takeChild(newnum) oldnum = newnum # update existing items for i in range(oldnum): item = self.child(i) track = album.tracks[i] selection_changed |= item.isSelected() and item.obj != track item.obj = track item.update(update_album=False) if newnum > oldnum: # add new items items = [] for i in range(oldnum, newnum): item = TrackItem(album.tracks[i]) item.setHidden(False) # Workaround to make sure the parent state gets updated items.append(item) # insertChildren behaves differently if sorting is disabled / enabled, which results # in different sort order of tracks in unsorted state. As we sort the tracks later # anyway make sure sorting is disabled here. tree_widget = self.treeWidget() if tree_widget: sorting_enabled = tree_widget.isSortingEnabled() tree_widget.setSortingEnabled(False) self.insertChildren(oldnum, items) if tree_widget: tree_widget.setSortingEnabled(sorting_enabled) for item in items: # Update after insertChildren so that setExpanded works item.update(update_album=False) if album.errors: self.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_error) self.setToolTip(ITEM_ICON_COLUMN, _("Processing error(s): See the Errors tab in the Album Info dialog")) elif album.is_complete(): if album.is_modified(): self.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_cd_saved_modified) self.setToolTip(ITEM_ICON_COLUMN, _("Album modified and complete")) else: self.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_cd_saved) self.setToolTip(ITEM_ICON_COLUMN, _("Album unchanged and complete")) else: if album.is_modified(): self.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_cd_modified) self.setToolTip(ITEM_ICON_COLUMN, _("Album modified")) else: self.setIcon(ITEM_ICON_COLUMN, AlbumItem.icon_cd) self.setToolTip(ITEM_ICON_COLUMN, _("Album unchanged")) self.update_colums_text() if selection_changed and update_selection: TreeItem.window.update_selection(new_selection=False) # Workaround for PICARD-1446: Expand/collapse indicator for the release # is briefly missing on Windows self.emitDataChanged() def __lt__(self, other): # Always show NAT entry on top, see also NatAlbumItem.__lt__ if isinstance(other, NatAlbumItem): return not other.__lt__(self) return super().__lt__(other) class NatAlbumItem(AlbumItem): def __lt__(self, other): # Always show NAT entry on top tree_widget = self.treeWidget() if not tree_widget: return True order = tree_widget.header().sortIndicatorOrder() return order == QtCore.Qt.SortOrder.AscendingOrder class TrackItem(TreeItem): def update(self, update_album=True, update_files=True, update_selection=True): track = self.obj num_linked_files = track.num_linked_files fingerprint_column = DEFAULT_COLUMNS.pos('~fingerprint') if num_linked_files == 1: file = track.files[0] file.ui_item = self color = TrackItem.track_colors[file.state] bgcolor = get_match_color(file.similarity, TreeItem.base_color) icon, icon_tooltip = FileItem.decide_file_icon_info(file) self.takeChildren() self.setExpanded(False) fingerprint_icon, fingerprint_tooltip = FileItem.decide_fingerprint_icon_info(file) self.setToolTip(fingerprint_column, fingerprint_tooltip) self.setIcon(fingerprint_column, fingerprint_icon) else: if num_linked_files == 0: icon_tooltip = _("There are no files matched to this track") else: icon_tooltip = ngettext('%i matched file', '%i matched files', num_linked_files) % num_linked_files self.setToolTip(fingerprint_column, "") self.setIcon(fingerprint_column, QtGui.QIcon()) if track.ignored_for_completeness(): color = TreeItem.text_color_secondary else: color = TreeItem.text_color bgcolor = get_match_color(1, TreeItem.base_color) if track.is_video(): icon = TrackItem.icon_video elif track.is_data(): icon = TrackItem.icon_data else: icon = TrackItem.icon_audio if update_files: oldnum = self.childCount() newnum = track.num_linked_files if oldnum > newnum: # remove old items for i in range(oldnum - newnum): self.takeChild(newnum - 1).obj = None oldnum = newnum for i in range(oldnum): # update existing items item = self.child(i) item.obj = track.files[i] item.update(update_track=False) if newnum > oldnum: # add new items items = [] for i in range(newnum - 1, oldnum - 1, -1): item = FileItem(track.files[i]) item.update(update_track=False, update_selection=update_selection) items.append(item) self.addChildren(items) self.setExpanded(True) if track.errors: self.setIcon(ITEM_ICON_COLUMN, TrackItem.icon_error) self.setToolTip(ITEM_ICON_COLUMN, _("Processing error(s): See the Errors tab in the Track Info dialog")) else: self.setIcon(ITEM_ICON_COLUMN, icon) self.setToolTip(ITEM_ICON_COLUMN, icon_tooltip) self.update_colums_text(color=color, bgcolor=bgcolor) if update_selection and self.isSelected(): TreeItem.window.update_selection(new_selection=False) if update_album: self.parent().update(update_tracks=False, update_selection=update_selection) class FileItem(TreeItem): def update(self, update_track=True, update_selection=True): file = self.obj icon, icon_tooltip = FileItem.decide_file_icon_info(file) self.setIcon(ITEM_ICON_COLUMN, icon) self.setToolTip(ITEM_ICON_COLUMN, icon_tooltip) fingerprint_column = DEFAULT_COLUMNS.pos('~fingerprint') fingerprint_icon, fingerprint_tooltip = FileItem.decide_fingerprint_icon_info(file) self.setToolTip(fingerprint_column, fingerprint_tooltip) self.setIcon(fingerprint_column, fingerprint_icon) color = FileItem.file_colors[file.state] bgcolor = get_match_color(file.similarity, TreeItem.base_color) self.update_colums_text(color=color, bgcolor=bgcolor) if update_selection and self.isSelected(): TreeItem.window.update_selection(new_selection=False) parent = self.parent() if isinstance(parent, TrackItem) and update_track: parent.update(update_files=False, update_selection=update_selection) @staticmethod def decide_file_icon_info(file): tooltip = "" if file.state == File.ERROR: if file.error_type == FileErrorType.NOTFOUND: icon = FileItem.icon_error_not_found tooltip = _("File not found") elif file.error_type == FileErrorType.NOACCESS: icon = FileItem.icon_error_no_access tooltip = _("File permission error") else: icon = FileItem.icon_error tooltip = _("Processing error(s): See the Errors tab in the File Info dialog") elif isinstance(file.parent_item, Track): if file.state == File.NORMAL: icon = FileItem.icon_saved tooltip = _("Track saved") elif file.state == File.PENDING: index = FileItem._match_icon_index(file.similarity) icon = FileItem.match_pending_icons[index] tooltip = _("Pending") else: index = FileItem._match_icon_index(file.similarity) icon = FileItem.match_icons[index] tooltip = _(FileItem.match_icons_info[index]) elif file.state == File.PENDING: icon = FileItem.icon_file_pending tooltip = _("Pending") else: icon = FileItem.icon_file return (icon, tooltip) def _match_icon_index(similarity): return int(similarity * 5 + 0.5) @staticmethod def decide_fingerprint_icon_info(file): if getattr(file, 'acoustid_fingerprint', None): tagger = QtCore.QCoreApplication.instance() if tagger.acoustidmanager.is_submitted(file): icon = FileItem.icon_fingerprint_gray tooltip = _("Fingerprint has already been submitted") else: icon = FileItem.icon_fingerprint tooltip = _("Unsubmitted fingerprint") else: icon = QtGui.QIcon() tooltip = _('No fingerprint was calculated for this file, use "Scan" or "Generate AcoustID Fingerprints" to calculate the fingerprint.') return (icon, tooltip)
25,110
Python
.py
544
35.911765
148
0.626307
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,089
columns.py
metabrainz_picard/picard/ui/itemviews/columns.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011-2012 Lukáš Lalinský # Copyright (C) 2007 Robert Kaye # Copyright (C) 2008 Gary van der Merwe # Copyright (C) 2008 Hendrik van Antwerpen # Copyright (C) 2008-2011, 2014-2015, 2018-2024 Philipp Wolfer # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009 Nikolai Prokoschenko # Copyright (C) 2011 Tim Blechmann # Copyright (C) 2011-2012 Chad Wilson # Copyright (C) 2011-2013 Michael Wiencek # Copyright (C) 2012 Your Name # Copyright (C) 2012-2013 Wieland Hoffmann # Copyright (C) 2013-2014, 2016, 2018-2024 Laurent Monin # Copyright (C) 2013-2014, 2017, 2020 Sophist-UK # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016 Simon Legner # Copyright (C) 2016 Suhas # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2020-2021 Gabriel Ferreira # Copyright (C) 2021 Bob Swift # Copyright (C) 2021 Louis Sautier # Copyright (C) 2021 Petit Minion # Copyright (C) 2023 certuna # Copyright (C) 2024 Suryansh Shakya # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from collections.abc import MutableSequence from enum import IntEnum from PyQt6 import QtCore from picard.i18n import N_ from picard.util import icontheme class ColumnAlign(IntEnum): LEFT = 0 RIGHT = 1 def __repr__(self): cls_name = self.__class__.__name__ return f'{cls_name}.{self.name}' class ColumnSortType(IntEnum): TEXT = 0 NAT = 1 SORTKEY = 2 # special case, use sortkey property def __repr__(self): cls_name = self.__class__.__name__ return f'{cls_name}.{self.name}' class Column: is_icon = False is_default = False def __init__(self, title, key, size=None, align=ColumnAlign.LEFT, sort_type=ColumnSortType.TEXT, sortkey=None): self.title = title self.key = key self.size = size self.align = align self.sort_type = sort_type if self.sort_type == ColumnSortType.SORTKEY: if not callable(sortkey): raise TypeError("sortkey should be a callable") self.sortkey = sortkey else: self.sortkey = None def __repr__(self): def parms(): yield from (repr(getattr(self, a)) for a in ('title', 'key')) yield from (a + '=' + repr(getattr(self, a)) for a in ('size', 'align', 'sort_type', 'sortkey')) return 'Column(' + ', '.join(parms()) + ')' def __str__(self): return repr(self) class DefaultColumn(Column): is_default = True class IconColumn(Column): is_icon = True _header_icon = None header_icon_func = None header_icon_size = QtCore.QSize(0, 0) header_icon_border = 0 header_icon_size_with_border = QtCore.QSize(0, 0) @property def header_icon(self): # icon cannot be set before QApplication is created # so create it during runtime and cache it # Avoid error: QPixmap: Must construct a QGuiApplication before a QPixmap if self._header_icon is None: self._header_icon = self.header_icon_func() return self._header_icon def set_header_icon_size(self, width, height, border): self.header_icon_size = QtCore.QSize(width, height) self.header_icon_border = border self.header_icon_size_with_border = QtCore.QSize(width + 2*border, height + 2*border) def paint_icon(self, painter, rect): icon = self.header_icon if not icon: return h = self.header_icon_size.height() w = self.header_icon_size.width() border = self.header_icon_border padding_v = (rect.height() - h) // 2 target_rect = QtCore.QRect( rect.x() + border, rect.y() + padding_v, w, h ) painter.drawPixmap(target_rect, icon.pixmap(self.header_icon_size)) class Columns(MutableSequence): def __init__(self, iterable=None): self._list = list() self._index = dict() self._index_dirty = True if iterable is not None: for e in iterable: self.append(e) def __len__(self): return len(self._list) def __delitem__(self, index): self._index_dirty = True self._list.__delitem__(index) def insert(self, index, column): if not isinstance(column, Column): raise TypeError("Not an instance of Column") self._list.insert(index, column) self._index_dirty = True def __setitem__(self, index, column): if not isinstance(column, Column): raise TypeError("Not an instance of Column") self._list.__setitem__(index, column) self._index_dirty = True def __getitem__(self, index): return self._list.__getitem__(index) def pos(self, key): if self._index_dirty: self._index = {c.key: i for i, c in enumerate(self._list)} self._index_dirty = False return self._index[key] def __repr__(self): return "Columns([\n" + "".join(" %r,\n" % e for e in self._list) + '])' def __str__(self): return repr(self) def _sortkey_length(obj): return obj.metadata.length or 0 def _sortkey_filesize(obj): try: return int(obj.metadata['~filesize'] or obj.orig_metadata['~filesize']) except ValueError: return 0 _fingerprint_column = IconColumn(N_("Fingerprint status"), '~fingerprint') _fingerprint_column.header_icon_func = lambda: icontheme.lookup('fingerprint-gray', icontheme.ICON_SIZE_MENU) _fingerprint_column.set_header_icon_size(16, 16, 1) DEFAULT_COLUMNS = Columns(( DefaultColumn(N_("Title"), 'title', sort_type=ColumnSortType.NAT, size=250), DefaultColumn(N_("Length"), '~length', align=ColumnAlign.RIGHT, sort_type=ColumnSortType.SORTKEY, sortkey=_sortkey_length, size=50), DefaultColumn(N_("Artist"), 'artist', size=200), Column(N_("Album Artist"), 'albumartist'), Column(N_("Composer"), 'composer'), Column(N_("Album"), 'album', sort_type=ColumnSortType.NAT), Column(N_("Disc Subtitle"), 'discsubtitle', sort_type=ColumnSortType.NAT), Column(N_("Track No."), 'tracknumber', align=ColumnAlign.RIGHT, sort_type=ColumnSortType.NAT), Column(N_("Disc No."), 'discnumber', align=ColumnAlign.RIGHT, sort_type=ColumnSortType.NAT), Column(N_("Catalog No."), 'catalognumber', sort_type=ColumnSortType.NAT), Column(N_("Barcode"), 'barcode'), Column(N_("Media"), 'media'), Column(N_("Size"), '~filesize', align=ColumnAlign.RIGHT, sort_type=ColumnSortType.SORTKEY, sortkey=_sortkey_filesize), Column(N_("Genre"), 'genre'), _fingerprint_column, Column(N_("Date"), 'date'), Column(N_("Original Release Date"), 'originaldate'), Column(N_("Release Date"), 'releasedate'), Column(N_("Cover"), 'covercount'), Column(N_("Cover Dimensions"), 'coverdimensions') )) ITEM_ICON_COLUMN = DEFAULT_COLUMNS.pos('title')
7,660
Python
.py
184
35.880435
136
0.661642
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,090
track.py
metabrainz_picard/picard/ui/searchdialog/track.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2018 Antonio Larrosa # Copyright (C) 2018-2021, 2023-2024 Laurent Monin # Copyright (C) 2018-2022 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.file import FILE_COMPARISON_WEIGHTS from picard.i18n import gettext as _ from picard.mbjson import ( countries_from_node, recording_to_metadata, release_group_to_metadata, release_to_metadata, ) from picard.metadata import Metadata from picard.track import Track from picard.util import ( countries_shortlist, sort_by_similarity, ) from picard.webservice.api_helpers import build_lucene_query from picard.ui.searchdialog import ( Retry, SearchDialog, ) class TrackSearchDialog(SearchDialog): dialog_header_state = 'tracksearchdialog_header_state' def __init__(self, parent, force_advanced_search=None): super().__init__( parent, accept_button_title=_("Load into Picard"), search_type='track', force_advanced_search=force_advanced_search) self.file_ = None self.setWindowTitle(_("Track Search Results")) self.columns = [ ('name', _("Name")), ('length', _("Length")), ('artist', _("Artist")), ('release', _("Release")), ('date', _("Date")), ('country', _("Country")), ('type', _("Type")), ('score', _("Score")), ] def search(self, text): """Perform search using query provided by the user.""" self.retry_params = Retry(self.search, text) self.search_box_text(text) self.show_progress() config = get_config() self.tagger.mb_api.find_tracks(self.handle_reply, query=text, search=True, advanced_search=self.use_advanced_search, limit=config.setting['query_limit']) def show_similar_tracks(self, file_): """Perform search using existing metadata information from the file as query.""" self.file_ = file_ metadata = file_.orig_metadata query = { 'track': metadata['title'], 'artist': metadata['artist'], 'release': metadata['album'], 'tnum': metadata['tracknumber'], 'tracks': metadata['totaltracks'], 'qdur': str(metadata.length // 2000), 'isrc': metadata['isrc'], } # If advanced query syntax setting is enabled by user, query in # advanced syntax style. Otherwise query only track title. if self.use_advanced_search: query_str = build_lucene_query(query) else: query_str = query['track'] self.search(query_str) def retry(self): self.retry_params.function(self.retry_params.query) def handle_reply(self, document, http, error): if error: self.network_error(http, error) return try: tracks = document['recordings'] except (KeyError, TypeError): self.no_results_found() return if self.file_: metadata = self.file_.orig_metadata candidates = ( metadata.compare_to_track(track, FILE_COMPARISON_WEIGHTS) for track in tracks ) tracks = (result.track for result in sort_by_similarity(candidates)) del self.search_results[:] # Clear existing data self.parse_tracks(tracks) self.display_results() def display_results(self): self.prepare_table() for row, obj in enumerate(self.search_results): track = obj[0] self.table.insertRow(row) self.set_table_item(row, 'name', track, 'title') self.set_table_item(row, 'length', track, '~length', sortkey=track.length) self.set_table_item(row, 'artist', track, 'artist') self.set_table_item(row, 'release', track, 'album') self.set_table_item(row, 'date', track, 'date') self.set_table_item(row, 'country', track, 'country') self.set_table_item(row, 'type', track, 'releasetype') self.set_table_item(row, 'score', track, 'score') self.show_table(sort_column='score') def parse_tracks(self, tracks): for node in tracks: if 'releases' in node: for rel_node in node['releases']: track = Metadata() recording_to_metadata(node, track) track['score'] = node['score'] release_to_metadata(rel_node, track) rg_node = rel_node['release-group'] release_group_to_metadata(rg_node, track) countries = countries_from_node(rel_node) if countries: track['country'] = countries_shortlist(countries) self.search_results.append((track, node)) else: # This handles the case when no release is associated with a track # i.e. the track is an NAT track = Metadata() recording_to_metadata(node, track) track['score'] = node['score'] track["album"] = _("Standalone Recording") self.search_results.append((track, node)) def accept_event(self, rows): for row in rows: self.load_selection(row) def _load_selection_non_nat(self, track, node): recording_id = track['musicbrainz_recordingid'] album_id = track['musicbrainz_albumid'] releasegroup_id = track['musicbrainz_releasegroupid'] file = self.file_ self.tagger.get_release_group_by_id(releasegroup_id).loaded_albums.add(album_id) if file: # Search is performed for a file. if isinstance(file.parent_item, Track): # Have to move that file from its existing album to the new one. album = file.parent_item.album self.tagger.move_file_to_track(file, album_id, recording_id) if album.get_num_total_files() == 0: # Remove album if it has no more files associated self.tagger.remove_album(album) else: # No parent album self.tagger.move_file_to_track(file, album_id, recording_id) else: # No files associated. Just a normal search. self.tagger.load_album(album_id) def _load_selection_nat(self, track, node): recording_id = track['musicbrainz_recordingid'] file = self.file_ if file: # Search is performed for a file. if getattr(file.parent_item, 'album', None): # Have to move that file from its existing album to NAT. album = file.parent_item.album self.tagger.move_file_to_nat(file, recording_id, node) if album.get_num_total_files() == 0: self.tagger.remove_album(album) else: # No parent album self.tagger.move_file_to_nat(file, recording_id, node) else: # No files associated. Just a normal search self.tagger.load_nat(recording_id, node) def load_selection(self, row): """Load the album corresponding to the selected track. If the search is performed for a file, also associate the file to corresponding track in the album. """ track, node = self.search_results[row] if track.get('musicbrainz_albumid'): # The track is not an NAT self._load_selection_non_nat(track, node) else: # Track is a Non Album Track (NAT) self._load_selection_nat(track, node)
8,808
Python
.py
204
32.45098
88
0.589044
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,091
album.py
metabrainz_picard/picard/ui/searchdialog/album.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2018-2022 Philipp Wolfer # Copyright (C) 2018-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from PyQt6.QtCore import pyqtSignal from picard import log from picard.config import get_config from picard.const import CAA_URL from picard.i18n import gettext as _ from picard.mbjson import ( countries_from_node, media_formats_from_node, release_group_to_metadata, release_to_metadata, ) from picard.metadata import Metadata from picard.util import countries_shortlist from picard.webservice.api_helpers import build_lucene_query from picard.ui.searchdialog import ( Retry, SearchDialog, ) class CoverWidget(QtWidgets.QWidget): shown = pyqtSignal() def __init__(self, width=100, height=100, parent=None): super().__init__(parent=parent) self.layout = QtWidgets.QVBoxLayout(self) self.destroyed.connect(self.invalidate) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) self.loading_gif_label = QtWidgets.QLabel(self) self.loading_gif_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) loading_gif = QtGui.QMovie(":/images/loader.gif") self.loading_gif_label.setMovie(loading_gif) loading_gif.start() self.layout.addWidget(self.loading_gif_label) self.__sizehint = self.__size = QtCore.QSize(width, height) self.setStyleSheet("padding: 0") def set_pixmap(self, pixmap): if not self.layout: return wid = self.layout.takeAt(0) if wid: wid.widget().deleteLater() cover_label = QtWidgets.QLabel(self) pixmap = pixmap.scaled(self.__size, QtCore.Qt.AspectRatioMode.KeepAspectRatio, QtCore.Qt.TransformationMode.SmoothTransformation) self.__sizehint = pixmap.size() cover_label.setPixmap(pixmap) self.layout.addWidget(cover_label) def not_found(self): """Update the widget with a blank image.""" shadow = QtGui.QPixmap(":/images/CoverArtShadow.png") self.set_pixmap(shadow) def sizeHint(self): return self.__sizehint def showEvent(self, event): super().showEvent(event) self.shown.emit() def invalidate(self): self.layout = None class CoverCell: def __init__(self, table, release, row, column, on_show=None): self.release = release self.fetched = False self.fetch_task = None self.widget = widget = CoverWidget(parent=table) self.widget.destroyed.connect(self.invalidate) if on_show is not None: widget.shown.connect(partial(on_show, self)) table.setCellWidget(row, column, widget) def is_visible(self): if self.widget: return not self.widget.visibleRegion().isEmpty() else: return False def set_pixmap(self, pixmap): if self.widget: self.widget.set_pixmap(pixmap) def not_found(self): if self.widget: self.widget.not_found() def invalidate(self): if self.widget: self.widget = None class AlbumSearchDialog(SearchDialog): dialog_header_state = 'albumsearchdialog_header_state' def __init__(self, parent, force_advanced_search=None, existing_album=None): super().__init__( parent, accept_button_title=_("Load into Picard"), search_type='album', force_advanced_search=force_advanced_search) self.cluster = None self.existing_album = existing_album self.setWindowTitle(_("Album Search Results")) self.columns = [ ('name', _("Name")), ('artist', _("Artist")), ('format', _("Format")), ('tracks', _("Tracks")), ('date', _("Date")), ('country', _("Country")), ('labels', _("Labels")), ('catnums', _("Catalog #s")), ('barcode', _("Barcode")), ('language', _("Language")), ('type', _("Type")), ('status', _("Status")), ('cover', _("Cover")), ('score', _("Score")), ] self.cover_cells = [] self.fetching = False self.scrolled.connect(self.fetch_coverarts) self.resized.connect(self.fetch_coverarts) @staticmethod def show_releasegroup_search(releasegroup_id, existing_album=None): tagger = QtCore.QCoreApplication.instance() dialog = AlbumSearchDialog( tagger.window, force_advanced_search=True, existing_album=existing_album) dialog.search("rgid:{0}".format(releasegroup_id)) dialog.exec() return dialog def search(self, text): """Perform search using query provided by the user.""" self.retry_params = Retry(self.search, text) self.search_box_text(text) self.show_progress() config = get_config() self.tagger.mb_api.find_releases(self.handle_reply, query=text, search=True, advanced_search=self.use_advanced_search, limit=config.setting['query_limit']) def show_similar_albums(self, cluster): """Perform search by using existing metadata information from the cluster as query.""" self.cluster = cluster metadata = cluster.metadata query = { "artist": metadata["albumartist"], "release": metadata["album"], "tracks": str(len(cluster.files)) } # If advanced query syntax setting is enabled by user, query in # advanced syntax style. Otherwise query only album title. if self.use_advanced_search: query_str = build_lucene_query(query) else: query_str = query['release'] self.search(query_str) def retry(self): self.retry_params.function(self.retry_params.query) def handle_reply(self, document, http, error): if error: self.network_error(http, error) return try: releases = document['releases'] except (KeyError, TypeError): self.no_results_found() return del self.search_results[:] self.parse_releases(releases) self.display_results() self.fetch_coverarts() def fetch_coverarts(self): if self.fetching: return self.fetching = True for cell in self.cover_cells: self.fetch_coverart(cell) self.fetching = False def fetch_coverart(self, cell): """Queue cover art jsons from CAA server for each album in search results. """ if cell.fetched: return if not cell.is_visible(): return cell.fetched = True mbid = cell.release['musicbrainz_albumid'] cell.fetch_task = self.tagger.webservice.get_url( url=f'{CAA_URL}/release/{mbid}', handler=partial(self._caa_json_downloaded, cell), ) def _caa_json_downloaded(self, cover_cell, data, http, error): """Handle json reply from CAA server. If server replies without error, try to get small thumbnail of front coverart of the release. """ cover_cell.fetch_task = None if error: cover_cell.not_found() return front = None try: for image in data['images']: if image['front']: front = image break if front: cover_cell.fetch_task = self.tagger.webservice.download_url( url=front['thumbnails']['small'], handler=partial(self._cover_downloaded, cover_cell) ) else: cover_cell.not_found() except (AttributeError, KeyError, TypeError): log.error("Error reading CAA response", exc_info=True) cover_cell.not_found() def _cover_downloaded(self, cover_cell, data, http, error): """Handle cover art query reply from CAA server. If server returns the cover image successfully, update the cover art cell of particular release. Args: row -- Album's row in results table """ cover_cell.fetch_task = None if error: cover_cell.not_found() else: pixmap = QtGui.QPixmap() try: pixmap.loadFromData(data) cover_cell.set_pixmap(pixmap) except Exception as e: cover_cell.not_found() log.error(e) def fetch_cleanup(self): for cell in self.cover_cells: if cell.fetch_task is not None: log.debug("Removing cover art fetch task for %s", cell.release['musicbrainz_albumid']) self.tagger.webservice.remove_task(cell.fetch_task) def closeEvent(self, event): if self.cover_cells: self.fetch_cleanup() super().closeEvent(event) def parse_releases(self, releases): for node in releases: release = Metadata() release_to_metadata(node, release) release['score'] = node['score'] rg_node = node['release-group'] release_group_to_metadata(rg_node, release) if 'media' in node: media = node['media'] release['format'] = media_formats_from_node(media) release['tracks'] = node['track-count'] countries = countries_from_node(node) if countries: release['country'] = countries_shortlist(countries) self.search_results.append(release) def display_results(self): self.prepare_table() self.cover_cells = [] column = self.colpos('cover') for row, release in enumerate(self.search_results): self.table.insertRow(row) self.set_table_item(row, 'name', release, 'album') self.set_table_item(row, 'artist', release, 'albumartist') self.set_table_item(row, 'format', release, 'format') self.set_table_item(row, 'tracks', release, 'tracks') self.set_table_item(row, 'date', release, 'date') self.set_table_item(row, 'country', release, 'country') self.set_table_item(row, 'labels', release, 'label') self.set_table_item(row, 'catnums', release, 'catalognumber') self.set_table_item(row, 'barcode', release, 'barcode') self.set_table_item(row, 'language', release, '~releaselanguage') self.set_table_item(row, 'type', release, 'releasetype') self.set_table_item(row, 'status', release, 'releasestatus') self.set_table_item(row, 'score', release, 'score') self.cover_cells.append(CoverCell(self.table, release, row, column, on_show=self.fetch_coverart)) if self.existing_album and release['musicbrainz_albumid'] == self.existing_album.id: self.highlight_row(row) self.show_table(sort_column='score') def accept_event(self, rows): for row in rows: self.load_selection(row) def load_selection(self, row): release = self.search_results[row] release_mbid = release['musicbrainz_albumid'] if self.existing_album: self.existing_album.switch_release_version(release_mbid) else: self.tagger.get_release_group_by_id( release['musicbrainz_releasegroupid']).loaded_albums.add( release_mbid) album = self.tagger.load_album(release_mbid) if self.cluster: files = self.cluster.iterfiles() self.tagger.move_files_to_album(files, release_mbid, album)
13,113
Python
.py
321
30.757009
96
0.599655
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,092
artist.py
metabrainz_picard/picard/ui/searchdialog/artist.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2018, 2020-2021, 2023-2024 Laurent Monin # Copyright (C) 2018-2022 Philipp Wolfer # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from picard.config import get_config from picard.i18n import gettext as _ from picard.mbjson import artist_to_metadata from picard.metadata import Metadata from picard.ui.searchdialog import ( Retry, SearchDialog, ) class ArtistSearchDialog(SearchDialog): dialog_header_state = 'artistsearchdialog_header_state' def __init__(self, parent): super().__init__( parent, accept_button_title=_("Show in browser"), search_type='artist') self.setWindowTitle(_("Artist Search Dialog")) self.columns = [ ('name', _("Name")), ('type', _("Type")), ('gender', _("Gender")), ('area', _("Area")), ('begindate', _("Begin")), ('beginarea', _("Begin Area")), ('enddate', _("End")), ('endarea', _("End Area")), ('score', _("Score")), ] def search(self, text): self.retry_params = Retry(self.search, text) self.search_box_text(text) self.show_progress() config = get_config() self.tagger.mb_api.find_artists(self.handle_reply, query=text, search=True, advanced_search=self.use_advanced_search, limit=config.setting['query_limit']) def retry(self): self.retry_params.function(self.retry_params.query) def handle_reply(self, document, http, error): if error: self.network_error(http, error) return try: artists = document['artists'] except (KeyError, TypeError): self.no_results() return del self.search_results[:] self.parse_artists(artists) self.display_results() def parse_artists(self, artists): for node in artists: artist = Metadata() artist_to_metadata(node, artist) artist['score'] = node['score'] self.search_results.append(artist) def display_results(self): self.prepare_table() for row, artist in enumerate(self.search_results): self.table.insertRow(row) self.set_table_item(row, 'name', artist, 'name') self.set_table_item(row, 'type', artist, 'type') self.set_table_item(row, 'gender', artist, 'gender') self.set_table_item(row, 'area', artist, 'area') self.set_table_item(row, 'begindate', artist, 'begindate') self.set_table_item(row, 'beginarea', artist, 'beginarea') self.set_table_item(row, 'enddate', artist, 'enddate') self.set_table_item(row, 'endarea', artist, 'endarea') self.set_table_item(row, 'score', artist, 'score') self.show_table(sort_column='score') def accept_event(self, rows): for row in rows: self.load_in_browser(row) def load_in_browser(self, row): self.tagger.search(self.search_results[row]['musicbrainz_artistid'], 'artist')
4,110
Python
.py
97
33.329897
86
0.597448
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,093
__init__.py
metabrainz_picard/picard/ui/searchdialog/__init__.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2018-2023 Philipp Wolfer # Copyright (C) 2018-2024 Laurent Monin # Copyright (C) 2020 Ray Bouchard # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from collections import namedtuple from PyQt6 import ( QtCore, QtGui, QtNetwork, QtWidgets, ) from picard.config import get_config from picard.i18n import gettext as _ from picard.util import ( icontheme, restore_method, ) from picard.ui.tablebaseddialog import TableBasedDialog from picard.ui.util import StandardButton class SearchBox(QtWidgets.QWidget): def __init__(self, force_advanced_search=None, parent=None): super().__init__(parent=parent) self.search_action = QtGui.QAction(icontheme.lookup('system-search'), _("Search"), self) self.search_action.setEnabled(False) self.search_action.triggered.connect(self.search) if force_advanced_search is None: config = get_config() self.force_advanced_search = False self.use_advanced_search = config.setting['use_adv_search_syntax'] else: self.force_advanced_search = True self.use_advanced_search = force_advanced_search self.setupUi() def focus_in_event(self, event): # When focus is on search edit box, need to disable # dialog's accept button. This would avoid closing of dialog when user # hits enter. parent = self.parent() if parent.table: parent.table.clearSelection() parent.accept_button.setEnabled(False) def setupUi(self): self.layout = QtWidgets.QVBoxLayout(self) self.search_row_widget = QtWidgets.QWidget(self) self.search_row_layout = QtWidgets.QHBoxLayout(self.search_row_widget) self.search_row_layout.setContentsMargins(1, 1, 1, 1) self.search_row_layout.setSpacing(1) self.search_edit = QtWidgets.QLineEdit(self.search_row_widget) self.search_edit.setClearButtonEnabled(True) self.search_edit.returnPressed.connect(self.trigger_search_action) self.search_edit.textChanged.connect(self.enable_search) self.search_edit.setFocusPolicy(QtCore.Qt.FocusPolicy.StrongFocus) self.search_edit.focusInEvent = self.focus_in_event self.search_row_layout.addWidget(self.search_edit) self.search_button = QtWidgets.QToolButton(self.search_row_widget) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.search_action) self.search_button.setIconSize(QtCore.QSize(22, 22)) self.search_row_layout.addWidget(self.search_button) self.search_row_widget.setLayout(self.search_row_layout) self.layout.addWidget(self.search_row_widget) self.adv_opt_row_widget = QtWidgets.QWidget(self) self.adv_opt_row_layout = QtWidgets.QHBoxLayout(self.adv_opt_row_widget) self.adv_opt_row_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft) self.adv_opt_row_layout.setContentsMargins(1, 1, 1, 1) self.adv_opt_row_layout.setSpacing(1) self.use_adv_search_syntax = QtWidgets.QCheckBox(self.adv_opt_row_widget) self.use_adv_search_syntax.setText(_("Use advanced query syntax")) self.use_adv_search_syntax.setChecked(self.use_advanced_search) self.use_adv_search_syntax.stateChanged.connect(self.update_advanced_syntax_setting) self.adv_opt_row_layout.addWidget(self.use_adv_search_syntax) self.adv_syntax_help = QtWidgets.QLabel(self.adv_opt_row_widget) self.adv_syntax_help.setOpenExternalLinks(True) self.adv_syntax_help.setText(_( "&#160;(<a href='https://musicbrainz.org/doc/Indexed_Search_Syntax'>" "Syntax Help</a>)")) self.adv_opt_row_layout.addWidget(self.adv_syntax_help) self.adv_opt_row_widget.setLayout(self.adv_opt_row_layout) self.layout.addWidget(self.adv_opt_row_widget) self.layout.setContentsMargins(1, 1, 1, 1) self.layout.setSpacing(1) self.setMaximumHeight(60) def search(self): self.parent().search(self.query) def restore_checkbox_state(self): self.use_adv_search_syntax.setChecked(self.use_advanced_search) def update_advanced_syntax_setting(self): self.use_advanced_search = self.use_adv_search_syntax.isChecked() if not self.force_advanced_search: config = get_config() config.setting['use_adv_search_syntax'] = self.use_advanced_search def enable_search(self): if self.query: self.search_action.setEnabled(True) else: self.search_action.setEnabled(False) def trigger_search_action(self): if self.search_action.isEnabled(): self.search_action.trigger() def get_query(self): return self.search_edit.text() def set_query(self, query): return self.search_edit.setText(query) query = property(get_query, set_query) Retry = namedtuple('Retry', ['function', 'query']) class SearchDialog(TableBasedDialog): accept_button_title = "" def __init__(self, parent, accept_button_title, show_search=True, search_type=None, force_advanced_search=None): self.accept_button_title = accept_button_title self.search_results = [] self.show_search = show_search self.search_type = search_type self.force_advanced_search = force_advanced_search self.search_box = None super().__init__(parent) @property def use_advanced_search(self): if self.show_search: return self.search_box.use_advanced_search elif self.force_advanced_search is not None: return self.force_advanced_search else: config = get_config() return config.setting['use_adv_search_syntax'] def get_value_for_row_id(self, row, value): return row def setupUi(self): self.verticalLayout = QtWidgets.QVBoxLayout(self) self.verticalLayout.setObjectName('vertical_layout') if self.show_search: self.search_box = SearchBox(force_advanced_search=self.force_advanced_search, parent=self) self.search_box.setObjectName('search_box') self.verticalLayout.addWidget(self.search_box) self.center_widget = QtWidgets.QWidget(self) self.center_widget.setObjectName('center_widget') self.center_layout = QtWidgets.QVBoxLayout(self.center_widget) self.center_layout.setObjectName('center_layout') self.center_layout.setContentsMargins(1, 1, 1, 1) self.center_widget.setLayout(self.center_layout) self.verticalLayout.addWidget(self.center_widget) self.buttonBox = QtWidgets.QDialogButtonBox(self) if self.show_search and self.search_type: self.search_browser_button = QtWidgets.QPushButton( _("Search in browser"), self.buttonBox) self.buttonBox.addButton( self.search_browser_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole) self.search_browser_button.clicked.connect(self.search_browser) self.accept_button = QtWidgets.QPushButton( self.accept_button_title, self.buttonBox) self.accept_button.setEnabled(False) self.buttonBox.addButton( self.accept_button, QtWidgets.QDialogButtonBox.ButtonRole.AcceptRole) self.buttonBox.addButton( StandardButton(StandardButton.CANCEL), QtWidgets.QDialogButtonBox.ButtonRole.RejectRole) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.verticalLayout.addWidget(self.buttonBox) def show_progress(self): progress_widget = QtWidgets.QWidget(self) progress_widget.setObjectName('progress_widget') layout = QtWidgets.QVBoxLayout(progress_widget) text_label = QtWidgets.QLabel(_('<strong>Loading…</strong>'), progress_widget) text_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter | QtCore.Qt.AlignmentFlag.AlignBottom) gif_label = QtWidgets.QLabel(progress_widget) movie = QtGui.QMovie(":/images/loader.gif") gif_label.setMovie(movie) movie.start() gif_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter | QtCore.Qt.AlignmentFlag.AlignTop) layout.addWidget(text_label) layout.addWidget(gif_label) layout.setContentsMargins(1, 1, 1, 1) progress_widget.setLayout(layout) self.add_widget_to_center_layout(progress_widget) def show_error(self, error, show_retry_button=False): """Display the error string. Args: error -- Error string show_retry_button -- Whether to display retry button or not """ error_widget = QtWidgets.QWidget(self) error_widget.setObjectName('error_widget') layout = QtWidgets.QVBoxLayout(error_widget) error_label = QtWidgets.QLabel(error, error_widget) error_label.setWordWrap(True) error_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) error_label.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.TextSelectableByMouse) layout.addWidget(error_label) if show_retry_button: retry_widget = QtWidgets.QWidget(error_widget) retry_layout = QtWidgets.QHBoxLayout(retry_widget) retry_button = QtWidgets.QPushButton(_("Retry"), error_widget) retry_button.clicked.connect(self.retry) retry_button.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Maximum, QtWidgets.QSizePolicy.Policy.Fixed)) retry_layout.addWidget(retry_button) retry_layout.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter | QtCore.Qt.AlignmentFlag.AlignTop) retry_widget.setLayout(retry_layout) layout.addWidget(retry_widget) error_widget.setLayout(layout) self.add_widget_to_center_layout(error_widget) def network_error(self, reply, error): params = { 'url': reply.request().url().toString(QtCore.QUrl.UrlFormattingOption.RemoveUserInfo), 'error': reply.errorString(), 'qtcode': error, 'statuscode': reply.attribute( QtNetwork.QNetworkRequest.Attribute.HttpStatusCodeAttribute) } error_msg = _("<strong>Following error occurred while fetching results:<br><br></strong>" "Network request error for %(url)s:<br>%(error)s (QT code %(qtcode)d, HTTP code %(statuscode)r)<br>") % params self.show_error(error_msg, show_retry_button=True) def no_results_found(self): error_msg = _("<strong>No results found. Please try a different search query.</strong>") self.show_error(error_msg) def search_browser(self): self.tagger.search(self.search_box.query, self.search_type, adv=self.use_advanced_search, force_browser=True) @restore_method def restore_state(self): super().restore_state() if self.show_search: self.search_box.restore_checkbox_state() def search_box_text(self, text): if self.search_box: self.search_box.query = text
12,129
Python
.py
246
40.764228
135
0.688328
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,094
__init__.py
metabrainz_picard/picard/ui/mainwindow/__init__.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011-2012, 2014 Lukáš Lalinský # Copyright (C) 2007 Nikolai Prokoschenko # Copyright (C) 2008 Gary van der Merwe # Copyright (C) 2008 Robert Kaye # Copyright (C) 2008 Will # Copyright (C) 2008-2010, 2015, 2018-2023 Philipp Wolfer # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009 David Hilton # Copyright (C) 2011-2012 Chad Wilson # Copyright (C) 2011-2013, 2015-2017 Wieland Hoffmann # Copyright (C) 2011-2014 Michael Wiencek # Copyright (C) 2013-2014, 2017 Sophist-UK # Copyright (C) 2013-2023 Laurent Monin # Copyright (C) 2015 Ohm Patel # Copyright (C) 2015 samithaj # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016 Simon Legner # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017 Antonio Larrosa # Copyright (C) 2017 Frederik “Freso” S. Olesen # Copyright (C) 2018 Kartik Ohri # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2018 virusMac # Copyright (C) 2018, 2021-2023 Bob Swift # Copyright (C) 2019 Timur Enikeev # Copyright (C) 2020-2021 Gabriel Ferreira # Copyright (C) 2021 Petit Minion # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from copy import deepcopy import datetime from functools import partial import itertools import os.path from PyQt6 import ( QtCore, QtGui, QtWidgets, ) from picard import ( PICARD_APP_ID, log, ) from picard.album import Album from picard.browser import addrelease from picard.cluster import ( Cluster, FileList, ) from picard.config import ( SettingConfigSection, get_config, ) from picard.const import PROGRAM_UPDATE_LEVELS from picard.const.sys import ( IS_MACOS, IS_WIN, ) from picard.extension_points.ui_init import ext_point_ui_init from picard.file import File from picard.formats import supported_formats from picard.i18n import ( N_, gettext as _, ngettext, ) from picard.script import get_file_naming_script_presets from picard.track import Track from picard.util import ( IgnoreUpdatesContext, icontheme, iter_files_from_objects, iter_unique, open_local_path, reconnect, restore_method, thread, throttle, webbrowser2, ) from picard.util.cdrom import ( DISCID_NOT_LOADED_MESSAGE, discid, get_cdrom_drives, ) from picard.ui import PreserveGeometry from picard.ui.aboutdialog import AboutDialog from picard.ui.coverartbox import CoverArtBox from picard.ui.enums import MainAction from picard.ui.filebrowser import FileBrowser from picard.ui.infodialog import ( AlbumInfoDialog, ClusterInfoDialog, FileInfoDialog, TrackInfoDialog, ) from picard.ui.infostatus import InfoStatus from picard.ui.itemviews import ( BaseTreeView, MainPanel, ) from picard.ui.logview import ( HistoryView, LogView, ) from picard.ui.mainwindow.actions import create_actions from picard.ui.metadatabox import MetadataBox from picard.ui.newuserdialog import NewUserDialog from picard.ui.options.dialog import OptionsDialog from picard.ui.passworddialog import ( PasswordDialog, ProxyDialog, ) from picard.ui.pluginupdatedialog import PluginUpdatesDialog from picard.ui.savewarningdialog import SaveWarningDialog from picard.ui.scripteditor import ( ScriptEditorDialog, ScriptEditorExamples, ) from picard.ui.searchdialog.album import AlbumSearchDialog from picard.ui.searchdialog.track import TrackSearchDialog from picard.ui.statusindicator import ( DesktopStatusIndicator, ProgressStatus, ) from picard.ui.tagsfromfilenames import TagsFromFileNamesDialog from picard.ui.util import ( FileDialog, find_starting_directory, menu_builder, ) class MainWindow(QtWidgets.QMainWindow, PreserveGeometry): defaultsize = QtCore.QSize(780, 560) selection_updated = QtCore.pyqtSignal(object) ready_for_display = QtCore.pyqtSignal() def __init__(self, parent=None, disable_player=False): super().__init__(parent=parent) self.actions = {} self.setAttribute(QtCore.Qt.WidgetAttribute.WA_NativeWindow) self.__shown = False self.tagger = QtCore.QCoreApplication.instance() self._is_wayland = self.tagger.is_wayland self.selected_objects = [] self.ignore_selection_changes = IgnoreUpdatesContext(on_exit=self.update_selection) self.suspend_sorting = IgnoreUpdatesContext( on_first_enter=partial(self.set_sorting, sorting=False), on_last_exit=partial(self.set_sorting, sorting=True), ) self.toolbar = None self.player = None self.status_indicators = [] if DesktopStatusIndicator: self.ready_for_display.connect(self._setup_desktop_status_indicator) if not disable_player: from picard.ui.playertoolbar import Player player = Player(self) if player.available: self.player = player self.player.error.connect(self._on_player_error) self.script_editor_dialog = None self.tagger.pluginmanager.updates_available.connect(self.show_plugin_update_dialog) self._check_and_repair_naming_scripts() self._check_and_repair_profiles() self.setupUi() webservice_manager = self.tagger.webservice.manager webservice_manager.authenticationRequired.connect(self._show_password_dialog) webservice_manager.proxyAuthenticationRequired.connect(self._show_proxy_dialog) def setupUi(self): self.setWindowTitle(_("MusicBrainz Picard")) icon = QtGui.QIcon() for size in (16, 24, 32, 48, 128, 256): icon.addFile( ":/images/{size}x{size}/{app_id}.png".format( size=size, app_id=PICARD_APP_ID), QtCore.QSize(size, size) ) self.setWindowIcon(icon) self.show_close_window = IS_MACOS self._create_actions() self._create_statusbar() self._create_toolbar() self._create_menus() if IS_MACOS: self.setUnifiedTitleAndToolBarOnMac(True) main_layout = QtWidgets.QSplitter(QtCore.Qt.Orientation.Vertical) main_layout.setObjectName('main_window_bottom_splitter') main_layout.setChildrenCollapsible(False) main_layout.setContentsMargins(0, 0, 0, 0) self.panel = MainPanel(self, main_layout) self.panel.setObjectName('main_panel_splitter') self.file_browser = FileBrowser(parent=self.panel) if not self.action_is_checked(MainAction.SHOW_FILE_BROWSER): self.file_browser.hide() self.panel.insertWidget(0, self.file_browser) self.log_dialog = LogView(self) self.history_dialog = HistoryView(self) self.metadata_box = MetadataBox(parent=self) self.cover_art_box = CoverArtBox(parent=self) metadata_view_layout = QtWidgets.QHBoxLayout() metadata_view_layout.setContentsMargins(0, 0, 0, 0) metadata_view_layout.setSpacing(0) metadata_view_layout.addWidget(self.metadata_box, 1) metadata_view_layout.addWidget(self.cover_art_box, 0) self.metadata_view = QtWidgets.QWidget() self.metadata_view.setLayout(metadata_view_layout) self.show_metadata_view() self.show_cover_art() main_layout.addWidget(self.panel) main_layout.addWidget(self.metadata_view) self.setCentralWidget(main_layout) # accessibility self.set_tab_order() for function in ext_point_ui_init: function(self) def set_processing(self, processing=True): self.panel.set_processing(processing) def set_sorting(self, sorting=True): self.panel.set_sorting(sorting) def keyPressEvent(self, event): # On macOS Command+Backspace triggers the so called "Forward Delete". # It should be treated the same as the Delete button. is_forward_delete = IS_MACOS and \ event.key() == QtCore.Qt.Key.Key_Backspace and \ event.modifiers() & QtCore.Qt.KeyboardModifier.ControlModifier if event.matches(QtGui.QKeySequence.StandardKey.Delete) or is_forward_delete: if self.metadata_box.hasFocus(): self.metadata_box.remove_selected_tags() else: self.remove_selected_objects() elif event.matches(QtGui.QKeySequence.StandardKey.Find): self.search_edit.setFocus(QtCore.Qt.FocusReason.ShortcutFocusReason) else: super().keyPressEvent(event) def show(self): self.restoreWindowState() super().show() self.show_new_user_dialog() if self.tagger.autoupdate_enabled: self._auto_update_check() self.check_for_plugin_update() self.metadata_box.restore_state() def showEvent(self, event): if not self.__shown: self.ready_for_display.emit() self.__shown = True super().showEvent(event) def closeEvent(self, event): config = get_config() if config.setting['quit_confirmation'] and not self.show_quit_confirmation(): event.ignore() return if self.player: config.persist['mediaplayer_playback_rate'] = self.player.playback_rate() config.persist['mediaplayer_volume'] = self.player.volume() self.saveWindowState() # Confirm loss of unsaved changes in script editor. if self.script_editor_dialog: if not self.script_editor_dialog.unsaved_changes_in_profile_confirmation(): event.ignore() return else: # Silently close the script editor without displaying the confirmation a second time. self.script_editor_dialog.loading = True event.accept() def _setup_desktop_status_indicator(self): if DesktopStatusIndicator: self._register_status_indicator(DesktopStatusIndicator(self.windowHandle())) def _register_status_indicator(self, indicator): self.status_indicators.append(indicator) def show_quit_confirmation(self): unsaved_files = sum(a.get_num_unsaved_files() for a in self.tagger.albums.values()) QMessageBox = QtWidgets.QMessageBox if unsaved_files > 0: msg = QMessageBox(self) msg.setIcon(QMessageBox.Icon.Question) msg.setWindowModality(QtCore.Qt.WindowModality.WindowModal) msg.setWindowTitle(_("Unsaved Changes")) msg.setText(_("Are you sure you want to quit Picard?")) txt = ngettext( "There is %d unsaved file. Closing Picard will lose all unsaved changes.", "There are %d unsaved files. Closing Picard will lose all unsaved changes.", unsaved_files) % unsaved_files msg.setInformativeText(txt) cancel = msg.addButton(QMessageBox.StandardButton.Cancel) msg.setDefaultButton(cancel) msg.addButton(_("&Quit Picard"), QMessageBox.ButtonRole.YesRole) ret = msg.exec() if ret == QMessageBox.StandardButton.Cancel: return False return True def saveWindowState(self): config = get_config() config.persist['window_state'] = self.saveState() is_maximized = bool(self.windowState() & QtCore.Qt.WindowState.WindowMaximized) self.save_geometry() config.persist['window_maximized'] = is_maximized config.persist['view_metadata_view'] = self.action_is_checked(MainAction.SHOW_METADATA_VIEW) config.persist['view_cover_art'] = self.action_is_checked(MainAction.SHOW_COVER_ART) config.persist['view_toolbar'] = self.action_is_checked(MainAction.SHOW_TOOLBAR) config.persist['view_file_browser'] = self.action_is_checked(MainAction.SHOW_FILE_BROWSER) self.file_browser.save_state() self.panel.save_state() self.metadata_box.save_state() @restore_method def restoreWindowState(self): config = get_config() self.restoreState(config.persist['window_state']) self.restore_geometry() if config.persist['window_maximized']: self.setWindowState(QtCore.Qt.WindowState.WindowMaximized) splitters = config.persist['splitters_MainWindow'] if splitters is None or 'main_window_bottom_splitter' not in splitters: self.centralWidget().setSizes([366, 194]) self.file_browser.restore_state() def _create_statusbar(self): """Creates a new status bar.""" self.statusBar().showMessage(_("Ready")) infostatus = InfoStatus(self) self._progress = infostatus.get_progress self.listening_label = QtWidgets.QLabel() self.listening_label.setStyleSheet("QLabel { margin: 0 4px 0 4px; }") self.listening_label.setVisible(False) self.listening_label.setToolTip("<qt/>" + _( "Picard listens on this port to integrate with your browser. When " "you \"Search\" or \"Open in Browser\" from Picard, clicking the " "\"Tagger\" button on the web page loads the release into Picard." )) self.statusBar().addPermanentWidget(infostatus) self.statusBar().addPermanentWidget(self.listening_label) self.tagger.tagger_stats_changed.connect(self._update_statusbar_stats) self.tagger.listen_port_changed.connect(self._update_statusbar_listen_port) self._register_status_indicator(infostatus) self._update_statusbar_stats() @throttle(100) def _update_statusbar_stats(self): """Updates the status bar information.""" progress_status = ProgressStatus( files=len(self.tagger.files), albums=len(self.tagger.albums), pending_files=File.num_pending_files, pending_requests=self.tagger.webservice.num_pending_web_requests, progress=self._progress(), ) for indicator in self.status_indicators: indicator.update(progress_status) def _update_statusbar_listen_port(self, listen_port): if listen_port: self.listening_label.setVisible(True) self.listening_label.setText(_("Listening on port %(port)d") % {"port": listen_port}) else: self.listening_label.setVisible(False) def set_statusbar_message(self, message, *args, **kwargs): """Set the status bar message. *args are passed to % operator, if args[0] is a mapping it is used for named place holders values >>> w.set_statusbar_message("File %(filename)s", {'filename': 'x.txt'}) Keyword arguments: `echo` parameter defaults to `log.debug`, called before message is translated, it can be disabled passing None or replaced by ie. `log.error`. If None, skipped. `translate` is a method called on message before it is sent to history log and status bar, it defaults to `_()`. If None, skipped. `timeout` defines duration of the display in milliseconds `history` is a method called with translated message as argument, it defaults to `log.history_info`. If None, skipped. Empty messages are never passed to echo and history functions but they are sent to status bar (ie. to clear it). """ def isdict(obj): return hasattr(obj, 'keys') and hasattr(obj, '__getitem__') echo = kwargs.get('echo', log.debug) translate = kwargs.get('translate', _) timeout = kwargs.get('timeout', 0) history = kwargs.get('history', log.history_info) if len(args) == 1 and isdict(args[0]): # named place holders mparms = args[0] else: # simple place holders, ensure compatibility mparms = args if message: if echo: echo(message % mparms) if translate: message = translate(message) message = message % mparms if history: history(message) thread.to_main(self.statusBar().showMessage, message, timeout) def _on_submit_acoustid(self): if self.tagger.use_acoustid: config = get_config() if not config.setting['acoustid_apikey']: msg = QtWidgets.QMessageBox(self) msg.setIcon(QtWidgets.QMessageBox.Icon.Information) msg.setWindowModality(QtCore.Qt.WindowModality.WindowModal) msg.setWindowTitle(_("AcoustID submission not configured")) msg.setText(_( "You need to configure your AcoustID API key before you can submit fingerprints.")) open_options = QtWidgets.QPushButton( icontheme.lookup('preferences-desktop'), _("Open AcoustID options")) msg.addButton(QtWidgets.QMessageBox.StandardButton.Cancel) msg.addButton(open_options, QtWidgets.QMessageBox.ButtonRole.YesRole) msg.exec() if msg.clickedButton() == open_options: self.show_options('fingerprinting') else: self.tagger.acoustidmanager.submit() def _create_actions(self): self.actions = dict(create_actions(self)) self._create_cd_lookup_menu() def _create_cd_lookup_menu(self): menu = QtWidgets.QMenu(_("Lookup &CD…")) menu.setIcon(icontheme.lookup('media-optical')) menu.triggered.connect(self.tagger.lookup_cd) self.cd_lookup_menu = menu if discid is None: log.warning("CDROM: discid library not found - Lookup CD functionality disabled") self.enable_action(MainAction.CD_LOOKUP, False) self.cd_lookup_menu.setEnabled(False) else: thread.run_task(get_cdrom_drives, self._update_cd_lookup_actions) def _update_cd_lookup_actions(self, result=None, error=None): if error: log.error("CDROM: Error on CD-ROM drive detection: %r", error) else: self.update_cd_lookup_drives(result) def update_cd_lookup_drives(self, drives): self.cd_lookup_menu.clear() self.enable_action(MainAction.CD_LOOKUP, discid is not None) if not drives: log.warning(DISCID_NOT_LOADED_MESSAGE) else: config = get_config() shortcut_drive = config.setting['cd_lookup_device'].split(",")[0] if len(drives) > 1 else "" for drive in drives: action = self.cd_lookup_menu.addAction(drive) action.setData(drive) if drive == shortcut_drive: self._update_cd_lookup_default_action(action) self._set_cd_lookup_from_file_actions(drives) self._update_cd_lookup_button() def _set_cd_lookup_from_file_actions(self, drives): if self.cd_lookup_menu.actions(): self.cd_lookup_menu.addSeparator() action = self.cd_lookup_menu.addAction(_("From CD ripper &log file…")) if not drives: self._update_cd_lookup_default_action(action) action.setData('logfile:eac') def _update_cd_lookup_default_action(self, action): if action: target = action.trigger else: target = self.tagger.lookup_cd reconnect(self.actions[MainAction.CD_LOOKUP].triggered, target) def _update_cd_lookup_button(self): button = self.toolbar.widgetForAction(self.actions[MainAction.CD_LOOKUP]) enabled = bool(self.cd_lookup_menu.actions() and discid) self.cd_lookup_menu.setEnabled(enabled) if button: if enabled: button.setPopupMode(QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup) button.setMenu(self.cd_lookup_menu) else: button.setMenu(None) def toggle_rename_files(self, checked): config = get_config() config.setting['rename_files'] = checked self._update_script_editor_examples() def toggle_move_files(self, checked): config = get_config() config.setting['move_files'] = checked self._update_script_editor_examples() def toggle_tag_saving(self, checked): config = get_config() config.setting['dont_write_tags'] = not checked def _get_selected_or_unmatched_files(self): if self.selected_objects: files = list(iter_files_from_objects(self.selected_objects)) if files: return files return self.tagger.unclustered_files.files def open_tags_from_filenames(self): files = self._get_selected_or_unmatched_files() if files: dialog = TagsFromFileNamesDialog(files, self) dialog.exec() def open_collection_in_browser(self): self.tagger.collection_lookup() def _create_menus(self): def add_menu(menu_title, *args): menu = self.menuBar().addMenu(menu_title) menu.setSeparatorsCollapsible(True) menu_builder(menu, self.actions, *args) add_menu( _("&File"), MainAction.ADD_DIRECTORY, MainAction.ADD_FILES, MainAction.CLOSE_WINDOW if self.show_close_window else None, '-', MainAction.PLAY_FILE, MainAction.OPEN_FOLDER, '-', MainAction.SAVE, MainAction.SUBMIT_ACOUSTID, '-', MainAction.EXIT, ) add_menu( _("&Edit"), MainAction.CUT, MainAction.PASTE, '-', MainAction.VIEW_INFO, MainAction.REMOVE, ) add_menu( _("&View"), MainAction.SHOW_FILE_BROWSER, MainAction.SHOW_METADATA_VIEW, MainAction.SHOW_COVER_ART, '-', MainAction.SHOW_TOOLBAR, MainAction.SEARCH_TOOLBAR_TOGGLE, MainAction.PLAYER_TOOLBAR_TOGGLE if self.player else None, ) self.script_quick_selector_menu = QtWidgets.QMenu(_("&Select file naming script")) self.script_quick_selector_menu.setIcon(icontheme.lookup('document-open')) self.make_script_selector_menu() self.profile_quick_selector_menu = QtWidgets.QMenu(_("&Enable/disable profiles")) self._make_profile_selector_menu() add_menu( _("&Options"), MainAction.ENABLE_RENAMING, MainAction.ENABLE_MOVING, MainAction.ENABLE_TAG_SAVING, '-', self.script_quick_selector_menu, MainAction.SHOW_SCRIPT_EDITOR, '-', self.profile_quick_selector_menu, '-', MainAction.OPTIONS, ) add_menu( _("&Tools"), MainAction.REFRESH, self.cd_lookup_menu, MainAction.AUTOTAG, MainAction.ANALYZE, MainAction.CLUSTER, MainAction.BROWSER_LOOKUP, MainAction.SIMILAR_ITEMS_SEARCH, MainAction.ALBUM_OTHER_VERSIONS, '-', MainAction.GENERATE_FINGERPRINTS, MainAction.TAGS_FROM_FILENAMES, MainAction.OPEN_COLLECTION_IN_BROWSER, ) self.menuBar().addSeparator() add_menu( _("&Help"), MainAction.HELP, '-', MainAction.VIEW_HISTORY, '-', MainAction.CHECK_UPDATE if self.tagger.autoupdate_enabled else None, '-', MainAction.SUPPORT_FORUM, MainAction.REPORT_BUG, MainAction.VIEW_LOG, '-', MainAction.DONATE, MainAction.ABOUT, ) def update_toolbar_style(self): config = get_config() style = QtCore.Qt.ToolButtonStyle.ToolButtonIconOnly if config.setting['toolbar_show_labels']: style = QtCore.Qt.ToolButtonStyle.ToolButtonTextUnderIcon self.toolbar.setToolButtonStyle(style) if self.player: self.player.toolbar.setToolButtonStyle(style) def _create_toolbar(self): self._create_search_toolbar() if self.player: self._create_player_toolbar() self.create_action_toolbar() self.update_toolbar_style() def create_action_toolbar(self): if self.toolbar: self.toolbar.clear() self.removeToolBar(self.toolbar) self.toolbar = toolbar = QtWidgets.QToolBar(_("Actions")) self.insertToolBar(self.search_toolbar, self.toolbar) toolbar.setObjectName('main_toolbar') if self._is_wayland: toolbar.setFloatable(False) # https://bugreports.qt.io/browse/QTBUG-92191 if IS_MACOS: toolbar.setMovable(False) def add_toolbar_action(action_id): action = self.actions[action_id] toolbar.addAction(action) widget = toolbar.widgetForAction(action) widget.setFocusPolicy(QtCore.Qt.FocusPolicy.TabFocus) widget.setAttribute(QtCore.Qt.WidgetAttribute.WA_MacShowFocusRect) config = get_config() for action_name in config.setting['toolbar_layout']: if action_name in {'-', 'separator'}: toolbar.addSeparator() else: try: action_id = MainAction(action_name) add_toolbar_action(action_id) if action_id == MainAction.CD_LOOKUP: self._update_cd_lookup_button() except (ValueError, KeyError) as e: log.warning("Warning: Unknown action name '%s' found in config. Ignored. %s", action_name, e) self.show_toolbar() def _create_player_toolbar(self): """"Create a toolbar with internal player control elements""" toolbar = self.player.create_toolbar() self.addToolBar(QtCore.Qt.ToolBarArea.BottomToolBarArea, toolbar) if self._is_wayland: toolbar.setFloatable(False) # https://bugreports.qt.io/browse/QTBUG-92191 self.actions[MainAction.PLAYER_TOOLBAR_TOGGLE] = toolbar.toggleViewAction() toolbar.hide() # Hide by default def _create_search_toolbar(self): config = get_config() self.search_toolbar = toolbar = self.addToolBar(_("Search")) self.actions[MainAction.SEARCH_TOOLBAR_TOGGLE] = self.search_toolbar.toggleViewAction() toolbar.setObjectName('search_toolbar') if self._is_wayland: toolbar.setFloatable(False) # https://bugreports.qt.io/browse/QTBUG-92191 if IS_MACOS: self.search_toolbar.setMovable(False) search_panel = QtWidgets.QWidget(toolbar) hbox = QtWidgets.QHBoxLayout(search_panel) self.search_combo = QtWidgets.QComboBox(search_panel) self.search_combo.addItem(_("Album"), 'album') self.search_combo.addItem(_("Artist"), 'artist') self.search_combo.addItem(_("Track"), 'track') hbox.addWidget(self.search_combo, 0) self.search_edit = QtWidgets.QLineEdit(search_panel) self.search_edit.setClearButtonEnabled(True) self.search_edit.returnPressed.connect(self._trigger_search_action) self.search_edit.textChanged.connect(self._toggle_search) hbox.addWidget(self.search_edit, 0) self.search_button = QtWidgets.QToolButton(search_panel) self.search_button.setAutoRaise(True) self.search_button.setDefaultAction(self.actions[MainAction.SEARCH]) self.search_button.setIconSize(QtCore.QSize(22, 22)) self.search_button.setAttribute(QtCore.Qt.WidgetAttribute.WA_MacShowFocusRect) # search button contextual menu, shortcut to toggle search options def search_button_menu(position): menu = QtWidgets.QMenu() opts = { 'use_adv_search_syntax': N_("&Advanced search"), 'builtin_search': N_("&Builtin search"), } def toggle_opt(opt, checked): config.setting[opt] = checked for opt, label in opts.items(): action = QtGui.QAction(_(label), menu) action.setCheckable(True) action.setChecked(config.setting[opt]) action.triggered.connect(partial(toggle_opt, opt)) menu.addAction(action) menu.exec(self.search_button.mapToGlobal(position)) self.search_button.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.search_button.customContextMenuRequested.connect(search_button_menu) hbox.addWidget(self.search_button) toolbar.addWidget(search_panel) def set_tab_order(self): tab_order = self.setTabOrder prev_action = None current_action = None # Setting toolbar widget tab-orders for accessibility config = get_config() for action_name in config.setting['toolbar_layout']: if action_name not in {'-', 'separator'}: try: action_id = MainAction(action_name) action = self.actions[action_id] current_action = self.toolbar.widgetForAction(action) except (ValueError, KeyError) as e: log.debug("Warning: Unknown action name '%s' found in config. Ignored. %s", action_name, e) if prev_action is not None and prev_action != current_action: tab_order(prev_action, current_action) prev_action = current_action tab_order(prev_action, self.search_combo) tab_order(self.search_combo, self.search_edit) tab_order(self.search_edit, self.search_button) # Panels tab_order(self.search_button, self.file_browser) self.panel.tab_order(tab_order, self.file_browser, self.metadata_box) def _toggle_search(self): """Enable/disable the 'Search' action.""" self.enable_action(MainAction.SEARCH, self.search_edit.text()) def _trigger_search_action(self): action = self.actions[MainAction.SEARCH] if action.isEnabled(): action.trigger() def _search_mbid_found(self, entity, mbid): self.search_edit.setText('%s:%s' % (entity, mbid)) def search(self): """Search for album, artist or track on the MusicBrainz website.""" text = self.search_edit.text() entity = self.search_combo.itemData(self.search_combo.currentIndex()) config = get_config() self.tagger.search(text, entity, config.setting['use_adv_search_syntax'], mbid_matched_callback=self._search_mbid_found) def add_files(self): """Add files to the tagger.""" current_directory = find_starting_directory() formats = [] extensions = [] for exts, name in supported_formats(): exts = ["*" + e.lower() for e in exts] if not exts: continue if not IS_MACOS and not IS_WIN: # Also consider upper case extensions # macOS and Windows usually support case sensitive file names. Furthermore on both systems # the file dialog filters list all extensions we provide, which becomes a bit long when we give the # full list twice. Hence only do this trick on other operating systems. exts.extend([e.upper() for e in exts]) exts.sort() formats.append("%s (%s)" % (name, " ".join(exts))) extensions.extend(exts) formats.sort() extensions.sort() formats.insert(0, _("All supported formats") + " (%s)" % " ".join(extensions)) formats.insert(1, _("All files") + " (*)") files, _filter = FileDialog.getOpenFileNames( parent=self, dir=current_directory, filter=";;".join(formats), ) if files: config = get_config() config.persist['current_directory'] = os.path.dirname(files[0]) self.tagger.add_files(files) def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] config = get_config() if not config.setting['allow_multi_dirs_selection']: directory = FileDialog.getExistingDirectory( parent=self, dir=current_directory, ) if directory: dir_list.append(directory) else: dir_list = FileDialog.getMultipleDirectories( parent=self, directory=current_directory, ) dir_count = len(dir_list) if dir_count: parent = os.path.dirname(dir_list[0]) if dir_count > 1 else dir_list[0] config.persist['current_directory'] = parent if dir_count > 1: self.set_statusbar_message( N_("Adding multiple directories from '%(directory)s' …"), {'directory': parent} ) else: self.set_statusbar_message( N_("Adding directory: '%(directory)s' …"), {'directory': dir_list[0]} ) self.tagger.add_paths(dir_list) def close_active_window(self): self.tagger.activeWindow().close() def show_about(self): return AboutDialog.show_instance(self) def show_options(self, page=None): options_dialog = OptionsDialog.show_instance(page, self) options_dialog.finished.connect(self._options_closed) if self.script_editor_dialog is not None: # Disable signal processing to avoid saving changes not processed with "Make It So!" for signal in self.script_editor_signals: signal.disconnect() return options_dialog def _options_closed(self): if self.script_editor_dialog is not None: self.open_file_naming_script_editor() self.script_editor_dialog.show() else: self.enable_action(MainAction.SHOW_SCRIPT_EDITOR, True) self._make_profile_selector_menu() self.make_script_selector_menu() def show_help(self): webbrowser2.open('documentation') def _show_log_dialog(self, dialog): dialog.show() dialog.raise_() dialog.activateWindow() def show_log(self): self._show_log_dialog(self.log_dialog) def show_history(self): self._show_log_dialog(self.history_dialog) def open_bug_report(self): webbrowser2.open('troubleshooting') def open_support_forum(self): webbrowser2.open('forum') def open_donation_page(self): webbrowser2.open('donate') def save(self): """Tell the tagger to save the selected objects.""" config = get_config() if config.setting['file_save_warning']: count = len(self.tagger.get_files_from_objects(self.selected_objects)) msg = SaveWarningDialog(self, count) proceed_with_save, disable_warning = msg.show() config.setting['file_save_warning'] = not disable_warning else: proceed_with_save = True if proceed_with_save: self.tagger.save(self.selected_objects) def remove_selected_objects(self): """Tell the tagger to remove the selected objects.""" self.panel.remove(self.selected_objects) def analyze(self): def callback(fingerprinting_system): if fingerprinting_system: self.tagger.analyze(self.selected_objects) self._ensure_fingerprinting_configured(callback) def generate_fingerprints(self): def callback(fingerprinting_system): if fingerprinting_system: self.tagger.generate_fingerprints(self.selected_objects) self._ensure_fingerprinting_configured(callback) def play_file(self): for file in iter_files_from_objects(self.selected_objects): open_local_path(file.filename) def _on_player_error(self, error, msg): self.set_statusbar_message(msg, echo=log.warning, translate=None) def open_folder(self): folders = iter_unique( os.path.dirname(f.filename) for f in iter_files_from_objects(self.selected_objects)) for folder in folders: open_local_path(folder) def _ensure_fingerprinting_configured(self, callback): config = get_config() if not config.setting['fingerprinting_system']: if self._show_analyze_settings_info(): def on_finished(result): callback(config.setting['fingerprinting_system']) dialog = self.show_options('fingerprinting') dialog.finished.connect(on_finished) else: callback(config.setting['fingerprinting_system']) def _show_analyze_settings_info(self): ret = QtWidgets.QMessageBox.question(self, _("Configuration Required"), _("Audio fingerprinting is not yet configured. Would you like to configure it now?"), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.Yes) return ret == QtWidgets.QMessageBox.StandardButton.Yes def _get_first_obj_with_type(self, type): for obj in self.selected_objects: if isinstance(obj, type): return obj return None def show_similar_items_search(self): obj = self._get_first_obj_with_type(Cluster) if obj: self.show_more_albums() else: self.show_more_tracks() def show_more_tracks(self): if not self.selected_objects: return obj = self.selected_objects[0] if isinstance(obj, Track) and obj.files: obj = obj.files[0] if not isinstance(obj, File): log.debug("show_more_tracks expected a File, got %r", obj) return dialog = TrackSearchDialog(self, force_advanced_search=True) dialog.show_similar_tracks(obj) dialog.exec() def show_more_albums(self): obj = self._get_first_obj_with_type(Cluster) if not obj: log.debug("show_more_albums expected a Cluster, got %r", obj) return dialog = AlbumSearchDialog(self, force_advanced_search=True) dialog.show_similar_albums(obj) dialog.exec() def show_album_other_versions(self): obj = self._get_first_obj_with_type(Album) if obj and obj.release_group: AlbumSearchDialog.show_releasegroup_search(obj.release_group.id, obj) def view_info(self, default_tab=0): try: selected = self.selected_objects[0] except IndexError: return if isinstance(selected, Album): dialog_class = AlbumInfoDialog elif isinstance(selected, Cluster): dialog_class = ClusterInfoDialog elif isinstance(selected, Track): dialog_class = TrackInfoDialog else: try: selected = next(iter_files_from_objects(self.selected_objects)) except StopIteration: return dialog_class = FileInfoDialog dialog = dialog_class(selected, self) dialog.ui.tabWidget.setCurrentIndex(default_tab) dialog.exec() def cluster(self): # Cluster all selected unclustered files. If there are no selected # unclustered files cluster all unclustered files. files = ( f for f in iter_files_from_objects(self.selected_objects) if f.parent_item == self.tagger.unclustered_files ) try: file = next(files) except StopIteration: files = self.tagger.unclustered_files.files else: files = itertools.chain([file], files) self.tagger.cluster(files, self._cluster_finished) def _cluster_finished(self): self.panel.update_current_view() # Select clusters if no other item or only empty unclustered files item is selected if not self.selected_objects or (len(self.selected_objects) == 1 and self.tagger.unclustered_files in self.selected_objects and not self.tagger.unclustered_files.files): self.panel.select_object(self.tagger.clusters) self._update_actions() def refresh(self): self.tagger.refresh(self.selected_objects) def browser_lookup(self): if not self.selected_objects: return self.tagger.browser_lookup(self.selected_objects[0]) def submit_cluster(self): if self.selected_objects and self._check_add_release(): for obj in self.selected_objects: if isinstance(obj, Cluster): addrelease.submit_cluster(obj) def submit_file(self, as_release=False): if self.selected_objects and self._check_add_release(): for file in iter_files_from_objects(self.selected_objects): addrelease.submit_file(file, as_release=as_release) def _check_add_release(self): if addrelease.is_enabled(): return True ret = QtWidgets.QMessageBox.question(self, _("Browser integration not enabled"), _("Submitting releases to MusicBrainz requires the browser integration to be enabled. Do you want to enable the browser integration now?"), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.Yes) if ret == QtWidgets.QMessageBox.StandardButton.Yes: config = get_config() config.setting['browser_integration'] = True self.tagger.update_browser_integration() if addrelease.is_enabled(): return True else: # Something went wrong, let the user configure browser integration manually self.show_options('network') return False else: return False @throttle(100) def _update_actions(self): can_remove = False can_save = False can_analyze = False can_refresh = False can_autotag = False can_submit = False single = self.selected_objects[0] if len(self.selected_objects) == 1 else None can_view_info = bool(single and single.can_view_info) can_browser_lookup = bool(single and single.can_browser_lookup) is_file = bool(single and isinstance(single, (File, Track))) is_album = bool(single and isinstance(single, Album)) is_cluster = bool(single and isinstance(single, Cluster) and not single.special) if not self.selected_objects: have_objects = have_files = False else: have_objects = True try: next(iter_files_from_objects(self.selected_objects)) have_files = True except StopIteration: have_files = False for obj in self.selected_objects: if obj is None: continue # using x = x or obj.x() form prevents calling function # if x is already True can_analyze = can_analyze or obj.can_analyze can_autotag = can_autotag or obj.can_autotag can_refresh = can_refresh or obj.can_refresh can_remove = can_remove or obj.can_remove can_save = can_save or obj.can_save can_submit = can_submit or obj.can_submit # Skip further loops if all values now True. if ( can_analyze and can_autotag and can_refresh and can_remove and can_save and can_submit ): break self.enable_action(MainAction.REMOVE, can_remove) self.enable_action(MainAction.SAVE, can_save) self.enable_action(MainAction.VIEW_INFO, can_view_info) self.enable_action(MainAction.ANALYZE, can_analyze) self.enable_action(MainAction.GENERATE_FINGERPRINTS, have_files) self.enable_action(MainAction.REFRESH, can_refresh) self.enable_action(MainAction.AUTOTAG, can_autotag) self.enable_action(MainAction.BROWSER_LOOKUP, can_browser_lookup) self.enable_action(MainAction.PLAY_FILE, have_files) self.enable_action(MainAction.OPEN_FOLDER, have_files) self.enable_action(MainAction.CUT, have_objects) self.enable_action(MainAction.SUBMIT_CLUSTER, can_submit) self.enable_action(MainAction.SUBMIT_FILE_AS_RECORDING, have_files) self.enable_action(MainAction.SUBMIT_FILE_AS_RELEASE, have_files) self.enable_action(MainAction.TAGS_FROM_FILENAMES, self._get_selected_or_unmatched_files()) self.enable_action(MainAction.SIMILAR_ITEMS_SEARCH, is_file or is_cluster) self.enable_action(MainAction.TRACK_SEARCH, is_file) self.enable_action(MainAction.ALBUM_SEARCH, is_cluster) self.enable_action(MainAction.ALBUM_OTHER_VERSIONS, is_album) def enable_action(self, action_id, enabled): if self.actions[action_id]: self.actions[action_id].setEnabled(bool(enabled)) def update_selection(self, objects=None, new_selection=True, drop_album_caches=False): if self.ignore_selection_changes: return if objects is not None: self.selected_objects = objects else: objects = self.selected_objects self._update_actions() obj = None # Clear any existing status bar messages self.set_statusbar_message("") if self.player: self.player.set_objects(self.selected_objects) metadata_visible = self.metadata_view.isVisible() coverart_visible = metadata_visible and self.cover_art_box.isVisible() if len(objects) == 1: obj = list(objects)[0] if isinstance(obj, File): if obj.state == obj.ERROR: msg = N_("%(filename)s (error: %(error)s)") mparms = { 'filename': obj.filename, 'error': obj.errors[0] if obj.errors else '' } else: msg = N_("%(filename)s") mparms = { 'filename': obj.filename, } self.set_statusbar_message(msg, mparms, echo=None, history=None) elif isinstance(obj, Track): if obj.num_linked_files == 1: file = obj.files[0] if file.has_error(): msg = N_("%(filename)s (%(similarity)d%%) (error: %(error)s)") mparms = { 'filename': file.filename, 'similarity': file.similarity * 100, 'error': file.errors[0] if file.errors else '' } else: msg = N_("%(filename)s (%(similarity)d%%)") mparms = { 'filename': file.filename, 'similarity': file.similarity * 100, } self.set_statusbar_message(msg, mparms, echo=None, history=None) elif coverart_visible and new_selection: # Create a temporary file list which allows changing cover art for all selected files files = list(iter_files_from_objects(objects)) obj = FileList(files) if coverart_visible and new_selection: self.cover_art_box.set_item(obj) if metadata_visible: if new_selection: self.metadata_box.selection_dirty = True self.metadata_box.update(drop_album_caches=drop_album_caches) self.selection_updated.emit(objects) self._update_script_editor_example_files() def refresh_metadatabox(self): self.tagger.window.metadata_box.selection_dirty = True self.tagger.window.metadata_box.update() def action_is_checked(self, action_id): return self.actions[action_id].isChecked() def show_metadata_view(self): """Show/hide the metadata view (including the cover art box).""" show = self.action_is_checked(MainAction.SHOW_METADATA_VIEW) self.metadata_view.setVisible(show) self.enable_action(MainAction.SHOW_COVER_ART, show) if show: self.update_selection() def show_cover_art(self): """Show/hide the cover art box.""" show = self.action_is_checked(MainAction.SHOW_COVER_ART) self.cover_art_box.setVisible(show) if show: self.update_selection() def show_toolbar(self): """Show/hide the Action toolbar.""" if self.action_is_checked(MainAction.SHOW_TOOLBAR): self.toolbar.show() else: self.toolbar.hide() def show_file_browser(self): """Show/hide the file browser.""" if self.action_is_checked(MainAction.SHOW_FILE_BROWSER): sizes = self.panel.sizes() if sizes[0] == 0: sizes[0] = sum(sizes) // 4 self.panel.setSizes(sizes) self.file_browser.show() else: self.file_browser.hide() def _show_password_dialog(self, reply, authenticator): config = get_config() if reply.url().host() == config.setting['server_host']: ret = QtWidgets.QMessageBox.question(self, _("Authentication Required"), _("Picard needs authorization to access your personal data on the MusicBrainz server. Would you like to log in now?"), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No, QtWidgets.QMessageBox.StandardButton.Yes) if ret == QtWidgets.QMessageBox.StandardButton.Yes: self.tagger.mb_login(self._on_mb_login_finished) else: dialog = PasswordDialog(authenticator, reply, parent=self) dialog.exec() def _on_mb_login_finished(self, successful, error_msg): if successful: log.debug("MusicBrainz authentication finished successfully") else: log.info("MusicBrainz authentication failed: %s", error_msg) QtWidgets.QMessageBox.critical(self, _("Authentication failed"), _("Login failed: %s") % error_msg) def _show_proxy_dialog(self, proxy, authenticator): dialog = ProxyDialog(authenticator, proxy, parent=self) dialog.exec() def autotag(self): self.tagger.autotag(self.selected_objects) def copy_files(self, objects): mimeData = QtCore.QMimeData() mimeData.setUrls(QtCore.QUrl.fromLocalFile(f.filename) for f in iter_files_from_objects(objects)) self.tagger.clipboard().setMimeData(mimeData) def paste_files(self, target): mimeData = self.tagger.clipboard().mimeData() if mimeData.hasUrls(): BaseTreeView.drop_urls(mimeData.urls(), target) def cut(self): self.copy_files(self.selected_objects) self.enable_action(MainAction.PASTE, self.selected_objects) def paste(self): selected_objects = self.selected_objects if not selected_objects: target = self.tagger.unclustered_files else: target = selected_objects[0] self.paste_files(target) self.enable_action(MainAction.PASTE, False) def do_update_check(self): self._check_for_update(True) def _auto_update_check(self): config = get_config() check_for_updates = config.setting['check_for_updates'] update_check_days = config.setting['update_check_days'] last_update_check = config.persist['last_update_check'] update_level = config.setting['update_level'] today = datetime.date.today().toordinal() do_auto_update_check = check_for_updates and update_check_days > 0 and today >= last_update_check + update_check_days log.debug("%(check_status)s startup check for program updates. Today: %(today_date)s, Last check: %(last_check)s (Check interval: %(check_interval)s days), Update level: %(update_level)s (%(update_level_name)s)", { 'check_status': 'Initiating' if do_auto_update_check else 'Skipping', 'today_date': datetime.date.today(), 'last_check': str(datetime.date.fromordinal(last_update_check)) if last_update_check > 0 else 'never', 'check_interval': update_check_days, 'update_level': update_level, 'update_level_name': PROGRAM_UPDATE_LEVELS[update_level]['name'] if update_level in PROGRAM_UPDATE_LEVELS else 'unknown', }) if do_auto_update_check: self._check_for_update(False) def _check_for_update(self, show_always): config = get_config() self.tagger.updatecheckmanager.check_update( show_always=show_always, update_level=config.setting['update_level'], callback=update_last_check_date ) def _check_and_repair_naming_scripts(self): """Check the 'file_renaming_scripts' config setting to ensure that the list of scripts is not empty. Check that the 'selected_file_naming_script_id' config setting points to a valid file naming script. """ config = get_config() script_key = 'file_renaming_scripts' if not config.setting[script_key]: config.setting[script_key] = { script['id']: script.to_dict() for script in get_file_naming_script_presets() } naming_script_ids = list(config.setting[script_key]) script_id_key = 'selected_file_naming_script_id' if config.setting[script_id_key] not in naming_script_ids: config.setting[script_id_key] = naming_script_ids[0] def _check_and_repair_profiles(self): """Check the profiles and profile settings and repair the values if required. Checks that there is a settings dictionary for each profile, and that no profiles reference a non-existant file naming script. """ script_id_key = 'selected_file_naming_script_id' config = get_config() naming_scripts = config.setting['file_renaming_scripts'] naming_script_ids = set(naming_scripts.keys()) profile_settings = deepcopy(config.profiles[SettingConfigSection.SETTINGS_KEY]) for profile in config.profiles[SettingConfigSection.PROFILES_KEY]: p_id = profile['id'] # Add empty settings if none found for a profile if p_id not in profile_settings: log.warning( "No settings dict found for profile '%s' ('%s'). Adding empty dict.", p_id, profile['title'], ) profile_settings[p_id] = {} # Remove any invalid naming script ids from profiles if script_id_key in profile_settings[p_id]: if profile_settings[p_id][script_id_key] not in naming_script_ids: log.warning( "Removing invalid naming script id '%s' from profile '%s' ('%s')", profile_settings[p_id][script_id_key], p_id, profile['title'], ) profile_settings[p_id][script_id_key] = None config.profiles[SettingConfigSection.SETTINGS_KEY] = profile_settings def make_script_selector_menu(self): """Update the sub-menu of available file naming scripts. """ if self.script_editor_dialog is None or not isinstance(self.script_editor_dialog, ScriptEditorDialog): config = get_config() naming_scripts = config.setting['file_renaming_scripts'] selected_script_id = config.setting['selected_file_naming_script_id'] else: naming_scripts = self.script_editor_dialog.naming_scripts selected_script_id = self.script_editor_dialog.selected_script_id self.script_quick_selector_menu.clear() group = QtGui.QActionGroup(self.script_quick_selector_menu) group.setExclusive(True) def _add_menu_item(title, id): script_action = QtGui.QAction(title, self.script_quick_selector_menu) script_action.triggered.connect(partial(self._select_new_naming_script, id)) script_action.setCheckable(True) script_action.setChecked(id == selected_script_id) self.script_quick_selector_menu.addAction(script_action) group.addAction(script_action) for (id, naming_script) in sorted(naming_scripts.items(), key=lambda item: item[1]['title']): _add_menu_item(naming_script['title'], id) def _select_new_naming_script(self, id): """Update the currently selected naming script ID in the settings. Args: id (str): ID of the selected file naming script """ config = get_config() log.debug("Setting naming script to: %s", id) config.setting['selected_file_naming_script_id'] = id self.make_script_selector_menu() if self.script_editor_dialog: self.script_editor_dialog.set_selected_script_id(id) def open_file_naming_script_editor(self): """Open the file naming script editor / manager in a new window. """ examples = ScriptEditorExamples(tagger=self.tagger) self.script_editor_dialog = ScriptEditorDialog.show_instance(parent=self, examples=examples) self.script_editor_dialog.signal_save.connect(self._script_editor_save) self.script_editor_dialog.signal_selection_changed.connect(self._update_selector_from_script_editor) self.script_editor_dialog.signal_index_changed.connect(self._script_editor_index_changed) self.script_editor_dialog.finished.connect(self._script_editor_closed) # Create list of signals to disconnect when opening Options dialog. # Do not include `finished` because that is still used to clean up # locally when the editor is closed from the Options dialog. self.script_editor_signals = [ self.script_editor_dialog.signal_save, self.script_editor_dialog.signal_selection_changed, self.script_editor_dialog.signal_index_changed, ] self.enable_action(MainAction.SHOW_SCRIPT_EDITOR, False) def _script_editor_save(self): """Process "signal_save" signal from the script editor. """ self.make_script_selector_menu() def _script_editor_closed(self): """Process "finished" signal from the script editor. """ self.enable_action(MainAction.SHOW_SCRIPT_EDITOR, True) self.script_editor_dialog = None self.make_script_selector_menu() def _update_script_editor_example_files(self): """Update the list of example files for the file naming script editor. """ script_editor_dialog = self.script_editor_dialog if script_editor_dialog and script_editor_dialog.isVisible(): script_editor_dialog.examples.update_sample_example_files() self._update_script_editor_examples() def _update_script_editor_examples(self): """Update the examples for the file naming script editor, using current settings. """ script_editor_dialog = self.script_editor_dialog if script_editor_dialog and script_editor_dialog.isVisible(): config = get_config() override = { "rename_files": config.setting["rename_files"], "move_files": config.setting["move_files"], } script_editor_dialog.examples.update_examples(override=override) script_editor_dialog.display_examples() def _script_editor_index_changed(self): """Process "signal_index_changed" signal from the script editor. """ self._script_editor_save() def _update_selector_from_script_editor(self): """Process "signal_selection_changed" signal from the script editor. """ self._script_editor_save() def _make_profile_selector_menu(self): """Update the sub-menu of available option profiles. """ config = get_config() option_profiles = config.profiles[SettingConfigSection.PROFILES_KEY] if not option_profiles: self.profile_quick_selector_menu.setDisabled(True) return self.profile_quick_selector_menu.setDisabled(False) self.profile_quick_selector_menu.clear() group = QtGui.QActionGroup(self.profile_quick_selector_menu) group.setExclusive(False) def _add_menu_item(title, enabled, profile_id): profile_action = QtGui.QAction(title, self.profile_quick_selector_menu) profile_action.triggered.connect(partial(self._update_profile_selection, profile_id)) profile_action.setCheckable(True) profile_action.setChecked(enabled) self.profile_quick_selector_menu.addAction(profile_action) group.addAction(profile_action) for profile in option_profiles: _add_menu_item(profile['title'], profile['enabled'], profile['id']) def _update_profile_selection(self, profile_id): """Toggle the enabled state of the selected profile. Args: profile_id (str): ID code of the profile to modify """ config = get_config() option_profiles = config.profiles[SettingConfigSection.PROFILES_KEY] for profile in option_profiles: if profile['id'] == profile_id: profile['enabled'] = not profile['enabled'] self.make_script_selector_menu() return def show_new_user_dialog(self): config = get_config() if config.setting['show_new_user_dialog']: msg = NewUserDialog(self) config.setting['show_new_user_dialog'] = msg.show() def check_for_plugin_update(self): config = get_config() if config.setting['check_for_plugin_updates']: self.tagger.pluginmanager.check_update() def show_plugin_update_dialog(self, plugin_names): if not plugin_names: return msg = PluginUpdatesDialog(self, plugin_names) show_options_page, perform_check = msg.show() config = get_config() config.setting['check_for_plugin_updates'] = perform_check if show_options_page: self.show_plugins_options_page() def show_plugins_options_page(self): self.show_options(page='plugins') def update_last_check_date(is_success): if is_success: config = get_config() config.persist['last_update_check'] = datetime.date.today().toordinal() else: log.debug('The update check was unsuccessful. The last update date will not be changed.')
64,678
Python
.py
1,419
35.158562
223
0.631608
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,095
actions.py
metabrainz_picard/picard/ui/mainwindow/actions.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2006-2008, 2011-2012, 2014 Lukáš Lalinský # Copyright (C) 2007 Nikolai Prokoschenko # Copyright (C) 2008 Gary van der Merwe # Copyright (C) 2008 Robert Kaye # Copyright (C) 2008 Will # Copyright (C) 2008-2010, 2015, 2018-2023 Philipp Wolfer # Copyright (C) 2009 Carlin Mangar # Copyright (C) 2009 David Hilton # Copyright (C) 2011-2012 Chad Wilson # Copyright (C) 2011-2013, 2015-2017 Wieland Hoffmann # Copyright (C) 2011-2014 Michael Wiencek # Copyright (C) 2013-2014, 2017 Sophist-UK # Copyright (C) 2013-2023 Laurent Monin # Copyright (C) 2015 Ohm Patel # Copyright (C) 2015 samithaj # Copyright (C) 2016 Rahul Raturi # Copyright (C) 2016 Simon Legner # Copyright (C) 2016-2017 Sambhav Kothari # Copyright (C) 2017 Antonio Larrosa # Copyright (C) 2017 Frederik “Freso” S. Olesen # Copyright (C) 2018 Kartik Ohri # Copyright (C) 2018 Vishal Choudhary # Copyright (C) 2018 virusMac # Copyright (C) 2018, 2021-2023 Bob Swift # Copyright (C) 2019 Timur Enikeev # Copyright (C) 2020-2021 Gabriel Ferreira # Copyright (C) 2021 Petit Minion # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. from functools import partial from PyQt6 import QtGui from picard.browser import addrelease from picard.config import get_config from picard.const.sys import IS_MACOS from picard.i18n import gettext as _ from picard.util import icontheme from picard.ui.enums import MainAction _actions_functions = dict() def add_action(action_name): def decorator(fn): _actions_functions[action_name] = fn return fn return decorator def create_actions(parent): for action_name, action in _actions_functions.items(): yield (action_name, action(parent)) @add_action(MainAction.OPTIONS) def _create_options_action(parent): action = QtGui.QAction(icontheme.lookup('preferences-desktop'), _("&Options…"), parent) action.setMenuRole(QtGui.QAction.MenuRole.PreferencesRole) action.triggered.connect(parent.show_options) return action @add_action(MainAction.SHOW_SCRIPT_EDITOR) def _create_show_script_editor_action(parent): action = QtGui.QAction(_("Open &file naming script editor…")) action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+S"))) action.triggered.connect(parent.open_file_naming_script_editor) return action @add_action(MainAction.CUT) def _create_cut_action(parent): action = QtGui.QAction(icontheme.lookup('edit-cut', icontheme.ICON_SIZE_MENU), _("&Cut"), parent) action.setShortcut(QtGui.QKeySequence.StandardKey.Cut) action.setEnabled(False) action.triggered.connect(parent.cut) return action @add_action(MainAction.PASTE) def _create_paste_action(parent): action = QtGui.QAction(icontheme.lookup('edit-paste', icontheme.ICON_SIZE_MENU), _("&Paste"), parent) action.setShortcut(QtGui.QKeySequence.StandardKey.Paste) action.setEnabled(False) action.triggered.connect(parent.paste) return action @add_action(MainAction.HELP) def _create_help_action(parent): action = QtGui.QAction(_("&Help…"), parent) action.setShortcut(QtGui.QKeySequence.StandardKey.HelpContents) action.triggered.connect(parent.show_help) return action @add_action(MainAction.ABOUT) def _create_about_action(parent): action = QtGui.QAction(_("&About…"), parent) action.setMenuRole(QtGui.QAction.MenuRole.AboutRole) action.triggered.connect(parent.show_about) return action @add_action(MainAction.DONATE) def _create_donate_action(parent): action = QtGui.QAction(_("&Donate…"), parent) action.triggered.connect(parent.open_donation_page) return action @add_action(MainAction.REPORT_BUG) def _create_report_bug_action(parent): action = QtGui.QAction(_("&Report a Bug…"), parent) action.triggered.connect(parent.open_bug_report) return action @add_action(MainAction.SUPPORT_FORUM) def _create_support_forum_action(parent): action = QtGui.QAction(_("&Support Forum…"), parent) action.triggered.connect(parent.open_support_forum) return action @add_action(MainAction.ADD_FILES) def _create_add_files_action(parent): action = QtGui.QAction(icontheme.lookup('document-open'), _("&Add Files…"), parent) action.setStatusTip(_("Add files to the tagger")) # TR: Keyboard shortcut for "Add Files…" action.setShortcut(QtGui.QKeySequence.StandardKey.Open) action.triggered.connect(parent.add_files) return action @add_action(MainAction.ADD_DIRECTORY) def _create_add_directory_action(parent): action = QtGui.QAction(icontheme.lookup('folder'), _("Add Fold&er…"), parent) action.setStatusTip(_("Add a folder to the tagger")) # TR: Keyboard shortcut for "Add Directory…" action.setShortcut(QtGui.QKeySequence(_("Ctrl+E"))) action.triggered.connect(parent.add_directory) return action @add_action(MainAction.CLOSE_WINDOW) def _create_close_window_action(parent): if parent.show_close_window: action = QtGui.QAction(_("Close Window"), parent) action.setShortcut(QtGui.QKeySequence(_("Ctrl+W"))) action.triggered.connect(parent.close_active_window) else: action = None return action @add_action(MainAction.SAVE) def _create_save_action(parent): action = QtGui.QAction(icontheme.lookup('document-save'), _("&Save"), parent) action.setStatusTip(_("Save selected files")) # TR: Keyboard shortcut for "Save" action.setShortcut(QtGui.QKeySequence.StandardKey.Save) action.setEnabled(False) action.triggered.connect(parent.save) return action @add_action(MainAction.SUBMIT_ACOUSTID) def _create_submit_acoustid_action(parent): action = QtGui.QAction(icontheme.lookup('acoustid-fingerprinter'), _("S&ubmit AcoustIDs"), parent) action.setStatusTip(_("Submit acoustic fingerprints")) action.setEnabled(False) action.triggered.connect(parent._on_submit_acoustid) return action @add_action(MainAction.EXIT) def _create_exit_action(parent): action = QtGui.QAction(_("E&xit"), parent) action.setMenuRole(QtGui.QAction.MenuRole.QuitRole) # TR: Keyboard shortcut for "Exit" action.setShortcut(QtGui.QKeySequence(_("Ctrl+Q"))) action.triggered.connect(parent.close) return action @add_action(MainAction.REMOVE) def _create_remove_action(parent): action = QtGui.QAction(icontheme.lookup('list-remove'), _("&Remove"), parent) action.setStatusTip(_("Remove selected files/albums")) action.setEnabled(False) action.triggered.connect(parent.remove_selected_objects) return action @add_action(MainAction.BROWSER_LOOKUP) def _create_browser_lookup_action(parent): action = QtGui.QAction(icontheme.lookup('lookup-musicbrainz'), _("Lookup in &Browser"), parent) action.setStatusTip(_("Lookup selected item on MusicBrainz website")) action.setEnabled(False) # TR: Keyboard shortcut for "Lookup in Browser" action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+L"))) action.triggered.connect(parent.browser_lookup) return action @add_action(MainAction.SUBMIT_CLUSTER) def _create_submit_cluster_action(parent): if addrelease.is_available(): action = QtGui.QAction(_("Submit cluster as release…"), parent) action.setStatusTip(_("Submit cluster as a new release to MusicBrainz")) action.setEnabled(False) action.triggered.connect(parent.submit_cluster) else: action = None return action @add_action(MainAction.SUBMIT_FILE_AS_RECORDING) def _create_submit_file_as_recording_action(parent): if addrelease.is_available(): action = QtGui.QAction(_("Submit file as standalone recording…"), parent) action.setStatusTip(_("Submit file as a new recording to MusicBrainz")) action.setEnabled(False) action.triggered.connect(parent.submit_file) else: action = None return action @add_action(MainAction.SUBMIT_FILE_AS_RELEASE) def _create_submit_file_as_release_action(parent): if addrelease.is_available(): action = QtGui.QAction(_("Submit file as release…"), parent) action.setStatusTip(_("Submit file as a new release to MusicBrainz")) action.setEnabled(False) action.triggered.connect(partial(parent.submit_file, as_release=True)) else: action = None return action @add_action(MainAction.SIMILAR_ITEMS_SEARCH) def _create_similar_items_search_action(parent): action = QtGui.QAction(icontheme.lookup('system-search'), _("Search for similar items…"), parent) action.setIconText(_("Similar items")) action.setStatusTip(_("View similar releases or recordings and optionally choose a different one")) action.setEnabled(False) action.setShortcut(QtGui.QKeySequence(_("Ctrl+T"))) action.triggered.connect(parent.show_similar_items_search) return action @add_action(MainAction.ALBUM_SEARCH) def _create_album_search_action(parent): action = QtGui.QAction(icontheme.lookup('system-search'), _("Search for similar albums…"), parent) action.setStatusTip(_("View similar releases and optionally choose a different release")) action.setEnabled(False) action.setShortcut(QtGui.QKeySequence(_("Ctrl+T"))) action.triggered.connect(parent.show_more_albums) return action @add_action(MainAction.TRACK_SEARCH) def _create_track_search_action(parent): action = QtGui.QAction(icontheme.lookup('system-search'), _("Search for similar tracks…"), parent) action.setStatusTip(_("View similar tracks and optionally choose a different release")) action.setEnabled(False) action.setShortcut(QtGui.QKeySequence(_("Ctrl+T"))) action.triggered.connect(parent.show_more_tracks) return action @add_action(MainAction.ALBUM_OTHER_VERSIONS) def _create_album_other_versions_action(parent): action = QtGui.QAction(_("Show &other album versions…"), parent) action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+O"))) action.triggered.connect(parent.show_album_other_versions) return action @add_action(MainAction.SHOW_FILE_BROWSER) def _create_show_file_browser_action(parent): config = get_config() action = QtGui.QAction(_("File &Browser"), parent) action.setCheckable(True) if config.persist['view_file_browser']: action.setChecked(True) action.setShortcut(QtGui.QKeySequence(_("Ctrl+B"))) action.triggered.connect(parent.show_file_browser) return action @add_action(MainAction.SHOW_METADATA_VIEW) def _create_show_metadata_view_action(parent): config = get_config() action = QtGui.QAction(_("&Metadata"), parent) action.setCheckable(True) if config.persist['view_metadata_view']: action.setChecked(True) action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+M"))) action.triggered.connect(parent.show_metadata_view) return action @add_action(MainAction.SHOW_COVER_ART) def _create_show_cover_art_action(parent): config = get_config() action = QtGui.QAction(_("&Cover Art"), parent) action.setCheckable(True) if config.persist['view_cover_art']: action.setChecked(True) action.setEnabled(config.persist['view_metadata_view']) action.triggered.connect(parent.show_cover_art) return action @add_action(MainAction.SHOW_TOOLBAR) def _create_show_toolbar_action(parent): config = get_config() action = QtGui.QAction(_("&Actions"), parent) action.setCheckable(True) if config.persist['view_toolbar']: action.setChecked(True) action.triggered.connect(parent.show_toolbar) return action @add_action(MainAction.SEARCH) def _create_search_action(parent): action = QtGui.QAction(icontheme.lookup('system-search'), _("Search"), parent) action.setEnabled(False) action.triggered.connect(parent.search) return action @add_action(MainAction.CD_LOOKUP) def _create_cd_lookup_action(parent): action = QtGui.QAction(icontheme.lookup('media-optical'), _("Lookup &CD…"), parent) action.setStatusTip(_("Lookup the details of the CD in your drive")) # TR: Keyboard shortcut for "Lookup CD" action.setShortcut(QtGui.QKeySequence(_("Ctrl+K"))) action.triggered.connect(parent.tagger.lookup_cd) return action @add_action(MainAction.ANALYZE) def _create_analyze_action(parent): action = QtGui.QAction(icontheme.lookup('picard-analyze'), _("&Scan"), parent) action.setStatusTip(_("Use AcoustID audio fingerprint to identify the files by the actual music, even if they have no metadata")) action.setEnabled(False) action.setToolTip(_("Identify the file using its AcoustID audio fingerprint")) # TR: Keyboard shortcut for "Analyze" action.setShortcut(QtGui.QKeySequence(_("Ctrl+Y"))) action.triggered.connect(parent.analyze) return action @add_action(MainAction.GENERATE_FINGERPRINTS) def _create_generate_fingerprints_action(parent): action = QtGui.QAction(icontheme.lookup('fingerprint'), _("&Generate AcoustID Fingerprints"), parent) action.setIconText(_("Generate Fingerprints")) action.setStatusTip(_("Generate the AcoustID audio fingerprints for the selected files without doing a lookup")) action.setEnabled(False) action.setToolTip(_("Generate the AcoustID audio fingerprints for the selected files")) action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+Y"))) action.triggered.connect(parent.generate_fingerprints) return action @add_action(MainAction.CLUSTER) def _create_cluster_action(parent): action = QtGui.QAction(icontheme.lookup('picard-cluster'), _("Cl&uster"), parent) action.setStatusTip(_("Cluster files into album clusters")) action.setEnabled(False) # TR: Keyboard shortcut for "Cluster" action.setShortcut(QtGui.QKeySequence(_("Ctrl+U"))) action.triggered.connect(parent.cluster) return action @add_action(MainAction.AUTOTAG) def _create_autotag_action(parent): action = QtGui.QAction(icontheme.lookup('picard-auto-tag'), _("&Lookup"), parent) tip = _("Lookup selected items in MusicBrainz") action.setToolTip(tip) action.setStatusTip(tip) action.setEnabled(False) # TR: Keyboard shortcut for "Lookup" action.setShortcut(QtGui.QKeySequence(_("Ctrl+L"))) action.triggered.connect(parent.autotag) return action @add_action(MainAction.VIEW_INFO) def _create_view_info_action(parent): action = QtGui.QAction(icontheme.lookup('picard-edit-tags'), _("&Info…"), parent) action.setEnabled(False) # TR: Keyboard shortcut for "Info" action.setShortcut(QtGui.QKeySequence(_("Ctrl+I"))) action.triggered.connect(parent.view_info) return action @add_action(MainAction.REFRESH) def _create_refresh_action(parent): action = QtGui.QAction(icontheme.lookup('view-refresh', icontheme.ICON_SIZE_MENU), _("&Refresh"), parent) action.setShortcut(QtGui.QKeySequence(_("Ctrl+R"))) action.triggered.connect(parent.refresh) return action @add_action(MainAction.ENABLE_RENAMING) def _create_enable_renaming_action(parent): config = get_config() action = QtGui.QAction(_("&Rename Files"), parent) action.setCheckable(True) action.setChecked(config.setting['rename_files']) action.triggered.connect(parent.toggle_rename_files) return action @add_action(MainAction.ENABLE_MOVING) def _create_enable_moving_action(parent): config = get_config() action = QtGui.QAction(_("&Move Files"), parent) action.setCheckable(True) action.setChecked(config.setting['move_files']) action.triggered.connect(parent.toggle_move_files) return action @add_action(MainAction.ENABLE_TAG_SAVING) def _create_enable_tag_saving_action(parent): config = get_config() action = QtGui.QAction(_("Save &Tags"), parent) action.setCheckable(True) action.setChecked(not config.setting['dont_write_tags']) action.triggered.connect(parent.toggle_tag_saving) return action @add_action(MainAction.TAGS_FROM_FILENAMES) def _create_tags_from_filenames_action(parent): action = QtGui.QAction(icontheme.lookup('picard-tags-from-filename'), _("Tags From &File Names…"), parent) action.setIconText(_("Parse File Names…")) action.setToolTip(_("Set tags based on the file names")) action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+T"))) action.setEnabled(False) action.triggered.connect(parent.open_tags_from_filenames) return action @add_action(MainAction.OPEN_COLLECTION_IN_BROWSER) def _create_open_collection_in_browser_action(parent): config = get_config() action = QtGui.QAction(_("&Open My Collections in Browser"), parent) action.setEnabled(config.setting['username'] != '') action.triggered.connect(parent.open_collection_in_browser) return action @add_action(MainAction.VIEW_LOG) def _create_view_log_action(parent): action = QtGui.QAction(_("View &Error/Debug Log"), parent) # TR: Keyboard shortcut for "View Error/Debug Log" action.setShortcut(QtGui.QKeySequence(_("Ctrl+G"))) action.triggered.connect(parent.show_log) return action @add_action(MainAction.VIEW_HISTORY) def _create_view_history_action(parent): action = QtGui.QAction(_("View Activity &History"), parent) # TR: Keyboard shortcut for "View Activity History" # On macOS ⌘+H is a system shortcut to hide the window. Use ⌘+Shift+H instead. action.setShortcut(QtGui.QKeySequence(_("Ctrl+Shift+H") if IS_MACOS else _("Ctrl+H"))) action.triggered.connect(parent.show_history) return action @add_action(MainAction.PLAY_FILE) def _create_play_file_action(parent): action = QtGui.QAction(icontheme.lookup('play-music'), _("Open in &Player"), parent) action.setStatusTip(_("Play the file in your default media player")) action.setEnabled(False) action.triggered.connect(parent.play_file) return action @add_action(MainAction.OPEN_FOLDER) def _create_open_folder_action(parent): action = QtGui.QAction(icontheme.lookup('folder', icontheme.ICON_SIZE_MENU), _("Open Containing &Folder"), parent) action.setStatusTip(_("Open the containing folder in your file explorer")) action.setEnabled(False) action.triggered.connect(parent.open_folder) return action @add_action(MainAction.CHECK_UPDATE) def _create_check_update_action(parent): if parent.tagger.autoupdate_enabled: action = QtGui.QAction(_("&Check for Update…"), parent) action.setMenuRole(QtGui.QAction.MenuRole.ApplicationSpecificRole) action.triggered.connect(parent.do_update_check) else: action = None return action
19,259
Python
.py
426
40.943662
133
0.745207
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,096
sys.py
metabrainz_picard/picard/const/sys.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2019, 2023 Philipp Wolfer # Copyright (C) 2019-2021, 2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import sys IS_WIN = sys.platform == 'win32' IS_LINUX = sys.platform == 'linux' IS_MACOS = sys.platform == 'darwin' IS_HAIKU = sys.platform == 'haiku1' # These variables are set by pyinstaller if running from a packaged build # See http://pyinstaller.readthedocs.io/en/stable/runtime-information.html IS_FROZEN = getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS') FROZEN_TEMP_PATH = getattr(sys, '_MEIPASS', '')
1,296
Python
.py
29
43.517241
80
0.760697
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,097
appdirs.py
metabrainz_picard/picard/const/appdirs.py
# -*- coding: utf-8 -*- # # Picard, the next-generation MusicBrainz tagger # # Copyright (C) 2021-2022 Philipp Wolfer # Copyright (C) 2021-2024 Laurent Monin # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import os import os.path from PyQt6.QtCore import ( QCoreApplication, QStandardPaths, ) from picard import ( PICARD_APP_NAME, PICARD_ORG_NAME, ) # Ensure the application is properly configured for the paths to work QCoreApplication.setApplicationName(PICARD_APP_NAME) QCoreApplication.setOrganizationName(PICARD_ORG_NAME) def config_folder(): return os.path.normpath(os.environ.get('PICARD_CONFIG_DIR', QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppConfigLocation))) def cache_folder(): return os.path.normpath(os.environ.get('PICARD_CACHE_DIR', QStandardPaths.writableLocation(QStandardPaths.StandardLocation.CacheLocation))) def plugin_folder(): # FIXME: This really should be in QStandardPaths.StandardLocation.AppDataLocation instead, # but this is a breaking change that requires data migration return os.path.normpath(os.environ.get('PICARD_PLUGIN_DIR', os.path.join(config_folder(), 'plugins')))
1,837
Python
.py
41
42.634146
148
0.789238
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,098
countries.py
metabrainz_picard/picard/const/countries.py
# -*- coding: utf-8 -*- # Automatically generated - don't edit. # Use `python setup.py update_constants` to update it. RELEASE_COUNTRIES = { 'AD': 'Andorra', 'AE': 'United Arab Emirates', 'AF': 'Afghanistan', 'AG': 'Antigua and Barbuda', 'AI': 'Anguilla', 'AL': 'Albania', 'AM': 'Armenia', 'AN': 'Netherlands Antilles', 'AO': 'Angola', 'AQ': 'Antarctica', 'AR': 'Argentina', 'AS': 'American Samoa', 'AT': 'Austria', 'AU': 'Australia', 'AW': 'Aruba', 'AX': 'Åland Islands', 'AZ': 'Azerbaijan', 'BA': 'Bosnia and Herzegovina', 'BB': 'Barbados', 'BD': 'Bangladesh', 'BE': 'Belgium', 'BF': 'Burkina Faso', 'BG': 'Bulgaria', 'BH': 'Bahrain', 'BI': 'Burundi', 'BJ': 'Benin', 'BL': 'Saint Barthélemy', 'BM': 'Bermuda', 'BN': 'Brunei', 'BO': 'Bolivia', 'BQ': 'Bonaire, Sint Eustatius and Saba', 'BR': 'Brazil', 'BS': 'Bahamas', 'BT': 'Bhutan', 'BV': 'Bouvet Island', 'BW': 'Botswana', 'BY': 'Belarus', 'BZ': 'Belize', 'CA': 'Canada', 'CC': 'Cocos (Keeling) Islands', 'CD': 'Democratic Republic of the Congo', 'CF': 'Central African Republic', 'CG': 'Congo', 'CH': 'Switzerland', 'CI': 'Côte d\'Ivoire', 'CK': 'Cook Islands', 'CL': 'Chile', 'CM': 'Cameroon', 'CN': 'China', 'CO': 'Colombia', 'CR': 'Costa Rica', 'CS': 'Serbia and Montenegro', 'CU': 'Cuba', 'CV': 'Cape Verde', 'CW': 'Curaçao', 'CX': 'Christmas Island', 'CY': 'Cyprus', 'CZ': 'Czechia', 'DE': 'Germany', 'DJ': 'Djibouti', 'DK': 'Denmark', 'DM': 'Dominica', 'DO': 'Dominican Republic', 'DZ': 'Algeria', 'EC': 'Ecuador', 'EE': 'Estonia', 'EG': 'Egypt', 'EH': 'Western Sahara', 'ER': 'Eritrea', 'ES': 'Spain', 'ET': 'Ethiopia', 'FI': 'Finland', 'FJ': 'Fiji', 'FK': 'Falkland Islands', 'FM': 'Federated States of Micronesia', 'FO': 'Faroe Islands', 'FR': 'France', 'GA': 'Gabon', 'GB': 'United Kingdom', 'GD': 'Grenada', 'GE': 'Georgia', 'GF': 'French Guiana', 'GG': 'Guernsey', 'GH': 'Ghana', 'GI': 'Gibraltar', 'GL': 'Greenland', 'GM': 'Gambia', 'GN': 'Guinea', 'GP': 'Guadeloupe', 'GQ': 'Equatorial Guinea', 'GR': 'Greece', 'GS': 'South Georgia and the South Sandwich Islands', 'GT': 'Guatemala', 'GU': 'Guam', 'GW': 'Guinea-Bissau', 'GY': 'Guyana', 'HK': 'Hong Kong', 'HM': 'Heard Island and McDonald Islands', 'HN': 'Honduras', 'HR': 'Croatia', 'HT': 'Haiti', 'HU': 'Hungary', 'ID': 'Indonesia', 'IE': 'Ireland', 'IL': 'Israel', 'IM': 'Isle of Man', 'IN': 'India', 'IO': 'British Indian Ocean Territory', 'IQ': 'Iraq', 'IR': 'Iran', 'IS': 'Iceland', 'IT': 'Italy', 'JE': 'Jersey', 'JM': 'Jamaica', 'JO': 'Jordan', 'JP': 'Japan', 'KE': 'Kenya', 'KG': 'Kyrgyzstan', 'KH': 'Cambodia', 'KI': 'Kiribati', 'KM': 'Comoros', 'KN': 'Saint Kitts and Nevis', 'KP': 'North Korea', 'KR': 'South Korea', 'KW': 'Kuwait', 'KY': 'Cayman Islands', 'KZ': 'Kazakhstan', 'LA': 'Laos', 'LB': 'Lebanon', 'LC': 'Saint Lucia', 'LI': 'Liechtenstein', 'LK': 'Sri Lanka', 'LR': 'Liberia', 'LS': 'Lesotho', 'LT': 'Lithuania', 'LU': 'Luxembourg', 'LV': 'Latvia', 'LY': 'Libya', 'MA': 'Morocco', 'MC': 'Monaco', 'MD': 'Moldova', 'ME': 'Montenegro', 'MF': 'Saint Martin (French part)', 'MG': 'Madagascar', 'MH': 'Marshall Islands', 'MK': 'North Macedonia', 'ML': 'Mali', 'MM': 'Myanmar', 'MN': 'Mongolia', 'MO': 'Macao', 'MP': 'Northern Mariana Islands', 'MQ': 'Martinique', 'MR': 'Mauritania', 'MS': 'Montserrat', 'MT': 'Malta', 'MU': 'Mauritius', 'MV': 'Maldives', 'MW': 'Malawi', 'MX': 'Mexico', 'MY': 'Malaysia', 'MZ': 'Mozambique', 'NA': 'Namibia', 'NC': 'New Caledonia', 'NE': 'Niger', 'NF': 'Norfolk Island', 'NG': 'Nigeria', 'NI': 'Nicaragua', 'NL': 'Netherlands', 'NO': 'Norway', 'NP': 'Nepal', 'NR': 'Nauru', 'NU': 'Niue', 'NZ': 'New Zealand', 'OM': 'Oman', 'PA': 'Panama', 'PE': 'Peru', 'PF': 'French Polynesia', 'PG': 'Papua New Guinea', 'PH': 'Philippines', 'PK': 'Pakistan', 'PL': 'Poland', 'PM': 'Saint Pierre and Miquelon', 'PN': 'Pitcairn', 'PR': 'Puerto Rico', 'PS': 'Palestine', 'PT': 'Portugal', 'PW': 'Palau', 'PY': 'Paraguay', 'QA': 'Qatar', 'RE': 'Réunion', 'RO': 'Romania', 'RS': 'Serbia', 'RU': 'Russia', 'RW': 'Rwanda', 'SA': 'Saudi Arabia', 'SB': 'Solomon Islands', 'SC': 'Seychelles', 'SD': 'Sudan', 'SE': 'Sweden', 'SG': 'Singapore', 'SH': 'Saint Helena, Ascension and Tristan da Cunha', 'SI': 'Slovenia', 'SJ': 'Svalbard and Jan Mayen', 'SK': 'Slovakia', 'SL': 'Sierra Leone', 'SM': 'San Marino', 'SN': 'Senegal', 'SO': 'Somalia', 'SR': 'Suriname', 'SS': 'South Sudan', 'ST': 'Sao Tome and Principe', 'SU': 'Soviet Union', 'SV': 'El Salvador', 'SX': 'Sint Maarten (Dutch part)', 'SY': 'Syria', 'SZ': 'Eswatini', 'TC': 'Turks and Caicos Islands', 'TD': 'Chad', 'TF': 'French Southern Territories', 'TG': 'Togo', 'TH': 'Thailand', 'TJ': 'Tajikistan', 'TK': 'Tokelau', 'TL': 'Timor-Leste', 'TM': 'Turkmenistan', 'TN': 'Tunisia', 'TO': 'Tonga', 'TR': 'Türkiye', 'TT': 'Trinidad and Tobago', 'TV': 'Tuvalu', 'TW': 'Taiwan', 'TZ': 'Tanzania', 'UA': 'Ukraine', 'UG': 'Uganda', 'UM': 'United States Minor Outlying Islands', 'US': 'United States', 'UY': 'Uruguay', 'UZ': 'Uzbekistan', 'VA': 'Vatican City', 'VC': 'Saint Vincent and The Grenadines', 'VE': 'Venezuela', 'VG': 'British Virgin Islands', 'VI': 'U.S. Virgin Islands', 'VN': 'Vietnam', 'VU': 'Vanuatu', 'WF': 'Wallis and Futuna', 'WS': 'Samoa', 'XC': 'Czechoslovakia', 'XE': 'Europe', 'XG': 'East Germany', 'XK': 'Kosovo', 'XW': '[Worldwide]', 'YE': 'Yemen', 'YT': 'Mayotte', 'YU': 'Yugoslavia', 'ZA': 'South Africa', 'ZM': 'Zambia', 'ZW': 'Zimbabwe', }
6,400
Python
.py
263
19.38403
57
0.506688
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)
11,099
attributes.py
metabrainz_picard/picard/const/attributes.py
# -*- coding: utf-8 -*- # Automatically generated - don't edit. # Use `python setup.py update_constants` to update it. MB_ATTRIBUTES = { 'DB:cover_art_archive.art_type/name:001': 'Front', 'DB:cover_art_archive.art_type/name:002': 'Back', 'DB:cover_art_archive.art_type/name:003': 'Booklet', 'DB:cover_art_archive.art_type/name:004': 'Medium', 'DB:cover_art_archive.art_type/name:005': 'Obi', 'DB:cover_art_archive.art_type/name:006': 'Spine', 'DB:cover_art_archive.art_type/name:007': 'Track', 'DB:cover_art_archive.art_type/name:008': 'Other', 'DB:cover_art_archive.art_type/name:009': 'Tray', 'DB:cover_art_archive.art_type/name:010': 'Sticker', 'DB:cover_art_archive.art_type/name:011': 'Poster', 'DB:cover_art_archive.art_type/name:012': 'Liner', 'DB:cover_art_archive.art_type/name:013': 'Watermark', 'DB:cover_art_archive.art_type/name:014': 'Raw/Unedited', 'DB:cover_art_archive.art_type/name:015': 'Matrix/Runout', 'DB:cover_art_archive.art_type/name:048': 'Top', 'DB:cover_art_archive.art_type/name:049': 'Bottom', 'DB:medium_format/name:001': 'CD', 'DB:medium_format/name:002': 'DVD', 'DB:medium_format/name:003': 'SACD', 'DB:medium_format/name:004': 'DualDisc', 'DB:medium_format/name:005': 'LaserDisc', 'DB:medium_format/name:006': 'MiniDisc', 'DB:medium_format/name:007': 'Vinyl', 'DB:medium_format/name:008': 'Cassette', 'DB:medium_format/name:009': 'Cartridge', 'DB:medium_format/name:010': 'Reel-to-reel', 'DB:medium_format/name:011': 'DAT', 'DB:medium_format/name:012': 'Digital Media', 'DB:medium_format/name:013': 'Other', 'DB:medium_format/name:014': 'Wax Cylinder', 'DB:medium_format/name:015': 'Piano Roll', 'DB:medium_format/name:016': 'DCC', 'DB:medium_format/name:017': 'HD-DVD', 'DB:medium_format/name:018': 'DVD-Audio', 'DB:medium_format/name:019': 'DVD-Video', 'DB:medium_format/name:020': 'Blu-ray', 'DB:medium_format/name:021': 'VHS', 'DB:medium_format/name:022': 'VCD', 'DB:medium_format/name:023': 'SVCD', 'DB:medium_format/name:024': 'Betamax', 'DB:medium_format/name:025': 'HDCD', 'DB:medium_format/name:026': 'USB Flash Drive', 'DB:medium_format/name:027': 'slotMusic', 'DB:medium_format/name:028': 'UMD', 'DB:medium_format/name:029': '7" Vinyl', 'DB:medium_format/name:030': '10" Vinyl', 'DB:medium_format/name:031': '12" Vinyl', 'DB:medium_format/name:033': 'CD-R', 'DB:medium_format/name:034': '8cm CD', 'DB:medium_format/name:035': 'Blu-spec CD', 'DB:medium_format/name:036': 'SHM-CD', 'DB:medium_format/name:037': 'HQCD', 'DB:medium_format/name:038': 'Hybrid SACD', 'DB:medium_format/name:039': 'CD+G', 'DB:medium_format/name:040': '8cm CD+G', 'DB:medium_format/name:041': 'CDV', 'DB:medium_format/name:042': 'Enhanced CD', 'DB:medium_format/name:043': 'Data CD', 'DB:medium_format/name:044': 'DTS CD', 'DB:medium_format/name:045': 'Playbutton', 'DB:medium_format/name:046': 'Download Card', 'DB:medium_format/name:047': 'DVDplus', 'DB:medium_format/name:048': 'VinylDisc', 'DB:medium_format/name:049': '3.5" Floppy Disk', 'DB:medium_format/name:050': 'Edison Diamond Disc', 'DB:medium_format/name:051': 'Flexi-disc', 'DB:medium_format/name:052': '7" Flexi-disc', 'DB:medium_format/name:053': 'Shellac', 'DB:medium_format/name:054': '10" Shellac', 'DB:medium_format/name:055': '12" Shellac', 'DB:medium_format/name:056': '7" Shellac', 'DB:medium_format/name:057': 'SHM-SACD', 'DB:medium_format/name:058': 'Pathé disc', 'DB:medium_format/name:059': 'VHD', 'DB:medium_format/name:060': 'CED', 'DB:medium_format/name:061': 'Copy Control CD', 'DB:medium_format/name:062': 'SD Card', 'DB:medium_format/name:063': 'Hybrid SACD (CD layer)', 'DB:medium_format/name:064': 'Hybrid SACD (SACD layer)', 'DB:medium_format/name:065': 'DualDisc (DVD-Audio side)', 'DB:medium_format/name:066': 'DualDisc (DVD-Video side)', 'DB:medium_format/name:067': 'DualDisc (CD side)', 'DB:medium_format/name:068': 'DVDplus (DVD-Audio side)', 'DB:medium_format/name:069': 'DVDplus (DVD-Video side)', 'DB:medium_format/name:070': 'DVDplus (CD side)', 'DB:medium_format/name:071': '8" LaserDisc', 'DB:medium_format/name:072': '12" LaserDisc', 'DB:medium_format/name:073': 'Phonograph record', 'DB:medium_format/name:074': 'PlayTape', 'DB:medium_format/name:075': 'HiPac', 'DB:medium_format/name:076': 'Floppy Disk', 'DB:medium_format/name:077': 'Zip Disk', 'DB:medium_format/name:078': '8-Track Cartridge', 'DB:medium_format/name:079': 'Blu-ray-R', 'DB:medium_format/name:080': 'VinylDisc (DVD side)', 'DB:medium_format/name:081': 'VinylDisc (Vinyl side)', 'DB:medium_format/name:082': 'VinylDisc (CD side)', 'DB:medium_format/name:083': 'Microcassette', 'DB:medium_format/name:084': 'SACD (2 channels)', 'DB:medium_format/name:085': 'SACD (multichannel)', 'DB:medium_format/name:086': 'Hybrid SACD (SACD layer, multichannel)', 'DB:medium_format/name:087': 'Hybrid SACD (SACD layer, 2 channels)', 'DB:medium_format/name:088': 'SHM-SACD (multichannel)', 'DB:medium_format/name:089': 'SHM-SACD (2 channels)', 'DB:medium_format/name:090': 'Tefifon', 'DB:medium_format/name:091': '5.25" Floppy Disk', 'DB:medium_format/name:092': 'DVD-R Video', 'DB:medium_format/name:093': 'Data DVD-R', 'DB:medium_format/name:094': 'Data DVD', 'DB:medium_format/name:095': 'KiT Album', 'DB:medium_format/name:128': 'DataPlay', 'DB:medium_format/name:129': 'Mixed Mode CD', 'DB:medium_format/name:130': 'DualDisc (DVD side)', 'DB:medium_format/name:131': 'Betacam SP', 'DB:medium_format/name:164': 'microSD', 'DB:medium_format/name:165': 'Minimax CD', 'DB:medium_format/name:166': 'MiniDVD', 'DB:medium_format/name:167': 'Minimax DVD', 'DB:medium_format/name:168': 'MiniDVD-Audio', 'DB:medium_format/name:169': 'MiniDVD-Video', 'DB:medium_format/name:170': 'Minimax DVD-Audio', 'DB:medium_format/name:171': 'Minimax DVD-Video', 'DB:medium_format/name:203': 'Acetate', 'DB:medium_format/name:204': '7" Acetate', 'DB:medium_format/name:205': '10" Acetate', 'DB:medium_format/name:206': '12" Acetate', 'DB:medium_format/name:207': '3" Vinyl', 'DB:medium_format/name:208': 'ROM cartridge', 'DB:release_group_primary_type/name:001': 'Album', 'DB:release_group_primary_type/name:002': 'Single', 'DB:release_group_primary_type/name:003': 'EP', 'DB:release_group_primary_type/name:011': 'Other', 'DB:release_group_primary_type/name:012': 'Broadcast', 'DB:release_group_secondary_type/name:001': 'Compilation', 'DB:release_group_secondary_type/name:002': 'Soundtrack', 'DB:release_group_secondary_type/name:003': 'Spokenword', 'DB:release_group_secondary_type/name:004': 'Interview', 'DB:release_group_secondary_type/name:005': 'Audiobook', 'DB:release_group_secondary_type/name:006': 'Live', 'DB:release_group_secondary_type/name:007': 'Remix', 'DB:release_group_secondary_type/name:008': 'DJ-mix', 'DB:release_group_secondary_type/name:009': 'Mixtape/Street', 'DB:release_group_secondary_type/name:010': 'Demo', 'DB:release_group_secondary_type/name:011': 'Audio drama', 'DB:release_group_secondary_type/name:012': 'Field recording', 'DB:release_status/name:001': 'Official', 'DB:release_status/name:002': 'Promotion', 'DB:release_status/name:003': 'Bootleg', 'DB:release_status/name:004': 'Pseudo-Release', 'DB:release_status/name:005': 'Withdrawn', 'DB:release_status/name:006': 'Cancelled', }
7,789
Python
.py
157
44.732484
74
0.660333
metabrainz/picard
3,687
383
10
GPL-2.0
9/5/2024, 5:11:02 PM (Europe/Amsterdam)