diff --git a/CustomQt.py b/CustomQt.py index 78db3d1..478a735 100644 --- a/CustomQt.py +++ b/CustomQt.py @@ -8,7 +8,7 @@ from aqt.utils import showInfo #Import all of the Qt GUI library -from aqt.qt import * +from aqt.qt import QPalette, QBrush, QColor, QComboBox, QStyledItemDelegate, QEvent, QFontMetrics, QStandardItem, Qt # Qt classes from Anki's qt wrapper #Taken from: https://gis.stackexchange.com/questions/350148/qcombobox-multiple-selection-pyqt5 @@ -28,8 +28,8 @@ def __init__(self, *args, **kwargs): self.setEditable(True) self.lineEdit().setReadOnly(True) # Make the lineedit the same color as QPushButton - palette = qApp.palette() - palette.setBrush(QPalette.Base, palette.button()) + palette = mw.palette() + palette.setBrush(QPalette.ColorRole.Base, palette.button()) self.lineEdit().setPalette(palette) # Use custom delegate @@ -53,7 +53,7 @@ def resizeEvent(self, event): def eventFilter(self, object, event): if object == self.lineEdit(): - if event.type() == QEvent.MouseButtonRelease: + if event.type() == QEvent.Type.MouseButtonRelease: if self.closeOnLineEditClick: self.hidePopup() else: @@ -62,14 +62,14 @@ def eventFilter(self, object, event): return False if object == self.view().viewport(): - if event.type() == QEvent.MouseButtonRelease: + if event.type() == QEvent.Type.MouseButtonRelease: index = self.view().indexAt(event.pos()) item = self.model().item(index.row()) - if item.checkState() == Qt.Checked: - item.setCheckState(Qt.Unchecked) + if item.checkState() == Qt.CheckState.Checked: + item.setCheckState(Qt.CheckState.Unchecked) else: - item.setCheckState(Qt.Checked) + item.setCheckState(Qt.CheckState.Checked) return True return False @@ -93,13 +93,13 @@ def timerEvent(self, event): def updateText(self): texts = [] for i in range(self.model().rowCount()): - if self.model().item(i).checkState() == Qt.Checked: + if self.model().item(i).checkState() == Qt.CheckState.Checked: texts.append(self.model().item(i).text()) text = ", ".join(texts) # Compute elided text (with "...") metrics = QFontMetrics(self.lineEdit().font()) - elidedText = metrics.elidedText(text, Qt.ElideRight, self.lineEdit().width()) + elidedText = metrics.elidedText(text, Qt.TextElideMode.ElideRight, self.lineEdit().width()) self.lineEdit().setText(elidedText) def addItem(self, text, data=None): @@ -109,8 +109,8 @@ def addItem(self, text, data=None): item.setData(text) else: item.setData(data) - item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable) - item.setData(Qt.Unchecked, Qt.CheckStateRole) + item.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable) + item.setData(Qt.CheckState.Unchecked, Qt.ItemDataRole.CheckStateRole) self.model().appendRow(item) def addItems(self, texts, datalist=None): diff --git a/FieldTable.py b/FieldTable.py index 8b0c909..144f83a 100644 --- a/FieldTable.py +++ b/FieldTable.py @@ -40,9 +40,9 @@ def __init__(self, group, *args, **kwargs): self.addFieldRow() #Resize the columns - self.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) - self.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch) - self.horizontalHeader().setSectionResizeMode(2, QHeaderView.Fixed) + self.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch) + self.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch) + self.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Fixed) self.horizontalHeader().resizeSection(2, 65) #Method trigger to update the field in the Comparer object and also adds a new row if the index = row count - 1 diff --git a/GroupWindow.py b/GroupWindow.py index ed640c4..cf6d84b 100644 --- a/GroupWindow.py +++ b/GroupWindow.py @@ -38,7 +38,7 @@ def __init__(self, Comparer, parent, *args, **kwargs): #Create and add widgets to this layout group window self.groupNum = self.groupIndex + 1 self.title = QLabel(f"Group {self.groupNum} (G{self.groupNum})", parent) - self.title.setAlignment(Qt.AlignCenter) + self.title.setAlignment(Qt.AlignmentFlag.AlignCenter) self.addWidget(self.title) #Add widget to select group type and link trigger method @@ -77,7 +77,7 @@ def __init__(self, Comparer, parent, *args, **kwargs): #Add widget with autocompleter to enter a tag for the duplicate action self.tagBox = QLineEdit(parent) completer = QCompleter(self.group.fieldInfo['Tags'].keys(), parent) - completer.setCaseSensitivity(Qt.CaseInsensitive) + completer.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive) self.tagBox.setCompleter(completer) self.tagBox.setPlaceholderText('Enter an existing tag or a new one.') self.addWidget(self.tagBox) @@ -282,4 +282,4 @@ def setEnabledAll(self, boolean): self.tagBox.setEnabled(boolean) self.fieldTableLabel.setEnabled(boolean) - self.fieldTable.setEnabledAll(boolean) \ No newline at end of file + self.fieldTable.setEnabledAll(boolean) diff --git a/MainWindow.py b/MainWindow.py index c96e6dc..5234140 100644 --- a/MainWindow.py +++ b/MainWindow.py @@ -37,7 +37,7 @@ def __init__(self, *args, **kwargs): \nBy default, notes in different groups are marked as duplicates when their fields with the same number matches.\ \nYou can disable this and specificy your own conditions for duplicate notes if you enable \'advanced mode\' below.\ \nHover over \'advanced mode\' or \'RegEx capture\' for more explanation.') - self.intro.setAlignment(Qt.AlignCenter) + self.intro.setAlignment(Qt.AlignmentFlag.AlignCenter) self.layout.addWidget(self.intro) #Create Comparer object and then using the Comparer, create subwindows. diff --git a/QueueDialog.py b/QueueDialog.py index 0e6060d..78d80a4 100644 --- a/QueueDialog.py +++ b/QueueDialog.py @@ -12,7 +12,7 @@ from aqt.utils import showInfo #Import all of the Qt GUI library -from aqt.qt import * +from aqt.qt import QComboBox, QDialog, QHeaderView, QLabel, QLineEdit, QMessageBox, QPushButton, QTableWidget, QTableWidgetItem, QVBoxLayout, Qt #Import local .py modules from . import Utils @@ -40,7 +40,7 @@ def __init__(self, Comparer, parent, *args, **kwargs): If you want to change the action for all duplicates in a group at once, close this window, select the appropiate action from the dropdown menu and reopen this window by pressing 'show duplicates'. If you hover over a duplicate note you will be able to see all of its fields. Some notes are marked as duplicates multiple times and all of the set actions will therefore be performed upon it.''', self) - self.intro.setAlignment(Qt.AlignCenter) + self.intro.setAlignment(Qt.AlignmentFlag.AlignCenter) self.layout.addWidget(self.intro) #Add a table widget to display the queue @@ -80,9 +80,9 @@ def __init__(self, Comparer, parent, *args, **kwargs): #Resize the columns for groupIndex in range(self.Comparer.groupNum): - self.queueTable.horizontalHeader().setSectionResizeMode(0 + groupIndex*3, QHeaderView.Stretch) - self.queueTable.horizontalHeader().setSectionResizeMode(1 + groupIndex*3, QHeaderView.Fixed) - self.queueTable.horizontalHeader().setSectionResizeMode(2 + groupIndex*3, QHeaderView.Fixed) + self.queueTable.horizontalHeader().setSectionResizeMode(0 + groupIndex*3, QHeaderView.ResizeMode.Stretch) + self.queueTable.horizontalHeader().setSectionResizeMode(1 + groupIndex*3, QHeaderView.ResizeMode.Fixed) + self.queueTable.horizontalHeader().setSectionResizeMode(2 + groupIndex*3, QHeaderView.ResizeMode.Fixed) self.queueTable.horizontalHeader().resizeSection(1 + groupIndex*3, 105) self.queueTable.horizontalHeader().resizeSection(2 + groupIndex*3, 105) @@ -208,15 +208,15 @@ def updateTextBox(self, rowIndex, groupIndex, textBox, action): #Method to ask for conformation for performing the actions by creating a message box def askConfirmation(self): msg = QMessageBox() - msg.setIcon(QMessageBox.Question) + msg.setIcon(QMessageBox.Icon.Question) msg.setText("All actions have been set and are ready to be performed.") msg.setInformativeText("Are you sure you want to perform the set actions on the notes?") msg.setWindowTitle("Confirmation") - msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel) res = msg.exec() #When the user agrees, close the current window #and perform the actions - if res == QMessageBox.Ok: + if res == QMessageBox.StandardButton.Ok: self.accept() self.Comparer.performActions(self.maxRows) diff --git a/README.md b/README.md index 609c22b..c4adcce 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Note Comparer Anki -An anki addon for 2.1 for comparing notes for duplicates. +An anki addon for > 25.09 for comparing notes for duplicates. ## What to use Note Comparer for? ![Main window](/screenshots/main.jpg)