From dff39ffd2051afe3dbaf982edfa1985f6278eac6 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 12 Oct 2021 14:15:24 +0800 Subject: [PATCH 1/6] Fix typo https://doc.qt.io/qt-6/qmake-variable-reference.html#qt-major-version --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index 1ba2f49fc..2728e6d5f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -23,7 +23,7 @@ nogui { DEFINES += QBT_STATIC_QT QTPLUGIN += qico } - win32: lessThan(QT_VERSION_MAJOR, 6) { + win32: lessThan(QT_MAJOR_VERSION, 6) { QT += winextras } macx { From 489d88e02abada4fe135af05bd50344176abae05 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 12 Oct 2021 15:33:13 +0800 Subject: [PATCH 2/6] Suppress conversion warning This fixes MSVC warning C4305: 'argument': truncation from 'double' to 'float'. `QColor::setAlphaF()` parameter has been changed to `float` in Qt6. --- src/gui/properties/piecesbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/properties/piecesbar.cpp b/src/gui/properties/piecesbar.cpp index f1f042b92..fda9c8113 100644 --- a/src/gui/properties/piecesbar.cpp +++ b/src/gui/properties/piecesbar.cpp @@ -186,7 +186,7 @@ void PiecesBar::paintEvent(QPaintEvent *) if (!m_highlightedRegion.isNull()) { QColor highlightColor {this->palette().color(QPalette::Active, QPalette::Highlight)}; - highlightColor.setAlphaF(0.35); + highlightColor.setAlphaF(0.35f); QRect targetHighlightRect {m_highlightedRegion.adjusted(borderWidth, borderWidth, borderWidth, height() - 2 * borderWidth)}; painter.fillRect(targetHighlightRect, highlightColor); } From 08b2cde8e8b9118b2866b60a45a1057a022a8c1d Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Tue, 12 Oct 2021 21:57:43 +0800 Subject: [PATCH 3/6] Let infohash v2 text be mouse selectable And drop unused property. --- src/gui/addnewtorrentdialog.ui | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gui/addnewtorrentdialog.ui b/src/gui/addnewtorrentdialog.ui index 3d5a66e8b..992109abc 100644 --- a/src/gui/addnewtorrentdialog.ui +++ b/src/gui/addnewtorrentdialog.ui @@ -326,9 +326,6 @@ - - Qt::PlainText - Qt::TextSelectableByMouse @@ -350,8 +347,8 @@ - - + + Qt::TextSelectableByMouse From ca28fc27dc19f3afe8d3dbb469c02279d91dd6ba Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 13 Oct 2021 00:35:55 +0800 Subject: [PATCH 4/6] Disable deprecated Qt functions Also Qt6 by default set these attributes to our preferred value. --- src/app/application.cpp | 2 ++ src/app/main.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/application.cpp b/src/app/application.cpp index 80b0dd61d..e02205995 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -141,7 +141,9 @@ Application::Application(int &argc, char **argv) setOrganizationDomain("qbittorrent.org"); #if !defined(DISABLE_GUI) setDesktopFileName("org.qbittorrent.qBittorrent"); +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) setAttribute(Qt::AA_UseHighDpiPixmaps, true); // opt-in to the high DPI pixmap support +#endif setQuitOnLastWindowClosed(false); QPixmapCache::setCacheLimit(PIXMAP_CACHE_SIZE); #endif diff --git a/src/app/main.cpp b/src/app/main.cpp index 270c4e421..7406545b4 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) // We must save it here because QApplication constructor may change it bool isOneArg = (argc == 2); -#if !defined(DISABLE_GUI) +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && !defined(DISABLE_GUI) // Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created if (qgetenv("QT_ENABLE_HIGHDPI_SCALING").isEmpty() && qgetenv("QT_AUTO_SCREEN_SCALE_FACTOR").isEmpty()) Application::setAttribute(Qt::AA_EnableHighDpiScaling, true); From e45e29b431017068d0623ad558975d8b0b3b93c8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 13 Oct 2021 00:40:59 +0800 Subject: [PATCH 5/6] Avoid type specifier mismatch Qt5 uses `int` and Qt6 uses `qsizetype`, so use the stream version of `qDebug()` to avoid specifying types. --- src/base/bittorrent/bencoderesumedatastorage.cpp | 3 ++- src/base/bittorrent/session.cpp | 2 +- src/gui/properties/propertieswidget.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base/bittorrent/bencoderesumedatastorage.cpp b/src/base/bittorrent/bencoderesumedatastorage.cpp index 0c6835882..668556427 100644 --- a/src/base/bittorrent/bencoderesumedatastorage.cpp +++ b/src/base/bittorrent/bencoderesumedatastorage.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -113,7 +114,7 @@ BitTorrent::BencodeResumeDataStorage::BencodeResumeDataStorage(const QString &pa loadQueue(m_resumeDataDir.absoluteFilePath(QLatin1String("queue"))); - qDebug("Registered torrents count: %d", m_registeredTorrents.size()); + qDebug() << "Registered torrents count: " << m_registeredTorrents.size(); m_asyncWorker->moveToThread(m_ioThread); connect(m_ioThread, &QThread::finished, m_asyncWorker, &QObject::deleteLater); diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 98599d0a0..7bbf3c6af 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2523,7 +2523,7 @@ QStringList Session::getListeningIPs() const } const QList addresses = networkIFace.addressEntries(); - qDebug("This network interface has %d IP addresses", addresses.size()); + qDebug() << "This network interface has " << addresses.size() << " IP addresses"; for (const QNetworkAddressEntry &entry : addresses) checkAndAddIP(entry.ip(), configuredAddr); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 0987ca141..5959c1eb7 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -412,7 +412,7 @@ void PropertiesWidget::saveSettings() sizes = hSplitter->sizes(); else sizes = m_slideSizes; - qDebug("Sizes: %d", sizes.size()); + if (sizes.size() == 2) pref->setPropSplitterSizes(QString::number(sizes.first()) + ',' + QString::number(sizes.last())); pref->setPropFileListState(m_ui->filesList->header()->saveState()); From 8a7179195f993d5960abf184bf471464ec3776f3 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 13 Oct 2021 01:39:43 +0800 Subject: [PATCH 6/6] Suppress remove null widget warning And improve text format for translation work. --- src/gui/properties/propertieswidget.cpp | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index 5959c1eb7..531447fc8 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -752,21 +752,31 @@ void PropertiesWidget::configure() // Speed widget if (Preferences::instance()->isSpeedWidgetEnabled()) { - if (!m_speedWidget || !qobject_cast(m_speedWidget)) + if (!qobject_cast(m_speedWidget)) { - m_ui->speedLayout->removeWidget(m_speedWidget); - delete m_speedWidget; - m_speedWidget = new SpeedWidget {this}; + if (m_speedWidget) + { + m_ui->speedLayout->removeWidget(m_speedWidget); + delete m_speedWidget; + } + + m_speedWidget = new SpeedWidget(this); m_ui->speedLayout->addWidget(m_speedWidget); } } else { - if (!m_speedWidget || !qobject_cast(m_speedWidget)) + if (!qobject_cast(m_speedWidget)) { - m_ui->speedLayout->removeWidget(m_speedWidget); - delete m_speedWidget; - auto *label = new QLabel(tr("
Speed graphs are disabled

You may change this setting in Advanced Options

"), this); + if (m_speedWidget) + { + m_ui->speedLayout->removeWidget(m_speedWidget); + delete m_speedWidget; + } + + const auto displayText = QString::fromLatin1("
%1

%2

") + .arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options")); + auto *label = new QLabel(displayText, this); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); m_speedWidget = label; m_ui->speedLayout->addWidget(m_speedWidget);