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 diff --git a/cmake/Modules/MacroQbtCommonConfig.cmake b/cmake/Modules/MacroQbtCommonConfig.cmake index 4b70fa9ef..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() @@ -70,8 +76,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/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index afbbc3587..68d549cb0 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 a7b84b5d9..49c113620 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -319,7 +319,7 @@ void PropertiesWidget::loadTorrentInfos(BitTorrent::Torrent *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 617a1d6fc..b665634cf 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -361,9 +361,9 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons 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::Torrent *torrent, cons 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: 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 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