From 24fa9e32b01b60c3765f6f686962fff9e009858a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Jan 2021 11:53:28 +0800 Subject: [PATCH 1/4] Set source character sets to UTF-8 This suppress warning C4819. https://docs.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-160 --- cmake/Modules/MacroQbtCommonConfig.cmake | 8 ++++++-- src/base/unicodestrings.h | 7 +------ winconf.pri | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/MacroQbtCommonConfig.cmake b/cmake/Modules/MacroQbtCommonConfig.cmake index 4b70fa9ef..9b789b2fe 100644 --- a/cmake/Modules/MacroQbtCommonConfig.cmake +++ b/cmake/Modules/MacroQbtCommonConfig.cmake @@ -70,8 +70,12 @@ macro(qbt_common_config) endif() if (MSVC) - target_compile_options(qbt_common_cfg INTERFACE /guard:cf) - target_link_options(qbt_common_cfg INTERFACE /guard:cf + target_compile_options(qbt_common_cfg INTERFACE + /guard:cf + /utf-8 + ) + target_link_options(qbt_common_cfg INTERFACE + /guard:cf $<$>:/OPT:REF /OPT:ICF> # suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON $<$:/INCREMENTAL:NO> diff --git a/src/base/unicodestrings.h b/src/base/unicodestrings.h index 9065c1693..245f99626 100644 --- a/src/base/unicodestrings.h +++ b/src/base/unicodestrings.h @@ -1,4 +1,4 @@ -/* +/* * Bittorrent Client using Qt and libtorrent. * Copyright (C) 2015 Mike Tzou * @@ -28,11 +28,6 @@ #pragma once -// This file must be encoded in "UTF-8 with BOM" -#ifdef _MSC_VER -#pragma execution_character_set("utf-8") -#endif - // Because of the poor handling of UTF-8 characters in MSVC (emits warning C4819), // we put all problematic UTF-8 chars/strings in this file. // See issue #3059 for more details (https://github.com/qbittorrent/qBittorrent/issues/3059). diff --git a/winconf.pri b/winconf.pri index 7fc06116e..26e58cc1c 100644 --- a/winconf.pri +++ b/winconf.pri @@ -40,7 +40,7 @@ win32-g++* { } else:win32-msvc* { CONFIG -= embed_manifest_exe - QMAKE_CXXFLAGS += /std:c++17 + QMAKE_CXXFLAGS += /std:c++17 /utf-8 QMAKE_LFLAGS += "/MANIFEST:EMBED /MANIFESTINPUT:$$quote($${PWD}/src/qbittorrent.exe.manifest) /STACK:0x800000" RC_FILE = qbittorrent.rc From 89559eae2b1b8744657548943088388cac39ad6f Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Jan 2021 12:04:11 +0800 Subject: [PATCH 2/4] Disable clang "range loop analysis" compiler warning See: https://github.com/qbittorrent/qBittorrent/pull/13915#issuecomment-739449084 --- cmake/Modules/MacroQbtCommonConfig.cmake | 6 ++++++ src/src.pro | 2 ++ 2 files changed, 8 insertions(+) diff --git a/cmake/Modules/MacroQbtCommonConfig.cmake b/cmake/Modules/MacroQbtCommonConfig.cmake index 9b789b2fe..0b31ffefa 100644 --- a/cmake/Modules/MacroQbtCommonConfig.cmake +++ b/cmake/Modules/MacroQbtCommonConfig.cmake @@ -59,6 +59,12 @@ macro(qbt_common_config) endif() endif() + if ((CXX_COMPILER_ID STREQUAL "Clang") OR (CXX_COMPILER_ID STREQUAL "AppleClang")) + target_compile_options(qbt_common_cfg INTERFACE + -Wno-range-loop-analysis + ) + endif() + if (MINGW) target_link_options(qbt_common_cfg INTERFACE $<$,$>:LINKER:--dynamicbase>) endif() diff --git a/src/src.pro b/src/src.pro index 5ad945bfe..0e265e615 100644 --- a/src/src.pro +++ b/src/src.pro @@ -9,6 +9,8 @@ unix:!macx: include(../unixconf.pri) QT += network xml +macx|*-clang*: QMAKE_CXXFLAGS_WARN_ON += -Wno-range-loop-analysis + nogui { TARGET = qbittorrent-nox QT -= gui From cede5ac9d203d484b643165941be3c532e9f9d99 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Jan 2021 12:47:18 +0800 Subject: [PATCH 3/4] Migrate away from deprecated Qt functions `QString QDateTime::toString(Qt::DateFormat format = Qt::TextDate)` will be removed in Qt6. --- src/gui/addnewtorrentdialog.cpp | 2 +- src/gui/log/logmodel.cpp | 4 ++-- src/gui/properties/propertieswidget.cpp | 8 ++++---- src/gui/rss/rsswidget.cpp | 2 +- src/gui/transferlistmodel.cpp | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index f05cd94c5..0a2fee182 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -655,7 +655,7 @@ void AddNewTorrentDialog::setupTreeview() // Set torrent information m_ui->labelCommentData->setText(Utils::Misc::parseHtmlLinks(m_torrentInfo.comment().toHtmlEscaped())); - m_ui->labelDateData->setText(!m_torrentInfo.creationDate().isNull() ? m_torrentInfo.creationDate().toString(Qt::DefaultLocaleShortDate) : tr("Not available")); + m_ui->labelDateData->setText(!m_torrentInfo.creationDate().isNull() ? QLocale().toString(m_torrentInfo.creationDate(), QLocale::ShortFormat) : tr("Not available")); // Prepare content tree m_contentModel = new TorrentContentFilterModel(this); diff --git a/src/gui/log/logmodel.cpp b/src/gui/log/logmodel.cpp index d15b66504..50386e323 100644 --- a/src/gui/log/logmodel.cpp +++ b/src/gui/log/logmodel.cpp @@ -155,7 +155,7 @@ LogMessageModel::LogMessageModel(QObject *parent) void LogMessageModel::handleNewMessage(const Log::Msg &message) { - const QString time = QDateTime::fromMSecsSinceEpoch(message.timestamp).toString(Qt::SystemLocaleShortDate); + const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(message.timestamp), QLocale::ShortFormat); const QString messageText = message.message; const QColor foreground = m_foregroundForMessageTypes[message.type]; @@ -173,7 +173,7 @@ LogPeerModel::LogPeerModel(QObject *parent) void LogPeerModel::handleNewMessage(const Log::Peer &peer) { - const QString time = QDateTime::fromMSecsSinceEpoch(peer.timestamp).toString(Qt::SystemLocaleShortDate); + const QString time = QLocale::system().toString(QDateTime::fromMSecsSinceEpoch(peer.timestamp), QLocale::ShortFormat); const QString message = peer.blocked ? tr("%1 was blocked. Reason: %2.", "0.0.0.0 was blocked. Reason: reason for blocking.").arg(peer.ip, peer.reason) : tr("%1 was banned", "0.0.0.0 was banned").arg(peer.ip); diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index ea050b175..960987149 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -319,7 +319,7 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent if (m_torrent->hasMetadata()) { // Creation date - m_ui->labelCreatedOnVal->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); + m_ui->labelCreatedOnVal->setText(QLocale().toString(m_torrent->creationDate(), QLocale::ShortFormat)); m_ui->labelTotalSizeVal->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); @@ -457,11 +457,11 @@ void PropertiesWidget::loadDynamicData() m_ui->labelUpSpeedVal->setText(tr("%1 (%2 avg.)", "%1 and %2 are speed rates, e.g. 200KiB/s (100KiB/s avg.)") .arg(Utils::Misc::friendlyUnit(m_torrent->uploadPayloadRate(), true), ulAvg)); - m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? m_torrent->lastSeenComplete().toString(Qt::DefaultLocaleShortDate) : tr("Never")); + m_ui->labelLastSeenCompleteVal->setText(m_torrent->lastSeenComplete().isValid() ? QLocale().toString(m_torrent->lastSeenComplete(), QLocale::ShortFormat) : tr("Never")); - m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? m_torrent->completedTime().toString(Qt::DefaultLocaleShortDate) : ""); + m_ui->labelCompletedOnVal->setText(m_torrent->completedTime().isValid() ? QLocale().toString(m_torrent->completedTime(), QLocale::ShortFormat) : QString {}); - m_ui->labelAddedOnVal->setText(m_torrent->addedTime().toString(Qt::DefaultLocaleShortDate)); + m_ui->labelAddedOnVal->setText(QLocale().toString(m_torrent->addedTime(), QLocale::ShortFormat)); if (m_torrent->hasMetadata()) { diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index ff085c38f..4a11a7635 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -486,7 +486,7 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL QString::fromLatin1("
") + QString::fromLatin1("
%3
").arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); if (article->date().isValid()) - html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Date: "), article->date().toLocalTime().toString(Qt::SystemLocaleLongDate)); + html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime())); if (!article->author().isEmpty()) html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Author: "), article->author()); html += "
" diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 479ec0d3c..26d25dabf 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -361,9 +361,9 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent case TR_TAGS: return tagsString(torrent->tags()); case TR_ADD_DATE: - return torrent->addedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat); case TR_SEED_DATE: - return torrent->completedTime().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->completedTime().toLocalTime(), QLocale::ShortFormat); case TR_TRACKER: return torrent->currentTracker(); case TR_DLLIMIT: @@ -387,7 +387,7 @@ QString TransferListModel::displayValue(const BitTorrent::TorrentHandle *torrent case TR_COMPLETED: return unitString(torrent->completedSize()); case TR_SEEN_COMPLETE_DATE: - return torrent->lastSeenComplete().toLocalTime().toString(Qt::DefaultLocaleShortDate); + return QLocale().toString(torrent->lastSeenComplete().toLocalTime(), QLocale::ShortFormat); case TR_LAST_ACTIVITY: return lastActivityString((torrent->isPaused() || torrent->isChecking()) ? -1 : torrent->timeSinceActivity()); case TR_AVAILABILITY: From 52ce52d4664994b0dbcd3003cc242c6d2b4900d8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 6 Jan 2021 13:35:36 +0800 Subject: [PATCH 4/4] Unify "github actions" artifacts naming scheme --- .github/workflows/ci.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4b805cdb0..54ee71974 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -72,7 +72,7 @@ jobs: - name: upload artifact as zip uses: actions/upload-artifact@v2 with: - name: qBittorrent-CI-Ubuntu_${{ matrix.os }}-${{ matrix.qbt_gui }} + name: qBittorrent-CI_${{ matrix.os }}-x64_${{ matrix.qbt_gui }} path: | build/compile_commands.json build/target_graph.dot @@ -151,7 +151,7 @@ jobs: - name: upload artifact as zip uses: actions/upload-artifact@v2 with: - name: qBittorrent-CI-Windows_x64-static-release + name: qBittorrent-CI_Windows-x64 path: | build/compile_commands.json build/target_graph.dot @@ -236,7 +236,7 @@ jobs: - name: upload artifact as zip uses: actions/upload-artifact@v2 with: - name: qBittorrent-CI-macOS_x64-static-release_${{ matrix.qbt_gui }} + name: qBittorrent-CI_macOS_${{ matrix.qbt_gui }} path: | build/compile_commands.json build/target_graph.dot