Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Fix Qt6 deprecations with incompatible changes

Freya Lupene052022362fd
diff --git a/krita/main.cc b/krita/main.cc
index 7bf3c79958..bca8ab4007 100644
--- a/krita/main.cc
+++ b/krita/main.cc
@@ -249,8 +249,10 @@ extern "C" MAIN_EXPORT int MAIN_FN(int argc, char **argv)
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ //Does nothing on Qt6.
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
-
+#endif
QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache, true);
// In Qt6, QImageReader has an allocation limit to prevent large memory allocations.
@@ -922,7 +924,11 @@ void installQtTranslations(KisApplication &app)
localeList.append(defaultLocale);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QString translationsPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
+#else
+ QString translationsPath = QLibraryInfo::path(QLibraryInfo::TranslationsPath);
+#endif
dbgLocale << "Qt translations path:" << translationsPath;
Q_FOREACH(const auto &localeToLoad, localeList) {
@@ -991,7 +997,11 @@ void installEcmTranslations(KisApplication &app)
#if defined(Q_OS_ANDROID)
const QString fullPath = QStringLiteral("assets:/") + subPath;
#else
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const QString root = QLibraryInfo::location(QLibraryInfo::PrefixPath);
+#else
+ const QString root = QLibraryInfo::path(QLibraryInfo::PrefixPath);
+#endif
// Our patched k18n uses AppDataLocation (for AppImage). Not using
// KoResourcePaths::getAppDataLocation is correct here, because we
diff --git a/libs/flake/text/KoSvgTextProperties.cpp b/libs/flake/text/KoSvgTextProperties.cpp
index 8ed0aa3bd5..b442a6d422 100644
--- a/libs/flake/text/KoSvgTextProperties.cpp
+++ b/libs/flake/text/KoSvgTextProperties.cpp
@@ -505,7 +505,11 @@ void KoSvgTextProperties::parseSvgTextAttribute(const SvgLoadingContext &context
} else if (param == "right") {
underlinePos.verticalPosition = UnderlineRight;
setPosition = true;
+#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
} else if (QColor::isValidColor(param)) {
+#else
+ } else if (QColor::isValidColorName(param)) {
+#endif
// TODO: Convert to KoColor::fromSvg11.
textDecorationColor = QColor(param);
}
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index 16344eb5f9..3af47d9db2 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -2623,7 +2623,11 @@ KoShape *KoSvgTextShapeFactory::createShape(const KoProperties *params, KoDocume
QVariant rect = params->property("shapeRect");
QVariant origin = params->property("origin");
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (rect.type()==QVariant::RectF) {
+#else
+ if (rect.typeId() == QMetaType::QRectF) {
+#endif
shapeRect = rect.toRectF();
}
@@ -2632,7 +2636,11 @@ KoShape *KoSvgTextShapeFactory::createShape(const KoProperties *params, KoDocume
defs,
shapeRect,
documentResources->documentResolution());
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (origin.type() == QVariant::PointF) {
+#else
+ if (origin.typeId() == QMetaType::QPointF) {
+#endif
shape->setPosition(origin.toPointF());
} else {
shape->setPosition(shapeRect.topLeft());
diff --git a/libs/global/KisUsageLogger.cpp b/libs/global/KisUsageLogger.cpp
index 0ca40195ba..c67faa4f27 100644
--- a/libs/global/KisUsageLogger.cpp
+++ b/libs/global/KisUsageLogger.cpp
@@ -115,7 +115,10 @@ QString KisUsageLogger::basicSystemInfo()
}
}
#endif
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ // Attribute does nothing on Qt6
systemInfo.append("\n Hidpi: ").append(QCoreApplication::testAttribute(Qt::AA_EnableHighDpiScaling) ? "true" : "false");
+#endif
#ifdef Q_OS_MACOS
KisMacosEntitlements entitlements;
systemInfo.append("\n Sandbox: ").append((entitlements.sandbox()) ? "true" : "false");
diff --git a/libs/global/kis_dom_utils.cpp b/libs/global/kis_dom_utils.cpp
index f8a84c4191..89de4b591b 100644
--- a/libs/global/kis_dom_utils.cpp
+++ b/libs/global/kis_dom_utils.cpp
@@ -276,7 +276,11 @@ bool loadValue(const QDomElement &e, QString *value)
bool loadValue(const QDomElement &e, QColor *value)
{
if (!Private::checkType(e, "qcolor")) return false;
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
value->setNamedColor(e.attribute("value", "#FFFF0000"));
+#else
+ value->fromString(e.attribute("value", "#FFFF0000"));
+#endif
return true;
}
diff --git a/libs/image/kis_properties_configuration.h b/libs/image/kis_properties_configuration.h
index a6d13576b8..4f3c99ec64 100644
--- a/libs/image/kis_properties_configuration.h
+++ b/libs/image/kis_properties_configuration.h
@@ -132,7 +132,7 @@ public:
* <li>A KoColor
* <li>A QColor
* <li>A string that can be parsed as an XML color definition
- * <li>A string that QColor can convert to a color (see https://doc.qt.io/qt-5/qcolor.html#setNamedColor)
+ * <li>A string that QColor can convert to a color (see https://doc.qt.io/qt-6/qcolor.html#fromString)
* <li>An integer that QColor can convert to a color
* </ul>
*
diff --git a/libs/image/tests/kis_transform_worker_test.cpp b/libs/image/tests/kis_transform_worker_test.cpp
index e05fc41a63..5fbdc427e5 100644
--- a/libs/image/tests/kis_transform_worker_test.cpp
+++ b/libs/image/tests/kis_transform_worker_test.cpp
@@ -61,7 +61,11 @@ void testMirror(const QRect &imageRect, const QRect &mirrorRect, Qt::Orientation
QImage srcImage = dev->convertToQImage(0, mirrorRect.x(), mirrorRect.y(), mirrorRect.width(), mirrorRect.height());
+#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
QImage mirroredImage = srcImage.mirrored(orientation == Qt::Horizontal, orientation == Qt::Vertical);
+#else
+ QImage mirroredImage = srcImage.flipped(orientation);
+#endif
QImage result;
//srcImage.save("input.png");
@@ -169,7 +173,11 @@ void KisTransformWorkerTest::testMirrorTransactionX()
QImage result = dev2->convertToQImage(0, 0, 0, image.width(), image.height());
+#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
image = image.mirrored(true, false);
+#else
+ image = image.flipped(Qt::Orientation::Horizontal);
+#endif
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, result)) {
@@ -193,7 +201,11 @@ void KisTransformWorkerTest::testMirrorTransactionY()
QImage result = dev2->convertToQImage(0, 0, 0, image.width(), image.height());
+#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
image = image.mirrored(false, true);
+#else
+ image = image.flipped(Qt::Orientation::Vertical);
+#endif
QPoint errpoint;
if (!TestUtil::compareQImages(errpoint, image, result)) {
diff --git a/libs/libkis/FillLayer.h b/libs/libkis/FillLayer.h
index a4295dcb08..284461e3a2 100644
--- a/libs/libkis/FillLayer.h
+++ b/libs/libkis/FillLayer.h
@@ -37,7 +37,7 @@ public:
* the name of a pattern as known to the resource system: "pattern" = "Cross01.pat".
*
* For a "color" fill layer, the InfoObject can contain a single "color" parameter with
- * a QColor, a string that QColor can parse (see https://doc.qt.io/qt-5/qcolor.html#setNamedColor)
+ * a QColor, a string that QColor can parse (see https://doc.qt.io/qt-6/qcolor.html#fromString)
* or an XML description of the color, which can be derived from a @see ManagedColor.
*
* @param selection a selection object, can be empty
diff --git a/libs/libkis/InfoObject.h b/libs/libkis/InfoObject.h
index b55e492233..5d39b4bc28 100644
--- a/libs/libkis/InfoObject.h
+++ b/libs/libkis/InfoObject.h
@@ -46,7 +46,7 @@ public Q_SLOTS:
* set the property identified by @p key to @p value
*
* If you want create a property that represents a color, you can use a QColor
- * or hex string, as defined in https://doc.qt.io/qt-5/qcolor.html#setNamedColor.
+ * or hex string, as defined in https://doc.qt.io/qt-6/qcolor.html#fromString.
*
*/
void setProperty(const QString &key, QVariant value);
diff --git a/libs/metadata/kis_meta_data_schema.cc b/libs/metadata/kis_meta_data_schema.cc
index 8266ec42a7..cc98d96067 100644
--- a/libs/metadata/kis_meta_data_schema.cc
+++ b/libs/metadata/kis_meta_data_schema.cc
@@ -33,11 +33,17 @@ bool Schema::Private::load(const QString& _fileName)
dbgMetaData << "Loading from " << _fileName;
QDomDocument document;
+ QFile file(_fileName);
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
QString error;
int line, column;
- QFile file(_fileName);
if (!document.setContent(&file, &error, &line, &column)) {
dbgMetaData << error << " at " << line << ", " << column << " in " << _fileName;
+#else
+ QDomDocument::ParseResult result = document.setContent(&file);
+ if (!result) {
+ dbgMetaData << result.errorMessage << " at " << result.errorLine << ", " << result.errorColumn << " in " << _fileName;
+#endif
return false;
}
diff --git a/libs/pigment/KoColor.cpp b/libs/pigment/KoColor.cpp
index 51697262c3..c75970d0ff 100644
--- a/libs/pigment/KoColor.cpp
+++ b/libs/pigment/KoColor.cpp
@@ -561,7 +561,11 @@ KoColor KoColor::fromSVG11(const QString value, QHash<QString, const KoColorProf
for (QString def : colorDefinitions) {
if (def.toLower() == "currentcolor") {
parsed = current;
+#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
} else if (QColor::isValidColor(def)) {
+#else
+ } else if (QColor::isValidColorName(def)) {
+#endif
parsed.fromQColor(QColor(def));
} else if (def.toLower().startsWith("rgb")) {
QString parse = def.trimmed();
diff --git a/libs/pigment/resources/KoColorSet.cpp b/libs/pigment/resources/KoColorSet.cpp
index 5288142cb3..8d4c02d77a 100644
--- a/libs/pigment/resources/KoColorSet.cpp
+++ b/libs/pigment/resources/KoColorSet.cpp
@@ -1909,6 +1909,7 @@ bool KoColorSet::Private::loadSbzSwatchbook(QScopedPointer<KoStore> &store)
dbgPigment << "XML palette: " << colorSet->filename() << ", SwatchBooker format";
QDomDocument doc;
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
int errorLine, errorColumn;
QString errorMessage;
if (!doc.setContent(bytes, &errorMessage, &errorLine, &errorColumn)) {
@@ -1916,6 +1917,14 @@ bool KoColorSet::Private::loadSbzSwatchbook(QScopedPointer<KoStore> &store)
warnPigment << "Error (line" << errorLine
<< ", column" << errorColumn
<< "):" << errorMessage;
+#else
+ QDomDocument::ParseResult result = doc.setContent(bytes);
+ if (!result) {
+ warnPigment << "Illegal XML palette:" << colorSet->filename();
+ warnPigment << "Error (line" << result.errorLine
+ << ", column" << result.errorColumn
+ << "):" << result.errorMessage;
+#endif
return false;
}
diff --git a/libs/resources/KoResourceBundleManifest.cpp b/libs/resources/KoResourceBundleManifest.cpp
index e68a6b65dd..9dfe97f6f1 100644
--- a/libs/resources/KoResourceBundleManifest.cpp
+++ b/libs/resources/KoResourceBundleManifest.cpp
@@ -60,6 +60,7 @@ bool KoResourceBundleManifest::load(QIODevice *device)
}
QDomDocument manifestDocument;
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
QString errorMessage;
int errorLine;
int errorColumn;
@@ -67,6 +68,13 @@ bool KoResourceBundleManifest::load(QIODevice *device)
warnKrita << "Error parsing manifest" << errorMessage
<< "line" << errorLine
<< "column" << errorColumn;
+#else
+ QDomDocument::ParseResult result = manifestDocument.setContent(device, QDomDocument::ParseOption::UseNamespaceProcessing);
+ if (!result) {
+ warnKrita << "Error parsing manifest" << result.errorMessage
+ << "line" << result.errorLine
+ << "column" << result.errorColumn;
+#endif
return false;
}
diff --git a/libs/ui/dialogs/kis_dlg_import_image_sequence.cpp b/libs/ui/dialogs/kis_dlg_import_image_sequence.cpp
index 92998282b6..19c82a79e1 100644
--- a/libs/ui/dialogs/kis_dlg_import_image_sequence.cpp
+++ b/libs/ui/dialogs/kis_dlg_import_image_sequence.cpp
@@ -73,7 +73,11 @@ KisDlgImportImageSequence::KisDlgImportImageSequence(KisMainWindow *mainWindow,
connect(m_ui.spinStep, SIGNAL(valueChanged(int)), this, SLOT(slotSkipChanged(int)));
connect(m_ui.cmbOrder, SIGNAL(currentIndexChanged(int)), this, SLOT(slotOrderOptionsChanged(int)));
connect(m_ui.cmbSortMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotOrderOptionsChanged(int)));
+#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
connect(m_ui.autoAddHoldframesBox, &QCheckBox::stateChanged, this, &KisDlgImportImageSequence::autoAddHoldframes);
+#else
+ connect(m_ui.autoAddHoldframesBox, &QCheckBox::checkStateChanged, this, &KisDlgImportImageSequence::autoAddHoldframes);
+#endif
// cold initialization of the controls
slotSkipChanged(m_ui.spinStep->value());
slotOrderOptionsChanged(m_ui.cmbOrder->currentIndex());
diff --git a/libs/ui/utils/KisManualUpdater.cpp b/libs/ui/utils/KisManualUpdater.cpp
index 631b8dead3..96dc196c02 100644
--- a/libs/ui/utils/KisManualUpdater.cpp
+++ b/libs/ui/utils/KisManualUpdater.cpp
@@ -87,8 +87,13 @@ bool KisManualUpdater::availableVersionIsHigher(QString currentVersion, QString
return false;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
int currentSuffixIndex {5};
int availableSuffixIndex {5};
+#else
+ qsizetype currentSuffixIndex {5};
+ qsizetype availableSuffixIndex {5};
+#endif
QVersionNumber currentVersionNumber = QVersionNumber::fromString(currentVersion, &currentSuffixIndex);
QVersionNumber availableVersionNumber = QVersionNumber::fromString(availableVersion, &availableSuffixIndex);
diff --git a/libs/widgets/KisStretchedIconButton.cpp b/libs/widgets/KisStretchedIconButton.cpp
index 903b9e50c5..b14daa8dd5 100644
--- a/libs/widgets/KisStretchedIconButton.cpp
+++ b/libs/widgets/KisStretchedIconButton.cpp
@@ -10,6 +10,7 @@
#include <QLabel>
#include <QHBoxLayout>
#include <QAction>
+#include <QWindow>
#include <kis_debug.h>
@@ -65,7 +66,11 @@ void KisStretchedIconButton::resizeEvent(QResizeEvent *event)
void KisStretchedIconButton::updateLabelIcon()
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_label->setPixmap(m_stretchedIcon.pixmap(this->windowHandle(), m_label->size()));
+#else
+ m_label->setPixmap(m_stretchedIcon.pixmap(m_label->size(), this->window()->devicePixelRatio()));
+#endif
}
void KisStretchedIconButton::slotActionChanged()
diff --git a/libs/widgetutils/kis_font_family_combo_box.cpp b/libs/widgetutils/kis_font_family_combo_box.cpp
index 458c687091..815bfefbb7 100644
--- a/libs/widgetutils/kis_font_family_combo_box.cpp
+++ b/libs/widgetutils/kis_font_family_combo_box.cpp
@@ -88,7 +88,9 @@ KisFontFamilyComboBox::KisFontFamilyComboBox(QWidget *parent)
void KisFontFamilyComboBox::refillComboBox(QVector<QFontDatabase::WritingSystem> writingSystems)
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QFontDatabase fonts = QFontDatabase();
+#endif
int maxWidth = 0;
this->clear();
@@ -100,9 +102,15 @@ void KisFontFamilyComboBox::refillComboBox(QVector<QFontDatabase::WritingSystem>
}
for (int i = 0; i < writingSystems.size(); i++) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_FOREACH (QString family, fonts.families(writingSystems.at(i))) {
// if it's a private family it shouldn't be added.
bool addFont = !fonts.isPrivateFamily(family);
+#else
+ Q_FOREACH (QString family, QFontDatabase::families(writingSystems.at(i))) {
+ // if it's a private family it shouldn't be added.
+ bool addFont = !QFontDatabase::isPrivateFamily(family);
+#endif
if (addFont && filteredFonts.contains(family)) {
addFont = false;
@@ -113,13 +121,21 @@ void KisFontFamilyComboBox::refillComboBox(QVector<QFontDatabase::WritingSystem>
if (addFont && m_blacklistedFonts.contains(family)) {
addFont = false;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (addFont && !fonts.isSmoothlyScalable(family)) {
+#else
+ if (addFont && !QFontDatabase::isSmoothlyScalable(family)) {
+#endif
addFont = false;
}
if (addFont) {
// now, check for all possible familyname+style name combinations, so we can avoid those.
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_FOREACH (const QString style, fonts.styles(family)) {
+#else
+ Q_FOREACH (const QString style, QFontDatabase::styles(family)) {
+#endif
duplicateFonts.append(family + " " + style);
duplicateFonts.append(family + "_" + style);
}
@@ -223,7 +239,11 @@ KisFontComboBoxes::KisFontComboBoxes(QWidget *parent)
void KisFontComboBoxes::setCurrentFont(QFont font)
{
setCurrentFamily(font.family());
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setCurrentStyle(QFontDatabase().styleString(font));
+#else
+ setCurrentStyle(QFontDatabase::styleString(font));
+#endif
}
void KisFontComboBoxes::setCurrentFamily(const QString family)
@@ -261,7 +281,11 @@ QString KisFontComboBoxes::currentStyle() const
QFont KisFontComboBoxes::currentFont(int pointSize) const
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QFontDatabase().font(m_family->currentText(), m_styles->currentText(), pointSize);
+#else
+ return QFontDatabase::font(m_family->currentText(), m_styles->currentText(), pointSize);
+#endif
}
void KisFontComboBoxes::refillComboBox(QVector<QFontDatabase::WritingSystem> writingSystems)
@@ -273,7 +297,9 @@ void KisFontComboBoxes::refillComboBox(QVector<QFontDatabase::WritingSystem> wri
void KisFontComboBoxes::fontFamilyChanged()
{
QString currentText = m_styles->currentText();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QFontDatabase fonts;
+#endif
const QString family = m_family->currentText();
int maxWidth = 0;
m_styles->clear();
@@ -282,15 +308,28 @@ void KisFontComboBoxes::fontFamilyChanged()
KisFontFamilyComboBox *cmb = qobject_cast<KisFontFamilyComboBox *>(m_family);
cmb->setTopFont(family);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (fonts.styles(family).isEmpty()) {
+#else
+ if (QFontDatabase::styles(family).isEmpty()) {
+#endif
styles.append("Normal");
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_FOREACH (const QString style, fonts.styles(family)) {
int b = fonts.weight(family, style);
+#else
+ Q_FOREACH (const QString style, QFontDatabase::styles(family)) {
+ int b = QFontDatabase::weight(family, style);
+#endif
int bindex = 0;
for (int i = 0; i < styles.size(); i++) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (b > fonts.weight(family, styles.at(i))) {
+#else
+ if (b > QFontDatabase::weight(family, styles.at(i))) {
+#endif
bindex = i;
}
}
diff --git a/libs/widgetutils/xmlgui/kswitchlanguagedialog_p.cpp b/libs/widgetutils/xmlgui/kswitchlanguagedialog_p.cpp
index 742c0b8a65..d49c478f4e 100644
--- a/libs/widgetutils/xmlgui/kswitchlanguagedialog_p.cpp
+++ b/libs/widgetutils/xmlgui/kswitchlanguagedialog_p.cpp
@@ -313,20 +313,28 @@ void KisKSwitchLanguageDialogPrivate::fillApplicationLanguages(KLanguageButton *
const QString languageName = nativeName.isEmpty() ? QLocale::languageToString(l.language()) : nativeName;
if (!insertedLanguages.contains(languageCode) && KLocalizedString::isApplicationTranslatedInto(languageCode)) {
QString displayName;
- // Check if languageCode contains a country name.
+ // Check if languageCode contains a territory name.
// For en and en_GB their native names already contain "American"
- // and "British", so no need to append the country name.
+ // and "British", so no need to append the territory name.
// Same applies for zh_CN and zh_TW, however we will need to
// disambiguate between zh_TW and zh_HK if it is eventually
// added.
+#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
if (l.language() != QLocale::English && l.language() != QLocale::Chinese && languageCode.contains('_')) {
- QString countryName = l.nativeCountryName();
+ QString territoryName = l.nativeCountryName();
// Fallback just in case.
- if (countryName.isEmpty()) {
- countryName = QLocale::countryToString(l.country());
+ if (territoryName.isEmpty()) {
+ territoryName = QLocale::countryToString(l.country());
+#else
+ if (l.language() != QLocale::English && l.language() != QLocale::Chinese && languageCode.contains('_')) {
+ QString territoryName = l.nativeTerritoryName();
+ // Fallback just in case.
+ if (territoryName.isEmpty()) {
+ territoryName = QLocale::territoryToString(l.territory());
+#endif
}
- // Append the country name for disambiguation.
- displayName = languageName % " (" % countryName % ")";
+ // Append the territory name for disambiguation.
+ displayName = languageName % " (" % territoryName % ")";
} else {
displayName = languageName;
}
diff --git a/libs/widgetutils/xmlgui/kxmlguiclient.cpp b/libs/widgetutils/xmlgui/kxmlguiclient.cpp
index cb9d87d3bc..5537ba90da 100644
--- a/libs/widgetutils/xmlgui/kxmlguiclient.cpp
+++ b/libs/widgetutils/xmlgui/kxmlguiclient.cpp
@@ -312,20 +312,28 @@ static void propagateTranslationDomain(QDomDocument &doc, const QStringList tagN
void KisKXMLGUIClient::setXML(const QString &document, bool merge)
{
QDomDocument doc;
- QString errorMsg;
- int errorLine, errorColumn;
// QDomDocument raises a parse error on empty document, but we accept no app-specific document,
// in which case you only get ui_standards.xmlgui layout.
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
+ QString errorMsg;
+ int errorLine, errorColumn;
bool result = document.isEmpty() || doc.setContent(document, &errorMsg, &errorLine, &errorColumn);
if (result) {
+#else
+ QDomDocument::ParseResult result = doc.setContent(document);
+ if (document.isEmpty() || result) {
+#endif
propagateTranslationDomain(doc, d->m_textTagNames);
setDOMDocument(doc, merge);
} else {
-#ifdef NDEBUG
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
qCritical() << "Error parsing XML document:" << errorMsg << "at line" << errorLine << "column" << errorColumn;
+#else
+ qCritical() << "Error parsing XML document:" << result.errorMessage << "at line" << result.errorLine << "column" << result.errorColumn;
+#endif
+#ifdef NDEBUG
setDOMDocument(QDomDocument(), merge); // otherwise empty menus from ui_standards.xmlgui stay around
#else
- qCritical() << "Error parsing XML document:" << errorMsg << "at line" << errorLine << "column" << errorColumn;
abort();
#endif
}
diff --git a/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp b/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp
index e5b1d842bf..256ab8b000 100644
--- a/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp
+++ b/plugins/dockers/advancedcolorselector/kis_color_selector_base.cpp
@@ -344,7 +344,11 @@ void KisColorSelectorBase::dropEvent(QDropEvent *e)
color = qvariant_cast<QColor>(e->mimeData()->colorData());
}
else if(e->mimeData()->hasText()) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
color.setNamedColor(e->mimeData()->text());
+#else
+ color.fromString(e->mimeData()->text());
+#endif
if(!color.isValid())
return;
}
diff --git a/plugins/dockers/animation/KisAnimTimelineFramesView.cpp b/plugins/dockers/animation/KisAnimTimelineFramesView.cpp
index a66c6b6b3c..d10891e819 100644
--- a/plugins/dockers/animation/KisAnimTimelineFramesView.cpp
+++ b/plugins/dockers/animation/KisAnimTimelineFramesView.cpp
@@ -1743,7 +1743,11 @@ QPixmap KisAnimTimelineFramesView::Private::renderToPixmap(const QModelIndexList
const QModelIndex &current = paintPairs.at(j).second;
//adjustViewOptionsForIndex(&option, current);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
q->itemDelegate(current)->paint(&painter, option, current);
+#else
+ q->itemDelegateForIndex(current)->paint(&painter, option, current);
+#endif
}
return pixmap;
diff --git a/plugins/dockers/storyboarddocker/StoryboardView.cpp b/plugins/dockers/storyboarddocker/StoryboardView.cpp
index 2c2f11677c..de525d7db6 100644
--- a/plugins/dockers/storyboarddocker/StoryboardView.cpp
+++ b/plugins/dockers/storyboarddocker/StoryboardView.cpp
@@ -340,7 +340,11 @@ void StoryboardView::mouseReleaseEvent(QMouseEvent *event) {
// To prevent selection changes from occurring when hitting the "plus" button,
// we want to filter out these inputs before passing it up to QListView / QAbstractItemView
if (index.isValid() && index.parent().isValid() && index.row() == StoryboardItem::FrameNumber) {
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
StoryboardDelegate* sbDelegate = dynamic_cast<StoryboardDelegate*>(itemDelegate(index));
+#else
+ StoryboardDelegate* sbDelegate = dynamic_cast<StoryboardDelegate*>(itemDelegateForIndex(index));
+#endif
QRect itemRect = visualRect(index);
if (sbDelegate && sbDelegate->isOverlappingActionIcons(itemRect, event)) {
return;
diff --git a/plugins/dockers/textproperties/LocaleHandler.cpp b/plugins/dockers/textproperties/LocaleHandler.cpp
index 58a3332993..ab4c6ed063 100644
--- a/plugins/dockers/textproperties/LocaleHandler.cpp
+++ b/plugins/dockers/textproperties/LocaleHandler.cpp
@@ -18,7 +18,11 @@ const QString localeName (const KoWritingSystemUtils::Bcp47Locale &locale) {
QString name;
const QLocale l = KoWritingSystemUtils::localeFromBcp47Locale(locale);
const QString lang = QLocale::languageToString(l.language());
+#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
const QString region = QLocale::countryToString(l.country());
+#else
+ const QString region = QLocale::territoryToString(l.territory());
+#endif
if (!lang.isEmpty() && lang != "C") {
if (!locale.regionTag.isEmpty()) {
diff --git a/plugins/dockers/widegamutcolorselector/WGColorPreviewToolTip.cpp b/plugins/dockers/widegamutcolorselector/WGColorPreviewToolTip.cpp
index 53b1ca068a..0094ede574 100644
--- a/plugins/dockers/widegamutcolorselector/WGColorPreviewToolTip.cpp
+++ b/plugins/dockers/widegamutcolorselector/WGColorPreviewToolTip.cpp
@@ -11,6 +11,7 @@
#include <QFile>
#include <QScreen>
#include <QPainter>
+#include <QWindow>
#include <cmath>
@@ -75,7 +76,11 @@ void WGColorPreviewToolTip::paintEvent(QPaintEvent *e) {
if (window && m_lastUsedColor.alpha() > 0) {
QIcon::State iconState;
iconState = estimateBrightness(m_lastUsedColor) > 0.5 ? QIcon::Off : QIcon::On;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
icon = m_brushIcon.pixmap(window, QSize(16, 16), QIcon::Normal, iconState);
+#else
+ icon = m_brushIcon.pixmap(QSize(16, 16), window->devicePixelRatio(), QIcon::Normal, iconState);
+#endif
}
if (!icon.isNull()) {
painter.drawPixmap(width() - 18, height() - 18, icon);
diff --git a/plugins/impex/libkra/kis_kra_load_visitor.cpp b/plugins/impex/libkra/kis_kra_load_visitor.cpp
index 4bf033bbb0..704a11327e 100644
--- a/plugins/impex/libkra/kis_kra_load_visitor.cpp
+++ b/plugins/impex/libkra/kis_kra_load_visitor.cpp
@@ -820,17 +820,25 @@ void KisKraLoadVisitor::loadNodeKeyframes(KisNode *node)
return;
}
+
+ QDomDocument dom;
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
QString errorMsg;
int errorLine;
int errorColumn;
-
- QDomDocument dom;
bool ok = dom.setContent(m_store->device(), &errorMsg, &errorLine, &errorColumn);
+#else
+ QDomDocument::ParseResult result = dom.setContent(m_store->device());
+#endif
m_store->close();
-
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
if (!ok) {
m_errorMessages << i18n("parsing error in the keyframe file %1 at line %2, column %3\nError message: %4", location, errorLine, errorColumn, i18n(errorMsg.toUtf8()));
+#else
+ if (!result) {
+ m_errorMessages << i18n("parsing error in the keyframe file %1 at line %2, column %3\nError message: %4", location, result.errorLine, result.errorColumn, i18n(result.errorMessage.toUtf8()));
+#endif
return;
}
diff --git a/plugins/impex/libkra/kra_converter.cpp b/plugins/impex/libkra/kra_converter.cpp
index 2d26630a56..7e2004d600 100644
--- a/plugins/impex/libkra/kra_converter.cpp
+++ b/plugins/impex/libkra/kra_converter.cpp
@@ -318,11 +318,16 @@ KisImportExportErrorCode KraConverter::oldLoadAndParse(KoStore *store, const QSt
m_doc->setErrorMessage(i18n("Could not find %1", filename));
return ImportExportCodes::FileNotExist;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
// Error variables for QDomDocument::setContent
QString errorMsg;
int errorLine, errorColumn;
bool ok = xmldoc.setContent(store->device(), &errorMsg, &errorLine, &errorColumn);
+#else
+ QDomDocument::ParseResult result = xmldoc.setContent(store->device());
+#endif
store->close();
+#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
if (!ok) {
errUI << "Parsing error in " << filename << "! Aborting!" << Qt::endl
<< " In line: " << errorLine << ", column: " << errorColumn << Qt::endl
@@ -330,6 +335,15 @@ KisImportExportErrorCode KraConverter::oldLoadAndParse(KoStore *store, const QSt
m_doc->setErrorMessage(i18n("Parsing error in %1 at line %2, column %3\nError message: %4",
filename, errorLine, errorColumn,
QCoreApplication::translate("QXml", errorMsg.toUtf8(), 0)));
+#else
+ if (!result) {
+ errUI << "Parsing error in " << filename << "! Aborting!" << Qt::endl
+ << " In line: " << result.errorLine << ", column: " << result.errorColumn << Qt::endl
+ << " Error message: " << result.errorMessage << Qt::endl;
+ m_doc->setErrorMessage(i18n("Parsing error in %1 at line %2, column %3\nError message: %4",
+ filename, result.errorLine, result.errorColumn,
+ QCoreApplication::translate("QXml", result.errorMessage.toUtf8(), 0)));
+#endif
return ImportExportCodes::FileFormatIncorrect;
}
dbgUI << "File" << filename << " loaded and parsed";