Commit e7d3b8f8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some qt6 compile error

parent 3031aeb9
Pipeline #191202 passed with stage
in 2 minutes and 23 seconds
......@@ -57,6 +57,9 @@
#if HAVE_X11
#include <QX11Info>
#endif
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkInformation>
#endif
using namespace Konversation;
......@@ -79,7 +82,6 @@ Application::Application(int &argc, char **argv)
m_urlModel = nullptr;
dbusObject = nullptr;
identDBus = nullptr;
m_networkConfigurationManager = nullptr;
}
Application::~Application()
......@@ -106,9 +108,9 @@ Application::~Application()
delete m_osd;
m_osd = nullptr;
closeWallet();
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
delete m_networkConfigurationManager;
#endif
if (m_restartScheduled) implementRestart();
}
......@@ -159,6 +161,7 @@ void Application::createMainWindow(AutoConnectMode autoConnectMode, WindowRestor
connect(m_connectionManager, &ConnectionManager::identityOffline, m_awayManager, &AwayManager::identityOffline);
connect(m_connectionManager, &ConnectionManager::connectionChangedAwayState, m_awayManager, &AwayManager::updateGlobalAwayAction);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Silence deprecation warnings as long as there is no known substitute for QNetworkConfigurationManager
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
......@@ -166,6 +169,10 @@ QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
m_networkConfigurationManager = new QNetworkConfigurationManager();
connect(m_networkConfigurationManager, &QNetworkConfigurationManager::onlineStateChanged, m_connectionManager, &ConnectionManager::onOnlineStateChanged);
QT_WARNING_POP
#else
QNetworkInformation::load(QNetworkInformation::Feature::Reachability);
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, m_connectionManager, &ConnectionManager::onOnlineStateChanged);
#endif
m_scriptLauncher = new ScriptLauncher(this);
......
......@@ -11,7 +11,6 @@
#ifndef APPLICATION_H
#define APPLICATION_H
#include <QNetworkConfigurationManager>
#include "preferences.h"
#include "mainwindow.h"
......@@ -21,6 +20,9 @@
#include "ircqueue.h"
#include <QApplication>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkConfigurationManager>
#endif
class ConnectionManager;
class AwayManager;
......@@ -202,14 +204,14 @@ class Application : public QApplication
Konversation::LauncherEntryHandler* m_launcherEntryHandler;
KWallet::Wallet* m_wallet;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Silence deprecation warnings as long as there is no known substitute for QNetworkConfigurationManager
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
QNetworkConfigurationManager* m_networkConfigurationManager;
QNetworkConfigurationManager* m_networkConfigurationManager = nullptr;
QT_WARNING_POP
#endif
QCommandLineParser *m_commandLineParser;
QStringList m_restartArguments;
......
......@@ -674,12 +674,16 @@ void ConnectionManager::reconnectInvoluntary()
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void ConnectionManager::onOnlineStateChanged(bool isOnline)
{
if (isOnline) {
#else
void ConnectionManager::onOnlineStateChanged(QNetworkInformation::Reachability reachability)
{
if (reachability == QNetworkInformation::Reachability::Online) {
#endif
reconnectInvoluntary();
} else {
involuntaryQuitServers();
......
......@@ -12,7 +12,9 @@
#include <QObject>
#include <QSet>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkInformation>
#endif
class ConnectionSettings;
......@@ -80,8 +82,11 @@ class ConnectionManager : public QObject
void handleConnectionStateChange(Server* server, Konversation::ConnectionState state);
void handleReconnect(Server* server);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void onOnlineStateChanged(bool isOnline);
#else
void onOnlineStateChanged(QNetworkInformation::Reachability reachability);
#endif
private:
void enlistConnection(int connectionId, Server* server);
......
......@@ -3742,7 +3742,7 @@ const QString& inputLineText
while ((found = toParse.indexOf(QLatin1Char('%'), index)) != -1)
{
// append part before the %
out.append(toParse.midRef(index,found-index));
out.append(QStringView(toParse).mid(index,found-index));
index = found + 1; // skip the part before, including %
if (index >= (int)toParse.length())
break; // % was the last char (not valid)
......@@ -3793,7 +3793,7 @@ const QString& inputLineText
}
// append last part
out.append(toParse.midRef(index,toParse.length()-index));
out.append(QStringView(toParse).mid(index,toParse.length()-index));
return out;
}
......
......@@ -12,7 +12,9 @@
#include <KAboutData>
#include <KCrash>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <Kdelibs4ConfigMigrator>
#endif
#include <KDBusService>
#include <chrono>
......@@ -30,11 +32,12 @@ int main(int argc, char* argv[])
QStringLiteral("konversationrc"),
QStringLiteral("konversation.notifyrc"),
};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Kdelibs4ConfigMigrator migrate(QStringLiteral("konversation"));
migrate.setConfigFiles(configFiles);
migrate.setUiFiles(QStringList { QStringLiteral("konversationui.rc") });
migrate.migrate();
#endif
KLocalizedString::setApplicationDomain("konversation");
......
......@@ -366,7 +366,11 @@ namespace Konversation
break;
case 'l':
m_ui.userLimitChBox->setChecked(true);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
m_ui.userLimitEdit->setValue(currentMode.midRef(1).toInt());
#else
m_ui.userLimitEdit->setValue(QStringView(currentMode).mid(1).toInt());
#endif
break;
case 'i':
m_ui.inviteModeChBox->setChecked(true);
......
......@@ -392,7 +392,9 @@ void ChatWindow::setLogfileName(const QString& name)
qint64 filePosition;
QTextStream backlog(&logfile);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
backlog.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
backlog.setAutoDetectUnicode(true);
QStringList firstColumns;
......@@ -503,7 +505,9 @@ void ChatWindow::logText(const QString& text)
// wrap the file into a stream
QTextStream logStream(&logfile);
// write log in utf8 to help i18n
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
logStream.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
logStream.setAutoDetectUnicode(true);
if(firstLog)
......
......@@ -105,7 +105,9 @@ void LogfileReader::updateView()
if(file.open(QIODevice::ReadOnly))
{
QTextStream stream(&file);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
stream.setCodec(QTextCodec::codecForName("UTF-8"));
#endif
stream.setAutoDetectUnicode(true);
// Set file pointer to <pos> bytes from the end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment