-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PICARD-2729: Allow disabling date sanitazation for APE and Vorbis tags
- Loading branch information
1 parent
05ddd5f
commit a00cb79
Showing
8 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# -*- 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.QtGui import QStandardItemModel, QStandardItem | ||
from PyQt6.QtWidgets import QComboBox | ||
from PyQt6.QtCore import Qt | ||
|
||
|
||
class MultiComboBox(QComboBox): | ||
def __init__(self, parent=None): | ||
super().__init__(parent) | ||
self.setEditable(True) | ||
self.lineEdit().setReadOnly(True) | ||
self.setModel(QStandardItemModel(self)) | ||
|
||
# Connect to the dataChanged signal to update the text | ||
self.model().dataChanged.connect(self.updateText) | ||
|
||
def addItem(self, text: str, data=None): | ||
item = QStandardItem() | ||
item.setText(text) | ||
item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable) | ||
item.setData(Qt.CheckState.Unchecked, Qt.ItemDataRole.CheckStateRole) | ||
self.model().appendRow(item) | ||
|
||
def addItems(self, items_list: list): | ||
for text in items_list: | ||
self.addItem(text) | ||
|
||
def updateText(self): | ||
selected_items = [self.model().item(i).text() for i in range(self.model().rowCount()) | ||
if self.model().item(i).checkState() == Qt.CheckState.Checked] | ||
self.lineEdit().setText(", ".join(selected_items)) | ||
|
||
def showPopup(self): | ||
super().showPopup() | ||
# Set the state of each item in the dropdown | ||
for i in range(self.model().rowCount()): | ||
item = self.model().item(i) | ||
combo_box_view = self.view() | ||
combo_box_view.setRowHidden(i, False) | ||
check_box = combo_box_view.indexWidget(item.index()) | ||
if check_box: | ||
check_box.setChecked(item.checkState() == Qt.CheckState.Checked) | ||
|
||
def hidePopup(self): | ||
# Update the check state of each item based on the checkbox state | ||
for i in range(self.model().rowCount()): | ||
item = self.model().item(i) | ||
combo_box_view = self.view() | ||
check_box = combo_box_view.indexWidget(item.index()) | ||
if check_box: | ||
item.setCheckState(Qt.CheckState.Checked if check_box.isChecked() else Qt.CheckState.Unchecked) | ||
super().hidePopup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters