-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
1222821
commit 21eaa85
Showing
10 changed files
with
142 additions
and
9 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
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,80 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Picard, the next-generation MusicBrainz tagger | ||
# | ||
# Copyright (C) 2024 Shubham Patel | ||
# | ||
# 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 ( | ||
QStandardItem, | ||
QStandardItemModel, | ||
) | ||
from PyQt6.QtWidgets import QComboBox | ||
|
||
|
||
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 show_selected_items(self): | ||
selected_items = [self.model().item(i).text() for i in range(self.model().rowCount()) | ||
if self.model().item(i).checkState() == Qt.CheckState.Checked] | ||
return 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
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