Skip to content

Commit

Permalink
Misc Qt6 port for slightly changed class names and method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlaltca committed Oct 18, 2023
1 parent cba0ebe commit b62b83e
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/kvirc/kernel/KviIpcSentinel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ struct fake_xcb_property_notify_event_t
}
#endif

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool KviIpcSentinel::nativeEvent(const QByteArray & id, void * msg, long * res)
#else
bool KviIpcSentinel::nativeEvent(const QByteArray & id, void * msg, qintptr * res)
#endif
{
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)
return winEvent((MSG *)msg, res);
Expand Down
5 changes: 4 additions & 1 deletion src/kvirc/kernel/KviIpcSentinel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class KVIRC_API KviIpcSentinel : public QWidget
virtual bool x11Event(XEvent * e);
bool x11GetRemoteMessage();
#endif //!COMPILE_X11_SUPPORT

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray & id, void * msg, long * res) override;
#else
bool nativeEvent(const QByteArray & id, void * msg, qintptr * res) override;
#endif
};
#endif //!COMPILE_NO_IPC

Expand Down
2 changes: 1 addition & 1 deletion src/kvirc/ui/KviIrcView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ KviIrcView::KviIrcView(QWidget * parent, KviWindow * pWnd)
setSizePolicy(oSizePolicy);
}

static inline void delete_text_line(KviIrcViewLine * line, QHash<KviIrcViewLine *, KviAnimatedPixmap *> * animatedSmiles)
static inline void delete_text_line(KviIrcViewLine * line, QMultiHash<KviIrcViewLine *, KviAnimatedPixmap *> * animatedSmiles)
{
QMultiHash<KviIrcViewLine *, KviAnimatedPixmap *>::iterator it = animatedSmiles->find(line);
while(it != animatedSmiles->end() && it.key() == line)
Expand Down
5 changes: 5 additions & 0 deletions src/kvirc/ui/KviIrcView_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,12 @@ void KviIrcView::mousePressEvent(QMouseEvent * e)
// We actually trigger the click event after the double click interval
// is elapsed without a second click.
m_iMouseTimer = startTimer(QApplication::doubleClickInterval());

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_pLastEvent = new QMouseEvent(*e);
#else
m_pLastEvent = new QMouseEvent(e->type(), e->position(), e->globalPosition(), e->button(), e->buttons(), e->modifiers(), e->pointingDevice());
#endif
}
}

Expand Down
1 change: 1 addition & 0 deletions src/kvirc/ui/KviToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "KviOptions.h"

#include <array>
#include <QActionGroup>
#include <QCursor>
#include <QEvent>
#include <QMenu>
Expand Down
4 changes: 4 additions & 0 deletions src/modules/notifier/NotifierWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,11 @@ void NotifierWindow::setCursor(int iCur)
}
}

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void NotifierWindow::enterEvent(QEvent *)
#else
void NotifierWindow::enterEvent(QEnterEvent *)
#endif
{
if(!m_pShowHideTimer)
{
Expand Down
4 changes: 4 additions & 0 deletions src/modules/notifier/NotifierWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ class NotifierWindow : public QWidget
void mouseReleaseEvent(QMouseEvent * e) override;
void mouseMoveEvent(QMouseEvent * e) override;
void leaveEvent(QEvent * e) override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void enterEvent(QEvent * e) override;
#else
void enterEvent(QEnterEvent * e) override;
#endif
bool eventFilter(QObject * pEdit, QEvent * e) override;
void keyPressEvent(QKeyEvent * e) override;
public slots:
Expand Down
2 changes: 1 addition & 1 deletion src/modules/objects/KvsObject_listWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const int item_flags[] = {
Qt::ItemIsDropEnabled,
Qt::ItemIsUserCheckable,
Qt::ItemIsEnabled,
Qt::ItemIsTristate
Qt::ItemIsUserTristate
};

const char * const itemflags_tbl[] = {
Expand Down
8 changes: 8 additions & 0 deletions src/modules/objects/KvsObject_multiLineEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ bool KvsObject_textedit::functionText(KviKvsObjectFunctionCall * c)
bool KvsObject_textedit::functionHtml(KviKvsObjectFunctionCall * c)
{
if(widget())
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
c->returnValue()->setString(((QTextEdit *)widget())->document()->toHtml(QByteArray("utf-8")));
#else
c->returnValue()->setString(((QTextEdit *)widget())->document()->toHtml());
#endif
return true;
}

Expand Down Expand Up @@ -823,7 +827,11 @@ bool KvsObject_textedit::functionsaveFile(KviKvsObjectFunctionCall * c)
KVSO_PARAMETERS_END(c)

if (KviQString::equalCI(szFormat, "html"))
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
szData = ((QTextEdit *)widget())->document()->toHtml(QByteArray("utf-8"));
#else
szData = ((QTextEdit *)widget())->document()->toHtml();
#endif
else {
if (!szFormat.isEmpty() && !KviQString::equalCI(szFormat, "text"))
c->warning(__tr2qs_ctx("Unknown text document format '%Q'. Writing the document as plain text.", "objects"), &szFormat);
Expand Down
2 changes: 1 addition & 1 deletion src/modules/objects/KvsObject_tableWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const int item_flags[] = {
Qt::ItemIsDropEnabled,
Qt::ItemIsUserCheckable,
Qt::ItemIsEnabled,
Qt::ItemIsTristate
Qt::ItemIsUserTristate
};

const char * const itemflags_tbl[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/objects/KvsObject_treeWidgeteItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const int item_flags[] = {
Qt::ItemIsDropEnabled,
Qt::ItemIsUserCheckable,
Qt::ItemIsEnabled,
Qt::ItemIsTristate
Qt::ItemIsUserTristate
};

const char * const itemflags_tbl[] = {
Expand Down
12 changes: 8 additions & 4 deletions src/modules/objects/KvsObject_webView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
#include <QWebEngineProfile>
#include <QWebEngineView>
#include <QWebEngineSettings>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QWebEngineDownloadItem>
#else
#include <QWebEngineDownloadRequest>
#endif
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QPixmap>
Expand All @@ -48,7 +52,7 @@
#include <QToolTip>

static int g_iDownloadId = 1;
KviKvsDownloadHandler::KviKvsDownloadHandler(KvsObject_webView * pParent, QString &szFilePath, QWebEngineDownloadItem * pDownload, int iId)
KviKvsDownloadHandler::KviKvsDownloadHandler(KvsObject_webView * pParent, QString &szFilePath, DOWNLOAD_CLASS_NAME * pDownload, int iId)
: QObject(pParent)
{
m_Id = iId;
Expand Down Expand Up @@ -401,8 +405,8 @@ bool KvsObject_webView::init(KviKvsRunTimeContext * c, KviKvsVariantList *)
connect(pView, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));
connect(pView, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));
connect(pPage, SIGNAL(linkClicked(const QUrl &)), this, SLOT(slotLinkClicked(const QUrl &)));
connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(slotDownloadRequest(QWebEngineDownloadItem*)));
connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(DOWNLOAD_CLASS_NAME*)),
this, SLOT(slotDownloadRequest(DOWNLOAD_CLASS_NAME*)));
return true;
}

Expand Down Expand Up @@ -717,7 +721,7 @@ void KvsObject_webView::slotLinkClicked(const QUrl & url)
callFunction(this, "linkClickedEvent", &params);
}

