Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Comics Manager: PyQt6 fixes
Freya Lupen330a8053006b
diff --git a/plugins/python/comics_project_management_tools/comics_export_dialog.py b/plugins/python/comics_project_management_tools/comics_export_dialog.pyindex 7a629f7195..58b3aeb706 100644--- a/plugins/python/comics_project_management_tools/comics_export_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_export_dialog.py@@ -134,7 +134,7 @@ class labelSelector(QComboBox):def __init__(self):super(labelSelector, self).__init__()lisOfColors = []- lisOfColors.append(Qt.transparent)+ lisOfColors.append(Qt.GlobalColor.transparent)lisOfColors.append(QColor(91, 173, 220))lisOfColors.append(QColor(151, 202, 63))lisOfColors.append(QColor(247, 229, 61))@@ -150,7 +150,7 @@ class labelSelector(QComboBox):item.setFlags(Qt.ItemFlag.ItemIsUserCheckable | Qt.ItemFlag.ItemIsEnabled)item.setCheckState(Qt.CheckState.Unchecked)item.setText(" ")- item.setData(color, Qt.ItemDataRole.BackgroundColorRole)+ item.setData(color, Qt.ItemDataRole.BackgroundRole)self.itemModel.appendRow(item)self.setModel(self.itemModel)diff --git a/plugins/python/comics_project_management_tools/comics_metadata_dialog.py b/plugins/python/comics_project_management_tools/comics_metadata_dialog.pyindex 6fe9b2b8cc..1f012f1c3f 100644--- a/plugins/python/comics_project_management_tools/comics_metadata_dialog.py+++ b/plugins/python/comics_project_management_tools/comics_metadata_dialog.py@@ -18,11 +18,11 @@ from pathlib import Path # For reading all the files in a directory.try:from PyQt6.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QPainter, QPalette, QFontDatabasefrom PyQt6.QtWidgets import QComboBox, QCompleter, QStyledItemDelegate, QLineEdit, QDialog, QDialogButtonBox, QVBoxLayout, QFormLayout, QTabWidget, QWidget, QPlainTextEdit, QHBoxLayout, QSpinBox, QDateEdit, QPushButton, QLabel, QTableView- from PyQt6.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid+ from PyQt6.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid, QLibraryInfoexcept:from PyQt5.QtGui import QStandardItem, QStandardItemModel, QImage, QIcon, QPixmap, QPainter, QPalette, QFontDatabasefrom PyQt5.QtWidgets import QComboBox, QCompleter, QStyledItemDelegate, QLineEdit, QDialog, QDialogButtonBox, QVBoxLayout, QFormLayout, QTabWidget, QWidget, QPlainTextEdit, QHBoxLayout, QSpinBox, QDateEdit, QPushButton, QLabel, QTableView- from PyQt5.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid+ from PyQt5.QtCore import QDir, QLocale, QStringListModel, Qt, QDate, QSize, QUuid, QLibraryInfo"""multi entry completer cobbled together from the two examples on stackoverflow:3779720@@ -88,8 +88,8 @@ class language_combo_box(QComboBox):codeIcon = QImage(self.iconSize(), QImage.Format.Format_ARGB32)painter = QPainter(codeIcon)painter.setBrush(Qt.GlobalColor.transparent)- codeIcon.fill(Qt.transparent)- font = QFontDatabase().systemFont(QFontDatabase.SystemFont.FixedFont)+ codeIcon.fill(Qt.GlobalColor.transparent)+ font = QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont)painter.setFont(font)painter.setPen(self.palette().color(QPalette.ColorRole.Text))painter.drawText(codeIcon.rect(), Qt.AlignmentFlag.AlignCenter,lang)@@ -136,9 +136,9 @@ class country_combo_box(QComboBox):self.setIconSize(QSize(32, 22))codeIcon = QImage(self.iconSize(), QImage.Format.Format_ARGB32)painter = QPainter(codeIcon)- painter.setBrush(Qt.transparent)- codeIcon.fill(Qt.transparent)- font = QFontDatabase().systemFont(QFontDatabase.SystemFont.FixedFont)+ painter.setBrush(Qt.GlobalColor.transparent)+ codeIcon.fill(Qt.GlobalColor.transparent)+ font = QFontDatabase.systemFont(QFontDatabase.SystemFont.FixedFont)painter.setFont(font)painter.setPen(self.palette().color(QPalette.ColorRole.Text))painter.drawText(codeIcon.rect(), Qt.AlignmentFlag.AlignCenter,country)@@ -216,7 +216,7 @@ class author_delegate(QStyledItemDelegate):if index.column() == self.completerColumn:editor.setCompleter(QCompleter(self.completerStrings))- editor.completer().setCaseSensitivity(False)+ editor.completer().setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)return editor@@ -278,13 +278,13 @@ class comic_meta_data_editor(QDialog):genreCompletion = multi_entry_completer()genreCompletion.setModel(QStringListModel(self.genreKeysList))self.lnGenre.setCompleter(genreCompletion)- genreCompletion.setCaseSensitivity(False)+ genreCompletion.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)self.lnGenre.setToolTip(i18n("The genre of the work. Prefilled values are from the ACBF, but you can fill in your own. Separate genres with commas. Try to limit the amount to about two or three."))self.lnCharacters = QLineEdit()characterCompletion = multi_entry_completer()characterCompletion.setModel(QStringListModel(self.characterKeysList))- characterCompletion.setCaseSensitivity(False)+ characterCompletion.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)characterCompletion.setFilterMode(Qt.MatchFlag.MatchContains) # So that if there is a list of names with last names, people can type in a last name.self.lnCharacters.setCompleter(characterCompletion)self.lnCharacters.setToolTip(i18n("The names of the characters that this comic revolves around. Comma-separated."))@@ -292,7 +292,7 @@ class comic_meta_data_editor(QDialog):self.lnFormat = QLineEdit()formatCompletion = multi_entry_completer()formatCompletion.setModel(QStringListModel(self.formatKeysList))- formatCompletion.setCaseSensitivity(False)+ formatCompletion.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)self.lnFormat.setCompleter(formatCompletion)ratingLayout = QHBoxLayout()@@ -318,7 +318,7 @@ class comic_meta_data_editor(QDialog):otherCompletion = multi_entry_completer()otherCompletion.setModel(QStringListModel(self.otherKeysList))- otherCompletion.setCaseSensitivity(False)+ otherCompletion.setCaseSensitivity(Qt.CaseSensitivity.CaseInsensitive)otherCompletion.setFilterMode(Qt.MatchFlag.MatchContains)self.lnOtherKeywords = QLineEdit()self.lnOtherKeywords.setCompleter(otherCompletion)@@ -623,12 +623,21 @@ class comic_meta_data_editor(QDialog):else:self.cmbLanguage.setEntryToCode(code)if "readingDirection" in config.keys():- if config["readingDirection"] == "leftToRight":- self.cmbReadingMode.setCurrentIndex(int(Qt.LayoutDirection.LeftToRight))- else:- self.cmbReadingMode.setCurrentIndex(int(Qt.LayoutDirection.RightToLeft))+ if QLibraryInfo.version().majorVersion() == 6: # PyQt6+ if config["readingDirection"] == "leftToRight":+ self.cmbReadingMode.setCurrentIndex(Qt.LayoutDirection.LeftToRight.value)+ else:+ self.cmbReadingMode.setCurrentIndex(Qt.LayoutDirection.RightToLeft.value)+ else: #PyQt5+ if config["readingDirection"] == "leftToRight":+ self.cmbReadingMode.setCurrentIndex(Qt.LayoutDirection.LeftToRight)+ else:+ self.cmbReadingMode.setCurrentIndex(Qt.LayoutDirection.RightToLeft)else:- self.cmbReadingMode.setCurrentIndex(QLocale(self.cmbLanguage.codeForCurrentEntry()).textDirection())+ if QLibraryInfo.version().majorVersion() == 6: # PyQt6+ self.cmbReadingMode.setCurrentIndex(QLocale(self.cmbLanguage.codeForCurrentEntry()).textDirection().value)+ else:+ self.cmbReadingMode.setCurrentIndex(QLocale(self.cmbLanguage.codeForCurrentEntry()).textDirection())if "publisherName" in config.keys():self.publisherName.setText(config["publisherName"])if "publisherCity" in config.keys():diff --git a/plugins/python/comics_project_management_tools/comics_project_manager_docker.py b/plugins/python/comics_project_management_tools/comics_project_manager_docker.pyindex 21244f09d0..0ff693a8a3 100644--- a/plugins/python/comics_project_management_tools/comics_project_manager_docker.py+++ b/plugins/python/comics_project_management_tools/comics_project_manager_docker.py@@ -135,7 +135,7 @@ class comic_page_delegate(QStyledItemDelegate):if (index.data(CPE.LASTEDIT) is None) and (index.data(CPE.EDITOR) is None):painter.setOpacity(0.3)painter.setFont(italics)- textLastEdit = metrics.elidedText(textLastEdit, Qt.TextElideFlag.ElideRight, labelWidth)+ textLastEdit = metrics.elidedText(textLastEdit, Qt.TextElideMode.ElideRight, labelWidth)painter.drawText(textRect, Qt.TextFlag.TextWordWrap, textLastEdit)painter.setFont(regular)@@ -154,7 +154,7 @@ class comic_page_delegate(QStyledItemDelegate):painter.setFont(italics)linesTotal = floor(descRect.height()/metrics.lineSpacing())if linesTotal == 1:- textDescription = metrics.elidedText(textDescription, Qt.TextElideFlag.ElideRight, labelWidth)+ textDescription = metrics.elidedText(textDescription, Qt.TextElideMode.ElideRight, labelWidth)painter.drawText(descRect, Qt.TextFlag.TextWordWrap, textDescription)else:descRect.setHeight(linesTotal*metrics.lineSpacing())@@ -844,7 +844,7 @@ class comics_project_manager_docker(DockWidget):# of `slot_check_for_page_update` would not know which files to update now.# https://bugs.kde.org/show_bug.cgi?id=426701self.updateurls.append(url)- QTimer.singleShot(200, Qt.PreciseTimer, self.slot_check_for_page_update)+ QTimer.singleShot(200, Qt.TimerType.PreciseTimer, self.slot_check_for_page_update)def slot_check_for_page_update(self):@@ -897,7 +897,7 @@ class comics_project_manager_docker(DockWidget):dialog.layout().addWidget(sizesBox)dialog.layout().addWidget(buttons)- if dialog.exec() == QDialog.Accepted:+ if dialog.exec() == QDialog.DialogCode.Accepted:progress = QProgressDialog(i18n("Resizing pages..."), str(), 0, len(self.setupDictionary["pages"]))progress.setWindowTitle(i18n("Resizing Pages"))progress.setCancelButton(None)diff --git a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.pyindex 149fcca409..13774fc2db 100644--- a/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py+++ b/plugins/python/comics_project_management_tools/exporters/CPMT_ACBF_XML_Exporter.py@@ -16,11 +16,11 @@ http://acbf.wikia.com/wiki/ACBF_Specificationsimport osimport retry:- from PyQt6.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer+ from PyQt6.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer, QLocalefrom PyQt6.QtGui import QImage, QColor, QFont, QRawFontfrom PyQt6.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeListexcept:- from PyQt5.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer+ from PyQt5.QtCore import QDate, Qt, QPointF, QByteArray, QBuffer, QLocalefrom PyQt5.QtGui import QImage, QColor, QFont, QRawFontfrom PyQt5.QtXml import QDomDocument, QDomElement, QDomText, QDomNodeListfrom . import CPMT_po_parser as po_parser@@ -351,7 +351,7 @@ def write_xml(configDictionary = {}, pageData = [], pagesLocationList = [], locacbfDate = document.createElement("creation-date")now = QDate.currentDate()acbfDate.setAttribute("value", now.toString(Qt.DateFormat.ISODate))- acbfDate.appendChild(document.createTextNode(str(now.toString(Qt.DateFormat.SystemLocaleLongDate))))+ acbfDate.appendChild(document.createTextNode(QLocale().toString(now, QLocale.FormatType.LongFormat)))documentInfo.appendChild(acbfDate)if "acbfSource" in configDictionary.keys():