aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects
diff options
context:
space:
mode:
authorGravatar ctrlaltca2024-03-24 11:39:46 +0100
committerGravatar GitHub2024-03-24 11:39:46 +0100
commite68e34095057a9d7d7aedbaf8ad9773913aa4794 (patch)
treed4953cef4477a68cacf76259a129653f2f080da8 /src/modules/objects
parentFix Wayland appId (#2621) (diff)
downloadKVIrc-e68e34095057a9d7d7aedbaf8ad9773913aa4794.tar.gz
KVIrc-e68e34095057a9d7d7aedbaf8ad9773913aa4794.tar.bz2
KVIrc-e68e34095057a9d7d7aedbaf8ad9773913aa4794.zip
More qt6 porting (#2622)
* Port QColor::setNamedColor to QColor::fromString * Port from QVariant::Type to QmetaType::Type * KviCoreActions: port from QAction::parentWidget to qobject_cast + QAction::parent * KviIrcView: port QString::fromUtf16 usage to the non-obsolete char16_t* overload * KviTopicWidget: port QMouseEvent to a non-obsolete overload * Port QMouseEvent from old pos(), x(), y(), to position() * Port obsolete QMessageBox usage to custom buttons * KviApplication: initialize the dbus notify message "replace ID" to 0 * KviIrcConnection: port deprecated QString::count() to QString::size() * KvsObject_*: port QColor::setNamedColor to QColor::fromString * KvsObject_widget: port QWidget::isTopLevel to QWidget::isWindow * KviMainWindow: use QKeyCombination instead of int for shortcuts * QHttp: avoid deprecated methods for QCryptographicHash * ScriptEditorWidget: use the new signature for QMenu::addAction() * KviInputEditor: Extract ACCEL_KEY from header and avoid warning * KviStringConversion: convert old Qt5 font weights to new "css" font weights * syntax fix
Diffstat (limited to 'src/modules/objects')
-rw-r--r--src/modules/objects/KvsObject_colorDialog.cpp4
-rw-r--r--src/modules/objects/KvsObject_listWidget.cpp4
-rw-r--r--src/modules/objects/KvsObject_painter.cpp4
-rw-r--r--src/modules/objects/KvsObject_pixmap.cpp8
-rw-r--r--src/modules/objects/KvsObject_sql.cpp19
-rw-r--r--src/modules/objects/KvsObject_tableWidget.cpp8
-rw-r--r--src/modules/objects/KvsObject_treeWidget.cpp4
-rw-r--r--src/modules/objects/KvsObject_webView.cpp5
-rw-r--r--src/modules/objects/KvsObject_widget.cpp22
-rw-r--r--src/modules/objects/qthttp/qhttpauthenticator.cpp25
10 files changed, 83 insertions, 20 deletions
diff --git a/src/modules/objects/KvsObject_colorDialog.cpp b/src/modules/objects/KvsObject_colorDialog.cpp
index 94d799b91..cb333f4ad 100644
--- a/src/modules/objects/KvsObject_colorDialog.cpp
+++ b/src/modules/objects/KvsObject_colorDialog.cpp
@@ -125,7 +125,11 @@ KVSO_CLASS_FUNCTION(colorDialog, setCurrentColor)
return true;
}
}
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
col.setNamedColor(szColor);
+#else
+ col = QColor::fromString(szColor);
+#endif
col.setAlpha(iOpacity);
}
else
diff --git a/src/modules/objects/KvsObject_listWidget.cpp b/src/modules/objects/KvsObject_listWidget.cpp
index 5ba1b8df6..677a43d46 100644
--- a/src/modules/objects/KvsObject_listWidget.cpp
+++ b/src/modules/objects/KvsObject_listWidget.cpp
@@ -418,7 +418,11 @@ KVSO_CLASS_FUNCTION(listWidget, setForeground)
return true;
}
}
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
col.setNamedColor(szColor);
+#else
+ col = QColor::fromString(szColor);
+#endif
col.setAlpha(iOpacity);
}
else
diff --git a/src/modules/objects/KvsObject_painter.cpp b/src/modules/objects/KvsObject_painter.cpp
index 0b425d38b..5c576ae5c 100644
--- a/src/modules/objects/KvsObject_painter.cpp
+++ b/src/modules/objects/KvsObject_painter.cpp
@@ -2007,7 +2007,11 @@ KVSO_CLASS_FUNCTION(painter, fillRect)
return true;
}
}
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
col.setNamedColor(szColor);
+#else
+ col = QColor::fromString(szColor);
+#endif
col.setAlpha(iOpacity);
}
else
diff --git a/src/modules/objects/KvsObject_pixmap.cpp b/src/modules/objects/KvsObject_pixmap.cpp
index 9bd184479..15377194b 100644
--- a/src/modules/objects/KvsObject_pixmap.cpp
+++ b/src/modules/objects/KvsObject_pixmap.cpp
@@ -150,7 +150,11 @@ KVSO_CLASS_FUNCTION(pixmap, fill)
return true;
}
}
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
col.setNamedColor(szColor);
+#else
+ col = QColor::fromString(szColor);
+#endif
col.setAlpha(iOpacity);
}
else
@@ -265,7 +269,11 @@ KVSO_CLASS_FUNCTION(pixmap, setPixel)
return true;
}
}
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
col.setNamedColor(szColor);
+#else
+ col = QColor::fromString(szColor);
+#endif
col.setAlpha(iOpacity);
}
else
diff --git a/src/modules/objects/KvsObject_sql.cpp b/src/modules/objects/KvsObject_sql.cpp
index a4c036546..361f28cc1 100644
--- a/src/modules/objects/KvsObject_sql.cpp
+++ b/src/modules/objects/KvsObject_sql.cpp
@@ -212,9 +212,13 @@ KVSO_CLASS_FUNCTION(sql, queryLastInsertId)
{
CHECK_QUERY_IS_INIT
QVariant value = m_pCurrentSQlQuery->lastInsertId();
- if(value.type() == QVariant::LongLong)
+#if(QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
+ uint vType = value.type();
+#else
+ uint vType = value.typeId();
+#endif
+ if(vType == QMetaType::LongLong)
c->returnValue()->setInteger((kvs_int_t)value.toLongLong());
- qDebug("type %i", value.type());
return true;
}
KVSO_CLASS_FUNCTION(sql, features)
@@ -467,11 +471,16 @@ KVSO_CLASS_FUNCTION(sql, queryRecord)
{
KviKvsVariant * pValue = nullptr;
QVariant value = record.value(i);
- if(value.type() == QVariant::LongLong)
+#if(QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
+ uint vType = value.type();
+#else
+ uint vType = value.typeId();
+#endif
+ if(vType == QMetaType::LongLong)
pValue = new KviKvsVariant((kvs_int_t)value.toLongLong());
- else if(value.type() == QVariant::String)
+ else if(vType == QMetaType::QString)
pValue = new KviKvsVariant(value.toString());
- else if(value.type() == QVariant::ByteArray)
+ else if(vType == QMetaType::QByteArray)
{
KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass("memoryBuffer");
KviKvsVariantList params(new KviKvsVariant(QString()));
diff --git a/src/modules/objects/KvsObject_tableWidget.cpp b/src/modules/objects/KvsObject_tableWidget.cpp
index f1e15edc5..a462db55b 100644
--- a/src/modules/objects/KvsObject_tableWidget.cpp
+++ b/src/modules/objects/KvsObject_tableWidget.cpp
@@ -336,11 +336,19 @@ KVSO_CLASS_FUNCTION(tableWidget, setForeground)
QString szColor;
pColArray->asString(szColor);
// maybe a color name?
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor(szColor);
+#else
+ color = QColor::fromString(szColor);
+#endif
if(!color.isValid())
{
// isn't a color name: lets try with an hex triplet
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor("#" + szColor);
+#else
+ color = QColor::fromString("#" + szColor);
+#endif
if(!color.isValid())
{
c->warning(__tr2qs_ctx("Not a valid color!", "objects"));
diff --git a/src/modules/objects/KvsObject_treeWidget.cpp b/src/modules/objects/KvsObject_treeWidget.cpp
index 15b8e1a47..3491b0ef5 100644
--- a/src/modules/objects/KvsObject_treeWidget.cpp
+++ b/src/modules/objects/KvsObject_treeWidget.cpp
@@ -621,7 +621,11 @@ void KviKvsTreeWidget::dropEvent(QDropEvent * e)
QUrl url = *it;
QString path = url.toLocalFile();
qDebug("path %s", path.toUtf8().data());
+#if(QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTreeWidgetItem * i = itemAt(e->pos());
+#else
+ QTreeWidgetItem * i = itemAt(e->position().toPoint());
+#endif
m_pParentScript->fileDropped(path, i);
}
}
diff --git a/src/modules/objects/KvsObject_webView.cpp b/src/modules/objects/KvsObject_webView.cpp
index 1dcf3781c..43adfdf3f 100644
--- a/src/modules/objects/KvsObject_webView.cpp
+++ b/src/modules/objects/KvsObject_webView.cpp
@@ -746,8 +746,13 @@ void KviKvsWebView::mouseMoveEvent(QMouseEvent * ev)
{
KviKvsVariant vRetValue;
KviKvsVariantList lParams;
+#if(QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
lParams.append(new KviKvsVariant((kvs_int_t)ev->x()));
lParams.append(new KviKvsVariant((kvs_int_t)ev->y()));
+#else
+ lParams.append(new KviKvsVariant((kvs_int_t)ev->position().x()));
+ lParams.append(new KviKvsVariant((kvs_int_t)ev->position().y()));
+#endif
if(!m_pParentScript->callFunction(m_pParentScript, "mouseMoveEvent", &vRetValue, &lParams))
QWebEngineView::mouseMoveEvent(ev); // ignore results of a broken event handler
else
diff --git a/src/modules/objects/KvsObject_widget.cpp b/src/modules/objects/KvsObject_widget.cpp
index 3da0bc09b..33ffc3957 100644
--- a/src/modules/objects/KvsObject_widget.cpp
+++ b/src/modules/objects/KvsObject_widget.cpp
@@ -1285,11 +1285,19 @@ KVSO_CLASS_FUNCTION(widget, setForegroundColor)
QString szColor;
pColArray->asString(szColor);
// maybe a color name?
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor(szColor);
+#else
+ color = QColor::fromString(szColor);
+#endif
if(!color.isValid())
{
- // itsn't a color name: let try with an hex triplette
+ // isn't a color name: lets try with an hex triplet
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor("#" + szColor);
+#else
+ color = QColor::fromString("#" + szColor);
+#endif
if(!color.isValid())
{
c->warning(__tr2qs_ctx("Not a valid color!", "objects"));
@@ -1368,11 +1376,19 @@ KVSO_CLASS_FUNCTION(widget, setBackgroundColor)
QString szColor;
pColArray->asString(szColor);
// maybe a color name?
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor(szColor);
+#else
+ color = QColor::fromString(szColor);
+#endif
if(!color.isValid())
{
- // itsn't a color name: let try with an hex triplette
+ // isn't a color name: lets try with an hex triplet
+#if (QT_VERSION < QT_VERSION_CHECK(6, 4, 0))
color.setNamedColor("#" + szColor);
+#else
+ color = QColor::fromString("#" + szColor);
+#endif
if(!color.isValid())
{
c->warning(__tr2qs_ctx("Not a valid color!", "objects"));
@@ -1474,7 +1490,7 @@ KVSO_CLASS_FUNCTION(widget, windowTitle)
KVSO_CLASS_FUNCTION(widget, isTopLevel)
{
CHECK_INTERNAL_POINTER(widget())
- c->returnValue()->setBoolean(widget()->isTopLevel());
+ c->returnValue()->setBoolean(widget()->isWindow());
return true;
}
diff --git a/src/modules/objects/qthttp/qhttpauthenticator.cpp b/src/modules/objects/qthttp/qhttpauthenticator.cpp
index daf1465e4..2d256c6de 100644
--- a/src/modules/objects/qthttp/qhttpauthenticator.cpp
+++ b/src/modules/objects/qthttp/qhttpauthenticator.cpp
@@ -599,10 +599,11 @@ static QByteArray digestMd5ResponseHelper(
)
{
QCryptographicHash hash(QCryptographicHash::Md5);
+ QByteArray colon(":");
hash.addData(userName);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(realm);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(password);
QByteArray ha1 = hash.result();
if(alg.toLower() == "md5-sess")
@@ -613,9 +614,9 @@ static QByteArray digestMd5ResponseHelper(
// but according to the errata page at http://www.rfc-editor.org/errata_list.php, ID 1649, it
// must be the following line:
hash.addData(ha1.toHex());
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(nonce);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(cNonce);
ha1 = hash.result();
};
@@ -624,11 +625,11 @@ static QByteArray digestMd5ResponseHelper(
// calculate H(A2)
hash.reset();
hash.addData(method);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(digestUri);
if(qop.toLower() == "auth-int")
{
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(hEntity);
}
QByteArray ha2hex = hash.result().toHex();
@@ -636,17 +637,17 @@ static QByteArray digestMd5ResponseHelper(
// calculate response
hash.reset();
hash.addData(ha1);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(nonce);
- hash.addData(":", 1);
+ hash.addData(colon);
if(!qop.isNull())
{
hash.addData(nonceCount);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(cNonce);
- hash.addData(":", 1);
+ hash.addData(colon);
hash.addData(qop);
- hash.addData(":", 1);
+ hash.addData(colon);
}
hash.addData(ha2hex);
return hash.result().toHex();
@@ -1226,7 +1227,7 @@ static QByteArray qCreatev2Hash(const QHttpAuthenticatorPrivate * ctx,
{
QCryptographicHash md4(QCryptographicHash::Md4);
QByteArray passUnicode = qStringAsUcs2Le(ctx->password);
- md4.addData(passUnicode.data(), passUnicode.size());
+ md4.addData(passUnicode);
QByteArray hashKey = md4.result();
Q_ASSERT(hashKey.size() == 16);