void KvsObject_webView::slotDownloadRequest(QWebEngineDownloadItem *pDownload)
void KvsObject_webView::slotDownloadRequest(DOWNLOAD_CLASS_NAME *pDownload)
{
QString szFilePath = "";
KviKvsVariant * filepathret = new KviKvsVariant(szFilePath);
Expand Down
15 changes: 11 additions & 4 deletions src/modules/objects/KvsObject_webView.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
#include <QMouseEvent>
#include <QContextMenuEvent>

class QWebEngineDownloadItem;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#define DOWNLOAD_CLASS_NAME QWebEngineDownloadItem
#else
#define DOWNLOAD_CLASS_NAME QWebEngineDownloadRequest
#endif

class DOWNLOAD_CLASS_NAME;

class KvsObject_webView;

class KviKvsWebView : public QWebEngineView
Expand Down Expand Up @@ -143,7 +150,7 @@ protected slots:
void slotLoadFinished(bool);
void slotLoadProgress(int);
void slotLoadStarted();
void slotDownloadRequest(QWebEngineDownloadItem *);
void slotDownloadRequest(DOWNLOAD_CLASS_NAME *);
void slotLinkClicked(const QUrl &);

void slotOnChange(QString);
Expand All @@ -157,13 +164,13 @@ class KviKvsDownloadHandler : public QObject
{
Q_OBJECT
public:
KviKvsDownloadHandler(KvsObject_webView * pParent, QString &szFilePath, QWebEngineDownloadItem * pDownload, int iId);
KviKvsDownloadHandler(KvsObject_webView * pParent, QString &szFilePath, DOWNLOAD_CLASS_NAME * pDownload, int iId);

~KviKvsDownloadHandler();

protected:
KvsObject_webView * m_pParentScript;
QWebEngineDownloadItem * m_pDownload;
DOWNLOAD_CLASS_NAME * m_pDownload;
int m_Id;
protected slots:
void slotDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
Expand Down
4 changes: 0 additions & 4 deletions src/modules/objects/qthttp/qhttp.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
#include <qscopedpointer.h>
#include <qtcpsocket.h>

QT_BEGIN_HEADER

class QTcpSocket;
class QTimerEvent;
class QIODevice;
Expand Down Expand Up @@ -300,6 +298,4 @@ public Q_SLOTS:
friend class QHttpPGHRequest;
};

QT_END_HEADER

#endif // QHTTP_H
2 changes: 1 addition & 1 deletion src/modules/options/OptionsWidget_windowList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void addAlertLevels(KviOptionsWidget * widget, KviTalGroupBox * g)
QString help_text = available_options_text + "<br>";
for (const auto& alert_type : alert_list)
{
if (alert_type != &alert_list.back())
if (alert_type != alert_list.back())
help_text += alert_type + ", ";
else
help_text += alert_type;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/snd/libkvisnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
#include "KviLocale.h"
#include "KviQString.h"

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QSound>
#else
#include <QSoundEffect>
#endif

#ifdef COMPILE_PHONON_SUPPORT
#include <phonon/mediaobject.h>
Expand Down Expand Up @@ -347,7 +351,13 @@ bool KviSoundPlayer::playQt(const QString & szFileName)
{
if(isMuted())
return true;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSound::play(szFileName);
#else
QSoundEffect effect;
effect.setSource(QUrl::fromLocalFile(szFileName));
effect.play();
#endif
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/modules/upnp/XmlFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ QString XmlFunctions::getNodeValue(const QDomNode & rootNode, const QString & pa
QString XmlFunctions::getSource(const QDomNode & node, int indent)
{
QString source;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QTextStream textStream(&source, QIODevice::WriteOnly);
#else
QTextStream textStream(&source, QIODeviceBase::WriteOnly);
#endif
node.save(textStream, indent);
return source;
}

0 comments on commit b62b83e

Please sign in to comment.