mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-10 04:11:16 +00:00
Merge pull request #14593 from glassez/qt6-compat
Make current codebase more compatible with Qt6
This commit is contained in:
commit
2d1c34d8e0
@ -126,7 +126,9 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
|
|||||||
if (!m_logFile.isOpen()) return;
|
if (!m_logFile.isOpen()) return;
|
||||||
|
|
||||||
QTextStream stream(&m_logFile);
|
QTextStream stream(&m_logFile);
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
stream.setCodec("UTF-8");
|
stream.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (msg.type)
|
switch (msg.type)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ int main(int argc, char *argv[])
|
|||||||
// 3. https://bugreports.qt.io/browse/QTBUG-46015
|
// 3. https://bugreports.qt.io/browse/QTBUG-46015
|
||||||
|
|
||||||
qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));
|
qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));
|
||||||
#if !defined(DISABLE_GUI)
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && !defined(DISABLE_GUI)
|
||||||
// this is the default in Qt6
|
// this is the default in Qt6
|
||||||
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,7 +58,9 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QNetworkAddressEntry>
|
#include <QNetworkAddressEntry>
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
#include <QNetworkConfigurationManager>
|
#include <QNetworkConfigurationManager>
|
||||||
|
#endif
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -95,7 +97,6 @@
|
|||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "torrentimpl.h"
|
#include "torrentimpl.h"
|
||||||
#include "tracker.h"
|
#include "tracker.h"
|
||||||
#include "trackerentry.h"
|
|
||||||
|
|
||||||
using namespace BitTorrent;
|
using namespace BitTorrent;
|
||||||
|
|
||||||
@ -444,7 +445,9 @@ Session::Session(QObject *parent)
|
|||||||
, m_statistics {new Statistics {this}}
|
, m_statistics {new Statistics {this}}
|
||||||
, m_ioThread {new QThread {this}}
|
, m_ioThread {new QThread {this}}
|
||||||
, m_recentErroredTorrentsTimer {new QTimer {this}}
|
, m_recentErroredTorrentsTimer {new QTimer {this}}
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
, m_networkManager {new QNetworkConfigurationManager {this}}
|
, m_networkManager {new QNetworkConfigurationManager {this}}
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (port() < 0)
|
if (port() < 0)
|
||||||
m_port = Utils::Random::rand(1024, 65535);
|
m_port = Utils::Random::rand(1024, 65535);
|
||||||
@ -485,11 +488,13 @@ Session::Session(QObject *parent)
|
|||||||
, &Net::ProxyConfigurationManager::proxyConfigurationChanged
|
, &Net::ProxyConfigurationManager::proxyConfigurationChanged
|
||||||
, this, &Session::configureDeferred);
|
, this, &Session::configureDeferred);
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
// Network configuration monitor
|
// Network configuration monitor
|
||||||
connect(m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &Session::networkOnlineStateChanged);
|
connect(m_networkManager, &QNetworkConfigurationManager::onlineStateChanged, this, &Session::networkOnlineStateChanged);
|
||||||
connect(m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &Session::networkConfigurationChange);
|
connect(m_networkManager, &QNetworkConfigurationManager::configurationAdded, this, &Session::networkConfigurationChange);
|
||||||
connect(m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &Session::networkConfigurationChange);
|
connect(m_networkManager, &QNetworkConfigurationManager::configurationRemoved, this, &Session::networkConfigurationChange);
|
||||||
connect(m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &Session::networkConfigurationChange);
|
connect(m_networkManager, &QNetworkConfigurationManager::configurationChanged, this, &Session::networkConfigurationChange);
|
||||||
|
#endif
|
||||||
|
|
||||||
m_fileSearcher = new FileSearcher;
|
m_fileSearcher = new FileSearcher;
|
||||||
m_fileSearcher->moveToThread(m_ioThread);
|
m_fileSearcher->moveToThread(m_ioThread);
|
||||||
@ -2413,6 +2418,7 @@ void Session::setTempPath(QString path)
|
|||||||
torrent->handleTempPathChanged();
|
torrent->handleTempPathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
void Session::networkOnlineStateChanged(const bool online)
|
void Session::networkOnlineStateChanged(const bool online)
|
||||||
{
|
{
|
||||||
LogMsg(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
|
LogMsg(tr("System network status changed to %1", "e.g: System network status changed to ONLINE").arg(online ? tr("ONLINE") : tr("OFFLINE")), Log::INFO);
|
||||||
@ -2433,6 +2439,7 @@ void Session::networkConfigurationChange(const QNetworkConfiguration &cfg)
|
|||||||
configureListeningInterface();
|
configureListeningInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QStringList Session::getListeningIPs() const
|
QStringList Session::getListeningIPs() const
|
||||||
{
|
{
|
||||||
|
@ -50,10 +50,13 @@
|
|||||||
#include "cachestatus.h"
|
#include "cachestatus.h"
|
||||||
#include "sessionstatus.h"
|
#include "sessionstatus.h"
|
||||||
#include "torrentinfo.h"
|
#include "torrentinfo.h"
|
||||||
|
#include "trackerentry.h"
|
||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
class QNetworkConfiguration;
|
class QNetworkConfiguration;
|
||||||
class QNetworkConfigurationManager;
|
class QNetworkConfigurationManager;
|
||||||
|
#endif
|
||||||
class QString;
|
class QString;
|
||||||
class QThread;
|
class QThread;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
@ -100,7 +103,6 @@ namespace BitTorrent
|
|||||||
class TorrentImpl;
|
class TorrentImpl;
|
||||||
class Tracker;
|
class Tracker;
|
||||||
struct LoadTorrentParams;
|
struct LoadTorrentParams;
|
||||||
struct TrackerEntry;
|
|
||||||
|
|
||||||
enum class MoveStorageMode;
|
enum class MoveStorageMode;
|
||||||
|
|
||||||
@ -542,9 +544,11 @@ namespace BitTorrent
|
|||||||
void handleDownloadFinished(const Net::DownloadResult &result);
|
void handleDownloadFinished(const Net::DownloadResult &result);
|
||||||
void fileSearchFinished(const TorrentID &id, const QString &savePath, const QStringList &fileNames);
|
void fileSearchFinished(const TorrentID &id, const QString &savePath, const QStringList &fileNames);
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
// Session reconfiguration triggers
|
// Session reconfiguration triggers
|
||||||
void networkOnlineStateChanged(bool online);
|
void networkOnlineStateChanged(bool online);
|
||||||
void networkConfigurationChange(const QNetworkConfiguration &);
|
void networkConfigurationChange(const QNetworkConfiguration &);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MoveStorageJob
|
struct MoveStorageJob
|
||||||
@ -783,8 +787,9 @@ namespace BitTorrent
|
|||||||
|
|
||||||
SessionStatus m_status;
|
SessionStatus m_status;
|
||||||
CacheStatus m_cacheStatus;
|
CacheStatus m_cacheStatus;
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
QNetworkConfigurationManager *m_networkManager = nullptr;
|
QNetworkConfigurationManager *m_networkManager = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
QList<MoveStorageJob> m_moveStorageQueue;
|
QList<MoveStorageJob> m_moveStorageQueue;
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include "reverseresolution.h"
|
#include "reverseresolution.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QCache>
|
#include <QCache>
|
||||||
|
#include <QHostAddress>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class QHostAddress;
|
|
||||||
class QHostInfo;
|
class QHostInfo;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
|
@ -224,7 +224,11 @@ void SettingsStorage::removeValue(const QString &key)
|
|||||||
{
|
{
|
||||||
const QString realKey = mapKey(key);
|
const QString realKey = mapKey(key);
|
||||||
const QWriteLocker locker(&m_lock);
|
const QWriteLocker locker(&m_lock);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
if (m_data.remove(realKey))
|
||||||
|
#else
|
||||||
if (m_data.remove(realKey) > 0)
|
if (m_data.remove(realKey) > 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
|
@ -549,10 +549,10 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||||||
|
|
||||||
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||||
|
|
||||||
const int priorityGroups = 3;
|
const qsizetype priorityGroups = 3;
|
||||||
const int priorityGroupSize = std::max((selectedRows.length() / priorityGroups), 1);
|
const auto priorityGroupSize = std::max<qsizetype>((selectedRows.length() / priorityGroups), 1);
|
||||||
|
|
||||||
for (int i = 0; i < selectedRows.length(); ++i)
|
for (qsizetype i = 0; i < selectedRows.length(); ++i)
|
||||||
{
|
{
|
||||||
auto priority = BitTorrent::DownloadPriority::Ignored;
|
auto priority = BitTorrent::DownloadPriority::Ignored;
|
||||||
switch (i / priorityGroupSize)
|
switch (i / priorityGroupSize)
|
||||||
|
@ -143,7 +143,11 @@ bool PiecesBar::event(QEvent *e)
|
|||||||
return base::event(e);
|
return base::event(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
void PiecesBar::enterEvent(QEnterEvent *e)
|
||||||
|
#else
|
||||||
void PiecesBar::enterEvent(QEvent *e)
|
void PiecesBar::enterEvent(QEvent *e)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
m_hovered = true;
|
m_hovered = true;
|
||||||
base::enterEvent(e);
|
base::enterEvent(e);
|
||||||
|
@ -54,15 +54,19 @@ public:
|
|||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
// QObject interface
|
// QObject interface
|
||||||
virtual bool event(QEvent*) override;
|
virtual bool event(QEvent *e) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
void enterEvent(QEvent*) override;
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
void leaveEvent(QEvent*) override;
|
void enterEvent(QEnterEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent*) override;
|
#else
|
||||||
|
void enterEvent(QEvent *e) override;
|
||||||
|
#endif
|
||||||
|
void leaveEvent(QEvent *e) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent*) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void requestImageUpdate();
|
void requestImageUpdate();
|
||||||
|
|
||||||
QColor backgroundColor() const;
|
QColor backgroundColor() const;
|
||||||
|
@ -637,10 +637,10 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||||||
|
|
||||||
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
||||||
|
|
||||||
const int priorityGroups = 3;
|
const qsizetype priorityGroups = 3;
|
||||||
const int priorityGroupSize = std::max((selectedRows.length() / priorityGroups), 1);
|
const auto priorityGroupSize = std::max<qsizetype>((selectedRows.length() / priorityGroups), 1);
|
||||||
|
|
||||||
for (int i = 0; i < selectedRows.length(); ++i)
|
for (qsizetype i = 0; i < selectedRows.length(); ++i)
|
||||||
{
|
{
|
||||||
auto priority = BitTorrent::DownloadPriority::Ignored;
|
auto priority = BitTorrent::DownloadPriority::Ignored;
|
||||||
switch (i / priorityGroupSize)
|
switch (i / priorityGroupSize)
|
||||||
|
@ -37,7 +37,9 @@
|
|||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <Shellapi.h>
|
#include <Shellapi.h>
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
#include <QtWin>
|
#include <QtWin>
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
#include <QMimeType>
|
#include <QMimeType>
|
||||||
@ -118,7 +120,11 @@ namespace
|
|||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
|
auto iconPixmap = QPixmap::fromImage(QImage::fromHICON(sfi.hIcon));
|
||||||
|
#else
|
||||||
QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
|
QPixmap iconPixmap = QtWin::fromHICON(sfi.hIcon);
|
||||||
|
#endif
|
||||||
::DestroyIcon(sfi.hIcon);
|
::DestroyIcon(sfi.hIcon);
|
||||||
return iconPixmap;
|
return iconPixmap;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user